This repository was archived by the owner on May 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsoleButton.cpp
More file actions
60 lines (51 loc) · 2.06 KB
/
ConsoleButton.cpp
File metadata and controls
60 lines (51 loc) · 2.06 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
#include "ConsoleButton.h"
ConsoleButton::ConsoleButton(QWidget *parent)
: ClickButton(parent)
{
this->setMouseTracking(true);
}
ConsoleButton::~ConsoleButton()
{
}
void ConsoleButton::paintEvent(QPaintEvent* event)
{
Q_UNUSED(event);
QPainter painter(this);
QColor col_background, col_main;
switch (this->state)
{
case State::NormalState:
{
col_background = GetStyle::parseStringToColor(QString::fromStdString(StyleContainer::getContainer().getStyleObject()["status"]["console-button"]("color-background-normal")));
col_main = GetStyle::parseStringToColor(QString::fromStdString(StyleContainer::getContainer().getStyleObject()["status"]["console-button"]("color-normal")));
break;
}
case State::HoverState:
{
col_background = GetStyle::parseStringToColor(QString::fromStdString(StyleContainer::getContainer().getStyleObject()["status"]["console-button"]("color-background-hover")));
col_main = GetStyle::parseStringToColor(QString::fromStdString(StyleContainer::getContainer().getStyleObject()["status"]["console-button"]("color-hover")));
break;
}
case State::PressedState:
{
col_background = GetStyle::parseStringToColor(QString::fromStdString(StyleContainer::getContainer().getStyleObject()["status"]["console-button"]("color-background-pressed")));
col_main = GetStyle::parseStringToColor(QString::fromStdString(StyleContainer::getContainer().getStyleObject()["status"]["console-button"]("color-pressed")));
break;
}
}
painter.fillRect(0, 0, this->width(), this->height(), col_background);
QPen pen;
pen.setWidth(1);
pen.setColor(col_main);
pen.setStyle(Qt::SolidLine);
pen.setCapStyle(Qt::PenCapStyle::FlatCap);
pen.setJoinStyle(Qt::PenJoinStyle::MiterJoin);
painter.setPen(pen);
QPolygon poly;
poly.append(QPoint(0.25 * this->width(), 0.3 * this->height()));
poly.append(QPoint(0.45 * this->width(), 0.45 * this->height()));
poly.append(QPoint(0.25 * this->width(), 0.6 * this->height()));
QLine line(0.5 * this->width(), 0.75 * this->height(), 0.75 * this->width(), 0.75 * this->height());
painter.drawPolyline(poly);
painter.drawLine(line);
}