-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
FrameStartCountdown.cpp
113 lines (67 loc) · 2.4 KB
/
FrameStartCountdown.cpp
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
/*
* QtSssSNibblers: SwissalpS Nibbles written with Qt-Framework
* Copyright (C) 2018-2019 Luke J. Zimmermann aka SwissalpS <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "FrameStartCountdown.h"
#include "ui_FrameStartCountdown.h"
#include <QPushButton>
namespace SwissalpS { namespace QtNibblers {
FrameStartCountdown::FrameStartCountdown(QWidget *pParent) :
QFrame(pParent),
pUi(new Ui::FrameStartCountdown) {
this->pUi->setupUi(this);
} // construct
FrameStartCountdown::~FrameStartCountdown() {
delete this->pUi;
} // dealloc
void FrameStartCountdown::changeEvent(QEvent *pEvent) {
QFrame::changeEvent(pEvent);
switch (pEvent->type()) {
case QEvent::LanguageChange:
this->pUi->retranslateUi(this);
break;
default:
break;
} // switch type
} // changeEvent
void FrameStartCountdown::keyPressEvent(QKeyEvent *pEvent) {
if (!this->pUi->button->isVisible()) return;
QKeySequence oKSin(pEvent->key());
static QKeySequence oKeyReturn(16777220);
static QKeySequence oKeyEnter(16777221);
static QKeySequence oKeySpace(32);
if ((oKSin == oKeyEnter)
|| (oKSin == oKeyReturn)
|| (oKSin == oKeySpace)) this->on_button_clicked();
else QFrame::keyPressEvent(pEvent);
} // keyPressEvent
void FrameStartCountdown::on_button_clicked() {
Q_EMIT this->done();
} // on_button_clicked
void FrameStartCountdown::onSetText(const QString sText, const QString sTextButton) {
this->pUi->labelNumber->setText(sText);
QPushButton *pButton = this->pUi->button;
if (sTextButton.length()) {
pButton->setText(sTextButton);
pButton->setVisible(true);
pButton->setEnabled(true);
pButton->setFocus();
} else {
pButton->setVisible(false);
pButton->setEnabled(false);
} // if got button text
} // onSetText
} } // namespace SwissalpS::QtNibblers