itom
Loading...
Searching...
No Matches
colorDialog.h
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 COLORDIALOG_H
22#define COLORDIALOG_H
23
24// Qt includes
25#include <QColorDialog>
26
27// CTK includes
28#include "commonWidgets.h"
29
31
35class ITOMWIDGETS_EXPORT ColorDialog : public QColorDialog
36{
37 Q_OBJECT
38
39public:
43 explicit ColorDialog(QWidget* parent = 0);
44 explicit ColorDialog(const QColor& initial, QWidget* parent = 0);
45 virtual ~ColorDialog();
46
57 inline void addTab(QWidget* widget, const QString& label);
58
62 void insertTab(int tabIndex, QWidget* widget, const QString& label);
63
67 void removeTab(int index);
68
70 void setCurrentTab(int index);
71
74 QWidget* widget(int index)const;
75
78 int indexOf(QWidget* widget)const;
79
81 QString colorName()const;
82
90 static QColor getColor(const QColor &initial, QWidget *parent,
91 const QString &title, ColorDialogOptions options = QColorDialog::ColorDialogOption());
95 static QString getColorName();
96
101 static inline void addDefaultTab(QWidget* widget, const QString& label,
102 const char* colorSignal = 0,
103 const char* nameSignal = 0);
107 static void insertDefaultTab(int tabIndex, QWidget* widget, const QString& label,
108 const char* colorSignal = 0,
109 const char* nameSignal = 0);
112 static void setDefaultTab(int index);
113
114public Q_SLOTS:
116 void setColor(const QColor& color);
117
120 void setColorName(const QString& name);
121
122Q_SIGNALS:
123 void currentColorNameChanged(const QString& colorName);
124
125protected Q_SLOTS:
126 void resetColorName();
127
128protected:
129 QScopedPointer<ColorDialogPrivate> d_ptr;
130
131 static QList<QWidget*> DefaultTabs;
132 static int DefaultTab;
133 static QString LastColorName;
134private:
135 Q_DECLARE_PRIVATE(ColorDialog);
136 Q_DISABLE_COPY(ColorDialog);
137};
138
139//------------------------------------------------------------------------------
140void ColorDialog::addTab(QWidget* widget, const QString& label)
141{
142 this->insertTab(-1, widget, label);
143}
144
145//------------------------------------------------------------------------------
146void ColorDialog::addDefaultTab(QWidget* widget, const QString& label,
147 const char* colorSignal,
148 const char* nameSignal)
149{
150 ColorDialog::insertDefaultTab(-1, widget, label, colorSignal, nameSignal);
151}
152
153#endif
Definition colorDialog.h:36
void insertTab(int tabIndex, QWidget *widget, const QString &label)
Definition colorDialog.cpp:110
void addTab(QWidget *widget, const QString &label)
Definition colorDialog.h:140
static void insertDefaultTab(int tabIndex, QWidget *widget, const QString &label, const char *colorSignal=0, const char *nameSignal=0)
Definition colorDialog.cpp:198
static void addDefaultTab(QWidget *widget, const QString &label, const char *colorSignal=0, const char *nameSignal=0)
Definition colorDialog.h:146
QWidget * widget(int index) const
Definition colorDialog.cpp:138
Definition colorDialog.cpp:37