Warning, file /frameworks/kcmutils/src/ksettings/dialog.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2003 Matthias Kretz <kretz@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 0008 #ifndef KSETTINGS_DIALOG_H 0009 #define KSETTINGS_DIALOG_H 0010 0011 #include <kcmultidialog.h> 0012 #include <kcmutils_export.h> 0013 0014 #if KCMUTILS_ENABLE_DEPRECATED_SINCE(5, 85) 0015 #include <KPluginInfo> 0016 #include <KService> 0017 0018 template<class T> 0019 class QList; 0020 class KCModuleInfo; 0021 0022 namespace KSettings 0023 { 0024 class DialogPrivate; 0025 0026 /** 0027 * @short Generic configuration dialog that works over component boundaries 0028 * 0029 * For more information see \ref KSettings. 0030 * 0031 * This class aims to standardize the use of configuration dialogs in applications. 0032 * Especially when using KParts and/or Plugins you face problems creating consistent 0033 * config dialogs. 0034 * 0035 * To show a configuration dialog you only have to call the show method and be 0036 * done with it. A code example: 0037 * 0038 * You initialize @c m_cfgdlg with 0039 * @code 0040 * m_cfgdlg = new Dialog(this); 0041 * @endcode 0042 * 0043 * If you use a KPart that was not especially designed for your app you can use 0044 * the second constructor: 0045 * @code 0046 * QStringList kpartslist; 0047 * for (all my kparts) { 0048 * kpartslist += m_mypart->componentData().componentName(); 0049 * } 0050 * 0051 * m_cfgdlg = new Dialog(kpartslist, this); 0052 * @endcode 0053 * 0054 * and ideally you can connect the "Configure MyApp" action to the config 0055 * dialog show() slot: 0056 * @code 0057 * KStandardAction::preferences(m_cfgdlg, &QDialog::show, actionCollection()); 0058 * @endcode 0059 * 0060 * If you need to be informed when the config is changed by the dialog, you can 0061 * connect to the @c KCMultiDialog::configCommitted() signal (which emits the 0062 * component name as its argument): 0063 * @code 0064 * connect(m_cfgdlg, QOverload<const QByteArray &>::of(&KCMultiDialog::configCommitted), this, &Foo::slotConfigUpdated); 0065 * @endcode 0066 * 0067 * @see KSettings. 0068 * 0069 * @author Matthias Kretz <kretz@kde.org> 0070 */ 0071 class KCMUTILS_EXPORT Dialog : public KCMultiDialog 0072 { 0073 friend class PageNode; 0074 Q_DECLARE_PRIVATE(Dialog) 0075 Q_OBJECT 0076 public: 0077 /** 0078 * Construct a new Preferences Dialog for the application. It uses all 0079 * KCMs with X-KDE-ParentApp set to QCoreApplication::instance()->applicationName(). 0080 * 0081 * @param content Select whether you want a static or configurable 0082 * config dialog. 0083 * @param parent The parent is only used as the parent for the 0084 * dialog - centering the dialog over the parent 0085 * widget. 0086 * @deprecated Since 5.85, use @ref KCMultiDialog instead 0087 */ 0088 KCMUTILS_DEPRECATED_VERSION(5, 85, "use KCMultiDialog instead") 0089 explicit Dialog(QWidget *parent = nullptr); 0090 0091 /** 0092 * Construct a new Preferences Dialog with the pages for the selected 0093 * instance names. For example if you want to have the configuration 0094 * pages for the kviewviewer KPart you would pass a 0095 * QStringList consisting of only the name of the part "kviewviewer". 0096 * 0097 * @param components A list of the names of the components that your 0098 * config dialog should merge the config pages in. 0099 * @param parent The parent is only used as the parent for the 0100 * dialog - centering the dialog over the parent 0101 * widget. 0102 * @deprecated Since 5.85, use @ref KCMultiDialog instead 0103 */ 0104 KCMUTILS_DEPRECATED_VERSION(5, 85, "use KCMultiDialog instead") 0105 explicit Dialog(const QStringList &components, QWidget *parent = nullptr); 0106 0107 ~Dialog() override; 0108 0109 /** 0110 * If you use a Configurable dialog you need to pass KPluginInfo 0111 * objects that the dialog should configure. 0112 */ 0113 void addPluginInfos(const QList<KPluginInfo> &plugininfos); 0114 0115 /** 0116 * Sets the argument list that is given to all the KControlModule's when 0117 * they are created. 0118 * Use this if you have KControlModule's that need special arguments to 0119 * work 0120 * 0121 * Note that this function only works before showing the 0122 * KSettings::Dialog for the first time. 0123 * @param arguments The list of arguments passed to each KCM 0124 */ 0125 void setKCMArguments(const QStringList &arguments); 0126 0127 /** 0128 * Set the blacklisted component list. Any KCM that lists one 0129 * of the components in the given blacklist is not loaded even if it 0130 * would fit otherwise. This is a way to explicitly prevent loading of 0131 * certain KControlModules. 0132 * 0133 * Note that this function only works before showing the 0134 * KSettings::Dialog for the first time. 0135 * @param blacklist the list of components that prevent a KCM from being 0136 * loaded 0137 */ 0138 void setComponentBlacklist(const QStringList &blacklist); 0139 0140 /** 0141 * Tells the dialog whether the entries in the listview are all static 0142 * or whether it should add checkboxes to select which parts 0143 * of the optional functionality should be active or not. 0144 * 0145 * Note that this function only works before showing the dialog for the first time. 0146 * 0147 * Defaults to \p false. 0148 * 0149 * @param allowSelection \p true The user can select what functionality he wants. 0150 * @param allowSelection \p false While running no entries are added or deleted 0151 */ 0152 void setAllowComponentSelection(bool allowSelection); 0153 0154 bool allowComponentSelection() const; 0155 0156 /** 0157 * Returns a list of all KPluginInfo objects the dialog uses. 0158 */ 0159 QList<KPluginInfo> pluginInfos() const; 0160 0161 protected: 0162 /** 0163 * Reimplemented to lazy create the dialog on first show. 0164 */ 0165 void showEvent(QShowEvent *) override; 0166 0167 Q_SIGNALS: 0168 /** 0169 * If you use the dialog in Configurable mode and want to be notified 0170 * when the user changes the plugin selections use this signal. It's 0171 * emitted if the selection has changed and the user pressed Apply or 0172 * Ok. In the slot you would then load and unload the plugins as 0173 * requested. 0174 */ 0175 void pluginSelectionChanged(); 0176 0177 private: 0178 // Q_PRIVATE_SLOT(d_func(), void _k_configureTree()) 0179 Q_PRIVATE_SLOT(d_func(), void _k_updateEnabledState(bool)) 0180 }; 0181 0182 } 0183 0184 #endif // KSETTINGS_DIALOG_H 0185 #endif