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:
parent
8014cdc3e7
commit
37bebd8f62
@ -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;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,8 @@
|
||||
namespace Ui
|
||||
{
|
||||
class MainWindow;
|
||||
const QString teamName = "VCMI Team";
|
||||
const QString appName = "VCMI Launcher";
|
||||
}
|
||||
|
||||
class QTableWidgetItem;
|
||||
|
Loading…
Reference in New Issue
Block a user