CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkSettingsDialog.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 __ctkSettingsDialog_h
22 #define __ctkSettingsDialog_h
23 
24 // Qt includes
25 #include <QDialog>
26 
27 // CTK includes
28 #include "ctkWidgetsExport.h"
29 
30 class QAbstractButton;
31 class QSettings;
32 class QTreeWidgetItem;
33 class ctkSettingsDialogPrivate;
34 class ctkSettingsPanel;
35 
37 class CTK_WIDGETS_EXPORT ctkSettingsDialog : public QDialog
38 {
39  Q_OBJECT
43  Q_PROPERTY(bool resetButton READ resetButton WRITE setResetButton);
44 
45  Q_PROPERTY(QSettings* settings READ settings WRITE setSettings);
46 
47  Q_PROPERTY(ctkSettingsPanel* currentPanel READ currentPanel WRITE setCurrentPanel);
48 
54  Q_PROPERTY(bool restartRequired READ isRestartRequired);
55 
56 public:
58  typedef QDialog Superclass;
59 
61  explicit ctkSettingsDialog(QWidget* parent = 0);
62 
64  virtual ~ctkSettingsDialog();
65 
66  QSettings* settings()const;
67  void setSettings(QSettings* settings);
68 
69  ctkSettingsPanel* panel(const QString& panel)const;
70  ctkSettingsPanel* currentPanel()const;
71 
77  Q_INVOKABLE void addPanel(ctkSettingsPanel* panel, ctkSettingsPanel* parentPanel = 0);
78 
83  Q_INVOKABLE void addPanel(const QString& label, ctkSettingsPanel* panel,
84  ctkSettingsPanel* parentPanel = 0);
85 
90  Q_INVOKABLE void addPanel(const QString& label, const QIcon& icon,
91  ctkSettingsPanel* panel, ctkSettingsPanel* parentPanel = 0);
92 
93  bool resetButton()const;
94  void setResetButton(bool show);
95 
98  bool isRestartRequired()const;
99 
100 public Q_SLOTS:
101  void setCurrentPanel(ctkSettingsPanel* panel);
102  void setCurrentPanel(const QString& label);
103 
104  void applySettings();
105  void resetSettings();
106  void restoreDefaultSettings();
107 
114  void reloadSettings();
115 
116  virtual void accept();
117  virtual void reject();
118 
120  void adjustTreeWidgetToContents();
121 
122 Q_SIGNALS:
123  void settingChanged(const QString& key, const QVariant& value);
127  void restartRequested();
128 
129 protected Q_SLOTS:
130  void onSettingChanged(const QString& key, const QVariant& newVal);
131  void onCurrentItemChanged(QTreeWidgetItem* currentItem, QTreeWidgetItem* previous);
132  void onDialogButtonClicked(QAbstractButton* button);
133 
134 protected:
135  virtual bool event(QEvent *);
136 
137 protected:
138  QScopedPointer<ctkSettingsDialogPrivate> d_ptr;
139 
140 private:
141  Q_DECLARE_PRIVATE(ctkSettingsDialog);
142  Q_DISABLE_COPY(ctkSettingsDialog);
143 };
144 
145 #endif
ctkSettingsPanel
Definition: ctkSettingsPanel.h:35
ctkSettingsDialog
Definition: ctkSettingsDialog.h:37
ctkSettingsDialog::Superclass
QDialog Superclass
Superclass typedef.
Definition: ctkSettingsDialog.h:54
ctkSettingsDialog::d_ptr
QScopedPointer< ctkSettingsDialogPrivate > d_ptr
Definition: ctkSettingsDialog.h:138