mirror-chatterino2/src/widgets/settingspages/logspage.cpp

47 lines
1.5 KiB
C++
Raw Normal View History

2018-01-12 23:09:05 +01:00
#include "logspage.hpp"
2018-02-03 16:17:59 +01:00
#include "singletons/pathmanager.hpp"
2018-01-12 23:09:05 +01:00
#include <QFormLayout>
#include <QVBoxLayout>
#include "util/layoutcreator.hpp"
2018-01-12 23:09:05 +01:00
namespace chatterino {
namespace widgets {
namespace settingspages {
2018-02-03 16:17:59 +01:00
inline QString CreateLink(const QString &url, bool file = false)
{
if (file) {
return QString("<a href=\"file:///" + url + "\"><span style=\"color: white;\">" + url +
"</span></a>");
}
return QString("<a href=\"" + url + "\"><span style=\"color: white;\">" + url + "</span></a>");
}
2018-01-12 23:09:05 +01:00
LogsPage::LogsPage()
: SettingsPage("Logs", "")
2018-01-12 23:09:05 +01:00
{
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
util::LayoutCreator<LogsPage> layoutCreator(this);
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
2018-02-03 16:17:59 +01:00
singletons::PathManager &pathManager = singletons::PathManager::getInstance();
auto logPath = pathManager.logsFolderPath;
2018-02-03 16:17:59 +01:00
auto created = layout.emplace<QLabel>();
created->setText("Logs are saved to " + CreateLink(logPath, true));
created->setTextFormat(Qt::RichText);
created->setTextInteractionFlags(Qt::TextBrowserInteraction | Qt::LinksAccessibleByKeyboard |
Qt::LinksAccessibleByKeyboard);
created->setOpenExternalLinks(true);
layout.append(this->createCheckBox("Enable logging", settings.enableLogging));
layout->addStretch(1);
2018-01-12 23:09:05 +01:00
}
2018-01-12 23:09:05 +01:00
} // namespace settingspages
} // namespace widgets
} // namespace chatterino