-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglinfoview.cpp
More file actions
141 lines (120 loc) · 3.82 KB
/
Copy pathglinfoview.cpp
File metadata and controls
141 lines (120 loc) · 3.82 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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include "glinfoview.h"
#include <QFile>
GlInfoView::GlInfoView(GlObject *parent) :
GlObject(parent)
{
borderColor = QColor(66, 74, 90);
gradientColorAt0 = QColor(40,40,40);
gradientColorAt1 = QColor(96,112,144);
border = 1;
borderRadius = 10;
fontColor = QColor(255,255,255,128);
fontSize = 25;
cbPoints = new GlComboBox(this);
cbPoints->setGeometry(300, 209, 200,30);
cbPoints->setFill(false);
connect(cbPoints, SIGNAL(open(GlComboBox*)), this, SLOT(comboBoxOpen(GlComboBox*)));
connect(cbPoints, SIGNAL(closed(GlComboBox*)), this, SLOT(comboBoxClosed(GlComboBox*)));
cbPoints->insertItem(QString("0 Points"));
cbPoints->insertItem(QString("1 Points"));
cbPoints->insertItem(QString("2 Points"));
cbPoints->insertItem(QString("3 Points"));
cbPoints->insertItem(QString("4 Points"));
cbPoints->insertItem(QString("5 Points"));
cbPoints->insertItem(QString("6 Points"));
cbPoints->insertItem(QString("7 Points"));
cbPoints->insertItem(QString("8 Points"));
cbPoints->insertItem(QString("9 Points"));
cbPoints->insertItem(QString("10 Points"));
}
void GlInfoView::comboBoxClosed(GlComboBox* cb)
{
qDebug() << Q_FUNC_INFO;
for(int i = 0; i < listChilds.size(); i++)
{
listChilds.at(i)->setVisible(true);
}
newChildToDraw(this->getParent());
QString t = cb->getText().left(2);
mp.points = t.toInt();
setNewPoints(mp);
}
void GlInfoView::comboBoxOpen(GlComboBox* cb)
{
for(int i = 0; i < listChilds.size(); i++)
{
listChilds.at(i)->setVisible(false);
}
cb->setVisible(true);
newChildToDraw(cb);
}
void GlInfoView::draw(QPainter *p)
{
p->fillRect(geometry(), Qt::black);
QLinearGradient gradient( getWidth()/2, getY(),
getWidth()/2, getY() + getHeight());
gradient.setColorAt(0, gradientColorAt0);
gradient.setColorAt(1, gradientColorAt1);
p->setBrush(QBrush(gradient));
QPainterPath pa;
QRect rect = geometry();
pa.addRoundedRect(rect, borderRadius, borderRadius);
pen.setWidth(border); //Strichbreite
pen.setColor(borderColor); //Strichfarbe
p->setPen(pen);
p->drawPath(pa);
QFile testFile(mp.coverUrl);
if(testFile.exists())
{
coverImg.load(mp.coverUrl);
coverImg = coverImg.scaled(200, 200);
p->drawImage(getX() + 75,
getY() + getHeight()/2 - 100,
coverImg);
}
QFont font = p->font();
font.setPixelSize(fontSize);
font.setBold(true);
p->setFont(font);
p->setPen(fontColor);
QRect re(getX() + 300,
getY() + getHeight()/2 + 10,
400, 30);
p->drawText(re, mp.interpret);
QRect re1(getX() + 300,
getY() + getHeight()/2 + 40,
400, 30);
p->drawText(re1, mp.album);
QRect re2(getX() + 300,
getY() + getHeight()/2 + 70,
400, 30);
p->drawText(re2, mp.title);
cbPoints->draw(p);
}
void GlInfoView::mousePressEvent(QMouseEvent *event)
{
/*Überprüft ob die Maus über einem Button gedrückt wurde und
führt die Funktion mousePressEvent des gedrückten Buttons aus*/
QRect rect;
for(int i = 0; i < listChilds.size(); i++)
{
rect = listChilds.at(i)->geometry();
if(listChilds.at(i)->isVisible() && rect.contains(event->pos()))
{
listChilds.at(i)->mousePressEvent(event);
}
}
}
void GlInfoView::mouseReleaseEvent(QMouseEvent *event)
{
/*siehe mouseReleaseEvent*/
QRect rect;
for(int i = 0; i < listChilds.size(); i++)
{
rect = listChilds.at(i)->geometry();
if(listChilds.at(i)->isVisible() && rect.contains(event->pos()))
{
listChilds.at(i)->mouseReleaseEvent(event);
}
}
}