File indexing completed on 2024-04-28 04:36:29
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 KDEVELOP_CONFIGPAGE_H 0008 #define KDEVELOP_CONFIGPAGE_H 0009 0010 #include <KTextEditor/ConfigPage> 0011 #include <KLocalizedString> 0012 0013 #include "interfacesexport.h" 0014 0015 class KCoreConfigSkeleton; 0016 0017 namespace KDevelop { 0018 class IPlugin; 0019 class ConfigPagePrivate; 0020 0021 class KDEVPLATFORMINTERFACES_EXPORT ConfigPage : public KTextEditor::ConfigPage 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 /** 0027 * Create a new config page 0028 * @param plugin the plugin that created this config page 0029 * @param config the config skeleton that is used to store the preferences. If you don't use 0030 * a K(Core)ConfigSkeleton to save the settings you can also pass null here. 0031 * However this means that you will have to manually implement the apply(), defaults() and reset() slots 0032 * @param parent parent widget 0033 */ 0034 explicit ConfigPage(IPlugin* plugin, KCoreConfigSkeleton* config = nullptr, QWidget* parent = nullptr); 0035 ~ConfigPage() override; 0036 0037 /** 0038 * Get the number of subpages of this page 0039 * @return The number of child pages or an integer < 1 if there are none. 0040 * The default implementation returns zero. 0041 */ 0042 virtual int childPages() const; 0043 0044 /** 0045 * @return the child config page for index @p number or @c nullptr if there is none. 0046 * The default implementation returns @c nullptr. 0047 */ 0048 virtual ConfigPage* childPage(int number); 0049 0050 enum ConfigPageType 0051 { 0052 DefaultConfigPage, 0053 LanguageConfigPage, ///< A config page that contains language specific settings. This page is appended as a child page to the "Language support" config page. 0054 AnalyzerConfigPage, ///< A config page that contains settings for some analyzer. This page is appended as a child page to the "Analyzers" config page. 0055 DocumentationConfigPage, ///< A config page that contains settings for some documentation plugin. This page is appended as a child page to the "Documentation" config page. 0056 RuntimeConfigPage ///< A config page that contains settings for some runtime plugin. This page is appended as a child page to the "Runtimes" config page. 0057 }; 0058 0059 /** 0060 * @return The type of this config page. Default implementation returns DefaultConfigPageType 0061 */ 0062 virtual ConfigPageType configPageType() const; 0063 0064 /** 0065 * @return the plugin that this config page was created by or nullptr if it was not created by a plugin. 0066 */ 0067 IPlugin* plugin() const; 0068 0069 /** 0070 * Initializes the KConfigDialogManager. 0071 * Must be called explicitly since not all child widgets are available at the end of the constructor. 0072 * This is handled automatically by KDevelop::ConfigDialog, subclasses don't need to call this. 0073 */ 0074 void initConfigManager(); 0075 0076 /** 0077 * @return the KCoreConfigSkeleton used to store the settings for this page or @c nullptr 0078 * if settings are managed differently 0079 */ 0080 KCoreConfigSkeleton* configSkeleton() const; 0081 0082 /** 0083 * Sets the config skeleton to @p skel and will create a KConfigDialogManager if needed. 0084 * This can be used if the KCoreConfigSkeleton* doesn't exist yet when calling the base class constructor. 0085 */ 0086 void setConfigSkeleton(KCoreConfigSkeleton* skel); 0087 0088 public Q_SLOTS: 0089 void apply() override; 0090 void defaults() override; 0091 void reset() override; 0092 0093 protected: 0094 /** 0095 * @return whether this page needs reset() to be called during initialization 0096 */ 0097 virtual bool needsResetDuringInitialization() const; 0098 0099 private: 0100 const QScopedPointer<class ConfigPagePrivate> d_ptr; 0101 Q_DECLARE_PRIVATE(ConfigPage) 0102 }; 0103 0104 } 0105 0106 #endif // KDEVELOP_CONFIGPAGE_H