-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglmenuinterpret.cpp
More file actions
129 lines (104 loc) · 3.72 KB
/
glmenuinterpret.cpp
File metadata and controls
129 lines (104 loc) · 3.72 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
#include "glmenuinterpret.h"
GlMenuInterpret::GlMenuInterpret(GlObject* parent) : GlObject(parent)
{
backGroundColor = QColor(Qt::black);
setGeometry(0,0,800,600);
setVisible(false);
listWidget = new GlListWidget(this);
listWidget->setGeometry(30,20,400,560);
connect(listWidget, SIGNAL(itemClicked(QString)), this, SIGNAL(interpretSelected(QString)));
buttonMain = new GlButton(this);
buttonMain->setGeometry(530, 48,200,30);
buttonMain->setBackGroundPixmap(QPixmap(":/images/button.png"));
buttonMain->setBackGroundPixmapPressed(QPixmap(":/images/button_pressed.png"));
buttonMain->setText("Main");
buttonMain->setImage();
connect(buttonMain, SIGNAL(clicked()), this, SIGNAL(buttonMainClicked()));
buttonPlayer = new GlButton(this);
buttonPlayer->setGeometry(530,108,200,30);
buttonPlayer->setBackGroundPixmap(QPixmap(":/images/button.png"));
buttonPlayer->setBackGroundPixmapPressed(QPixmap(":/images/button_pressed.png"));
buttonPlayer->setText("Player");
buttonPlayer->setImage();
connect(buttonPlayer, SIGNAL(clicked()), this, SIGNAL(buttonPlayerClicked()));
buttonList = new GlButtonList(this);
buttonList->setGeometry(530,160,200,390);
connect(buttonList, SIGNAL(buttonClicked(QString)), this, SLOT(buttonClicked(QString)));
}
void GlMenuInterpret::buttonClicked(QString s)
{
/*SLOT: Wird ausgeführt wenn ein Button aus der ButtonList angeklickt wird.
- aus der Datenbank werden alle Interpreten mit dem Anfangsbuchstaben gesucht
- die Liste der Interpreten wird an listWidget übergeben*/
listWidget->insertItem(db->getInterpreten(s));
}
void GlMenuInterpret::draw(QPainter *p)
{
/*Zeichnet das Menü Interpret neu
- erstmal ein Rechteck schwarz füllen
- alle Kindobjekte zeichenen*/
if(backGroundColor.isValid())
{
p->setBrush(backGroundColor);
p->drawRect(geometry());
}
for(int i = 0; i < listChilds.size(); i++)
listChilds.at(i)->draw(p);
}
void GlMenuInterpret::mousePressEvent(QMouseEvent *event)
{
/*Überprüft ob die Maus über einem Kindobjekt gedrückt wurde und
führt die Funktion mousePressEvent des Kindobjekts 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 GlMenuInterpret::mouseReleaseEvent(QMouseEvent *event)
{
/*Siehe mousePressEvent*/
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);
}
}
}
void GlMenuInterpret::rollIn(QPainter *p)
{
/*Alle Kindobjekte werden eingerollt*/
int per = getPercent();
int angle = int((per/100.)* -90);
if(per < 0 || per > 100) return;
buttonMain->drawImageAt(p, angle, per);
buttonPlayer->drawImageAt(p, angle, per);
listWidget->drawImageAt(p, angle, per);
buttonList->drawImageAt(p, angle, per);
}
void GlMenuInterpret::rollOut(QPainter *p)
{
int per = getPercent();
int angle = int((per/100.) * 90);
if(per < 0 || per > 100) return;
buttonMain->drawImageAt(p, angle, per);
buttonPlayer->drawImageAt(p, angle, per);
listWidget->drawImageAt(p, angle, per);
buttonList->drawImageAt(p, angle, per);
}
void GlMenuInterpret::setLarge()
{
/*Alles auf 1024 x 768 zoomen*/
setGeometry(0,0,1024,768);
for(int i = 0; i < listChilds.size(); i++)
{
listChilds.at(i)->setLarge();
}
}