diff --git a/mainwindow.cpp b/mainwindow.cpp index 3537b9f..97a12c7 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -7,6 +7,7 @@ #include #include +#include class QNetworkReply; namespace shutdown2 { @@ -29,6 +30,21 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi mCss = css.readAll(); setStyleSheet(mCss); + // init timers + QApplication::setEffectEnabled(Qt::UI_AnimateCombo, false); + ui->cb_timers->setValidator(new QIntValidator(0, 99999, this)); + ui->cb_timers->setAutoCompletion(false); + ui->cb_timers->lineEdit()->setAlignment(Qt::AlignRight); + ui->cb_timers->addItem("0"); + ui->cb_timers->addItem("11"); + ui->cb_timers->addItem("22"); + ui->cb_timers->addItem("30"); + ui->cb_timers->addItem("45"); + ui->cb_timers->addItem("60"); + ui->cb_timers->addItem("90"); + ui->cb_timers->addItem("120"); + ui->cb_timers->addItem("240"); + // init state machine initStateMachine(); connect(&mTimer, &QTimer::timeout, this, &MainWindow::updateTime); @@ -78,6 +94,7 @@ void MainWindow::shutdown() void MainWindow::updateTime() { if (mTimeLeft == 0) { + ui->lbl_timer->setText("00:00"); shutdown(); mTimer.stop(); return; @@ -93,27 +110,20 @@ void MainWindow::updateTime() } void MainWindow::timerToggled() { + if (ui->btn_startstop->property("on").toBool()) { - - int time = 0; - foreach (QRadioButton* r, ui->groupBox->findChildren()) { - if (r->isChecked()) { - time = r->property("value").toInt(); - break; - } - } - - if (time == -1) - time = ui->spinBox->value(); - + int time = ui->cb_timers->currentText().toInt(); time *= 60; // convert to seconds mTimeLeft = time; updateTime(); mTimer.start(1000); + ui->stackedWidget->setCurrentIndex(1); + } else { - mTimeLeft = -2; + mTimeLeft = -1; mTimer.stop(); ui->lbl_timer->setText("-- : --"); + ui->stackedWidget->setCurrentIndex(0); } } diff --git a/mainwindow.ui b/mainwindow.ui index fb72b3b..ee9a126 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 365 - 269 + 279 + 118 @@ -29,26 +29,137 @@ false - + - 10 + 8 - 10 + 8 - 10 + 8 - 10 + 8 0 - 10 + 8 - + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 15 + + + 0 + + + + + + 0 + 0 + + + + + 28 + + + + Qt::RightToLeft + + + true + + + QComboBox::InsertAtTop + + + + + + + + 20 + + + + minutes + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 28 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + -- : -- + + + Qt::AlignCenter + + + false + + + + + + + + @@ -64,9 +175,12 @@ - 10 + 20 + + Qt::LeftToRight + Start @@ -81,517 +195,12 @@ - - - - - 0 - 0 - - - - - 28 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - -- : -- - - - Qt::AlignCenter - - - false - - - - - - - - 0 - 0 - - - - - - - Qt::AlignCenter - - - - 5 - - - 0 - - - 5 - - - 5 - - - 5 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 5 - - - 0 - - - - - 10 - - - QLayout::SetDefaultConstraint - - - 10 - - - 0 - - - 10 - - - 0 - - - - - - 0 - 0 - - - - - 10 - - - - 90 min - - - 90 - - - - - - - - - 10 - - - QLayout::SetDefaultConstraint - - - 10 - - - 0 - - - 10 - - - 0 - - - - - - 0 - 0 - - - - - 10 - - - - 22 min - - - 22 - - - - - - - - - 10 - - - QLayout::SetDefaultConstraint - - - 10 - - - 0 - - - 10 - - - 0 - - - - - - 0 - 0 - - - - - 10 - - - - 60 min - - - 60 - - - - - - - - - 10 - - - QLayout::SetDefaultConstraint - - - 10 - - - 0 - - - 10 - - - 0 - - - - - - 0 - 0 - - - - - 10 - - - - 11 min - - - 11 - - - - - - - - - 10 - - - QLayout::SetDefaultConstraint - - - 10 - - - 0 - - - 10 - - - 0 - - - - - - 0 - 0 - - - - - 10 - - - - 45 min - - - 45 - - - - - - - - - 10 - - - QLayout::SetDefaultConstraint - - - 10 - - - 0 - - - 10 - - - 0 - - - - - - 0 - 0 - - - - - 10 - - - - 30 min - - - 30 - - - - - - - - - 10 - - - QLayout::SetDefaultConstraint - - - 10 - - - 0 - - - 10 - - - 0 - - - - - - 0 - 0 - - - - - 10 - - - - 120 min - - - 120 - - - - - - - - - 5 - - - QLayout::SetDefaultConstraint - - - 10 - - - 0 - - - 10 - - - 0 - - - - - - 0 - 0 - - - - - 10 - - - - - - - -1 - - - - - - - - 0 - 0 - - - - - 10 - - - - 999 - - - 240 - - - - - - - - - 10 - - - QLayout::SetDefaultConstraint - - - 10 - - - 0 - - - 10 - - - 0 - - - - - - 0 - 0 - - - - - 10 - - - - Now - - - true - - - 0 - - - - - - - - - - btn_startstop - r_0 - r_11 - r_22 - r_30 - r_45 - r_60 - r_90 - r_120 - r_custom diff --git a/mwicon.png b/mwicon.png new file mode 100644 index 0000000..6b15ef3 Binary files /dev/null and b/mwicon.png differ diff --git a/resources.qrc b/resources.qrc index 6827504..4e6388f 100644 --- a/resources.qrc +++ b/resources.qrc @@ -1,5 +1,6 @@ - - + + style.css + mwicon.png diff --git a/shutdown2.pro.user b/shutdown2.pro.user deleted file mode 100644 index 2c0c045..0000000 --- a/shutdown2.pro.user +++ /dev/null @@ -1,337 +0,0 @@ - - - - - - EnvironmentId - {2eab4085-7443-4062-b54e-64c18ac87c35} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - -fno-delayed-template-parsing - - true - - - - ProjectExplorer.Project.Target.0 - - Desktop Qt 5.12.2 MinGW 64-bit - Desktop Qt 5.12.2 MinGW 64-bit - qt.qt5.5122.win64_mingw73_kit - 0 - 0 - 0 - - L:/workspace/shutdown2/build-shutdown2-Desktop_Qt_5_12_2_MinGW_64_bit-Debug - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - true - - - L:/workspace/build-yremote-Desktop_Qt_5_12_2_MinGW_64_bit-Release - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - - false - false - true - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - - L:/workspace/build-yremote-Desktop_Qt_5_12_2_MinGW_64_bit-Profile - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - true - true - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - 3 - - - 0 - Deploy - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy Configuration - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - shutdown2 - - Qt4ProjectManager.Qt4RunConfiguration:L:/workspace/shutdown2/shutdown2.pro - - 3768 - false - true - true - false - false - true - - L:/workspace/shutdown2/build-shutdown2-Desktop_Qt_5_12_2_MinGW_64_bit-Debug - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 22 - - - Version - 22 - - diff --git a/style.css b/style.css index 2fa19ed..ba489a1 100644 --- a/style.css +++ b/style.css @@ -12,6 +12,10 @@ QMainWindow { border-color: #edf2f4; } +QPushButton { + padding-bottom: 5px; +} + QPushButton[on=true] { background-color: #d63429; color: #edf2f4; @@ -22,39 +26,44 @@ QPushButton[on=false] { color: #404040; } -QPushButton:hover { +QPushButton::hover { border: 1px solid #edf2f4; } -QRadioButton { - color: #edf2f4; - background-color: #404040; -} - -QSpinBox { +QComboBox { color: #edf2f4; background-color: #404040; + padding-top: 10px; + padding-bottom: 10px; } -QSpinBox::up-button { - color: #404040; +QComboBox:hover { + border: 1px solid #edf2f4; } -QSpinBox::down-button { - color: #404040; +QComboBox::drop-down { + color: #edf2f4; + background-color: #999999; + margin: 2px; + + subcontrol-origin: padding; + subcontrol-position: top right; + width: 15px; } -QSpinBox:hover { - border: 1px solid #0077fd; +QComboBox::down-arrow +{ + image: url(:/mwicon.png); + width: 48px; + height: 48px; } -QLineEdit { +QComboBox QAbstractItemView{ background-color: #404040; color: #edf2f4; - border: 1px solid #0077fd; -} -QLineEdit:hover { + selection-background-color: #999999; + selection-color: #24e895; } QLabel { @@ -62,25 +71,10 @@ QLabel { } QLabel#lbl_timer[on=false] { - border: 1px solid #d63429; -} - -QLabel#lbl_timer[on=true] { border: 1px solid #24e895; } -QGroupBox { - color: #edf2f4; - border: 1px solid #edf2f4; - margin-top: 5px; +QLabel#lbl_timer[on=true] { + border: 1px solid #d63429; } -QGroupBox::title { - subcontrol-origin: margin; - left: 5px; - padding: 0px 5px 0px 5px; - } -/* -QLabel#lbl_volume:hover { - border: 1px solid var(--highlight-blue); -}*/