diff --git a/forms/preferenceeditor.ui b/forms/preferenceeditor.ui
index 83de6f18..0fcaf17e 100644
--- a/forms/preferenceeditor.ui
+++ b/forms/preferenceeditor.ui
@@ -80,6 +80,43 @@
+ -
+
+
+ Logging
+
+
+
-
+
+
+ Status bar message types
+
+
+
+ -
+
+
+ Errors
+
+
+
+ -
+
+
+ Warnings
+
+
+
+ -
+
+
+ Information
+
+
+
+
+
+
-
diff --git a/include/config.h b/include/config.h
index 2e99dc3e..d261beb6 100644
--- a/include/config.h
+++ b/include/config.h
@@ -12,6 +12,7 @@
#include
#include
#include
+#include
#include "events.h"
#include "gridsettings.h"
@@ -96,6 +97,7 @@ public:
this->eventSelectionShapeMode = QGraphicsPixmapItem::MaskShape;
this->shownInGameReloadMessage = false;
this->gridSettings = GridSettings();
+ this->statusBarLogTypes = { LogType::LOG_ERROR, LogType::LOG_WARN };
}
void addRecentProject(QString project);
void setRecentProjects(QStringList projects);
@@ -161,6 +163,8 @@ public:
QByteArray newLayoutDialogGeometry;
bool shownInGameReloadMessage;
GridSettings gridSettings;
+ // Prefer over QSet to prevent shuffling elements when writing the config file.
+ std::set statusBarLogTypes;
protected:
virtual QString getConfigFilepath() override;
diff --git a/include/mainwindow.h b/include/mainwindow.h
index 5de2a50a..016aefc9 100644
--- a/include/mainwindow.h
+++ b/include/mainwindow.h
@@ -398,6 +398,7 @@ private:
void updateWindowTitle();
void initWindow();
+ void initLogStatusBar();
void initCustomUI();
void initExtraSignals();
void initEditor();
diff --git a/src/config.cpp b/src/config.cpp
index 7914cdce..669136c0 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -476,6 +476,13 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
this->gridSettings.style = GridSettings::getStyleFromName(value);
} else if (key == "grid_color") {
this->gridSettings.color = getConfigColor(key, value);
+ } else if (key == "status_bar_log_types") {
+ this->statusBarLogTypes.clear();
+ auto typeStrings = value.split(",", Qt::SkipEmptyParts);
+ for (const auto &typeString : typeStrings) {
+ LogType type = static_cast(getConfigInteger(key, typeString, 0, 2));
+ this->statusBarLogTypes.insert(type);
+ }
} else {
logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key));
}
@@ -559,6 +566,12 @@ QMap PorymapConfig::getKeyValueMap() {
map.insert("grid_y", QString::number(this->gridSettings.offsetY));
map.insert("grid_style", GridSettings::getStyleName(this->gridSettings.style));
map.insert("grid_color", this->gridSettings.color.name().remove("#")); // Our text config treats '#' as the start of a comment.
+
+ QStringList logTypesStrings;
+ for (const auto &type : this->statusBarLogTypes) {
+ logTypesStrings.append(QString::number(type));
+ }
+ map.insert("status_bar_log_types", logTypesStrings.join(","));
return map;
}
diff --git a/src/log.cpp b/src/log.cpp
index a27f46f1..75847372 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -110,6 +110,7 @@ void updateLogDisplays(const QString &message, LogType type) {
{LogType::LOG_ERROR, QPixmap(QStringLiteral(":/icons/error.ico"))},
};
+ bool startTimer = false;
auto it = QMutableListIterator(Log::displays);
while (it.hasNext()) {
auto display = it.next();
@@ -123,11 +124,12 @@ void updateLogDisplays(const QString &message, LogType type) {
display.icon->setPixmap(icons.value(type));
display.statusBar->clearMessage();
display.message->setText(message);
+ startTimer = true;
}
}
// Auto-hide status bar messages after a set period of time
- Log::displayClearTimer.start(5000);
+ if (startTimer) Log::displayClearTimer.start(5000);
}
void clearLogDisplays() {
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 7dc75114..0f05a966 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -75,7 +75,6 @@ MainWindow::MainWindow(QWidget *parent) :
ui->setupUi(this);
logInit();
- addLogStatusBar(this->statusBar(), {LOG_ERROR, LOG_WARN});
logInfo(QString("Launching Porymap v%1").arg(QCoreApplication::applicationVersion()));
}
@@ -144,6 +143,7 @@ void MainWindow::setWindowDisabled(bool disabled) {
void MainWindow::initWindow() {
porymapConfig.load();
+ this->initLogStatusBar();
this->initCustomUI();
this->initExtraSignals();
this->initEditor();
@@ -239,6 +239,14 @@ void MainWindow::applyUserShortcuts() {
shortcut->setKeys(shortcutsConfig.userShortcuts(shortcut));
}
+void MainWindow::initLogStatusBar() {
+ removeLogStatusBar(this->statusBar());
+ QSet logTypes = QSet(porymapConfig.statusBarLogTypes.begin(), porymapConfig.statusBarLogTypes.end());
+ if (!logTypes.isEmpty()) {
+ addLogStatusBar(this->statusBar(), logTypes);
+ }
+}
+
void MainWindow::initCustomUI() {
static const QMap mainTabNames = {
{MainTab::Map, "Map"},
@@ -2921,6 +2929,7 @@ void MainWindow::on_actionPreferences_triggered() {
connect(preferenceEditor, &PreferenceEditor::themeChanged, this, &MainWindow::setTheme);
connect(preferenceEditor, &PreferenceEditor::themeChanged, editor, &Editor::maskNonVisibleConnectionTiles);
connect(preferenceEditor, &PreferenceEditor::preferencesSaved, this, &MainWindow::togglePreferenceSpecificUi);
+ connect(preferenceEditor, &PreferenceEditor::preferencesSaved, this, &MainWindow::initLogStatusBar);
// Changes to porymapConfig.loadAllEventScripts or porymapConfig.eventSelectionShapeMode
// require us to repopulate the EventFrames and redraw event pixmaps, respectively.
connect(preferenceEditor, &PreferenceEditor::preferencesSaved, editor, &Editor::updateEvents);
diff --git a/src/ui/preferenceeditor.cpp b/src/ui/preferenceeditor.cpp
index 1289fe79..291c14ab 100644
--- a/src/ui/preferenceeditor.cpp
+++ b/src/ui/preferenceeditor.cpp
@@ -57,6 +57,11 @@ void PreferenceEditor::updateFields() {
ui->checkBox_CheckForUpdates->setChecked(porymapConfig.checkForUpdates);
ui->checkBox_DisableEventWarning->setChecked(porymapConfig.eventDeleteWarningDisabled);
ui->checkBox_AutocompleteAllScripts->setChecked(porymapConfig.loadAllEventScripts);
+
+ auto logTypeEnd = porymapConfig.statusBarLogTypes.end();
+ ui->checkBox_StatusErrors->setChecked(porymapConfig.statusBarLogTypes.find(LogType::LOG_ERROR) != logTypeEnd);
+ ui->checkBox_StatusWarnings->setChecked(porymapConfig.statusBarLogTypes.find(LogType::LOG_WARN) != logTypeEnd);
+ ui->checkBox_StatusInformation->setChecked(porymapConfig.statusBarLogTypes.find(LogType::LOG_INFO) != logTypeEnd);
}
void PreferenceEditor::saveFields() {
@@ -77,6 +82,12 @@ void PreferenceEditor::saveFields() {
porymapConfig.reopenOnLaunch = ui->checkBox_OpenRecentProject->isChecked();
porymapConfig.checkForUpdates = ui->checkBox_CheckForUpdates->isChecked();
porymapConfig.eventDeleteWarningDisabled = ui->checkBox_DisableEventWarning->isChecked();
+
+ porymapConfig.statusBarLogTypes.clear();
+ if (ui->checkBox_StatusErrors->isChecked()) porymapConfig.statusBarLogTypes.insert(LogType::LOG_ERROR);
+ if (ui->checkBox_StatusWarnings->isChecked()) porymapConfig.statusBarLogTypes.insert(LogType::LOG_WARN);
+ if (ui->checkBox_StatusInformation->isChecked()) porymapConfig.statusBarLogTypes.insert(LogType::LOG_INFO);
+
porymapConfig.save();
emit preferencesSaved();