From e873e4c665fc5db9f5dd99c71f97fbb7a090744a Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 12 Jan 2024 22:47:50 -0500 Subject: [PATCH] Save states of new splitters in config --- include/config.h | 7 ++++--- src/config.cpp | 15 +++++++++++++-- src/mainwindow.cpp | 4 +++- src/ui/tileseteditor.cpp | 4 +++- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/include/config.h b/include/config.h index cba0c013..17a19dec 100644 --- a/include/config.h +++ b/include/config.h @@ -80,8 +80,8 @@ class PorymapConfig: public KeyValueConfigBase void setReopenOnLaunch(bool enabled); void setMapSortOrder(MapSortOrder order); void setPrettyCursors(bool enabled); - void setMainGeometry(QByteArray, QByteArray, QByteArray, QByteArray); - void setTilesetEditorGeometry(QByteArray, QByteArray); + void setMainGeometry(QByteArray, QByteArray, QByteArray, QByteArray, QByteArray); + void setTilesetEditorGeometry(QByteArray, QByteArray, QByteArray); void setPaletteEditorGeometry(QByteArray, QByteArray); void setRegionMapEditorGeometry(QByteArray, QByteArray); void setProjectSettingsEditorGeometry(QByteArray, QByteArray); @@ -151,10 +151,11 @@ class PorymapConfig: public KeyValueConfigBase QByteArray mainWindowGeometry; QByteArray mainWindowState; QByteArray mapSplitterState; - QByteArray eventsSlpitterState; QByteArray mainSplitterState; + QByteArray metatilesSplitterState; QByteArray tilesetEditorGeometry; QByteArray tilesetEditorState; + QByteArray tilesetEditorSplitterState; QByteArray paletteEditorGeometry; QByteArray paletteEditorState; QByteArray regionMapEditorGeometry; diff --git a/src/config.cpp b/src/config.cpp index 3f756a7b..0c49605c 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -342,12 +342,16 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) { this->mapSplitterState = bytesFromString(value); } else if (key == "main_splitter_state") { this->mainSplitterState = bytesFromString(value); + } else if (key == "metatiles_splitter_state") { + this->metatilesSplitterState = bytesFromString(value); } else if (key == "collision_opacity") { this->collisionOpacity = getConfigInteger(key, value, 0, 100, 50); } else if (key == "tileset_editor_geometry") { this->tilesetEditorGeometry = bytesFromString(value); } else if (key == "tileset_editor_state") { this->tilesetEditorState = bytesFromString(value); + } else if (key == "tileset_editor_splitter_state") { + this->tilesetEditorSplitterState = bytesFromString(value); } else if (key == "palette_editor_geometry") { this->paletteEditorGeometry = bytesFromString(value); } else if (key == "palette_editor_state") { @@ -418,8 +422,10 @@ QMap PorymapConfig::getKeyValueMap() { map.insert("main_window_state", stringFromByteArray(this->mainWindowState)); map.insert("map_splitter_state", stringFromByteArray(this->mapSplitterState)); map.insert("main_splitter_state", stringFromByteArray(this->mainSplitterState)); + map.insert("metatiles_splitter_state", stringFromByteArray(this->metatilesSplitterState)); map.insert("tileset_editor_geometry", stringFromByteArray(this->tilesetEditorGeometry)); map.insert("tileset_editor_state", stringFromByteArray(this->tilesetEditorState)); + map.insert("tileset_editor_splitter_state", stringFromByteArray(this->tilesetEditorSplitterState)); map.insert("palette_editor_geometry", stringFromByteArray(this->paletteEditorGeometry)); map.insert("palette_editor_state", stringFromByteArray(this->paletteEditorState)); map.insert("region_map_editor_geometry", stringFromByteArray(this->regionMapEditorGeometry)); @@ -505,17 +511,20 @@ void PorymapConfig::setTilesetCheckerboardFill(bool checkerboard) { } void PorymapConfig::setMainGeometry(QByteArray mainWindowGeometry_, QByteArray mainWindowState_, - QByteArray mapSplitterState_, QByteArray mainSplitterState_) { + QByteArray mapSplitterState_, QByteArray mainSplitterState_, QByteArray metatilesSplitterState_) { this->mainWindowGeometry = mainWindowGeometry_; this->mainWindowState = mainWindowState_; this->mapSplitterState = mapSplitterState_; this->mainSplitterState = mainSplitterState_; + this->metatilesSplitterState = metatilesSplitterState_; this->save(); } -void PorymapConfig::setTilesetEditorGeometry(QByteArray tilesetEditorGeometry_, QByteArray tilesetEditorState_) { +void PorymapConfig::setTilesetEditorGeometry(QByteArray tilesetEditorGeometry_, QByteArray tilesetEditorState_, + QByteArray tilesetEditorSplitterState_) { this->tilesetEditorGeometry = tilesetEditorGeometry_; this->tilesetEditorState = tilesetEditorState_; + this->tilesetEditorSplitterState = tilesetEditorSplitterState_; this->save(); } @@ -649,6 +658,7 @@ QMap PorymapConfig::getMainGeometry() { geometry.insert("main_window_state", this->mainWindowState); geometry.insert("map_splitter_state", this->mapSplitterState); geometry.insert("main_splitter_state", this->mainSplitterState); + geometry.insert("metatiles_splitter_state", this->metatilesSplitterState); return geometry; } @@ -658,6 +668,7 @@ QMap PorymapConfig::getTilesetEditorGeometry() { geometry.insert("tileset_editor_geometry", this->tilesetEditorGeometry); geometry.insert("tileset_editor_state", this->tilesetEditorState); + geometry.insert("tileset_editor_splitter_state", this->tilesetEditorSplitterState); return geometry; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index da1c14f1..3a649062 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -464,6 +464,7 @@ void MainWindow::restoreWindowState() { this->restoreState(geometry.value("main_window_state")); this->ui->splitter_map->restoreState(geometry.value("map_splitter_state")); this->ui->splitter_main->restoreState(geometry.value("main_splitter_state")); + this->ui->splitter_Metatiles->restoreState(geometry.value("metatiles_splitter_state")); } void MainWindow::setTheme(QString theme) { @@ -2940,7 +2941,8 @@ void MainWindow::closeEvent(QCloseEvent *event) { this->saveGeometry(), this->saveState(), this->ui->splitter_map->saveState(), - this->ui->splitter_main->saveState() + this->ui->splitter_main->saveState(), + this->ui->splitter_Metatiles->saveState() ); porymapConfig.save(); shortcutsConfig.save(); diff --git a/src/ui/tileseteditor.cpp b/src/ui/tileseteditor.cpp index fc32884a..6f36aba3 100644 --- a/src/ui/tileseteditor.cpp +++ b/src/ui/tileseteditor.cpp @@ -293,6 +293,7 @@ void TilesetEditor::restoreWindowState() { QMap geometry = porymapConfig.getTilesetEditorGeometry(); this->restoreGeometry(geometry.value("tileset_editor_geometry")); this->restoreState(geometry.value("tileset_editor_state")); + this->ui->splitter->restoreState(geometry.value("tileset_editor_splitter_state")); } void TilesetEditor::initMetatileHistory() { @@ -766,7 +767,8 @@ void TilesetEditor::closeEvent(QCloseEvent *event) if (this->paletteEditor) this->paletteEditor->close(); porymapConfig.setTilesetEditorGeometry( this->saveGeometry(), - this->saveState() + this->saveState(), + this->ui->splitter->saveState() ); } }