-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcolorchooser.cpp
More file actions
84 lines (73 loc) · 3.89 KB
/
colorchooser.cpp
File metadata and controls
84 lines (73 loc) · 3.89 KB
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
#include "colorchooser.h"
#include "ui_colorchooser.h"
ColorChooser::ColorChooser(QWidget *parent) :
QWidget(parent),
ui(new Ui::ColorChooser)
{
ui->setupUi(this);
this->setAttribute(Qt::WA_Hover);
setMouseTracking(true);
grabMouse();
m_primaryScreen = QApplication::primaryScreen();
m_screenWidth = m_primaryScreen->geometry().width();
m_mouseColor = Qt::white;
}
void ColorChooser::mouseMoveEvent(QMouseEvent *event)
{
m_mouseX = QCursor::pos().x();
if (m_mouseX < 100)
m_mouseX = 0;
if (m_mouseX > m_screenWidth - 100)
m_mouseX = m_screenWidth;
int hue = (m_mouseX * 255) / m_screenWidth;
QColor hsv = Qt::white;
hsv.setHsv(hue, 255, 255);
m_mouseColor = hsv;
repaint();
}
void ColorChooser::mousePressEvent(QMouseEvent *event)
{
releaseMouse();
this->setVisible(false);
m_colorButton->setStyleSheet(QStringLiteral("QPushButton#colorButton { background-color : ") + m_mouseColor.name() + QStringLiteral("; color : ") + m_mouseColor.name() + QStringLiteral("; }"));
m_logoLabel->color = m_mouseColor;
m_logoLabel->repaint();
m_installerWidget->setStyleSheet(QStringLiteral( \
"QPushButton { background-color: black; \
padding: 4px; \
color : ") + m_mouseColor.name() + QStringLiteral("; \
border: 1px solid ") + m_mouseColor.name() + QStringLiteral("; } \
QLabel { color : ") + m_mouseColor.name() + QStringLiteral("; } \
QRadioButton { color : ") + m_mouseColor.name() + QStringLiteral("; } \
QCheckBox { color : ") + m_mouseColor.name() + QStringLiteral("; } \
QComboBox { color : ") + m_mouseColor.name() + QStringLiteral("; \
background-color : #000000; } \
QGroupBox { color : ") + m_mouseColor.name() + QStringLiteral("; } \
QLineEdit { color : ") + m_mouseColor.name() + QStringLiteral("; } \
QListWidget { color : ") + m_mouseColor.name() + QStringLiteral("; \
selection-color : #000000; \
selection-background-color : ") + m_mouseColor.name() + QStringLiteral("; } \
QScrollBar::vertical { border : 1px solid ") + m_mouseColor.name() + QStringLiteral("; \
background : #000000; \
width : 15px; } \
QScrollBar::handle { background : #000000; border : 1px solid ") + m_mouseColor.name() + QStringLiteral("; } \
QScrollBar::up-arrow::vertical, QScrollBar::down-arrow::vertical { background : #000000; border : 1px solid ") + m_mouseColor.name() + QStringLiteral("; } \
QScrollBar::add-line::vertical, QScrollBar::sub-line::vertical { background : #000000; border : 1px solid ") + m_mouseColor.name() + QStringLiteral("; } \
QDateTimeEdit { color : ") + m_mouseColor.name() + QStringLiteral("; }"));
emit done();
this->close();
}
void ColorChooser::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.drawPixmap(0, 0, width(), height(), QPixmap(QString::fromUtf8(":images/images/wallpaper_system.png")));
painter.setCompositionMode(QPainter::CompositionMode_Darken);
QBrush brush(m_mouseColor);
QPen pen(brush, 3000);
painter.setPen(pen);
painter.drawLine(0, 0, 3000, 3000);
}
ColorChooser::~ColorChooser()
{
delete ui;
}