1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Merge pull request #614 from vcmi/Launcher_GUI_fixes

Hmm.. it looks like it works for me.
This commit is contained in:
DjWarmonger 2019-10-14 18:21:28 +02:00 committed by GitHub
commit 3fd8faf41b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 7 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;

View File

@ -69,6 +69,9 @@
<height>89</height>
</size>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="flow">
<enum>QListView::TopToBottom</enum>
</property>
@ -138,7 +141,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="CModListView" name="stackedWidgetPage2"/>
<widget class="CSettingsView" name="settingsView"/>

View File

@ -11,6 +11,7 @@
#include "cmodlistview_moc.h"
#include "ui_cmodlistview_moc.h"
#include "imageviewer_moc.h"
#include "../mainwindow_moc.h"
#include <QJsonArray>
#include <QCryptographicHash>
@ -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;
}