File indexing completed on 2024-04-28 04:37:15
0001 /* 0002 SPDX-FileCopyrightText: 2014 Alex Richardson <arichardson.kde@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef KDEVPLATFORM_CONFIGDIALOG_H 0008 #define KDEVPLATFORM_CONFIGDIALOG_H 0009 0010 #include <KPageDialog> 0011 0012 namespace KDevelop { 0013 class ConfigPage; 0014 class IPlugin; 0015 0016 /** 0017 * This class is meant to be used to show the global config dialog and the per-project config dialog. 0018 * 0019 * This used to be handled by KSettings::Dialog, but since we are no longer using KCMs for config widgets, 0020 * we use this class instead. 0021 * 0022 * TODO: check if we can share this with Kate 0023 */ 0024 class ConfigDialog : public KPageDialog 0025 { 0026 Q_OBJECT 0027 0028 public: 0029 explicit ConfigDialog(QWidget* parent = nullptr); 0030 0031 public Q_SLOTS: 0032 /** 0033 * Remove a config page 0034 */ 0035 void removeConfigPage(ConfigPage* page); 0036 0037 /** 0038 * Add a new config page to the end of the list of pages. 0039 * @param page the new page to add 0040 */ 0041 void appendConfigPage(ConfigPage* page); 0042 0043 /** 0044 * Add a new config page. 0045 * @param before the page before which the new page will be inserted. 0046 * @param page the new page to add 0047 */ 0048 void insertConfigPage(ConfigPage* before, ConfigPage* page); 0049 0050 /** 0051 * Add a new sub config page 0052 * @param parentPage the parent page 0053 * @param page the page to add 0054 */ 0055 void appendSubConfigPage(ConfigPage* parentPage, ConfigPage* page); 0056 0057 Q_SIGNALS: 0058 void configSaved(ConfigPage* page); 0059 0060 protected: 0061 void closeEvent(QCloseEvent* event) override; 0062 0063 private: 0064 KPageWidgetItem* itemForPage(ConfigPage* page) const; 0065 int checkForUnsavedChanges(KPageWidgetItem* current, KPageWidgetItem* before); 0066 void applyChanges(ConfigPage* page); 0067 void removePagesForPlugin(IPlugin* plugin); 0068 void addConfigPageInternal(KPageWidgetItem* item, ConfigPage* page); 0069 void onPageChanged(); 0070 0071 private: 0072 // we have to use QPointer since KPageDialog::removePage() also removes all child pages 0073 QVector<QPointer<KPageWidgetItem>> m_pages; 0074 bool m_currentPageHasChanges = false; 0075 bool m_currentlyApplyingChanges = false; 0076 }; 0077 0078 } 0079 0080 #endif // KDEVPLATFORM_CONFIGDIALOG_H