From 333dc87b756de32f1d61d330bc923b4d339fc529 Mon Sep 17 00:00:00 2001 From: rogo Date: Sat, 17 Nov 2018 21:56:15 +0100 Subject: [PATCH] dark mode --- mainwindow.cpp | 35 ++++++--- mainwindow.h | 2 + mainwindow.ui | 208 +++++++++++++++++++++++++++---------------------- resources.qrc | 5 ++ style.css | 47 +++++++++++ yremote.pro | 4 + 6 files changed, 199 insertions(+), 102 deletions(-) create mode 100644 resources.qrc create mode 100644 style.css diff --git a/mainwindow.cpp b/mainwindow.cpp index c8bfa99..e4efb88 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,6 +1,7 @@ #include "mainwindow.h" #include "ui_mainwindow.h" +#include #include #include @@ -23,6 +24,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi sendCommand("GetParam"); sendCommand("GetParam"); sendCommand("GetParam"); + + QFile css(":style.css"); + if (css.open(QFile::ReadOnly | QFile::Text)) + this->setStyleSheet(css.readAll()); } MainWindow::~MainWindow() @@ -92,15 +97,7 @@ void MainWindow::updateUi() { ui->btn_audioin->setEnabled(mPowered); setActiveButton(mInput); - - if (mPowered) { - ui->btn_onoff->setText("On"); - ui->btn_onoff->setStyleSheet("background-color: SpringGreen"); - } else { - ui->btn_onoff->setText("Off"); - ui->btn_onoff->setStyleSheet("background-color: DarkRed"); - setActiveButton(""); - } + setPowerState(); } void MainWindow::setActiveButton(QString prop) @@ -109,13 +106,31 @@ void MainWindow::setActiveButton(QString prop) QPushButton *b = dynamic_cast(q); if (b){ if (b->property("input") == prop) - b->setStyleSheet("background-color: SpringGreen"); + b->setStyleSheet("background-color: #24e895; color: #404040;"); else b->setStyleSheet(""); } } } +void MainWindow::setPowerState() +{ + if (mPowered) { + ui->btn_onoff->setText("On"); + ui->btn_onoff->setStyleSheet("background-color: #24e895; color: #404040;"); + ui->lbl_volume->setStyleSheet("color: #24e895"); + ui->dial->setStyleSheet("background-color: #24e895"); + } else { + ui->btn_onoff->setText("Off"); + ui->btn_onoff->setStyleSheet(""); + ui->lbl_volume->setStyleSheet(""); + ui->dial->setStyleSheet(""); + setActiveButton(""); + } + qDebug() << ui->btn_onoff->isEnabled(); // rogo: delete +} + + void MainWindow::on_txt_address_textEdited(const QString &arg1) { mAddress = arg1; diff --git a/mainwindow.h b/mainwindow.h index 0eb625c..2d57e22 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -19,6 +19,8 @@ public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); + void setPowerState(); + private slots: void on_btn_onoff_clicked(); void replyFinished(QNetworkReply *reply); diff --git a/mainwindow.ui b/mainwindow.ui index ea999fc..e3cd274 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 359 - 161 + 170 @@ -16,105 +16,21 @@ yremote + + false + - - - - On - - - - - - - 10.0.0.227 - - - Qt::AlignCenter - - - - - - - - Source Code Pro Medium - 16 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - -400 - - - Qt::AlignCenter - - - - - - - Address: - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - -805 - - - -200 - - - 5 - - - 5 - - - -400 - - - Qt::Vertical - - - false - - - 10.000000000000000 - - - true - - - Input + + Qt::AlignBottom|Qt::AlignHCenter + - true + false @@ -125,9 +41,15 @@ 21 + + + HDMI 1 + + false + HDMI1 @@ -214,6 +136,108 @@ + + + + Address: + + + + + + + -805 + + + -200 + + + 5 + + + 5 + + + -400 + + + Qt::Vertical + + + false + + + 10.000000000000000 + + + true + + + + + + + false + + + + + + On + + + false + + + + + + + 10.0.0.227 + + + Qt::AlignCenter + + + + + + + + Source Code Pro Medium + 16 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + -400 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 40 + 20 + + + + diff --git a/resources.qrc b/resources.qrc new file mode 100644 index 0000000..6827504 --- /dev/null +++ b/resources.qrc @@ -0,0 +1,5 @@ + + + style.css + + diff --git a/style.css b/style.css new file mode 100644 index 0000000..4863f2e --- /dev/null +++ b/style.css @@ -0,0 +1,47 @@ +QMainWindow { + background-color: #404040; + border-color: #edf2f4; +} + +QPushButton { + background-color: #404040; + color: #edf2f4; +} + +/*QPushbutton:disabled { + background-color: #24e895; + color: #404040; +}*/ + +QPushButton:hover { + border: 1px solid #0077fd; +} + +QLineEdit { + background-color: #404040; + color: #edf2f4; + border: 1px solid #0077fd; +} + +QLabel { + color: #edf2f4; +} + +QGroupBox { + color: #edf2f4; + border: 1px solid #0077fd; + margin-top: 5px; +} + +QGroupBox::title { + subcontrol-origin: margin; + left: 5px; + padding: 0px 5px 0px 5px; + } + +QDial:hover { + border: 1px solid #0077fd; +} +QLabel#lbl_volume:hover { + border: 1px solid #0077fd; +} diff --git a/yremote.pro b/yremote.pro index f7c0ab8..6fdb922 100644 --- a/yremote.pro +++ b/yremote.pro @@ -33,3 +33,7 @@ HEADERS += \ FORMS += \ mainwindow.ui + +RESOURCES = resources.qrc \ + resources.qrc +