Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
settingspage.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2015 by the Quassel Project *
3  * devel@quassel-irc.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) version 3. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef _SETTINGSPAGE_H_
22 #define _SETTINGSPAGE_H_
23 
24 #include <QWidget>
25 
26 class QCheckBox;
27 class QComboBox;
28 class QSpinBox;
29 
31 
57 class SettingsPage : public QWidget
58 {
59  Q_OBJECT
60 
61 public:
62  SettingsPage(const QString &category, const QString &name, QWidget *parent = 0);
63  virtual ~SettingsPage() {};
64 
66  inline virtual QString category() const { return _category; }
67 
69  inline virtual QString title() const { return _title; }
70 
72 
75  inline virtual bool needsCoreConnection() const { return false; }
76 
78 
85  inline virtual QString settingsKey() const { return QString(); }
86 
88 
93  inline virtual bool hasDefaults() const { return false; }
94 
96  inline bool hasChanged() const { return _changed || _autoWidgetsChanged; }
97 
99 
102  inline virtual bool aboutToSave() { return true; }
103 
105  static void load(QCheckBox *box, bool checked);
106  static bool hasChanged(QCheckBox *box);
107  static void load(QComboBox *box, int index);
108  static bool hasChanged(QComboBox *box);
109  static void load(QSpinBox *box, int value);
110  static bool hasChanged(QSpinBox *box);
111 
112 public slots:
114 
117  virtual void save();
118 
120 
123  virtual void load();
124 
126 
129  virtual void defaults();
130 
131 protected slots:
133  inline void changed() { setChangedState(true); }
134 
136  void setChangedState(bool hasChanged = true);
137 
138 protected:
139  void initAutoWidgets();
140  virtual QVariant loadAutoWidgetValue(const QString &widgetName);
141  virtual void saveAutoWidgetValue(const QString &widgetName, const QVariant &value);
142 
143 signals:
145  void changed(bool hasChanged);
146 
147 private slots:
148  // for auto stuff
149  void autoWidgetHasChanged();
150 
151 private:
152  void findAutoWidgets(QObject *parent, QObjectList *widgetList) const;
153  QByteArray autoWidgetPropertyName(QObject *widget) const;
154  QString autoWidgetSettingsKey(QObject *widget) const;
155 
156  QString _category, _title;
158  QObjectList _autoWidgets;
159 };
160 
161 
162 #endif