ctkSettingsDialog.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkSettingsDialog_h
  15. #define __ctkSettingsDialog_h
  16. // Qt includes
  17. #include <QDialog>
  18. // CTK includes
  19. #include "ctkWidgetsExport.h"
  20. class QAbstractButton;
  21. class QSettings;
  22. class QTreeWidgetItem;
  23. class ctkSettingsDialogPrivate;
  24. class ctkSettingsPanel;
  25. /// \ingroup Widgets
  26. class CTK_WIDGETS_EXPORT ctkSettingsDialog : public QDialog
  27. {
  28. Q_OBJECT
  29. public:
  30. /// Superclass typedef
  31. typedef QDialog Superclass;
  32. /// Constructor
  33. explicit ctkSettingsDialog(QWidget* parent = 0);
  34. /// Destructor
  35. virtual ~ctkSettingsDialog();
  36. QSettings* settings()const;
  37. void setSettings(QSettings* settings);
  38. ctkSettingsPanel* panel(const QString& panel)const;
  39. ctkSettingsPanel* currentPanel()const;
  40. /// Uses the ctkSettingsPanel::windowTitle property to show in the list
  41. void addPanel(ctkSettingsPanel* panel, ctkSettingsPanel* parentPanel = 0);
  42. /// Utility function
  43. void addPanel(const QString& label, ctkSettingsPanel* panel, ctkSettingsPanel* parentPanel = 0);
  44. void addPanel(const QString& label, const QIcon& icon, ctkSettingsPanel* panel, ctkSettingsPanel* parentPanel = 0);
  45. void adjustTreeWidgetToContents();
  46. public Q_SLOTS:
  47. void setCurrentPanel(ctkSettingsPanel* panel);
  48. void setCurrentPanel(const QString& label);
  49. void applySettings();
  50. void resetSettings();
  51. void restoreDefaultSettings();
  52. virtual void accept();
  53. virtual void reject();
  54. Q_SIGNALS:
  55. void settingChanged(const QString& key, const QVariant& value);
  56. protected Q_SLOTS:
  57. void onSettingChanged(const QString& key, const QVariant& newVal);
  58. void onCurrentItemChanged(QTreeWidgetItem* currentItem, QTreeWidgetItem* previous);
  59. void onDialogButtonClicked(QAbstractButton* button);
  60. protected:
  61. virtual bool event(QEvent *);
  62. protected:
  63. QScopedPointer<ctkSettingsDialogPrivate> d_ptr;
  64. private:
  65. Q_DECLARE_PRIVATE(ctkSettingsDialog);
  66. Q_DISABLE_COPY(ctkSettingsDialog);
  67. };
  68. #endif