added spacebar support to start timer
This commit is contained in:
@@ -20,7 +20,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
setWindowFlags(windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
|
||||
#endif
|
||||
|
||||
mSettings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "RogoSoftware", "EasyShutdown2");
|
||||
mSettings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "RogoSoftware", "shutdown2");
|
||||
|
||||
restoreGeometry(mSettings->value("geometry", saveGeometry()).toByteArray());
|
||||
move(mSettings->value("pos", pos()).toPoint());
|
||||
@@ -44,6 +44,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
ui->cb_timers->addItem("90");
|
||||
ui->cb_timers->addItem("120");
|
||||
ui->cb_timers->addItem("240");
|
||||
ui->cb_timers->installEventFilter(this);
|
||||
|
||||
// init state machine
|
||||
initStateMachine();
|
||||
@@ -120,22 +121,37 @@ void MainWindow::timerToggled() {
|
||||
updateTime();
|
||||
mTimer.start(1000);
|
||||
ui->stackedWidget->setCurrentIndex(1);
|
||||
ui->btn_startstop->setFocus();
|
||||
|
||||
} else {
|
||||
mTimeLeft = -1;
|
||||
mTimer.stop();
|
||||
ui->lbl_timer->setText("--:--:--");
|
||||
ui->stackedWidget->setCurrentIndex(0);
|
||||
ui->cb_timers->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent *event)
|
||||
void MainWindow::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
|
||||
if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
|
||||
ui->btn_startstop->click(); // this is needed this way to trigger statemachine transition
|
||||
event->accept();
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::eventFilter(QObject *watched, QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::KeyPress) {
|
||||
if (QKeyEvent* ke = dynamic_cast<QKeyEvent*>(e)) {
|
||||
if (ke->key() == Qt::Key_Space) {
|
||||
ui->btn_startstop->click(); // this is needed this way to trigger statemachine transition
|
||||
e->accept();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QObject::eventFilter(watched, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ private:
|
||||
QTimer mTimer;
|
||||
int mTimeLeft = -1; // in seconds
|
||||
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
void initStateMachine();
|
||||
void triggerCssUpdate();
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
@@ -46,6 +46,8 @@ QComboBox::drop-down {
|
||||
background-color: #999999;
|
||||
margin: 2px;
|
||||
|
||||
padding: 5px;
|
||||
|
||||
subcontrol-origin: padding;
|
||||
subcontrol-position: top right;
|
||||
width: 15px;
|
||||
@@ -54,8 +56,8 @@ QComboBox::drop-down {
|
||||
QComboBox::down-arrow
|
||||
{
|
||||
image: url(:/mwicon.png);
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
}
|
||||
|
||||
QComboBox QAbstractItemView{
|
||||
|
||||
Reference in New Issue
Block a user