MCPcopy Create free account
hub / github.com/KDE/kdevelop / checkForUnsavedChanges

Method checkForUnsavedChanges

kdevplatform/shell/configdialog.cpp:70–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70int 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
102void ConfigDialog::closeEvent(QCloseEvent* event)
103{

Callers

nothing calls this directly

Calls 5

buttonFunction · 0.85
applyFunction · 0.50
widgetMethod · 0.45
resetMethod · 0.45
setEnabledMethod · 0.45

Tested by

no test coverage detected