diff --git a/.gitignore b/.gitignore index 8525730..43982b8 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,7 @@ moc_*.cpp qrc_*.cpp ui_*.h Makefile* -*-build-* +*build-* # QtCreator diff --git a/mainwindow.cpp b/mainwindow.cpp index 747587b..5c2d093 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -2,6 +2,10 @@ #include "ui_mainwindow.h" #include +#include +#include + +#include class QNetworkReply; namespace shutdown2 { @@ -21,7 +25,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi QFile css(":style.css"); if (css.open(QFile::ReadOnly | QFile::Text)) - this->setStyleSheet(css.readAll()); + mCss = css.readAll(); + setStyleSheet(mCss); + + // init state machine + initStateMachine(); } MainWindow::~MainWindow() @@ -30,4 +38,37 @@ MainWindow::~MainWindow() delete mSettings; } +void MainWindow::initStateMachine() +{ + // states + QState* on = new QState(); + on->assignProperty(ui->btn_startstop, "on", false); + on->assignProperty(ui->lbl_timer, "on", false); + + QState* off = new QState(); + off->assignProperty(ui->btn_startstop, "on", true); + off->assignProperty(ui->lbl_timer, "on", true); + + // transistions + on->addTransition(ui->btn_startstop, SIGNAL(clicked()), off); + off->addTransition(ui->btn_startstop, SIGNAL(clicked()), on); + + // init + mState.addState(on); + mState.addState(off); + mState.setInitialState(off); + mState.start(); +} + +void MainWindow::triggerCssUpdate() +{ + qDebug() << QTime::currentTime() << "updating CSS"; // rogo: delete + setStyleSheet(mCss); +} + +} + +void shutdown2::MainWindow::on_btn_startstop_clicked() +{ + triggerCssUpdate(); } diff --git a/mainwindow.h b/mainwindow.h index 9fe1000..77f9c89 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -3,6 +3,7 @@ #include #include +#include namespace Ui { class MainWindow; @@ -18,10 +19,18 @@ public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow() override; +private slots: + void on_btn_startstop_clicked(); + private: Ui::MainWindow *ui; QSettings* mSettings = nullptr; + QStateMachine mState; + QByteArray mCss; + + void initStateMachine(); + void triggerCssUpdate(); }; } diff --git a/mainwindow.ui b/mainwindow.ui index 49549e7..e1f79ac 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 359 - 170 + 361 @@ -20,7 +20,84 @@ false - + + + 5 + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + + + false + + + + + + + + 0 + 0 + + + + + 18 + + + + Start + + + false + + + + + + + + 0 + 0 + + + + + 28 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + -- : -- + + + Qt::AlignCenter + + + false + + + + diff --git a/shutdown2.pro.user b/shutdown2.pro.user index 7cd5faf..ab683fe 100644 --- a/shutdown2.pro.user +++ b/shutdown2.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -71,7 +71,7 @@ 0 0 - L:/workspace/build-yremote-Desktop_Qt_5_12_2_MinGW_64_bit-Debug + L:/workspace/shutdown2/build-shutdown2-Desktop_Qt_5_12_2_MinGW_64_bit-Debug true @@ -305,9 +305,9 @@ 2 - yremote + shutdown2 - Qt4ProjectManager.Qt4RunConfiguration:L:/workspace/shutdown2/yremote.pro + Qt4ProjectManager.Qt4RunConfiguration:L:/workspace/shutdown2/shutdown2.pro 3768 false @@ -317,7 +317,7 @@ false true - L:/workspace/build-yremote-Desktop_Qt_5_12_2_MinGW_64_bit-Debug + L:/workspace/shutdown2/build-shutdown2-Desktop_Qt_5_12_2_MinGW_64_bit-Debug 1 diff --git a/style.css b/style.css index cd7600d..13d4c1f 100644 --- a/style.css +++ b/style.css @@ -1,15 +1,29 @@ +/* +green #24e895 +grey #404040 +white #edf2f4 +blue #0077fd +red #d63429 +*/ + + QMainWindow { background-color: #404040; border-color: #edf2f4; } -QPushButton { - background-color: #404040; +QPushButton[on=true] { + background-color: #d63429; color: #edf2f4; } +QPushButton[on=false] { + background-color: #24e895; + color: #404040; +} + QPushButton:hover { - border: 1px solid #0077fd; + border: 1px solid #edf2f4; } QLineEdit { @@ -26,9 +40,17 @@ QLabel { color: #edf2f4; } +QLabel#lbl_timer[on=false] { + border: 1px solid #d63429; +} + +QLabel#lbl_timer[on=true] { + border: 1px solid #24e895; +} + QGroupBox { color: #edf2f4; - border: 1px solid #0077fd; + border: 1px solid #edf2f4; margin-top: 5px; } @@ -37,7 +59,7 @@ QGroupBox::title { left: 5px; padding: 0px 5px 0px 5px; } - +/* QLabel#lbl_volume:hover { - border: 1px solid #0077fd; -} + border: 1px solid var(--highlight-blue); +}*/