| 68 | } |
| 69 | |
| 70 | int ConfigDialog::checkForUnsavedChanges(KPageWidgetItem* current, KPageWidgetItem* before) |
| 71 | { |
| 72 | Q_UNUSED(current); |
| 73 | |
| 74 | if (!m_currentPageHasChanges) { |
| 75 | return KMessageBox::PrimaryAction; |
| 76 | } |
| 77 | |
| 78 | // before must be non-null, because if we change from nothing to a new page m_currentPageHasChanges must also be false! |
| 79 | Q_ASSERT(before); |
| 80 | auto oldPage = qobject_cast<ConfigPage*>(before->widget()); |
| 81 | Q_ASSERT(oldPage); |
| 82 | auto dialogResult = |
| 83 | KMessageBox::warningTwoActionsCancel(this, |
| 84 | i18n("The settings of the current module have changed.\n" |
| 85 | "Do you want to apply the changes or discard them?"), |
| 86 | i18nc("@title:window", "Apply Settings"), KStandardGuiItem::apply(), |
| 87 | KStandardGuiItem::discard(), KStandardGuiItem::cancel()); |
| 88 | if (dialogResult == KMessageBox::SecondaryAction) { |
| 89 | oldPage->reset(); |
| 90 | m_currentPageHasChanges = false; |
| 91 | button(QDialogButtonBox::Apply)->setEnabled(false); |
| 92 | } else if (dialogResult == KMessageBox::PrimaryAction) { |
| 93 | applyChanges(oldPage); |
| 94 | } else if (dialogResult == KMessageBox::Cancel) { |
| 95 | // restore old state |
| 96 | QSignalBlocker block(this); // prevent recursion |
| 97 | setCurrentPage(before); |
| 98 | } |
| 99 | return dialogResult; |
| 100 | } |
| 101 | |
| 102 | void ConfigDialog::closeEvent(QCloseEvent* event) |
| 103 | { |
nothing calls this directly
no test coverage detected