added ui reactions

This commit is contained in:
2018-10-20 16:41:19 +02:00
parent f1d9a08a84
commit e462c3d749
5 changed files with 163 additions and 117 deletions

View File

@@ -81,7 +81,6 @@ void MainWindow::replyFinished(QNetworkReply* reply)
} }
void MainWindow::updateUi() { void MainWindow::updateUi() {
ui->btn_onoff->setText(mPowered ? "On" : "Off");
ui->dial->setEnabled(mPowered); ui->dial->setEnabled(mPowered);
ui->dial->setValue(mVolume); ui->dial->setValue(mVolume);
ui->lbl_volume->setEnabled(mPowered); ui->lbl_volume->setEnabled(mPowered);
@@ -91,7 +90,30 @@ void MainWindow::updateUi() {
ui->btn_spotify->setEnabled(mPowered); ui->btn_spotify->setEnabled(mPowered);
ui->btn_airplay->setEnabled(mPowered); ui->btn_airplay->setEnabled(mPowered);
ui->btn_audioin->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<QPushButton*>(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) void MainWindow::on_txt_address_textEdited(const QString &arg1)

View File

@@ -45,6 +45,8 @@ private:
void sendCommand(QString cmd); void sendCommand(QString cmd);
void updateUi(); void updateUi();
void sendVolume(); void sendVolume();
void setActiveButton(QString prop);
}; };
} }

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>528</width> <width>426</width>
<height>199</height> <height>174</height>
</rect> </rect>
</property> </property>
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
@@ -18,95 +18,24 @@
</property> </property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="2" column="0" rowspan="2" colspan="3"> <item row="1" column="0">
<widget class="QGroupBox" name="groupBox"> <widget class="QPushButton" name="btn_onoff">
<property name="title">
<string>Input</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<widget class="QPushButton" name="btn_hdmi1">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>80</width>
<height>21</height>
</rect>
</property>
<property name="text"> <property name="text">
<string>HDMI 1</string> <string>On</string>
</property> </property>
</widget> </widget>
<widget class="QPushButton" name="btn_hdmi2">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>80</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>HDMI 2</string>
</property>
</widget>
<widget class="QPushButton" name="btn_hdmi3">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>80</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>HDMI 3</string>
</property>
</widget>
<widget class="QPushButton" name="btn_spotify">
<property name="geometry">
<rect>
<x>110</x>
<y>30</y>
<width>80</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Spotify</string>
</property>
</widget>
<widget class="QPushButton" name="btn_airplay">
<property name="geometry">
<rect>
<x>110</x>
<y>60</y>
<width>80</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Airplay</string>
</property>
</widget>
<widget class="QPushButton" name="btn_audioin">
<property name="geometry">
<rect>
<x>110</x>
<y>90</y>
<width>80</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Audio In</string>
</property>
</widget>
</widget>
</item> </item>
<item row="3" column="3"> <item row="1" column="4">
<widget class="QLineEdit" name="txt_address">
<property name="text">
<string>10.0.0.227</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QLabel" name="lbl_volume"> <widget class="QLabel" name="lbl_volume">
<property name="font"> <property name="font">
<font> <font>
@@ -128,14 +57,27 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="1" column="2">
<widget class="QPushButton" name="btn_onoff"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>On</string> <string>Address:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="3" rowspan="3"> <item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="4">
<widget class="QDial" name="dial"> <widget class="QDial" name="dial">
<property name="minimum"> <property name="minimum">
<number>-805</number> <number>-805</number>
@@ -163,32 +105,111 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="2" column="0" rowspan="2" colspan="3">
<widget class="QLabel" name="label"> <widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Input</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<widget class="QPushButton" name="btn_hdmi1">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>80</width>
<height>21</height>
</rect>
</property>
<property name="text"> <property name="text">
<string>Address:</string> <string>HDMI 1</string>
</property>
<property name="input" stdset="0">
<string>HDMI1</string>
</property> </property>
</widget> </widget>
</item> <widget class="QPushButton" name="btn_hdmi2">
<item row="1" column="1"> <property name="geometry">
<widget class="QLineEdit" name="txt_address"> <rect>
<property name="text"> <x>10</x>
<string>10.0.0.227</string> <y>60</y>
<width>80</width>
<height>21</height>
</rect>
</property> </property>
<property name="alignment"> <property name="text">
<set>Qt::AlignCenter</set> <string>HDMI 2</string>
</property>
<property name="input" stdset="0">
<string>HDMI2</string>
</property> </property>
</widget> </widget>
</item> <widget class="QPushButton" name="btn_hdmi3">
<item row="0" column="1"> <property name="geometry">
<widget class="QLabel" name="lbl_input"> <rect>
<x>10</x>
<y>90</y>
<width>80</width>
<height>21</height>
</rect>
</property>
<property name="text"> <property name="text">
<string/> <string>HDMI 3</string>
</property> </property>
<property name="alignment"> <property name="input" stdset="0">
<set>Qt::AlignCenter</set> <string>HDMI3</string>
</property> </property>
</widget> </widget>
<widget class="QPushButton" name="btn_spotify">
<property name="geometry">
<rect>
<x>110</x>
<y>30</y>
<width>80</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Spotify</string>
</property>
<property name="input" stdset="0">
<string>Spotify</string>
</property>
</widget>
<widget class="QPushButton" name="btn_airplay">
<property name="geometry">
<rect>
<x>110</x>
<y>60</y>
<width>80</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Airplay</string>
</property>
<property name="input" stdset="0">
<string>IPOD</string>
</property>
</widget>
<widget class="QPushButton" name="btn_audioin">
<property name="geometry">
<rect>
<x>110</x>
<y>90</y>
<width>80</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Audio In</string>
</property>
<property name="input" stdset="0">
<string>AUDIO</string>
</property>
</widget>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>

BIN
yremote.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

View File

@@ -24,6 +24,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
# You can also select to disable deprecated APIs only up to a certain version of Qt. # 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 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
RC_ICONS = yremote.ico
SOURCES += \ SOURCES += \
main.cpp \ main.cpp \