ctkSettingsWidget.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 __ctkSettingsWidget_h
  15. #define __ctkSettingsWidget_h
  16. // Qt includes
  17. #include <QWidget>
  18. // CTK includes
  19. #include "ctkWidgetsExport.h"
  20. class ctkSettingsWidgetPrivate;
  21. class QTreeWidgetItem;
  22. class ctkSettingsPanel;
  23. class QSettings;
  24. class CTK_WIDGETS_EXPORT ctkSettingsWidget : public QWidget
  25. {
  26. Q_OBJECT
  27. public:
  28. /// Superclass typedef
  29. typedef QWidget Superclass;
  30. /// Constructor
  31. explicit ctkSettingsWidget(QWidget* parent = 0);
  32. /// Destructor
  33. virtual ~ctkSettingsWidget();
  34. QSettings* settings()const;
  35. void setSettings(QSettings* settings);
  36. ctkSettingsPanel* panel(const QString& panel)const;
  37. ctkSettingsPanel* currentPanel()const;
  38. /// Uses the ctkSettingsPanel::windowTitle property to show in the list
  39. void addPanel(ctkSettingsPanel* panel, ctkSettingsPanel* parentPanel = 0);
  40. /// Utility function
  41. void addPanel(const QString& label, ctkSettingsPanel* panel, ctkSettingsPanel* parentPanel = 0);
  42. void addPanel(const QString& label, const QIcon& icon, ctkSettingsPanel* panel, ctkSettingsPanel* parentPanel = 0);
  43. public slots:
  44. void setCurrentPanel(ctkSettingsPanel* panel);
  45. void setCurrentPanel(const QString& label);
  46. signals:
  47. void settingChanged(const QString& key, const QVariant& value);
  48. protected slots:
  49. void onCurrentItemChanged(QTreeWidgetItem* currentItem, QTreeWidgetItem* previous);
  50. protected:
  51. QScopedPointer<ctkSettingsWidgetPrivate> d_ptr;
  52. private:
  53. Q_DECLARE_PRIVATE(ctkSettingsWidget);
  54. Q_DISABLE_COPY(ctkSettingsWidget);
  55. };
  56. #endif