From 3157b10ef24aab5c3a4783b643e4c7472b59c7c1 Mon Sep 17 00:00:00 2001 From: apa420 Date: Wed, 16 May 2018 01:39:08 +0200 Subject: [PATCH] fixed some functionality, cleaned up and removed an unused QBoolSetting --- src/singletons/settingsmanager.hpp | 5 +- src/widgets/settingspages/moderationpage.cpp | 50 ++++++++++---------- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/singletons/settingsmanager.hpp b/src/singletons/settingsmanager.hpp index e3eaf8523..acf65d742 100644 --- a/src/singletons/settingsmanager.hpp +++ b/src/singletons/settingsmanager.hpp @@ -101,9 +101,8 @@ public: /// Logging BoolSetting enableLogging = {"/logging/enabled", false}; - BoolSetting customLogPath = {"/logging/customPath", false}; - - QStringSetting logPath = {"/logging/path", ""}; + QStringSetting logPath = {"/logging/path", + QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)}; QStringSetting pathHighlightSound = {"/highlighting/highlightSoundPath", "qrc:/sounds/ping2.wav"}; diff --git a/src/widgets/settingspages/moderationpage.cpp b/src/widgets/settingspages/moderationpage.cpp index cad7a5c85..65ccb3f94 100644 --- a/src/widgets/settingspages/moderationpage.cpp +++ b/src/widgets/settingspages/moderationpage.cpp @@ -53,41 +53,39 @@ ModerationPage::ModerationPage() layout->addStretch(1); - auto selectDir = layout.emplace("Logs"); + auto selectDir = layout.emplace("Set custom logpath"); - QObject::connect( - selectDir.getElement(), &QPushButton::clicked, this, - [ this, created, app, dirMemory = QString{app->settings->logPath} ]() mutable { - auto dirName = QFileDialog::getExistingDirectory(); + // Setting custom logpath + QObject::connect(selectDir.getElement(), &QPushButton::clicked, this, [ + this, created, app, dirMemory = QString{app->settings->logPath} + ]() mutable { + auto dirName = QFileDialog::getExistingDirectory(this); + created->setText("Logs are saved to " + CreateLink(dirName, true)); + if (dirName == "" && dirMemory == "") { + created->setText( + "Logs are saved to " + + CreateLink(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), + true)); + } else if (dirName == "") { + dirName = dirMemory; created->setText("Logs are saved to " + CreateLink(dirName, true)); - app->settings->customLogPath = true; - if (dirName == "" && dirMemory == "") { - created->setText("Logs are saved to " + - CreateLink(QCoreApplication::applicationDirPath(), true)); - app->settings->customLogPath = false; - } else if (dirName == "") { - dirName = dirMemory; - created->setText("Logs are saved to " + CreateLink(dirName, true)); - } - app->settings->logPath = dirName; + } - qDebug() << "dirMemory" << dirMemory; - qDebug() << "dirName" << dirName; - qDebug() << app->settings->logPath.getValue(); - qDebug() << app->settings->customLogPath.getValue(); + app->settings->logPath = dirName; + dirMemory = dirName; + app->logging->refreshLoggingPath(); - dirMemory = dirName; - app->logging->refreshLoggingPath(); - - }); + }); + // Reset custom logpath auto resetDir = layout.emplace("Reset logpath"); QObject::connect( resetDir.getElement(), &QPushButton::clicked, this, [this, created, app]() mutable { app->settings->logPath = ""; - created->setText("Logs are saved to " + - CreateLink(QCoreApplication::applicationDirPath(), true)); - app->settings->customLogPath = false; + created->setText( + "Logs are saved to " + + CreateLink(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), + true)); app->logging->refreshLoggingPath(); });