diff --git a/mainwindow.cpp b/mainwindow.cpp index 545c39f..c8bfa99 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -81,7 +81,6 @@ void MainWindow::replyFinished(QNetworkReply* reply) } void MainWindow::updateUi() { - ui->btn_onoff->setText(mPowered ? "On" : "Off"); ui->dial->setEnabled(mPowered); ui->dial->setValue(mVolume); ui->lbl_volume->setEnabled(mPowered); @@ -91,7 +90,30 @@ void MainWindow::updateUi() { ui->btn_spotify->setEnabled(mPowered); ui->btn_airplay->setEnabled(mPowered); ui->btn_audioin->setEnabled(mPowered); - ui->lbl_input->setText(mInput); + + 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(""); + } +} + +void MainWindow::setActiveButton(QString prop) +{ + for (QObject *q : ui->groupBox->children()) { + QPushButton *b = dynamic_cast(q); + if (b){ + if (b->property("input") == prop) + b->setStyleSheet("background-color: SpringGreen"); + else + b->setStyleSheet(""); + } + } } void MainWindow::on_txt_address_textEdited(const QString &arg1) diff --git a/mainwindow.h b/mainwindow.h index 9b64113..0eb625c 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -45,6 +45,8 @@ private: void sendCommand(QString cmd); void updateUi(); void sendVolume(); + + void setActiveButton(QString prop); }; } diff --git a/mainwindow.ui b/mainwindow.ui index 6e8b73c..6d79f36 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 528 - 199 + 426 + 174 @@ -18,95 +18,24 @@ - - - - Input + + + + On - - true - - - - - 10 - 30 - 80 - 21 - - - - HDMI 1 - - - - - - 10 - 60 - 80 - 21 - - - - HDMI 2 - - - - - - 10 - 90 - 80 - 21 - - - - HDMI 3 - - - - - - 110 - 30 - 80 - 21 - - - - Spotify - - - - - - 110 - 60 - 80 - 21 - - - - Airplay - - - - - - 110 - 90 - 80 - 21 - - - - Audio In - - - + + + + 10.0.0.227 + + + Qt::AlignCenter + + + + @@ -128,14 +57,27 @@ - - + + - On + Address: - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + -805 @@ -163,31 +105,110 @@ - - - - Address: + + + + Input - - - - - - 10.0.0.227 - - - Qt::AlignCenter - - - - - - - - - - Qt::AlignCenter + + true + + + + 10 + 30 + 80 + 21 + + + + HDMI 1 + + + HDMI1 + + + + + + 10 + 60 + 80 + 21 + + + + HDMI 2 + + + HDMI2 + + + + + + 10 + 90 + 80 + 21 + + + + HDMI 3 + + + HDMI3 + + + + + + 110 + 30 + 80 + 21 + + + + Spotify + + + Spotify + + + + + + 110 + 60 + 80 + 21 + + + + Airplay + + + IPOD + + + + + + 110 + 90 + 80 + 21 + + + + Audio In + + + AUDIO + + diff --git a/yremote.ico b/yremote.ico new file mode 100644 index 0000000..3640a5c Binary files /dev/null and b/yremote.ico differ diff --git a/yremote.pro b/yremote.pro index 9624e95..e6e8947 100644 --- a/yremote.pro +++ b/yremote.pro @@ -24,6 +24,7 @@ DEFINES += QT_DEPRECATED_WARNINGS # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 +RC_ICONS = yremote.ico SOURCES += \ main.cpp \