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
30class ctkColorDialogPrivate;
31
35class CTK_WIDGETS_EXPORT ctkColorDialog : public QColorDialog
36{
37 Q_OBJECT
38 Q_PROPERTY(QString colorName READ colorName WRITE setColorName)
39
40public:
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
115public Q_SLOTS:
117 void setColor(const QColor& color);
118
121 void setColorName(const QString& name);
122
123Q_SIGNALS:
124 void currentColorNameChanged(const QString& colorName);
125
126protected Q_SLOTS:
128
129protected:
130 QScopedPointer<ctkColorDialogPrivate> d_ptr;
131
133 static int DefaultTab;
134 static QString LastColorName;
135private:
136 Q_DECLARE_PRIVATE(ctkColorDialog);
137 Q_DISABLE_COPY(ctkColorDialog);
138};
139
140//------------------------------------------------------------------------------
141void ctkColorDialog::addTab(QWidget* widget, const QString& label)
142{
143 this->insertTab(-1, widget, label);
144}
145
146//------------------------------------------------------------------------------
147void 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
static QString LastColorName
Q_INVOKABLE QWidget * widget(int index) const
void setColorName(const QString &name)
static Q_INVOKABLE void setDefaultTab(int index)
Q_INVOKABLE void insertTab(int tabIndex, QWidget *widget, const QString &label)
ctkColorDialog(QWidget *parent=0)
Q_INVOKABLE int indexOf(QWidget *widget) const
void currentColorNameChanged(const QString &colorName)
static int DefaultTab
ctkColorDialog(const QColor &initial, QWidget *parent=0)
void setColor(const QColor &color)
Slot-ify QColorDialog::setCurrentColor(QColor)
virtual ~ctkColorDialog()
Q_INVOKABLE void removeTab(int index)
Q_INVOKABLE void setCurrentTab(int index)
Set the current tab index. 0 ("Basic" tab) by default.
static Q_INVOKABLE QString getColorName()
Q_INVOKABLE void addTab(QWidget *widget, const QString &label)
static Q_INVOKABLE void addDefaultTab(QWidget *widget, const QString &label, const char *colorSignal=0, const char *nameSignal=0)
static Q_INVOKABLE QColor getColor(const QColor &initial, QWidget *parent, const QString &title, ColorDialogOptions options=0)
void resetColorName()
static Q_INVOKABLE void insertDefaultTab(int tabIndex, QWidget *widget, const QString &label, const char *colorSignal=0, const char *nameSignal=0)
static QList< QWidget * > DefaultTabs
QString colorName() const
Return the current color name if any has been set.
QScopedPointer< ctkColorDialogPrivate > d_ptr