123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- /*=========================================================================
- Library: CTK
- Copyright (c) Kitware Inc.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0.txt
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- =========================================================================*/
- #ifndef __ctkSettingsDialog_h
- #define __ctkSettingsDialog_h
- // Qt includes
- #include <QDialog>
- // CTK includes
- #include "ctkWidgetsExport.h"
- class QAbstractButton;
- class QSettings;
- class QTreeWidgetItem;
- class ctkSettingsDialogPrivate;
- class ctkSettingsPanel;
- /// \ingroup Widgets
- class CTK_WIDGETS_EXPORT ctkSettingsDialog : public QDialog
- {
- Q_OBJECT
- /// This property controls whether the reset button is visible in the
- /// button box or not. The Cancel button is a reset button and closes
- /// the dialog at the same time.
- Q_PROPERTY(bool resetButton READ resetButton WRITE setResetButton);
- public:
- /// Superclass typedef
- typedef QDialog Superclass;
- /// Constructor
- explicit ctkSettingsDialog(QWidget* parent = 0);
- /// Destructor
- virtual ~ctkSettingsDialog();
- QSettings* settings()const;
- void setSettings(QSettings* settings);
- ctkSettingsPanel* panel(const QString& panel)const;
- ctkSettingsPanel* currentPanel()const;
- /// Uses the ctkSettingsPanel::windowTitle property to show in the list
- void addPanel(ctkSettingsPanel* panel, ctkSettingsPanel* parentPanel = 0);
- /// Utility function
- void addPanel(const QString& label, ctkSettingsPanel* panel, ctkSettingsPanel* parentPanel = 0);
- void addPanel(const QString& label, const QIcon& icon, ctkSettingsPanel* panel, ctkSettingsPanel* parentPanel = 0);
- bool resetButton()const;
- void setResetButton(bool show);
- /// True if at least one OptionRestartRequired setting is changed.
- /// It doesn't mean the user accepted to restart the application
- /// \sa restartRequired
- bool isRestartRequired()const;
- public Q_SLOTS:
- void setCurrentPanel(ctkSettingsPanel* panel);
- void setCurrentPanel(const QString& label);
- void applySettings();
- void resetSettings();
- void restoreDefaultSettings();
- virtual void accept();
- virtual void reject();
- /// Resize the left panel based on the panels titles.
- void adjustTreeWidgetToContents();
- Q_SIGNALS:
- void settingChanged(const QString& key, const QVariant& value);
- /// Signal fired when the user accepts to restart the application because
- /// some OptionRestartRequired settings have changed.
- /// \sa isrestartRequired
- void restartRequested();
- protected Q_SLOTS:
- void onSettingChanged(const QString& key, const QVariant& newVal);
- void onCurrentItemChanged(QTreeWidgetItem* currentItem, QTreeWidgetItem* previous);
- void onDialogButtonClicked(QAbstractButton* button);
- protected:
- virtual bool event(QEvent *);
- protected:
- QScopedPointer<ctkSettingsDialogPrivate> d_ptr;
- private:
- Q_DECLARE_PRIVATE(ctkSettingsDialog);
- Q_DISABLE_COPY(ctkSettingsDialog);
- };
- #endif
|