1 // Copyright 2005-2019 The Mumble Developers. All rights reserved.
2 // Use of this source code is governed by a BSD-style license
3 // that can be found in the LICENSE file at the root of the
4 // Mumble source tree or at <https://www.mumble.info/LICENSE>.
5 
6 #ifndef MUMBLE_MUMBLE_CONFIGWIDGET_H_
7 #define MUMBLE_MUMBLE_CONFIGWIDGET_H_
8 
9 #include <QtCore/QtGlobal>
10 #include <QtCore/QObject>
11 #if QT_VERSION >= 0x050000
12 # include <QtWidgets/QWidget>
13 #else
14 # include <QtGui/QWidget>
15 #endif
16 
17 struct Settings;
18 class ConfigDialog;
19 class QSlider;
20 class QAbstractButton;
21 class QComboBox;
22 
23 class ConfigWidget : public QWidget {
24 	private:
25 		Q_OBJECT
26 		Q_DISABLE_COPY(ConfigWidget)
27 	protected:
28 		void loadSlider(QSlider *, int);
29 		void loadCheckBox(QAbstractButton *, bool);
30 		void loadComboBox(QComboBox *, int);
31 	signals:
32 		void intSignal(int);
33 	public:
34 		Settings &s;
35 		ConfigWidget(Settings &st);
36 		virtual QString title() const = 0;
37 		virtual QIcon icon() const;
38 	public slots:
39 		virtual void accept() const;
40 		virtual void save() const = 0;
41 		virtual void load(const Settings &r) = 0;
42 };
43 
44 typedef ConfigWidget *(*ConfigWidgetNew)(Settings &st);
45 
46 class ConfigRegistrar Q_DECL_FINAL {
47 		friend class ConfigDialog;
48 		friend class ConfigDialogMac;
49 	private:
50 		Q_DISABLE_COPY(ConfigRegistrar)
51 	protected:
52 		int iPriority;
53 		static QMap<int, ConfigWidgetNew> *c_qmNew;
54 	public:
55 		ConfigRegistrar(int priority, ConfigWidgetNew n);
56 		~ConfigRegistrar();
57 };
58 
59 #endif
60