Fix logging to a custom folder

Progress on #352
This commit is contained in:
Rasmus Karlsson
2018-06-06 20:30:11 +02:00
parent 7cd2d77524
commit 578795fbc3
8 changed files with 69 additions and 130 deletions
+24 -40
View File
@@ -46,12 +46,16 @@ ModerationPage::ModerationPage()
// Logs (copied from LoggingMananger)
auto created = logs.emplace<QLabel>();
if (app->settings->logPath == "") {
created->setText("Logs are saved to " +
CreateLink(QCoreApplication::applicationDirPath(), true));
} else {
created->setText("Logs are saved to " + CreateLink(app->settings->logPath, true));
}
app->settings->logPath.connect([app, created](const QString &logPath, auto) mutable {
if (logPath == "") {
created->setText("Logs are saved to " +
CreateLink(app->paths->logsFolderPath, true));
} else {
created->setText("Logs are saved to " + CreateLink(logPath, true));
}
});
created->setTextFormat(Qt::RichText);
created->setTextInteractionFlags(Qt::TextBrowserInteraction |
Qt::LinksAccessibleByKeyboard |
@@ -60,44 +64,24 @@ ModerationPage::ModerationPage()
logs.append(this->createCheckBox("Enable logging", app->settings->enableLogging));
logs->addStretch(1);
/*
auto selectDir = logs.emplace<QPushButton>("Set custom logpath");
auto selectDir = logs.emplace<QPushButton>("Set custom logpath");
// 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));
// Setting custom logpath
QObject::connect(selectDir.getElement(), &QPushButton::clicked, this, [this]() {
auto app = getApp();
auto dirName = QFileDialog::getExistingDirectory(this);
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->logPath = dirName;
});
app->settings->logPath = dirName;
dirMemory = dirName;
app->logging->refreshLoggingPath();
});
// Reset custom logpath
auto resetDir = logs.emplace<QPushButton>("Reset logpath");
QObject::connect(
resetDir.getElement(), &QPushButton::clicked, this, [this, created, app]() mutable {
app->settings->logPath = "";
created->setText(
"Logs are saved to " +
CreateLink(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation),
true));
app->logging->refreshLoggingPath();
});
// Reset custom logpath
auto resetDir = logs.emplace<QPushButton>("Reset logpath");
QObject::connect(resetDir.getElement(), &QPushButton::clicked, this, []() {
auto app = getApp();
app->settings->logPath = "";
});
// Logs end
*/
// Logs end
}
auto modMode = tabs.appendTab(new QVBoxLayout, "Moderation mode");