ctkSettingsDialog.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.commontk.org/LICENSE
  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. class CTK_WIDGETS_EXPORT ctkSettingsDialog : public QDialog
  26. {
  27. Q_OBJECT
  28. public:
  29. /// Superclass typedef
  30. typedef QDialog Superclass;
  31. /// Constructor
  32. explicit ctkSettingsDialog(QWidget* parent = 0);
  33. /// Destructor
  34. virtual ~ctkSettingsDialog();
  35. QSettings* settings()const;
  36. void setSettings(QSettings* settings);
  37. ctkSettingsPanel* panel(const QString& panel)const;
  38. ctkSettingsPanel* currentPanel()const;
  39. /// Uses the ctkSettingsPanel::windowTitle property to show in the list
  40. void addPanel(ctkSettingsPanel* panel, ctkSettingsPanel* parentPanel = 0);
  41. /// Utility function
  42. void addPanel(const QString& label, ctkSettingsPanel* panel, ctkSettingsPanel* parentPanel = 0);
  43. void addPanel(const QString& label, const QIcon& icon, ctkSettingsPanel* panel, ctkSettingsPanel* parentPanel = 0);
  44. public slots:
  45. void setCurrentPanel(ctkSettingsPanel* panel);
  46. void setCurrentPanel(const QString& label);
  47. void applySettings();
  48. void resetSettings();
  49. void restoreDefaultSettings();
  50. virtual void accept();
  51. virtual void reject();
  52. signals:
  53. void settingChanged(const QString& key, const QVariant& value);
  54. protected slots:
  55. void onSettingChanged(const QString& key, const QVariant& newVal);
  56. void onCurrentItemChanged(QTreeWidgetItem* currentItem, QTreeWidgetItem* previous);
  57. void onDialogButtonClicked(QAbstractButton* button);
  58. protected:
  59. QScopedPointer<ctkSettingsDialogPrivate> d_ptr;
  60. private:
  61. Q_DECLARE_PRIVATE(ctkSettingsDialog);
  62. Q_DISABLE_COPY(ctkSettingsDialog);
  63. };
  64. #endif