KShutdown – graphical shutdown utility
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.

624 lines
19KB

  1. /*
  2. msettingsdialog.cpp - A settings dialog
  3. Copyright (C) 2003 Konrad Twardowski <kdtonline@poczta.onet.pl>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. */
  16. #include "configuration.h"
  17. #include "extras.h"
  18. #include "links.h"
  19. #include "mactioneditdialog.h"
  20. #include "miscutils.h"
  21. #include "mmessagedialog.h"
  22. #include "msettingsdialog.h"
  23. #include "msystemtray.h"
  24. #include "mtip.h"
  25. #include "systemconfig.h"
  26. #include <tqcheckbox.h>
  27. #include <tqfile.h>
  28. #include <tqhbox.h>
  29. #include <tqhbuttongroup.h>
  30. #include <tqheader.h>
  31. #include <tqlabel.h>
  32. #include <tqlayout.h>
  33. #include <tqradiobutton.h>
  34. #include <tqtooltip.h>
  35. #include <tqvgroupbox.h>
  36. #include <tqwhatsthis.h>
  37. #include <tdeconfigdialogmanager.h>
  38. #include <kiconloader.h>
  39. #include <klineedit.h>
  40. #include <tdelistview.h>
  41. #include <tdelocale.h>
  42. #include <tdemessagebox.h>
  43. #include <tdepopupmenu.h>
  44. #include <knuminput.h>
  45. #include <kpushbutton.h>
  46. #include <kstandarddirs.h>
  47. #include <ktabwidget.h>
  48. #include <kurllabel.h>
  49. int MSettingsDialog::_lastPage = 0;
  50. MSettingsDialog *MSettingsDialog::_instance = 0;
  51. // public
  52. MSettingsDialog::MSettingsDialog(TQWidget *parent)
  53. : KDialogBase(
  54. IconList,
  55. i18n("Settings"),
  56. Apply | Cancel | Default | Ok,
  57. Ok, // default button
  58. parent,
  59. "MSettingsDialog",
  60. true, // modal
  61. true // separator
  62. )
  63. {
  64. _instance = this;
  65. initGeneralPage();
  66. initMessagesPage();
  67. initActionsPage();
  68. initAdvancedPage();
  69. _configDialogManager = new TDEConfigDialogManager(this, kshutdownrc);
  70. _configDialogManager->updateWidgets();
  71. connect(_configDialogManager, SIGNAL(widgetModified()), SLOT(slotConfigChanged()));
  72. connect(this, SIGNAL(applyClicked()), SLOT(slotOKClicked()));
  73. connect(this, SIGNAL(okClicked()), SLOT(slotOKClicked()));
  74. // lock after login
  75. c_autoLock->setChecked(TQFile::exists(TDEGlobalSettings::autostartPath() + "/kshutdown-autolock.desktop"));
  76. setInitialSize(configDialogSize("Settings Dialog"));
  77. showPage(_lastPage); // restore last page
  78. exec();
  79. }
  80. MSettingsDialog::~MSettingsDialog()
  81. {
  82. _lastPage = activePageIndex(); // remember last page
  83. }
  84. // private
  85. TQFrame *MSettingsDialog::addPage(const TQString &itemName, const TQString &iconName)
  86. {
  87. return KDialogBase::addPage(itemName, TQString::null, MainBarIcon(iconName, 32));
  88. }
  89. bool MSettingsDialog::disabledByAdmin(const TQString &key, TQFrame *page,
  90. TQBoxLayout *pageLayout) const
  91. {
  92. if (MiscUtils::isRestricted("settings_" + key))
  93. {
  94. // add tip
  95. if (page)
  96. {
  97. MTip *t_admin = new MTip(MTip::Info, page);
  98. t_admin->setTipText(i18n("Disabled by the Administrator."));
  99. pageLayout->addWidget(t_admin);
  100. }
  101. return true; // disabled
  102. }
  103. return false; // enabled
  104. }
  105. void MSettingsDialog::initActionsPage()
  106. {
  107. _actionsPage = addPage(i18n("Actions"), "kshutdown");
  108. TQVBoxLayout *l = new TQVBoxLayout(_actionsPage, 5);
  109. if (disabledByAdmin("actions", _actionsPage, l))
  110. return;
  111. TQVGroupBox *gb_general = new TQVGroupBox(i18n("Actions"), _actionsPage);
  112. _actions = new TDEListView(gb_general, "TDEListView::_actions");
  113. _actions->setAllColumnsShowFocus(true);
  114. _actions->setItemMargin(5);
  115. _actions->setMaximumHeight(200);
  116. _actions->setSorting(-1); // no sort
  117. _actions->addColumn(i18n("Action"));
  118. _actions->addColumn(i18n("Method"));
  119. _actions->addColumn(i18n("Command before action"));
  120. _actions->header()->setClickEnabled(false);
  121. _logoutItem = new TDEListViewItem(_actions, ks_actions->getName(Action::Logout));
  122. _logoutItem->setPixmap(0, ks_actions->getIcon(Action::Logout));
  123. _lockScreenItem = new TDEListViewItem(_actions, ks_actions->getName(Action::LockScreen));
  124. _lockScreenItem->setPixmap(0, ks_actions->getIcon(Action::LockScreen));
  125. _rebootItem = new TDEListViewItem(_actions, ks_actions->getName(Action::Reboot));
  126. _rebootItem->setPixmap(0, ks_actions->getIcon(Action::Reboot));
  127. _shutDownItem = new TDEListViewItem(_actions, ks_actions->getName(Action::ShutDown));
  128. _shutDownItem->setPixmap(0, ks_actions->getIcon(Action::ShutDown));
  129. connect(_actions, SIGNAL(doubleClicked(TQListViewItem *, const TQPoint &, int)), SLOT(slotEditAction()));
  130. connect(_actions, SIGNAL(spacePressed(TQListViewItem *)), SLOT(slotEditAction()));
  131. // edit action
  132. KPushButton *b_editAction = new KPushButton(SmallIcon("edit"), i18n("Edit..."), gb_general, "KPushButton::b_editAction");
  133. connect(b_editAction, SIGNAL(clicked()), SLOT(slotEditAction()));
  134. // check system configuration
  135. KPushButton *b_checkSystemConfig = new KPushButton(SmallIcon("button_ok"), i18n("Check System Configuration"), gb_general, "KPushButton::b_checkSystemConfig");
  136. connect(b_checkSystemConfig, SIGNAL(clicked()), SLOT(slotCheckSystemConfig()));
  137. TQVGroupBox *gb_extras = new TQVGroupBox(i18n("Extras Menu"), _actionsPage);
  138. KPushButton *b_modifyExtras = new KPushButton(SmallIcon("edit"), i18n("Modify..."), gb_extras, "KPushButton::b_modifyExtras");
  139. if (!ks_actions->isEnabled(Action::Extras))
  140. gb_extras->hide();
  141. connect(
  142. b_modifyExtras, SIGNAL(clicked()),
  143. ks_extras, SLOT(slotModify()));
  144. l->addWidget(gb_general);
  145. l->addStretch();
  146. l->addWidget(gb_extras);
  147. // update items after widgets init
  148. updateActions();
  149. }
  150. void MSettingsDialog::initAdvancedPage()
  151. {
  152. _advancedPage = addPage(i18n("Advanced"), "misc");
  153. TQVBoxLayout *l = new TQVBoxLayout(_advancedPage, 5);
  154. // after login
  155. TQVGroupBox *gb_afterLogin = new TQVGroupBox(i18n("After Login"), _advancedPage);
  156. c_autoLock = new TQCheckBox(i18n("Lock screen"), gb_afterLogin);
  157. connect(c_autoLock, SIGNAL(clicked()), SLOT(slotConfigChanged()));
  158. // cd tray close
  159. TQVGroupBox *gb_cdTrayClose = new TQVGroupBox(i18n("Before Logout"), _advancedPage);
  160. TQCheckBox *c_cdTrayClose = new TQCheckBox(i18n("Close CD-ROM Tray"), gb_cdTrayClose, "kcfg_cd_tray_close");
  161. TQHBox *cdTrayCloseBox = new TQHBox(gb_cdTrayClose);
  162. TQLabel *l_cdTrayCloseCommand = new TQLabel(i18n("Command:"), cdTrayCloseBox);
  163. // FIXME: 2.0: disable "in_cdTrayCloseCommand" if "c_cdTrayClose" is not checked
  164. // TODO: 2.0: "Test" button
  165. KLineEdit *in_cdTrayCloseCommand = new KLineEdit(cdTrayCloseBox, "kcfg_cd_tray_close_command");
  166. l_cdTrayCloseCommand->setBuddy(in_cdTrayCloseCommand);
  167. connect(
  168. c_cdTrayClose, SIGNAL(toggled(bool)),
  169. in_cdTrayCloseCommand, SLOT(setEnabled(bool)));
  170. // kde settings
  171. KPushButton *b_kdeSettings = new KPushButton(SmallIcon("misc"), i18n("Related TDE Settings..."), _advancedPage, "KPushButton::b_kdeSettings");
  172. connect(b_kdeSettings, SIGNAL(clicked()), SLOT(slotKDESettings()));
  173. l->addWidget(gb_afterLogin);
  174. l->addWidget(gb_cdTrayClose);
  175. l->addStretch();
  176. l->addWidget(b_kdeSettings);
  177. }
  178. void MSettingsDialog::initGeneralPage()
  179. {
  180. _generalPage = addPage(i18n("General"), "misc");
  181. TQVBoxLayout *l = new TQVBoxLayout(_generalPage, 5);
  182. // problems
  183. TQVGroupBox *gb_problems = new TQVGroupBox(i18n("Common Problems"), _generalPage);
  184. KURLLabel *ul_shutDownProblem = new KURLLabel(gb_problems);
  185. ul_shutDownProblem->setText(i18n("\"Turn Off Computer\" does not work"));
  186. connect(ul_shutDownProblem, SIGNAL(leftClickedURL()), SLOT(slotShutDownProblem()));
  187. KURLLabel *ul_trayMessageProblem = new KURLLabel(gb_problems);
  188. ul_trayMessageProblem->setText(i18n("Popup messages are very annoying"));
  189. connect(ul_trayMessageProblem, SIGNAL(leftClickedURL()), SLOT(slotTrayMessageProblem()));
  190. // links
  191. TQVGroupBox *gb_links = new TQVGroupBox(i18n("Add/Remove Links"), _generalPage);
  192. new Links(gb_links);
  193. // system tray
  194. gb_systemTray = new TQHButtonGroup(i18n("Show System Tray Icon"), _generalPage, "kcfg_system_tray");
  195. TQRadioButton *rb_systemTray;
  196. rb_systemTray = new TQRadioButton(i18n("Always"), gb_systemTray);
  197. MiscUtils::setHint(rb_systemTray, i18n("Tray icon will be always visible."));
  198. rb_systemTray = new TQRadioButton(i18n("If Active"), gb_systemTray);
  199. MiscUtils::setHint(rb_systemTray, i18n("Tray icon will be visible only if KShutDown is active."));
  200. rb_systemTray = new TQRadioButton(i18n("Never"), gb_systemTray);
  201. MiscUtils::setHint(rb_systemTray, i18n("Tray icon will be always hidden."));
  202. l->addWidget(gb_problems);
  203. l->addWidget(gb_links);
  204. l->addWidget(gb_systemTray);
  205. // karamba info
  206. TQString karambaThemes = locate("appdata", "karamba/kshutdown-48x48.png");
  207. if (!karambaThemes.isNull())
  208. {
  209. int i = karambaThemes.findRev("/");
  210. if ((i != -1) && (i > 0))
  211. {
  212. MTip *t_karamba = new MTip(MTip::Info, _generalPage);
  213. /* TODO: 2.0: superkaramba integration
  214. t_karamba->disconnect(
  215. t_karamba, SIGNAL(linkClicked(const TQString &)),
  216. t_karamba, SLOT(openLink(const TQString &))
  217. );
  218. t_karamba->connect(
  219. t_karamba, SIGNAL(linkClicked(const TQString &)),
  220. this, SLOT(slotOpenKarambaLink(const TQString &))
  221. );
  222. */
  223. karambaThemes = karambaThemes.left(i);
  224. t_karamba->setTipText(
  225. // title
  226. "<h2>SuperKaramba</h2>" \
  227. // themes
  228. "<a href=\"" + karambaThemes + "\">" + i18n("Show KShutDown Themes") + "</a><br>" \
  229. // home page
  230. "<a href=\"http://www.superkaramba.com/index.php\">" + i18n("SuperKaramba Home Page") + "</a>" \
  231. );
  232. l->addWidget(t_karamba);
  233. }
  234. }
  235. }
  236. void MSettingsDialog::initMessagesPage()
  237. {
  238. _messagesPage = addPage(i18n("Messages"), "messagebox_warning");
  239. TQVBoxLayout *l = new TQVBoxLayout(_messagesPage, 5);
  240. KTabWidget *t_messages = new KTabWidget(_messagesPage);
  241. t_messages->setFocusPolicy(StrongFocus);
  242. // warning message:
  243. TQWidget *w_warning = new TQWidget(_messagesPage);
  244. TQVBoxLayout *l_warning = new TQVBoxLayout(w_warning, 5);
  245. // enabled/info
  246. TQCheckBox *c_warningMessageEnabled = new TQCheckBox(i18n("Display a warning message before action"), w_warning, "kcfg_warning_message_enabled");
  247. // slider
  248. in_warningMessageDelay = new KIntNumInput(w_warning, "kcfg_warning_message_delay");
  249. in_warningMessageDelay->setSuffix(" " + i18n("minute(s)"));
  250. in_warningMessageDelay->setRange(1, 60, 1, true);
  251. KPushButton *b_warningMessageTest = new KPushButton(KStdGuiItem::test(), w_warning, "KPushButton::b_warningMessageTest");
  252. connect(b_warningMessageTest, SIGNAL(clicked()), SLOT(slotWarningMessageTest()));
  253. TQLabel *l_warningText = new TQLabel(i18n("Recommended"), w_warning);
  254. l_warningText->setFont(TQFont(l_warningText->font().family(), l_warningText->font().pointSize(), TQFont::Bold));
  255. l_warning->addWidget(l_warningText);
  256. l_warning->addWidget(c_warningMessageEnabled);
  257. l_warning->addWidget(in_warningMessageDelay);
  258. l_warning->addStretch();
  259. l_warning->addWidget(b_warningMessageTest);
  260. t_messages->addTab(w_warning, i18n("Warning Message"));
  261. // custom message:
  262. TQWidget *w_customMessage = new TQWidget(_messagesPage);
  263. TQVBoxLayout *l_customMessage = new TQVBoxLayout(w_customMessage, 5);
  264. TQCheckBox *c_customMessageEnabled = new TQCheckBox(i18n("Enabled"), w_customMessage, "kcfg_custom_message_enabled");
  265. TQLabel *l_customMessageCommand = new TQLabel(i18n("A shell command to execute:"), w_customMessage);
  266. in_customMessageCommand = new KLineEdit(w_customMessage, "kcfg_custom_message_command");
  267. MiscUtils::setHint(
  268. in_customMessageCommand,
  269. MiscUtils::HTML(
  270. i18n("Enter a command.") +
  271. "<ul>" \
  272. "<li><b>%appname</b> KShutDown</li>" \
  273. "<li><b>%text</b> " + i18n("A message text") + "</li>" \
  274. "<li><b>%title</b> " + i18n("The current main window title") + "</li>" \
  275. "</ul>"
  276. )
  277. );
  278. l_customMessageCommand->setBuddy(in_customMessageCommand);
  279. KPushButton *b_customMessagePresets = new KPushButton(i18n("Presets"), w_customMessage, "KPushButton::b_customMessagePresets");
  280. TDEPopupMenu *pm_customMessagePresets = new TDEPopupMenu(b_customMessagePresets);
  281. pm_customMessagePresets->insertItem("KDialog", this, SLOT(slotSetKDialogCustomMessage()));
  282. pm_customMessagePresets->insertItem("Amor", this, SLOT(slotSetAmorCustomMessage()));
  283. b_customMessagePresets->setPopup(pm_customMessagePresets);
  284. KPushButton *b_testCustomMessage = new KPushButton(KStdGuiItem::test(), w_customMessage, "KPushButton::b_testCustomMessage");
  285. connect(b_testCustomMessage, SIGNAL(clicked()), SLOT(slotCustomMessageTest()));
  286. l_customMessage->addWidget(c_customMessageEnabled);
  287. l_customMessage->addWidget(l_customMessageCommand);
  288. l_customMessage->addWidget(in_customMessageCommand);
  289. l_customMessage->addWidget(b_customMessagePresets);
  290. l_customMessage->addStretch();
  291. l_customMessage->addWidget(b_testCustomMessage);
  292. t_messages->addTab(w_customMessage, i18n("Custom Message"));
  293. // progress bar
  294. TQVGroupBox *w_progressBar = new TQVGroupBox(i18n("Progress Bar"), _messagesPage);
  295. new TQCheckBox(i18n("Enabled"), w_progressBar, "kcfg_progress_bar_enabled");
  296. // re-enable messages
  297. b_enableAllMessages = new KPushButton(i18n("Re-enable All Message Boxes"), _messagesPage, "KPushButton::b_enableAllMessages");
  298. MiscUtils::setHint(
  299. b_enableAllMessages,
  300. MiscUtils::HTML(i18n(
  301. "Enable all messages which have been turned off with the " \
  302. "<b>Do not show this message again</b> feature."
  303. ))
  304. );
  305. connect(b_enableAllMessages, SIGNAL(clicked()), SLOT(slotEnableAllMessages()));
  306. l->addWidget(t_messages);
  307. l->addWidget(w_progressBar);
  308. l->addStretch();
  309. l->addWidget(b_enableAllMessages);
  310. connect(
  311. c_warningMessageEnabled, SIGNAL(toggled(bool)),
  312. in_warningMessageDelay, SLOT(setEnabled(bool)));
  313. connect(
  314. c_warningMessageEnabled, SIGNAL(toggled(bool)),
  315. b_warningMessageTest, SLOT(setEnabled(bool)));
  316. connect(
  317. c_customMessageEnabled, SIGNAL(toggled(bool)),
  318. in_customMessageCommand, SLOT(setEnabled(bool)));
  319. connect(
  320. c_customMessageEnabled, SIGNAL(toggled(bool)),
  321. b_customMessagePresets, SLOT(setEnabled(bool)));
  322. connect(
  323. c_customMessageEnabled, SIGNAL(toggled(bool)),
  324. b_testCustomMessage, SLOT(setEnabled(bool)));
  325. }
  326. Action::Type MSettingsDialog::itemToActionType(const TDEListViewItem *item) const
  327. {
  328. if (!item)
  329. return Action::Nothing;
  330. if (item == _lockScreenItem)
  331. return Action::LockScreen;
  332. if (item == _logoutItem)
  333. return Action::Logout;
  334. if (item == _rebootItem)
  335. return Action::Reboot;
  336. if (item == _shutDownItem)
  337. return Action::ShutDown;
  338. return Action::Nothing;
  339. }
  340. void MSettingsDialog::updateActions()
  341. {
  342. updateItem(_shutDownItem);
  343. updateItem(_rebootItem);
  344. updateItem(_lockScreenItem);
  345. updateItem(_logoutItem);
  346. _actions->setCurrentItem(_shutDownItem);
  347. }
  348. void MSettingsDialog::updateItem(TDEListViewItem *item)
  349. {
  350. Action::Type action = itemToActionType(item);
  351. if (action == Action::Nothing)
  352. return;
  353. Action::Method method = Action::Method_TDE;
  354. TQString
  355. command,
  356. group = ks_actions->actionToConfigGroup(action);
  357. ks_actions->getMethod(action, method, command);
  358. // method
  359. if (method == Action::Method_TDE)
  360. item->setText(1, i18n("TDE (default)"));
  361. else
  362. item->setText(1, command);
  363. // command before action
  364. if (!group.isNull())
  365. {
  366. TDEConfig *conf = kshutdownrc->config();
  367. conf->setGroup(group);
  368. if (conf->readBoolEntry("RunCommandBeforeAction", false))
  369. {
  370. TQString cmd = conf->readEntry("CommandBeforeAction", "");
  371. int pause = conf->readNumEntry("CommandBeforeActionPause", 10);
  372. if (pause == 0)
  373. cmd += " [" + i18n("No pause") + "]";
  374. else
  375. cmd += " [" + i18n("Pause: %1").arg(TQString::number(pause) + "s") + "]";
  376. item->setText(2, cmd);
  377. }
  378. else
  379. {
  380. item->setText(2, "");
  381. }
  382. }
  383. }
  384. // private slots
  385. void MSettingsDialog::slotCheckSystemConfig()
  386. {
  387. SystemConfig::check(this);
  388. }
  389. void MSettingsDialog::slotConfigChanged()
  390. {
  391. actionButton(Apply)->setEnabled(_configDialogManager->hasChanged());
  392. }
  393. void MSettingsDialog::slotCustomMessageTest()
  394. {
  395. MiscUtils::customMessage(i18n("Test"), in_customMessageCommand->text());
  396. }
  397. void MSettingsDialog::slotEditAction()
  398. {
  399. TDEListViewItem *item = static_cast<TDEListViewItem *>(_actions->currentItem());
  400. if (!item)
  401. return;
  402. MActionEditDialog *dialog = new MActionEditDialog(this, itemToActionType(item));
  403. if (dialog->exec() == TQDialog::Accepted)
  404. {
  405. updateItem(item);
  406. slotConfigChanged();
  407. }
  408. delete dialog;
  409. }
  410. void MSettingsDialog::slotEnableAllMessages()
  411. {
  412. KMessageBox::enableAllMessages();
  413. b_enableAllMessages->setEnabled(false);
  414. }
  415. void MSettingsDialog::slotKDESettings()
  416. {
  417. MiscUtils::runCommand("tdecmshell screensaver kcmsmserver tdm");
  418. }
  419. void MSettingsDialog::slotOKClicked()
  420. {
  421. saveDialogSize("Settings Dialog");
  422. _configDialogManager->updateSettings();
  423. // FIXME: 2.0: apply button
  424. // lock after login
  425. if (c_autoLock->isChecked())
  426. {
  427. Links::createLink(
  428. TDEGlobalSettings::autostartPath() + "/kshutdown-autolock.desktop",
  429. "kshutdown --init --lock",
  430. "kshutdown",
  431. "KShutDown",
  432. i18n("This file is used to lock session at TDE startup")
  433. );
  434. }
  435. else
  436. {
  437. Links::removeLink(TDEGlobalSettings::autostartPath() + "/kshutdown-autolock.desktop");
  438. }
  439. int id = gb_systemTray->selectedId();
  440. if (id != -1)
  441. MSystemTray::setMode((MSystemTray::Mode)id);
  442. kshutdownrc->writeConfig();
  443. slotConfigChanged();
  444. }
  445. // TODO: 2.0: remember last page
  446. void MSettingsDialog::slotSetAmorCustomMessage() {
  447. in_customMessageCommand->setText(KS_CONFIG_AMOR_MESSAGE);
  448. }
  449. void MSettingsDialog::slotSetKDialogCustomMessage() {
  450. in_customMessageCommand->setText(KS_CONFIG_KDIALOG_MESSAGE);
  451. }
  452. void MSettingsDialog::slotShutDownProblem()
  453. {
  454. showPage(pageIndex(_actionsPage));
  455. }
  456. void MSettingsDialog::slotTrayMessageProblem()
  457. {
  458. showPage(pageIndex(_messagesPage));
  459. }
  460. void MSettingsDialog::slotWarningMessageTest()
  461. {
  462. MMessageDialog *messageDialog = new MMessageDialog(
  463. in_warningMessageDelay->value() * 60,
  464. Action::Nothing,
  465. i18n("Test")
  466. );
  467. messageDialog->exec();
  468. delete messageDialog;
  469. }
  470. // protected slots
  471. void MSettingsDialog::slotDefault()
  472. {
  473. int index = activePageIndex();
  474. if (index == -1)
  475. return;
  476. _configDialogManager->updateSettings();
  477. // general
  478. if (index == pageIndex(_generalPage))
  479. {
  480. kshutdownrc->i_systemTray->setDefault();
  481. }
  482. // messages
  483. else if (index == pageIndex(_messagesPage))
  484. {
  485. kshutdownrc->i_warningMessageEnabled->setDefault();
  486. kshutdownrc->i_warningMessageDelay->setDefault();
  487. kshutdownrc->i_customMessageEnabled->setDefault();
  488. kshutdownrc->i_customMessageCommand->setDefault();
  489. }
  490. // actions
  491. else if (index == pageIndex(_actionsPage))
  492. {
  493. if (disabledByAdmin("actions"))
  494. return;
  495. if (KMessageBox::warningYesNo(
  496. 0,
  497. i18n("Restore default settings for this page?"),
  498. caption()) != KMessageBox::Yes
  499. )
  500. return;
  501. TDEConfig *conf = kshutdownrc->config();
  502. conf->deleteGroup("Shut Down");
  503. conf->deleteGroup("Reboot");
  504. conf->deleteGroup("Lock Screen");
  505. conf->deleteGroup("Logout");
  506. updateActions();
  507. slotConfigChanged();
  508. }
  509. // advanced
  510. else if (index == pageIndex(_advancedPage))
  511. {
  512. c_autoLock->setChecked(false);
  513. kshutdownrc->i_cdTrayClose->setDefault();
  514. kshutdownrc->i_cdTrayCloseCommand->setDefault();
  515. slotConfigChanged();
  516. }
  517. else
  518. {
  519. return;
  520. }
  521. _configDialogManager->updateWidgets();
  522. }
  523. #include "msettingsdialog.moc"