1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Persist window settings in system

This commit is contained in:
DJWarmonger 2019-07-30 08:32:35 +02:00
parent 8014cdc3e7
commit 37bebd8f62
2 changed files with 24 additions and 0 deletions

View File

@ -45,6 +45,23 @@ MainWindow::MainWindow(QWidget * parent)
load(); // load FS before UI
ui->setupUi(this);
//load window settings
QSettings s(Ui::teamName, Ui::appName);
auto size = s.value("MainWindow/Size").toSize();
if (size.isValid())
{
resize(size);
}
auto position = s.value("MainWindow/Position").toPoint();
if (!position.isNull())
{
move(position);
}
//set default margins
auto width = ui->startGameTitle->fontMetrics().boundingRect(ui->startGameTitle->text()).width();
if(ui->startGameButton->iconSize().width() < width)
{
@ -67,6 +84,11 @@ MainWindow::MainWindow(QWidget * parent)
MainWindow::~MainWindow()
{
//save window settings
QSettings s(Ui::teamName, Ui::appName);
s.setValue("MainWindow/Size", size());
s.setValue("MainWindow/Position", pos());
delete ui;
}

View File

@ -14,6 +14,8 @@
namespace Ui
{
class MainWindow;
const QString teamName = "VCMI Team";
const QString appName = "VCMI Launcher";
}
class QTableWidgetItem;