| 25 | //FIXME: unit test this code! |
| 26 | |
| 27 | ConfigDialog::ConfigDialog(QWidget* parent) |
| 28 | : KPageDialog(parent) |
| 29 | { |
| 30 | setWindowTitle(i18nc("@title:window", "Configure")); |
| 31 | setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults); |
| 32 | button(QDialogButtonBox::Apply)->setEnabled(false); |
| 33 | setObjectName(QStringLiteral("configdialog")); |
| 34 | |
| 35 | auto onApplyClicked = [this] { |
| 36 | auto page = qobject_cast<ConfigPage*>(currentPage()->widget()); |
| 37 | Q_ASSERT(page); |
| 38 | applyChanges(page); |
| 39 | }; |
| 40 | |
| 41 | connect(button(QDialogButtonBox::Apply), &QPushButton::clicked, onApplyClicked); |
| 42 | connect(button(QDialogButtonBox::Ok), &QPushButton::clicked, [this, onApplyClicked] { |
| 43 | if (m_currentPageHasChanges) { |
| 44 | onApplyClicked(); |
| 45 | } |
| 46 | }); |
| 47 | connect(button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, this, [this]() { |
| 48 | auto page = qobject_cast<ConfigPage*>(currentPage()->widget()); |
| 49 | Q_ASSERT(page); |
| 50 | page->defaults(); |
| 51 | }); |
| 52 | |
| 53 | connect(this, &KPageDialog::currentPageChanged, this, &ConfigDialog::checkForUnsavedChanges); |
| 54 | // make sure we don't keep any entries for unloaded plugins |
| 55 | connect(ICore::self()->pluginController(), &IPluginController::unloadingPlugin, |
| 56 | this, &ConfigDialog::removePagesForPlugin); |
| 57 | } |
| 58 | |
| 59 | |
| 60 | KPageWidgetItem* ConfigDialog::itemForPage(ConfigPage* page) const |
nothing calls this directly
no test coverage detected