File indexing completed on 2024-05-05 05:53:55
0001 /* 0002 SPDX-FileCopyrightText: 2019 Mariusz Glebocki <mglb@arccos-1.net> 0003 0004 Based on KConfigDialog and KConfigDialogManager from KConfigWidgets 0005 0006 SPDX-FileCopyrightText: 2003 Benjamin C Meyer (ben+kdelibs at meyerhome dot net) 0007 SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org> 0008 0009 SPDX-License-Identifier: GPL-2.0-or-later 0010 */ 0011 0012 #ifndef CONFIGDIALOGBUTTONGROUPMANAGER_H 0013 #define CONFIGDIALOGBUTTONGROUPMANAGER_H 0014 0015 // Qt 0016 #include <QObject> 0017 0018 // KDE 0019 #include <KCoreConfigSkeleton> 0020 0021 class QString; 0022 class QButtonGroup; 0023 class QAbstractButton; 0024 template<typename T> 0025 class QList; 0026 template<class Key, class T> 0027 class QMap; 0028 0029 namespace Konsole 0030 { 0031 // KConfigDialogManager-like class for managing QButtonGroups, 0032 // which are not supported by KConfigDialogManager yet. When 0033 // support will be available in minimum KF5 used by Konsole, 0034 // just remove this class and all expressions which refer to it. 0035 class ConfigDialogButtonGroupManager : public QObject 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 ConfigDialogButtonGroupManager(QObject *parent, KCoreConfigSkeleton *config); 0041 0042 void addChildren(const QObject *parentObj); 0043 void add(const QButtonGroup *obj); 0044 bool hasChanged() const; 0045 bool isDefault() const; 0046 0047 Q_SIGNALS: 0048 void settingsChanged(); 0049 void widgetModified(); 0050 0051 public Q_SLOTS: 0052 void updateWidgets(); 0053 void updateWidgetsDefault(); 0054 void updateSettings(); 0055 0056 protected Q_SLOTS: 0057 void setButtonState(QAbstractButton *button, bool checked); 0058 0059 private: 0060 // Returns configuration item associated with the group 0061 KCoreConfigSkeleton::ItemEnum *groupToConfigItemEnum(const QButtonGroup *group) const; 0062 0063 // Returns a value the button represents in its group 0064 int buttonToEnumValue(const QAbstractButton *button) const; 0065 0066 static const QString ManagedNamePrefix; 0067 0068 mutable QMap<const QAbstractButton *, int> _buttonValues; 0069 KCoreConfigSkeleton *_config = nullptr; 0070 QList<const QButtonGroup *> _groups; 0071 }; 0072 } 0073 0074 #endif