mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
slightly changed layout for logs and cache
This commit is contained in:
parent
577e2e0a21
commit
1c0ed6b1aa
3 changed files with 45 additions and 19 deletions
|
@ -430,11 +430,19 @@ void GeneralPage::initLayout(SettingsLayout &layout)
|
||||||
cachePathLabel->setToolTip(newPath);
|
cachePathLabel->setToolTip(newPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
layout.addButton("Choose", [this]() {
|
// Choose and reset buttons
|
||||||
getSettings()->cachePath = QFileDialog::getExistingDirectory(this);
|
{
|
||||||
});
|
auto box = new QHBoxLayout;
|
||||||
|
|
||||||
layout.addButton("Reset", []() { getSettings()->cachePath = ""; });
|
box->addWidget(layout.makeButton("Choose cache path", [this]() {
|
||||||
|
getSettings()->cachePath = QFileDialog::getExistingDirectory(this);
|
||||||
|
}));
|
||||||
|
box->addWidget(layout.makeButton(
|
||||||
|
"Reset", []() { getSettings()->cachePath = ""; }));
|
||||||
|
box->addStretch(1);
|
||||||
|
|
||||||
|
layout.addLayout(box);
|
||||||
|
}
|
||||||
|
|
||||||
layout.addTitle("AppData");
|
layout.addTitle("AppData");
|
||||||
layout.addDescription("All local files like settings and cache files are "
|
layout.addDescription("All local files like settings and cache files are "
|
||||||
|
|
|
@ -69,14 +69,21 @@ public:
|
||||||
bool editable = false);
|
bool editable = false);
|
||||||
|
|
||||||
template <typename OnClick>
|
template <typename OnClick>
|
||||||
QPushButton *addButton(const QString &text, OnClick onClick)
|
QPushButton *makeButton(const QString &text, OnClick onClick)
|
||||||
{
|
{
|
||||||
auto button = new QPushButton(text);
|
auto button = new QPushButton(text);
|
||||||
|
this->groups_.back().widgets.push_back({button, {text}});
|
||||||
|
QObject::connect(button, &QPushButton::clicked, onClick);
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename OnClick>
|
||||||
|
QPushButton *addButton(const QString &text, OnClick onClick)
|
||||||
|
{
|
||||||
|
auto button = makeButton(text, onClick);
|
||||||
auto layout = new QHBoxLayout();
|
auto layout = new QHBoxLayout();
|
||||||
layout->addWidget(button);
|
layout->addWidget(button);
|
||||||
layout->addStretch(1);
|
layout->addStretch(1);
|
||||||
this->groups_.back().widgets.push_back({button, {text}});
|
|
||||||
QObject::connect(button, &QPushButton::clicked, onClick);
|
|
||||||
this->addLayout(layout);
|
this->addLayout(layout);
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,13 +83,10 @@ ModerationPage::ModerationPage()
|
||||||
|
|
||||||
auto logs = tabs.appendTab(new QVBoxLayout, "Logs");
|
auto logs = tabs.appendTab(new QVBoxLayout, "Logs");
|
||||||
{
|
{
|
||||||
|
logs.append(this->createCheckBox("Enable logging",
|
||||||
|
getSettings()->enableLogging));
|
||||||
auto logsPathLabel = logs.emplace<QLabel>();
|
auto logsPathLabel = logs.emplace<QLabel>();
|
||||||
|
|
||||||
// Show how big (size-wise) the logs are
|
|
||||||
auto logsPathSizeLabel = logs.emplace<QLabel>();
|
|
||||||
logsPathSizeLabel->setText(
|
|
||||||
QtConcurrent::run([] { return fetchLogDirectorySize(); }));
|
|
||||||
|
|
||||||
// Logs (copied from LoggingMananger)
|
// Logs (copied from LoggingMananger)
|
||||||
getSettings()->logPath.connect([logsPathLabel](const QString &logPath,
|
getSettings()->logPath.connect([logsPathLabel](const QString &logPath,
|
||||||
auto) mutable {
|
auto) mutable {
|
||||||
|
@ -109,13 +106,27 @@ ModerationPage::ModerationPage()
|
||||||
logsPathLabel->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
logsPathLabel->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
||||||
Qt::LinksAccessibleByKeyboard);
|
Qt::LinksAccessibleByKeyboard);
|
||||||
logsPathLabel->setOpenExternalLinks(true);
|
logsPathLabel->setOpenExternalLinks(true);
|
||||||
logs.append(this->createCheckBox("Enable logging",
|
|
||||||
getSettings()->enableLogging));
|
|
||||||
|
|
||||||
|
auto buttons = logs.emplace<QHBoxLayout>().withoutMargin();
|
||||||
|
|
||||||
|
// Select and Reset
|
||||||
|
auto selectDir = buttons.emplace<QPushButton>("Select log directory ");
|
||||||
|
auto resetDir = buttons.emplace<QPushButton>("Reset");
|
||||||
|
|
||||||
|
getSettings()->logPath.connect(
|
||||||
|
[element = resetDir.getElement()](const QString &path) {
|
||||||
|
element->setEnabled(!path.isEmpty());
|
||||||
|
});
|
||||||
|
|
||||||
|
buttons->addStretch();
|
||||||
logs->addStretch(1);
|
logs->addStretch(1);
|
||||||
auto selectDir = logs.emplace<QPushButton>("Set custom logpath");
|
|
||||||
|
|
||||||
// Setting custom logpath
|
// Show how big (size-wise) the logs are
|
||||||
|
auto logsPathSizeLabel = logs.emplace<QLabel>();
|
||||||
|
logsPathSizeLabel->setText(
|
||||||
|
QtConcurrent::run([] { return fetchLogDirectorySize(); }));
|
||||||
|
|
||||||
|
// Select event
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
selectDir.getElement(), &QPushButton::clicked, this,
|
selectDir.getElement(), &QPushButton::clicked, this,
|
||||||
[this, logsPathSizeLabel]() mutable {
|
[this, logsPathSizeLabel]() mutable {
|
||||||
|
@ -128,8 +139,9 @@ ModerationPage::ModerationPage()
|
||||||
QtConcurrent::run([] { return fetchLogDirectorySize(); }));
|
QtConcurrent::run([] { return fetchLogDirectorySize(); }));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
buttons->addSpacing(16);
|
||||||
|
|
||||||
// Reset custom logpath
|
// Reset custom logpath
|
||||||
auto resetDir = logs.emplace<QPushButton>("Reset logpath");
|
|
||||||
QObject::connect(resetDir.getElement(), &QPushButton::clicked, this,
|
QObject::connect(resetDir.getElement(), &QPushButton::clicked, this,
|
||||||
[logsPathSizeLabel]() mutable {
|
[logsPathSizeLabel]() mutable {
|
||||||
getSettings()->logPath = "";
|
getSettings()->logPath = "";
|
||||||
|
@ -139,8 +151,7 @@ ModerationPage::ModerationPage()
|
||||||
[] { return fetchLogDirectorySize(); }));
|
[] { return fetchLogDirectorySize(); }));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Logs end
|
} // logs end
|
||||||
}
|
|
||||||
|
|
||||||
auto modMode = tabs.appendTab(new QVBoxLayout, "Moderation buttons");
|
auto modMode = tabs.appendTab(new QVBoxLayout, "Moderation buttons");
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue