fixed some functionality, cleaned up and removed an unused QBoolSetting

This commit is contained in:
apa420 2018-05-16 01:39:08 +02:00
parent 26a0d5bc26
commit 3157b10ef2
2 changed files with 26 additions and 29 deletions

View file

@ -101,9 +101,8 @@ public:
/// Logging /// Logging
BoolSetting enableLogging = {"/logging/enabled", false}; BoolSetting enableLogging = {"/logging/enabled", false};
BoolSetting customLogPath = {"/logging/customPath", false}; QStringSetting logPath = {"/logging/path",
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)};
QStringSetting logPath = {"/logging/path", ""};
QStringSetting pathHighlightSound = {"/highlighting/highlightSoundPath", QStringSetting pathHighlightSound = {"/highlighting/highlightSoundPath",
"qrc:/sounds/ping2.wav"}; "qrc:/sounds/ping2.wav"};

View file

@ -53,41 +53,39 @@ ModerationPage::ModerationPage()
layout->addStretch(1); layout->addStretch(1);
auto selectDir = layout.emplace<QPushButton>("Logs"); auto selectDir = layout.emplace<QPushButton>("Set custom logpath");
QObject::connect( // Setting custom logpath
selectDir.getElement(), &QPushButton::clicked, this, QObject::connect(selectDir.getElement(), &QPushButton::clicked, this, [
[ this, created, app, dirMemory = QString{app->settings->logPath} ]() mutable { this, created, app, dirMemory = QString{app->settings->logPath}
auto dirName = QFileDialog::getExistingDirectory(); ]() 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)); 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; app->settings->logPath = dirName;
qDebug() << "dirName" << dirName; dirMemory = dirName;
qDebug() << app->settings->logPath.getValue(); app->logging->refreshLoggingPath();
qDebug() << app->settings->customLogPath.getValue();
dirMemory = dirName; });
app->logging->refreshLoggingPath(); // Reset custom logpath
});
auto resetDir = layout.emplace<QPushButton>("Reset logpath"); auto resetDir = layout.emplace<QPushButton>("Reset logpath");
QObject::connect( QObject::connect(
resetDir.getElement(), &QPushButton::clicked, this, [this, created, app]() mutable { resetDir.getElement(), &QPushButton::clicked, this, [this, created, app]() mutable {
app->settings->logPath = ""; app->settings->logPath = "";
created->setText("Logs are saved to " + created->setText(
CreateLink(QCoreApplication::applicationDirPath(), true)); "Logs are saved to " +
app->settings->customLogPath = false; CreateLink(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation),
true));
app->logging->refreshLoggingPath(); app->logging->refreshLoggingPath();
}); });