save window state on app close
This commit is contained in:
parent
761c25ee4c
commit
25bc9e44ce
4 changed files with 45 additions and 15 deletions
|
@ -16,7 +16,7 @@
|
||||||
<widget class="QWidget" name="centralWidget">
|
<widget class="QWidget" name="centralWidget">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QSplitter" name="splitter">
|
<widget class="QSplitter" name="splitter_main">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -197,7 +197,7 @@
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QSplitter" name="splitter_2">
|
<widget class="QSplitter" name="splitter_map">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -482,8 +482,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>481</width>
|
<width>545</width>
|
||||||
<height>606</height>
|
<height>587</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_8">
|
<layout class="QGridLayout" name="gridLayout_8">
|
||||||
|
@ -797,8 +797,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>300</width>
|
<width>256</width>
|
||||||
<height>70</height>
|
<height>74</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
|
@ -909,8 +909,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>304</width>
|
<width>222</width>
|
||||||
<height>372</height>
|
<height>353</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -1201,7 +1201,7 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QSplitter" name="splitter_3">
|
<widget class="QSplitter" name="splitter_events">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -1226,8 +1226,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>385</width>
|
<width>371</width>
|
||||||
<height>655</height>
|
<height>643</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_7">
|
<layout class="QGridLayout" name="gridLayout_7">
|
||||||
|
@ -1405,7 +1405,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>428</width>
|
<width>428</width>
|
||||||
<height>586</height>
|
<height>578</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -2024,8 +2024,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>829</width>
|
<width>818</width>
|
||||||
<height>552</height>
|
<height>539</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_14">
|
<layout class="QGridLayout" name="gridLayout_14">
|
||||||
|
@ -2197,7 +2197,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1117</width>
|
<width>1117</width>
|
||||||
<height>20</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QGraphicsPixmapItem>
|
#include <QGraphicsPixmapItem>
|
||||||
#include <QGraphicsItemGroup>
|
#include <QGraphicsItemGroup>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
#include <QCloseEvent>
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
@ -133,6 +134,8 @@ private slots:
|
||||||
|
|
||||||
void on_lineEdit_filterBox_textChanged(const QString &arg1);
|
void on_lineEdit_filterBox_textChanged(const QString &arg1);
|
||||||
|
|
||||||
|
void closeEvent(QCloseEvent *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
TilesetEditor *tilesetEditor = nullptr;
|
TilesetEditor *tilesetEditor = nullptr;
|
||||||
|
@ -175,6 +178,7 @@ private:
|
||||||
void initMiscHeapObjects();
|
void initMiscHeapObjects();
|
||||||
void initMapSortOrder();
|
void initMapSortOrder();
|
||||||
void loadUserSettings();
|
void loadUserSettings();
|
||||||
|
void restoreWindowState();
|
||||||
void openRecentProject();
|
void openRecentProject();
|
||||||
void updateTilesetEditor();
|
void updateTilesetEditor();
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
this->initMiscHeapObjects();
|
this->initMiscHeapObjects();
|
||||||
this->initMapSortOrder();
|
this->initMapSortOrder();
|
||||||
this->openRecentProject();
|
this->openRecentProject();
|
||||||
|
this->restoreWindowState();
|
||||||
|
|
||||||
on_toolButton_Paint_clicked();
|
on_toolButton_Paint_clicked();
|
||||||
}
|
}
|
||||||
|
@ -167,6 +168,18 @@ void MainWindow::loadUserSettings() {
|
||||||
mapSortOrder = static_cast<MapSortOrder>(settings.value("map_sort_order").toInt());
|
mapSortOrder = static_cast<MapSortOrder>(settings.value("map_sort_order").toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::restoreWindowState() {
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
if (settings.contains("saved_widget_geometry")) {
|
||||||
|
this->restoreGeometry(settings.value("window_geometry").toByteArray());
|
||||||
|
this->restoreState(settings.value("window_state").toByteArray());
|
||||||
|
this->ui->splitter_map->restoreState(settings.value("map_splitter_state").toByteArray());
|
||||||
|
this->ui->splitter_events->restoreState(settings.value("events_splitter_state").toByteArray());
|
||||||
|
this->ui->splitter_main->restoreState(settings.value("main_splitter_state").toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::openRecentProject() {
|
void MainWindow::openRecentProject() {
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString key = "recent_projects";
|
QString key = "recent_projects";
|
||||||
|
@ -1406,6 +1419,17 @@ void MainWindow::on_actionTileset_Editor_triggered()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::closeEvent(QCloseEvent *event) {
|
||||||
|
QSettings settings;
|
||||||
|
settings.setValue("saved_widget_geometry", "true");
|
||||||
|
settings.setValue("window_geometry", this->saveGeometry());
|
||||||
|
settings.setValue("window_state", this->saveState());
|
||||||
|
settings.setValue("map_splitter_state", this->ui->splitter_map->saveState());
|
||||||
|
settings.setValue("events_splitter_state", this->ui->splitter_events->saveState());
|
||||||
|
settings.setValue("main_splitter_state", this->ui->splitter_main->saveState());
|
||||||
|
QMainWindow::closeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::onTilesetEditorClosed() {
|
void MainWindow::onTilesetEditorClosed() {
|
||||||
if (this->tilesetEditor) {
|
if (this->tilesetEditor) {
|
||||||
delete this->tilesetEditor;
|
delete this->tilesetEditor;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "connectionpixmapitem.h"
|
#include "connectionpixmapitem.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
void ConnectionPixmapItem::render(qreal opacity) {
|
void ConnectionPixmapItem::render(qreal opacity) {
|
||||||
QPixmap newPixmap = this->basePixmap.copy(0, 0, this->basePixmap.width(), this->basePixmap.height());
|
QPixmap newPixmap = this->basePixmap.copy(0, 0, this->basePixmap.width(), this->basePixmap.height());
|
||||||
if (opacity < 1) {
|
if (opacity < 1) {
|
||||||
|
|
Loading…
Reference in a new issue