diff --git a/mainwindow.cpp b/mainwindow.cpp
index 24ce509..1835a88 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -20,13 +20,14 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
ui->txt_address->setText(DEFAULT_ADDRESS);
mAddress = ui->txt_address->text();
- connect(&mTimer, &QTimer::timeout, this, &MainWindow::sendVolume);
- mTimer.setSingleShot(true);
+ // setup volume value collection
+ connect(&mTimerValCollect, &QTimer::timeout, this, &MainWindow::sendVolume);
+ mTimerValCollect.setSingleShot(true);
- // load initial data
- sendCommand("GetParam");
- sendCommand("GetParam");
- sendCommand("GetParam");
+ // load initial data and set update rate
+ updateAVState();
+ connect(&mTimerUpdate, &QTimer::timeout, this, &MainWindow::updateAVState);
+ mTimerUpdate.start(UPDATETIME);
QFile css(":style.css");
if (css.open(QFile::ReadOnly | QFile::Text))
@@ -130,10 +131,8 @@ void MainWindow::setPowerState()
ui->dial->setStyleSheet("");
setActiveButton("");
}
- qDebug() << ui->btn_onoff->isEnabled(); // rogo: delete
}
-
void MainWindow::on_txt_address_textEdited(const QString &arg1)
{
mAddress = arg1;
@@ -164,7 +163,7 @@ void MainWindow::on_dial_valueChanged(int value)
ui->lbl_volume->setText(QString::number(value));
mVolume = value;
- mTimer.start(WAITTIME);
+ mTimerValCollect.start(COLLECTTIME);
}
void MainWindow::sendVolume()
@@ -174,6 +173,13 @@ void MainWindow::sendVolume()
+ "1dB");
}
+void MainWindow::updateAVState()
+{
+ sendCommand("GetParam");
+ sendCommand("GetParam");
+ sendCommand("GetParam");
+}
+
void MainWindow::on_btn_hdmi1_clicked()
{
sendCommand("HDMI1");
diff --git a/mainwindow.h b/mainwindow.h
index 2d57e22..26a3f38 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -16,11 +16,13 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
- explicit MainWindow(QWidget *parent = 0);
+ explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
void setPowerState();
+ void updateAVState();
+
private slots:
void on_btn_onoff_clicked();
void replyFinished(QNetworkReply *reply);
@@ -38,11 +40,14 @@ private:
Ui::MainWindow *ui;
QString mAddress;
- QTimer mTimer;
+ QTimer mTimerValCollect;
+ QTimer mTimerUpdate;
+
bool mPowered = false;
int mVolume = 0;
QString mInput;
- const int WAITTIME = 400;
+ const int COLLECTTIME = 400;
+ const int UPDATETIME = 20000;
void sendCommand(QString cmd);
void updateUi();
diff --git a/style.css b/style.css
index 035e66b..cd7600d 100644
--- a/style.css
+++ b/style.css
@@ -8,11 +8,6 @@ QPushButton {
color: #edf2f4;
}
-/*QPushbutton:disabled {
- background-color: #24e895;
- color: #404040;
-}*/
-
QPushButton:hover {
border: 1px solid #0077fd;
}