From 0a15dfbf4c964d073ada2f9e1524d465a0b54b1d Mon Sep 17 00:00:00 2001 From: BigBahss Date: Mon, 16 Nov 2020 06:46:21 -0500 Subject: [PATCH] Add preferred text editor to PorymapConfig --- include/config.h | 3 +++ src/config.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/config.h b/include/config.h index 008eeeb7..a680c55d 100644 --- a/include/config.h +++ b/include/config.h @@ -61,6 +61,7 @@ public: void setMonitorFiles(bool monitor); void setRegionMapDimensions(int width, int height); void setTheme(QString theme); + void setTextEditorCommand(const QString &command); QString getRecentProject(); QString getRecentMap(); MapSortOrder getMapSortOrder(); @@ -76,6 +77,7 @@ public: bool getMonitorFiles(); QSize getRegionMapDimensions(); QString getTheme(); + QString getTextEditorCommand(); protected: virtual QString getConfigFilepath() override; virtual void parseConfigKeyValue(QString key, QString value) override; @@ -107,6 +109,7 @@ private: bool monitorFiles; QSize regionMapDimensions; QString theme; + QString textEditorCommand; }; extern PorymapConfig porymapConfig; diff --git a/src/config.cpp b/src/config.cpp index 3c9fe33d..2a1b16c7 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -187,6 +187,8 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) { } } else if (key == "theme") { this->theme = value; + } else if (key == "text_editor") { + this->textEditorCommand = value; } else { logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key)); } @@ -216,6 +218,7 @@ QMap PorymapConfig::getKeyValueMap() { map.insert("region_map_dimensions", QString("%1x%2").arg(this->regionMapDimensions.width()) .arg(this->regionMapDimensions.height())); map.insert("theme", this->theme); + map.insert("text_editor", this->textEditorCommand); return map; } @@ -316,6 +319,11 @@ void PorymapConfig::setTheme(QString theme) { this->theme = theme; } +void PorymapConfig::setTextEditorCommand(const QString &command) { + this->textEditorCommand = command; + this->save(); +} + QString PorymapConfig::getRecentProject() { return this->recentProject; } @@ -398,6 +406,10 @@ QString PorymapConfig::getTheme() { return this->theme; } +QString PorymapConfig::getTextEditorCommand() { + return this->textEditorCommand; +} + const QMap baseGameVersionMap = { {BaseGameVersion::pokeruby, "pokeruby"}, {BaseGameVersion::pokefirered, "pokefirered"},