KioskTool – tool to configure the TDE kiosk framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

150 lines
4.2 KiB

  1. /*
  2. * kioskConfigDialog.cpp
  3. *
  4. * Copyright (C) 2004 Waldo Bastian <bastian@kde.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. #include "kioskConfigDialog.h"
  20. #include <tqcheckbox.h>
  21. #include <tqtextedit.h>
  22. #include <tdeapplication.h>
  23. #include <tdeconfig.h>
  24. #include <tdefiledialog.h>
  25. #include <knuminput.h>
  26. #include <klineedit.h>
  27. #include <tdelocale.h>
  28. #include <kurlrequester.h>
  29. #include "kioskrun.h"
  30. #include "kioskConfigDialog_ui.h"
  31. KioskConfigDialog::KioskConfigDialog(TQWidget *parent)
  32. : KDialogBase(parent, "KioskConfigDialog", true, i18n("Configure Kiosk Admin Tool"),
  33. KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, true )
  34. {
  35. w = new KioskConfigDialogUI(this);
  36. w->lineProfilePrefix->setMode(KFile::Directory | KFile::LocalOnly);
  37. w->lineUpload->setMode(KFile::Directory);
  38. setMainWidget(w);
  39. init();
  40. connect(w->lineProfilePrefix, TQT_SIGNAL(textChanged( const TQString& )), TQT_SLOT(updateExample()));
  41. connect(w->lineUpload, TQT_SIGNAL(textChanged( const TQString& )), TQT_SLOT(updateExample()));
  42. connect(w->lineUploadPrefix, TQT_SIGNAL(textChanged( const TQString& )), TQT_SLOT(updateExample()));
  43. }
  44. KioskConfigDialog::~KioskConfigDialog()
  45. {
  46. }
  47. void KioskConfigDialog::init()
  48. {
  49. TQString prefix = KioskRun::self()->getProfilePrefix();
  50. if (prefix.isEmpty())
  51. {
  52. w->checkProfilePrefix->setChecked(false);
  53. w->lineProfilePrefix->setURL("/etc/kde-profile/");
  54. }
  55. else
  56. {
  57. w->checkProfilePrefix->setChecked(true);
  58. w->lineProfilePrefix->setURL(prefix);
  59. }
  60. TDEConfig *config = kapp->config();
  61. config->setGroup("General");
  62. TQString uploadURL = config->readEntry("uploadURL");
  63. if (uploadURL.isEmpty())
  64. {
  65. w->checkUpload->setChecked(false);
  66. w->lineUpload->setURL("fish://root@host/");
  67. }
  68. else
  69. {
  70. w->checkUpload->setChecked(true);
  71. w->lineUpload->setURL(uploadURL);
  72. }
  73. w->lineUploadPrefix->setText(config->readEntry("uploadPrefix"));
  74. int minUID = config->readNumEntry("FirstUIDShown", 500);
  75. if (!minUID)
  76. {
  77. w->checkUID->setChecked(false);
  78. w->numUID->setValue(500);
  79. }
  80. else
  81. {
  82. w->checkUID->setChecked(true);
  83. w->numUID->setValue(minUID);
  84. }
  85. updateExample();
  86. }
  87. void KioskConfigDialog::updateExample()
  88. {
  89. TQString uploadPrefix = w->lineUploadPrefix->text();
  90. TQString file1 = w->lineProfilePrefix->url()+"default";
  91. TQString file2 = file1;
  92. if (file2.startsWith(uploadPrefix))
  93. file2 = file2.mid(uploadPrefix.length());
  94. if (file2.startsWith("/"))
  95. file2 = file2.mid(1);
  96. TQString url = w->lineUpload->url();
  97. if (!url.endsWith("/"))
  98. url += "/";
  99. url += file2;
  100. TQString example = TQString("<qt><center><b>%1</b><br>--><br><b>%2</b></center>").arg(file1, url);
  101. w->lblUploadExample->setText(example);
  102. w->lblUploadExample->setFixedSize(TQSize(500,fontMetrics().lineSpacing()*3 + 6));
  103. }
  104. bool KioskConfigDialog::save()
  105. {
  106. TQString uploadURL;
  107. TQString uploadPrefix;
  108. TQString prefix;
  109. int minUID = 0;
  110. uploadPrefix = w->lineUploadPrefix->text();
  111. if (w->checkUpload->isChecked())
  112. uploadURL = w->lineUpload->url();
  113. if (w->checkProfilePrefix->isChecked())
  114. prefix = w->lineProfilePrefix->url();
  115. if (w->checkUID->isChecked())
  116. minUID = w->numUID->value();
  117. TDEConfig *config = kapp->config();
  118. config->setGroup("General");
  119. config->writeEntry("uploadURL", uploadURL);
  120. config->writeEntry("uploadPrefix", uploadPrefix);
  121. config->writeEntry("FirstUIDShown", minUID);
  122. config->sync();
  123. return KioskRun::self()->setProfilePrefix(prefix);
  124. }
  125. #include "kioskConfigDialog.moc"