diff --git a/launcher/mainwindow_moc.cpp b/launcher/mainwindow_moc.cpp
index a07774ed2..df475eb12 100644
--- a/launcher/mainwindow_moc.cpp
+++ b/launcher/mainwindow_moc.cpp
@@ -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;
}
diff --git a/launcher/mainwindow_moc.h b/launcher/mainwindow_moc.h
index 2234f27aa..ce7c9d625 100644
--- a/launcher/mainwindow_moc.h
+++ b/launcher/mainwindow_moc.h
@@ -14,6 +14,8 @@
namespace Ui
{
class MainWindow;
+const QString teamName = "VCMI Team";
+const QString appName = "VCMI Launcher";
}
class QTableWidgetItem;
diff --git a/launcher/mainwindow_moc.ui b/launcher/mainwindow_moc.ui
index 9e099e547..95ba70e52 100644
--- a/launcher/mainwindow_moc.ui
+++ b/launcher/mainwindow_moc.ui
@@ -69,6 +69,9 @@
89
+
+ QListView::Static
+
QListView::TopToBottom
@@ -138,7 +141,7 @@
- 1
+ 0
diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp
index c31054cf2..702896900 100644
--- a/launcher/modManager/cmodlistview_moc.cpp
+++ b/launcher/modManager/cmodlistview_moc.cpp
@@ -11,6 +11,7 @@
#include "cmodlistview_moc.h"
#include "ui_cmodlistview_moc.h"
#include "imageviewer_moc.h"
+#include "../mainwindow_moc.h"
#include
#include
@@ -42,16 +43,26 @@ void CModListView::setupModsView()
ui->allModsView->setModel(filterModel);
// input data is not sorted - sort it before display
ui->allModsView->sortByColumn(ModFields::TYPE, Qt::AscendingOrder);
- ui->allModsView->setColumnWidth(ModFields::NAME, 185);
- ui->allModsView->setColumnWidth(ModFields::STATUS_ENABLED, 30);
- ui->allModsView->setColumnWidth(ModFields::STATUS_UPDATE, 30);
- ui->allModsView->setColumnWidth(ModFields::TYPE, 75);
- ui->allModsView->setColumnWidth(ModFields::SIZE, 80);
- ui->allModsView->setColumnWidth(ModFields::VERSION, 60);
ui->allModsView->header()->setSectionResizeMode(ModFields::STATUS_ENABLED, QHeaderView::Fixed);
ui->allModsView->header()->setSectionResizeMode(ModFields::STATUS_UPDATE, QHeaderView::Fixed);
+ QSettings s(Ui::teamName, Ui::appName);
+ auto state = s.value("AllModsView/State").toByteArray();
+ if(!state.isNull()) //read last saved settings
+ {
+ ui->allModsView->header()->restoreState(state);
+ }
+ else //default //TODO: default high-DPI scaling
+ {
+ ui->allModsView->setColumnWidth(ModFields::NAME, 185);
+ ui->allModsView->setColumnWidth(ModFields::STATUS_ENABLED, 30);
+ ui->allModsView->setColumnWidth(ModFields::STATUS_UPDATE, 30);
+ ui->allModsView->setColumnWidth(ModFields::TYPE, 75);
+ ui->allModsView->setColumnWidth(ModFields::SIZE, 80);
+ ui->allModsView->setColumnWidth(ModFields::VERSION, 60);
+ }
+
ui->allModsView->setUniformRowHeights(true);
connect(ui->allModsView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex&,const QModelIndex&)),
@@ -70,6 +81,7 @@ CModListView::CModListView(QWidget * parent)
settingsListener([&](const JsonNode &){ repositoriesChanged = true; });
ui->setupUi(this);
+
setupModModel();
setupFilterModel();
setupModsView();
@@ -104,6 +116,9 @@ void CModListView::loadRepositories()
CModListView::~CModListView()
{
+ QSettings s(Ui::teamName, Ui::appName);
+ s.setValue("AllModsView/State", ui->allModsView->header()->saveState());
+
delete ui;
}