added persistent address

This commit is contained in:
2018-11-17 22:46:40 +01:00
parent eafff377fd
commit 112090ab82
3 changed files with 24 additions and 12 deletions

View File

@@ -10,24 +10,26 @@ namespace yremote {
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
QString DEFAULT_ADDRESS = "10.0.0.227";
ui->setupUi(this);
setFixedSize(size());
#if defined(Q_OS_WIN)
setWindowFlags(windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
#endif
ui->txt_address->setText(DEFAULT_ADDRESS);
ui->txt_address->setText(mSettings.value("av_address", "").toString());
mAddress = ui->txt_address->text();
// setup volume value collection
connect(&mTimerValCollect, &QTimer::timeout, this, &MainWindow::sendVolume);
mTimerValCollect.setSingleShot(true);
connect(&mTimerUpdateAddress, &QTimer::timeout, this, &MainWindow::updateAVState);
mTimerUpdateAddress.setSingleShot(true);
// load initial data and set update rate
updateAVState();
connect(&mTimerUpdate, &QTimer::timeout, this, &MainWindow::updateAVState);
mTimerUpdate.start(UPDATETIME);
connect(&mTimerUpdateState, &QTimer::timeout, this, &MainWindow::updateAVState);
mTimerUpdateState.start(TIME_UPDATE_STATE);
QFile css(":style.css");
if (css.open(QFile::ReadOnly | QFile::Text))
@@ -61,7 +63,8 @@ void MainWindow::replyFinished(QNetworkReply* reply)
} else {
qDebug() << reply->url();
qDebug() << reply->errorString();
return;
mPowered = false;
}
// check power state
@@ -136,6 +139,8 @@ void MainWindow::setPowerState()
void MainWindow::on_txt_address_textEdited(const QString &arg1)
{
mAddress = arg1;
mSettings.setValue("av_address", mAddress);
mTimerUpdateAddress.start(TIME_UPDATE_ADDRESS);
}
void MainWindow::on_btn_onoff_clicked()
@@ -163,7 +168,7 @@ void MainWindow::on_dial_valueChanged(int value)
ui->lbl_volume->setText(QString::number(value));
mVolume = value;
mTimerValCollect.start(COLLECTTIME);
mTimerValCollect.start(TIME_VOL_COLLECT);
}
void MainWindow::sendVolume()