read/save window geometry (position + size)
This commit is contained in:
parent
cdc737a823
commit
593ae8531c
2 changed files with 34 additions and 0 deletions
|
@ -76,6 +76,8 @@ MainWindow::MainWindow()
|
|||
&MainWindow::onExportSalesJsonActionTriggered);
|
||||
connect(ui_.importSalesJsonAction, &QAction::triggered, this,
|
||||
&MainWindow::onImportSalesJsonActionTriggered);
|
||||
|
||||
readGeometry();
|
||||
}
|
||||
|
||||
void MainWindow::onActionEditSellerTriggered()
|
||||
|
@ -353,3 +355,29 @@ void MainWindow::onImportSalesJsonActionTriggered()
|
|||
}
|
||||
setSaleModel();
|
||||
}
|
||||
|
||||
void MainWindow::writeGeometry()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
settings.beginGroup("mainwindow");
|
||||
settings.setValue("size", size());
|
||||
settings.setValue("pos", pos());
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void MainWindow::readGeometry()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
settings.beginGroup("mainwindow");
|
||||
resize(settings.value("size", QSize(800, 600)).toSize());
|
||||
move(settings.value("pos", QPoint(200, 200)).toPoint());
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
writeGeometry();
|
||||
event->accept();
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
#include <marketplace.h>
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QtGui/QCloseEvent>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
@ -29,6 +30,9 @@ class MainWindow : public QMainWindow
|
|||
void onAboutQt();
|
||||
void onAbout();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent* event) override;
|
||||
|
||||
private:
|
||||
void onActionEditSellerTriggered();
|
||||
void onSellerNoEditCheckSellerNo();
|
||||
|
@ -39,6 +43,8 @@ class MainWindow : public QMainWindow
|
|||
void onExportSalesJsonActionTriggered();
|
||||
void onImportSalesJsonActionTriggered();
|
||||
void setSaleModel();
|
||||
void writeGeometry();
|
||||
void readGeometry();
|
||||
|
||||
Ui::MainWindow ui_;
|
||||
std::unique_ptr<Marketplace> marketplace_;
|
||||
|
|
Loading…
Reference in a new issue