-
Notifications
You must be signed in to change notification settings - Fork 6
/
QColourEdit.cpp
110 lines (94 loc) · 1.59 KB
/
QColourEdit.cpp
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
#include "QColourEdit.h"
QColourEdit::QColourEdit(QWidget *parent)
: QWidget(parent)
,red(0.0)
,green(0.0)
,blue(0.0)
,alpha(0.0)
{
ui.setupUi(this);
}
QColourEdit::~QColourEdit()
{
}
void QColourEdit::setColour(const double *c)
{
red=*c++;
green=*c++;
blue=*c++;
alpha=*c++;
}
void QColourEdit::setColour(double r,double g,double b,double a)
{
red=r;
green=g;
blue=b;
alpha=a;
}
void QColourEdit::setLabel(QString f)
{
ui.label->setText(f);
}
QString QColourEdit::label() const
{
return ui.label->text();
}
int QColourEdit::labelWidth() const
{
return labelWidth_;
}
void QColourEdit::setLabelWidth(int w)
{
labelWidth_=w;
QSize s=ui.label->minimumSize();
s.setWidth(w);
ui.label->setMinimumSize(s);
s=ui.label->maximumSize();
s.setWidth(w);
ui.label->setMaximumSize(s);
update();
}
bool QColourEdit::showAlpha() const
{
return ui.alpha->isVisible();
}
void QColourEdit::setShowAlpha(bool w)
{
ui.alpha->setVisible(w);
}
void QColourEdit::on_red_editingFinished()
{
bool ok=false;
double value_=ui.red->text().toDouble(&ok);
if(!ok)
return;
red=value_;
emit valueChanged();
}
void QColourEdit::on_green_editingFinished()
{
bool ok=false;
double value_=ui.green->text().toDouble(&ok);
if(!ok)
return;
green=value_;
emit valueChanged();
}
void QColourEdit::on_blue_editingFinished()
{
bool ok=false;
double value_=ui.blue->text().toDouble(&ok);
if(!ok)
return;
blue=value_;
emit valueChanged();
}
void QColourEdit::on_alpha_editingFinished()
{
bool ok=false;
double value_=ui.alpha->text().toDouble(&ok);
if(!ok)
return;
alpha=value_;
emit valueChanged();
}