CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkColorDialog.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 __ctkColorDialog_h
22 #define __ctkColorDialog_h
23 
24 // Qt includes
25 #include <QColorDialog>
26 
27 // CTK includes
28 #include "ctkWidgetsExport.h"
29 
30 class ctkColorDialogPrivate;
31 
35 class CTK_WIDGETS_EXPORT ctkColorDialog : public QColorDialog
36 {
37  Q_OBJECT
38  Q_PROPERTY(QString colorName READ colorName WRITE setColorName)
39 
40 public:
44  explicit ctkColorDialog(QWidget* parent = 0);
45  explicit ctkColorDialog(const QColor& initial, QWidget* parent = 0);
46  virtual ~ctkColorDialog();
47 
58  Q_INVOKABLE inline void addTab(QWidget* widget, const QString& label);
59 
63  Q_INVOKABLE void insertTab(int tabIndex, QWidget* widget, const QString& label);
64 
68  Q_INVOKABLE void removeTab(int index);
69 
71  Q_INVOKABLE void setCurrentTab(int index);
72 
75  Q_INVOKABLE QWidget* widget(int index)const;
76 
79  Q_INVOKABLE int indexOf(QWidget* widget)const;
80 
82  QString colorName()const;
83 
91  Q_INVOKABLE static QColor getColor(const QColor &initial, QWidget *parent,
92  const QString &title, ColorDialogOptions options = 0);
96  Q_INVOKABLE static QString getColorName();
97 
102  Q_INVOKABLE static inline void addDefaultTab(QWidget* widget, const QString& label,
103  const char* colorSignal = 0,
104  const char* nameSignal = 0);
108  Q_INVOKABLE static void insertDefaultTab(int tabIndex, QWidget* widget, const QString& label,
109  const char* colorSignal = 0,
110  const char* nameSignal = 0);
113  Q_INVOKABLE static void setDefaultTab(int index);
114 
115 public Q_SLOTS:
117  void setColor(const QColor& color);
118 
121  void setColorName(const QString& name);
122 
123 Q_SIGNALS:
124  void currentColorNameChanged(const QString& colorName);
125 
126 protected Q_SLOTS:
128 
129 protected:
130  QScopedPointer<ctkColorDialogPrivate> d_ptr;
131 
133  static int DefaultTab;
134  static QString LastColorName;
135 private:
136  Q_DECLARE_PRIVATE(ctkColorDialog);
137  Q_DISABLE_COPY(ctkColorDialog);
138 };
139 
140 //------------------------------------------------------------------------------
141 void ctkColorDialog::addTab(QWidget* widget, const QString& label)
142 {
143  this->insertTab(-1, widget, label);
144 }
145 
146 //------------------------------------------------------------------------------
147 void ctkColorDialog::addDefaultTab(QWidget* widget, const QString& label,
148  const char* colorSignal,
149  const char* nameSignal)
150 {
151  ctkColorDialog::insertDefaultTab(-1, widget, label, colorSignal, nameSignal);
152 }
153 
154 #endif
ctkColorDialog::DefaultTab
static int DefaultTab
Definition: ctkColorDialog.h:133
ctkColorDialog::DefaultTabs
static QList< QWidget * > DefaultTabs
Definition: ctkColorDialog.h:132
ctkColorDialog::setCurrentTab
Q_INVOKABLE void setCurrentTab(int index)
Set the current tab index. 0 ("Basic" tab) by default.
ctkColorDialog::indexOf
Q_INVOKABLE int indexOf(QWidget *widget) const
ctkColorDialog::removeTab
Q_INVOKABLE void removeTab(int index)
ctkWrapPythonQt.options
options
Definition: ctkWrapPythonQt.py:229
QList< QWidget * >
ctkColorDialog::LastColorName
static QString LastColorName
Definition: ctkColorDialog.h:134
ctkColorDialog::ctkColorDialog
ctkColorDialog(QWidget *parent=0)
ctkColorDialog::d_ptr
QScopedPointer< ctkColorDialogPrivate > d_ptr
Definition: ctkColorDialog.h:130
ctkColorDialog::getColorName
static Q_INVOKABLE QString getColorName()
ctkColorDialog::resetColorName
void resetColorName()
ctkColorDialog::getColor
static Q_INVOKABLE QColor getColor(const QColor &initial, QWidget *parent, const QString &title, ColorDialogOptions options=0)
ctkColorDialog::currentColorNameChanged
void currentColorNameChanged(const QString &colorName)
ctkColorDialog::insertTab
Q_INVOKABLE void insertTab(int tabIndex, QWidget *widget, const QString &label)
ctkColorDialog::ctkColorDialog
ctkColorDialog(const QColor &initial, QWidget *parent=0)
ctkColorDialog
Definition: ctkColorDialog.h:36
ctkColorDialog::setDefaultTab
static Q_INVOKABLE void setDefaultTab(int index)
ctkColorDialog::setColor
void setColor(const QColor &color)
Slot-ify QColorDialog::setCurrentColor(QColor)
ctkColorDialog::widget
Q_INVOKABLE QWidget * widget(int index) const
ctkColorDialog::addTab
Q_INVOKABLE void addTab(QWidget *widget, const QString &label)
Definition: ctkColorDialog.h:141
ctkColorDialog::setColorName
void setColorName(const QString &name)
ctkColorDialog::colorName
QString colorName() const
Return the current color name if any has been set.
ctkColorDialog::addDefaultTab
static Q_INVOKABLE void addDefaultTab(QWidget *widget, const QString &label, const char *colorSignal=0, const char *nameSignal=0)
Definition: ctkColorDialog.h:147
ctkColorDialog::insertDefaultTab
static Q_INVOKABLE void insertDefaultTab(int tabIndex, QWidget *widget, const QString &label, const char *colorSignal=0, const char *nameSignal=0)
ctkColorDialog::~ctkColorDialog
virtual ~ctkColorDialog()