Save & restore palette editor geometry & state from config
This commit is contained in:
parent
daae6fe52b
commit
8b7f4069cd
5 changed files with 39 additions and 1 deletions
|
@ -52,6 +52,7 @@ public:
|
|||
void setPrettyCursors(bool enabled);
|
||||
void setMainGeometry(QByteArray, QByteArray, QByteArray, QByteArray);
|
||||
void setTilesetEditorGeometry(QByteArray, QByteArray);
|
||||
void setPaletteEditorGeometry(QByteArray, QByteArray);
|
||||
void setRegionMapEditorGeometry(QByteArray, QByteArray);
|
||||
void setCollisionOpacity(int opacity);
|
||||
void setMetatilesZoom(int zoom);
|
||||
|
@ -66,6 +67,7 @@ public:
|
|||
bool getPrettyCursors();
|
||||
QMap<QString, QByteArray> getMainGeometry();
|
||||
QMap<QString, QByteArray> getTilesetEditorGeometry();
|
||||
QMap<QString, QByteArray> getPaletteEditorGeometry();
|
||||
QMap<QString, QByteArray> getRegionMapEditorGeometry();
|
||||
int getCollisionOpacity();
|
||||
int getMetatilesZoom();
|
||||
|
@ -94,6 +96,8 @@ private:
|
|||
QByteArray mainSplitterState;
|
||||
QByteArray tilesetEditorGeometry;
|
||||
QByteArray tilesetEditorState;
|
||||
QByteArray paletteEditorGeometry;
|
||||
QByteArray paletteEditorState;
|
||||
QByteArray regionMapEditorGeometry;
|
||||
QByteArray regionMapEditorState;
|
||||
int collisionOpacity;
|
||||
|
|
|
@ -46,6 +46,7 @@ private:
|
|||
void setColor(int);
|
||||
void commitEditHistory(int paletteid);
|
||||
void setColorsFromHistory(PaletteHistoryItem*, int);
|
||||
void closeEvent(QCloseEvent*);
|
||||
|
||||
signals:
|
||||
void closed();
|
||||
|
|
|
@ -141,6 +141,10 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
|
|||
this->tilesetEditorGeometry = bytesFromString(value);
|
||||
} else if (key == "tileset_editor_state") {
|
||||
this->tilesetEditorState = bytesFromString(value);
|
||||
} else if (key == "palette_editor_geometry") {
|
||||
this->paletteEditorGeometry = bytesFromString(value);
|
||||
} else if (key == "palette_editor_state") {
|
||||
this->paletteEditorState = bytesFromString(value);
|
||||
} else if (key == "region_map_editor_geometry") {
|
||||
this->regionMapEditorGeometry = bytesFromString(value);
|
||||
} else if (key == "region_map_editor_state") {
|
||||
|
@ -200,6 +204,8 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
|
|||
map.insert("main_splitter_state", stringFromByteArray(this->mainSplitterState));
|
||||
map.insert("tileset_editor_geometry", stringFromByteArray(this->tilesetEditorGeometry));
|
||||
map.insert("tileset_editor_state", stringFromByteArray(this->tilesetEditorState));
|
||||
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));
|
||||
map.insert("region_map_editor_state", stringFromByteArray(this->regionMapEditorState));
|
||||
map.insert("collision_opacity", QString("%1").arg(this->collisionOpacity));
|
||||
|
@ -270,6 +276,12 @@ void PorymapConfig::setTilesetEditorGeometry(QByteArray tilesetEditorGeometry_,
|
|||
this->save();
|
||||
}
|
||||
|
||||
void PorymapConfig::setPaletteEditorGeometry(QByteArray paletteEditorGeometry_, QByteArray paletteEditorState_) {
|
||||
this->paletteEditorGeometry = paletteEditorGeometry_;
|
||||
this->paletteEditorState = paletteEditorState_;
|
||||
this->save();
|
||||
}
|
||||
|
||||
void PorymapConfig::setRegionMapEditorGeometry(QByteArray regionMapEditorGeometry_, QByteArray regionMapEditorState_) {
|
||||
this->regionMapEditorGeometry = regionMapEditorGeometry_;
|
||||
this->regionMapEditorState = regionMapEditorState_;
|
||||
|
@ -340,6 +352,15 @@ QMap<QString, QByteArray> PorymapConfig::getTilesetEditorGeometry() {
|
|||
return geometry;
|
||||
}
|
||||
|
||||
QMap<QString, QByteArray> PorymapConfig::getPaletteEditorGeometry() {
|
||||
QMap<QString, QByteArray> geometry;
|
||||
|
||||
geometry.insert("palette_editor_geometry", this->paletteEditorGeometry);
|
||||
geometry.insert("palette_editor_state", this->paletteEditorState);
|
||||
|
||||
return geometry;
|
||||
}
|
||||
|
||||
QMap<QString, QByteArray> PorymapConfig::getRegionMapEditorGeometry() {
|
||||
QMap<QString, QByteArray> geometry;
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#include "paletteeditor.h"
|
||||
#include "ui_paletteeditor.h"
|
||||
#include "paletteutil.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include "log.h"
|
||||
|
||||
PaletteEditor::PaletteEditor(Project *project, Tileset *primaryTileset, Tileset *secondaryTileset, int paletteId, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
|
@ -311,3 +312,10 @@ void PaletteEditor::on_actionImport_Palette_triggered()
|
|||
this->commitEditHistory(paletteId);
|
||||
emit this->changedPaletteColor();
|
||||
}
|
||||
|
||||
void PaletteEditor::closeEvent(QCloseEvent*) {
|
||||
porymapConfig.setPaletteEditorGeometry(
|
||||
this->saveGeometry(),
|
||||
this->saveState()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -694,6 +694,10 @@ void TilesetEditor::on_actionChange_Palettes_triggered()
|
|||
this->paletteEditor = new PaletteEditor(this->project, this->primaryTileset, this->secondaryTileset, this->paletteId, this);
|
||||
connect(this->paletteEditor, SIGNAL(changedPaletteColor()), this, SLOT(onPaletteEditorChangedPaletteColor()));
|
||||
connect(this->paletteEditor, SIGNAL(changedPalette(int)), this, SLOT(onPaletteEditorChangedPalette(int)));
|
||||
logInfo("Restoring palette editor geometry from previous session.");
|
||||
QMap<QString, QByteArray> geometry = porymapConfig.getPaletteEditorGeometry();
|
||||
this->paletteEditor->restoreGeometry(geometry.value("palette_editor_geometry"));
|
||||
this->paletteEditor->restoreState(geometry.value("palette_editor_state"));
|
||||
}
|
||||
|
||||
if (!this->paletteEditor->isVisible()) {
|
||||
|
|
Loading…
Reference in a new issue