diff --git a/include/config.h b/include/config.h index 1fd50216..165bab60 100644 --- a/include/config.h +++ b/include/config.h @@ -39,6 +39,7 @@ public: } virtual void reset() override { this->recentProject = ""; + this->reopenOnLaunch = true; this->mapSortOrder = MapSortOrder::Group; this->prettyCursors = true; this->collisionOpacity = 50; @@ -54,6 +55,7 @@ public: this->textEditorGotoLine = ""; } void setRecentProject(QString project); + void setReopenOnLaunch(bool enabled); void setMapSortOrder(MapSortOrder order); void setPrettyCursors(bool enabled); void setMainGeometry(QByteArray, QByteArray, QByteArray, QByteArray); @@ -72,6 +74,7 @@ public: void setTextEditorOpenFolder(const QString &command); void setTextEditorGotoLine(const QString &command); QString getRecentProject(); + bool getReopenOnLaunch(); MapSortOrder getMapSortOrder(); bool getPrettyCursors(); QMap getMainGeometry(); @@ -97,6 +100,7 @@ protected: virtual void setUnreadKeys() override {}; private: QString recentProject; + bool reopenOnLaunch; QString stringFromByteArray(QByteArray); QByteArray bytesFromString(QString); MapSortOrder mapSortOrder; diff --git a/src/config.cpp b/src/config.cpp index d29537db..0ed1e081 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -116,6 +116,8 @@ QString PorymapConfig::getConfigFilepath() { void PorymapConfig::parseConfigKeyValue(QString key, QString value) { if (key == "recent_project") { this->recentProject = value; + } else if (key == "reopen_on_launch") { + setConfigBool(key, &this->reopenOnLaunch, value); } else if (key == "pretty_cursors") { setConfigBool(key, &this->prettyCursors, value); } else if (key == "map_sort_order") { @@ -195,6 +197,7 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) { QMap PorymapConfig::getKeyValueMap() { QMap map; map.insert("recent_project", this->recentProject); + map.insert("reopen_on_launch", this->reopenOnLaunch ? "1" : "0"); map.insert("pretty_cursors", this->prettyCursors ? "1" : "0"); map.insert("map_sort_order", mapSortOrderMap.value(this->mapSortOrder)); map.insert("main_window_geometry", stringFromByteArray(this->mainWindowGeometry)); @@ -244,6 +247,11 @@ void PorymapConfig::setRecentProject(QString project) { this->save(); } +void PorymapConfig::setReopenOnLaunch(bool enabled) { + this->reopenOnLaunch = enabled; + this->save(); +} + void PorymapConfig::setMapSortOrder(MapSortOrder order) { this->mapSortOrder = order; this->save(); @@ -338,6 +346,10 @@ QString PorymapConfig::getRecentProject() { return this->recentProject; } +bool PorymapConfig::getReopenOnLaunch() { + return this->reopenOnLaunch; +} + MapSortOrder PorymapConfig::getMapSortOrder() { return this->mapSortOrder; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 73ef97c4..8ee883f9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -485,6 +485,9 @@ void MainWindow::setTheme(QString theme) { } bool MainWindow::openRecentProject() { + if (!porymapConfig.getReopenOnLaunch()) + return false; + QString default_dir = porymapConfig.getRecentProject(); if (!default_dir.isNull() && default_dir.length() > 0) { logInfo(QString("Opening recent project: '%1'").arg(default_dir));