saving window positioning
This commit is contained in:
@@ -16,7 +16,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
setWindowFlags(windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
|
setWindowFlags(windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ui->txt_address->setText(mSettings.value("av_address", "").toString());
|
mSettings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "RogoSoftware", "yremote");
|
||||||
|
|
||||||
|
restoreGeometry(mSettings->value("geometry", saveGeometry()).toByteArray());
|
||||||
|
move(mSettings->value("pos", pos()).toPoint());
|
||||||
|
|
||||||
|
ui->txt_address->setText(mSettings->value("av_address", "").toString());
|
||||||
mAddress = ui->txt_address->text();
|
mAddress = ui->txt_address->text();
|
||||||
|
|
||||||
// setup volume value collection
|
// setup volume value collection
|
||||||
@@ -139,7 +144,7 @@ void MainWindow::setPowerState()
|
|||||||
void MainWindow::on_txt_address_textEdited(const QString &arg1)
|
void MainWindow::on_txt_address_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
mAddress = arg1;
|
mAddress = arg1;
|
||||||
mSettings.setValue("av_address", mAddress);
|
mSettings->setValue("av_address", mAddress);
|
||||||
mTimerUpdateAddress.start(TIME_UPDATE_ADDRESS);
|
mTimerUpdateAddress.start(TIME_UPDATE_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,6 +183,12 @@ void MainWindow::sendVolume()
|
|||||||
+ "</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume></Main_Zone></YAMAHA_AV>");
|
+ "</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume></Main_Zone></YAMAHA_AV>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::moveEvent(QMoveEvent *)
|
||||||
|
{
|
||||||
|
mSettings->setValue("geometry", geometry());
|
||||||
|
mSettings->setValue("pos", pos());
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::updateAVState()
|
void MainWindow::updateAVState()
|
||||||
{
|
{
|
||||||
sendCommand("<YAMAHA_AV cmd=\"GET\"><System><Power_Control><Power>GetParam</Power></Power_Control></System></YAMAHA_AV>");
|
sendCommand("<YAMAHA_AV cmd=\"GET\"><System><Power_Control><Power>GetParam</Power></Power_Control></System></YAMAHA_AV>");
|
||||||
|
|||||||
@@ -18,10 +18,9 @@ class MainWindow : public QMainWindow
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = nullptr);
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow() override;
|
||||||
|
|
||||||
void setPowerState();
|
void setPowerState();
|
||||||
|
|
||||||
void updateAVState();
|
void updateAVState();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@@ -41,7 +40,7 @@ private:
|
|||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
|
||||||
QString mAddress;
|
QString mAddress;
|
||||||
QSettings mSettings;
|
QSettings* mSettings;
|
||||||
QTimer mTimerValCollect;
|
QTimer mTimerValCollect;
|
||||||
QTimer mTimerUpdateState;
|
QTimer mTimerUpdateState;
|
||||||
QTimer mTimerUpdateAddress;
|
QTimer mTimerUpdateAddress;
|
||||||
@@ -58,6 +57,10 @@ private:
|
|||||||
void updateUi();
|
void updateUi();
|
||||||
void setActiveButton(QString prop);
|
void setActiveButton(QString prop);
|
||||||
void sendVolume();
|
void sendVolume();
|
||||||
|
|
||||||
|
// QWidget interface
|
||||||
|
protected:
|
||||||
|
void moveEvent(QMoveEvent *) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user