-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMenuColor.h
121 lines (70 loc) · 2.23 KB
/
MenuColor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef COLORMENU_H
#define COLORMENU_H
#include <QMenu>
#include <QToolButton>
#include "app_settings.h"
class QGridLayout;
class QColorPicker;
class QActionColor : public QAction
{
Q_OBJECT
public:
enum _TAction{
ApplyCurrentColor = 0
, PickColorFromDlg
};
protected:
_TAction m_iAction;
QIcon m_xIcon;
QSize m_szIcon;
QColor m_clSelected;
QString m_sDlgTitle;
protected:
void setIconForColorBtn(const QColor& clColor);
public:
QActionColor(const QString& sText, const QColor& clInit = QColor(Qt::transparent), QObject* parent = NULL);
QActionColor(const QString& sText, const QIcon& xIcon, const QColor& clInit = QColor(Qt::transparent), QObject* parent = NULL);
QActionColor(const QIcon& xIcon, const QColor& clInit = QColor(Qt::transparent), QObject* parent = NULL);
_TAction triggerAction() const {return m_iAction;}
void setTriggerAction(_TAction iAction){m_iAction = iAction;}
QString colorDialogTitle() const {return m_sDlgTitle;}
void setColorDialogTitle(const QString& sTitle){m_sDlgTitle = sTitle;}
QColor currentColor() const {return m_clSelected;}
signals:
void colorChose(const QColor& clColor);
protected slots:
void onTriggered();
public slots:
void setCurrentColor(const QColor& clCurrent){m_clSelected = clCurrent; setIconForColorBtn(clCurrent);}
};
///////////////////////////////////////////////////////////
class QMenuColor : public QMenu
{
Q_OBJECT
protected:
QColorPicker * m_pColorPicker;
public:
QMenuColor(QWidget* parent = 0);
signals:
void colorChose(const QColor& clColor);
protected slots:
void onColorChose(const QColor& clColor){QWidget::close(); emit colorChose(clColor);}
};
///////////////////////////////////////////////////////////
class QToolButtonColor : public QToolButton
{
Q_OBJECT
protected:
QActionColor * m_pDefAction;
QMenuColor * m_pMenuColor;
public:
QToolButtonColor(const QIcon& xIcon, const QColor& clInit, QWidget* parent);
QColor currentColor() const {return m_pDefAction->currentColor();}
signals:
void colorChose(const QColor& clColor);
protected slots:
void onChooseColor(const QColor& clColor);
public slots:
void setCurrentColor(const QColor& clCurrent){m_pDefAction->setCurrentColor(clCurrent);}
};
#endif // COLORMENU_H