Skip to content

Commit

Permalink
Save states of new splitters in config
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffinRichards committed Jan 13, 2024
1 parent 86d0200 commit e873e4c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
7 changes: 4 additions & 3 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 13 additions & 2 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -418,8 +422,10 @@ QMap<QString, QString> 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));
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -649,6 +658,7 @@ QMap<QString, QByteArray> 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;
}
Expand All @@ -658,6 +668,7 @@ QMap<QString, QByteArray> 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;
}
Expand Down
4 changes: 3 additions & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion src/ui/tileseteditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ void TilesetEditor::restoreWindowState() {
QMap<QString, QByteArray> 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() {
Expand Down Expand Up @@ -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()
);
}
}
Expand Down

0 comments on commit e873e4c

Please sign in to comment.