This repository was archived by the owner on Jan 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquitmenuwidget.cpp
More file actions
63 lines (54 loc) · 1.77 KB
/
quitmenuwidget.cpp
File metadata and controls
63 lines (54 loc) · 1.77 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
#include "quitmenuwidget.h"
quitMenuWidget::quitMenuWidget(QWidget *parent): QWidget(parent)
{
this->currentOption=true;
this->setGeometry(0,367,512,147);
this->setFocus();
this->textLabel=new QLabel(this);
this->yesSelect=new QLabel(this);
this->noSelect=new QLabel(this);
this->textLabel->setGeometry(0,0,512,147);
this->yesSelect->setGeometry(133,82,114,31);
this->noSelect->setGeometry(275,82,95,31);
this->textLabel->setPixmap(QPixmap(":/images/resources/quitMenu/quitMenu.png"));
this->yesSelect->setPixmap(QPixmap(":/images/resources/quitMenu/yesSelect.png"));
this->noSelect->setPixmap(QPixmap(":/images/resources/quitMenu/noSelect.png"));
this->textLabel->show();
this->yesSelect->show();
this->noSelect->hide();
connect(this,SIGNAL(logEvent(QString)),&(tetrisLogger::Instance()),SLOT(logEvent(QString)));
}
void quitMenuWidget::keyPressEvent(QKeyEvent *event)
{
switch(event->key())
{
case Qt::Key_Right:
if(currentOption)
{
currentOption=false;
yesSelect->hide();
noSelect->show();
}
break;
case Qt::Key_Left:
if(!currentOption)
{
currentOption=true;
noSelect->hide();
yesSelect->show();
}
break;
case Qt::Key_Space:
if(currentOption)
{
emit logEvent("QuitMenu: Application quits!");
QApplication::quit();
}
else
{
emit logEvent("QuitMenu: Going back to main menu");
emit newModeRequest(1); //No selected and activated - going back to main menu
}
break;
}
}