CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkSettingsPanel.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Library: CTK
4
5 Copyright (c) Kitware Inc.
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0.txt
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18
19=========================================================================*/
20
21#ifndef __ctkSettingsPanel_h
22#define __ctkSettingsPanel_h
23
24// Qt includes
25#include <QMetaType>
26#include <QWidget>
27
28// CTK includes
29#include "ctkWidgetsExport.h"
30
31class QSettings;
32class ctkSettingsPanelPrivate;
33
35class CTK_WIDGETS_EXPORT ctkSettingsPanel : public QWidget
36{
37 Q_OBJECT
38 Q_ENUMS(SettingOption)
39 Q_FLAGS(SettingOptions)
40
41 Q_PROPERTY(QSettings* settings READ settings WRITE setSettings);
42
43public:
45 typedef QWidget Superclass;
46
48 explicit ctkSettingsPanel(QWidget* parent = 0);
49
52
53 QSettings* settings()const;
54 void setSettings(QSettings* settings);
55
57 OptionNone = 0x0000,
58 OptionRequireRestart = 0x0001,
59 OptionAll_Mask = ~0
60 };
61 Q_DECLARE_FLAGS(SettingOptions, SettingOption)
81 void registerProperty(const QString& settingKey,
82 QObject* object,
83 const QString& objectProperty,
84 const char* propertySignal,
85 const QString& settingLabel = QString(),
86 SettingOptions options = OptionNone,
87 QSettings * settings = 0);
88
91 Q_INVOKABLE void registerProperty(const QString& settingKey, QObject* object,
92 const QString& objectProperty,
93 const QByteArray& propertySignal,
94 const QString& settingLabel = QString(),
95 SettingOptions options = OptionNone,
96 QSettings * settings = 0);
97
100 void setSetting(const QString& key, const QVariant& newVal);
101
104 QStringList changedSettings()const;
105
107 QString settingLabel(const QString& settingKey)const;
108
110 SettingOptions settingOptions(const QString& settingKey)const;
111public Q_SLOTS:
112
116 virtual void applySettings();
117
120 virtual void resetSettings();
121
124 virtual void restoreDefaultSettings();
125
131 virtual void reloadSettings();
132
133Q_SIGNALS:
135 void settingChanged(const QString& key, const QVariant& value);
136
137protected:
140 QVariant defaultPropertyValue(const QString& key) const;
141
144 QVariant previousPropertyValue(const QString& key) const;
145
148 QVariant propertyValue(const QString& key) const;
149
150protected Q_SLOTS:
151 void updateSetting(const QString& key);
152
153protected:
154 QScopedPointer<ctkSettingsPanelPrivate> d_ptr;
155
156private:
157 Q_DECLARE_PRIVATE(ctkSettingsPanel);
158 Q_DISABLE_COPY(ctkSettingsPanel);
159};
160
164
165#endif
QWidget Superclass
Superclass typedef.
ctkSettingsPanel(QWidget *parent=0)
Constructor.
QSettings * settings() const
void setSettings(QSettings *settings)
virtual ~ctkSettingsPanel()
Destructor.
Q_DECLARE_METATYPE(ctkDICOMPersonName)
Q_DECLARE_OPERATORS_FOR_FLAGS(ctkVTKDataSetModel::AttributeTypes)