moved cache into general page

This commit is contained in:
fourtf 2019-09-03 12:46:22 +02:00
parent 41a49b854e
commit 577e2e0a21
7 changed files with 32 additions and 98 deletions

View file

@ -202,7 +202,6 @@ SOURCES += \
src/widgets/Scrollbar.cpp \
src/widgets/settingspages/AboutPage.cpp \
src/widgets/settingspages/AccountsPage.cpp \
src/widgets/settingspages/AdvancedPage.cpp \
src/widgets/settingspages/CommandPage.cpp \
src/widgets/settingspages/ExternalToolsPage.cpp \
src/widgets/settingspages/GeneralPage.cpp \
@ -382,7 +381,6 @@ HEADERS += \
src/widgets/Scrollbar.hpp \
src/widgets/settingspages/AboutPage.hpp \
src/widgets/settingspages/AccountsPage.hpp \
src/widgets/settingspages/AdvancedPage.hpp \
src/widgets/settingspages/CommandPage.hpp \
src/widgets/settingspages/ExternalToolsPage.hpp \
src/widgets/settingspages/GeneralPage.hpp \
@ -449,4 +447,4 @@ git_hash = $$str_member($$git_commit, 0, 8)
# https://stackoverflow.com/questions/3348711/add-a-define-to-qmake-with-a-value/18343449#18343449
DEFINES += CHATTERINO_GIT_COMMIT=\\\"$$git_commit\\\"
DEFINES += CHATTERINO_GIT_RELEASE=\\\"$$git_release\\\"
DEFINES += CHATTERINO_GIT_HASH=\\\"$$git_hash\\\"
DEFINES += CHATTERINO_GIT_HASH=\\\"$$git_hash\\\"

View file

@ -3,7 +3,8 @@
namespace chatterino {
class Resources2 : public Singleton {
class Resources2 : public Singleton
{
public:
Resources2();

View file

@ -7,7 +7,6 @@
#include "widgets/helper/SettingsDialogTab.hpp"
#include "widgets/settingspages/AboutPage.hpp"
#include "widgets/settingspages/AccountsPage.hpp"
#include "widgets/settingspages/AdvancedPage.hpp"
#include "widgets/settingspages/CommandPage.hpp"
#include "widgets/settingspages/ExternalToolsPage.hpp"
#include "widgets/settingspages/GeneralPage.hpp"
@ -27,6 +26,8 @@ SettingsDialog *SettingsDialog::handle = nullptr;
SettingsDialog::SettingsDialog()
: BaseWindow(nullptr, BaseWindow::DisableCustomScaling)
{
this->setWindowTitle("Chatterino Settings");
this->initUi();
this->addTabs();
@ -173,7 +174,6 @@ void SettingsDialog::addTabs()
this->addTab(this->ui_.moderationPage = new ModerationPage);
this->addTab(new NotificationPage);
this->addTab(new ExternalToolsPage);
this->addTab(new AdvancedPage);
this->ui_.tabContainer->addStretch(1);
this->addTab(new AboutPage, Qt::AlignBottom);

View file

@ -1,78 +0,0 @@
#include "AdvancedPage.hpp"
#include "Application.hpp"
#include "controllers/taggedusers/TaggedUsersController.hpp"
#include "controllers/taggedusers/TaggedUsersModel.hpp"
#include "singletons/Logging.hpp"
#include "singletons/Paths.hpp"
#include "util/Helpers.hpp"
#include "util/LayoutCreator.hpp"
#include <QFileDialog>
#include <QFormLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QHeaderView>
#include <QLabel>
#include <QListView>
#include <QPushButton>
#include <QTableView>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QtConcurrent/QtConcurrent>
namespace chatterino {
AdvancedPage::AdvancedPage()
: SettingsPage("Advanced", ":/settings/advanced.svg")
{
LayoutCreator<AdvancedPage> layoutCreator(this);
auto tabs = layoutCreator.emplace<QTabWidget>();
{
auto layout = tabs.appendTab(new QVBoxLayout, "Cache");
auto folderLabel = layout.emplace<QLabel>();
folderLabel->setTextFormat(Qt::RichText);
folderLabel->setTextInteractionFlags(Qt::TextBrowserInteraction |
Qt::LinksAccessibleByKeyboard |
Qt::LinksAccessibleByKeyboard);
folderLabel->setOpenExternalLinks(true);
getSettings()->cachePath.connect([folderLabel](const auto &,
auto) mutable {
QString newPath = getPaths()->cacheDirectory();
QString pathShortened = "Cache saved at <a href=\"file:///" +
newPath +
"\"><span style=\"color: white;\">" +
shortenString(newPath, 50) + "</span></a>";
folderLabel->setText(pathShortened);
folderLabel->setToolTip(newPath);
});
layout->addStretch(1);
auto selectDir = layout.emplace<QPushButton>("Set custom cache folder");
QObject::connect(
selectDir.getElement(), &QPushButton::clicked, this, [this] {
auto dirName = QFileDialog::getExistingDirectory(this);
getSettings()->cachePath = dirName;
});
auto resetDir =
layout.emplace<QPushButton>("Reset custom cache folder");
QObject::connect(resetDir.getElement(), &QPushButton::clicked, this,
[]() mutable {
getSettings()->cachePath = ""; //
});
// Logs end
}
}
} // namespace chatterino

View file

@ -1,13 +0,0 @@
#pragma once
#include "widgets/settingspages/SettingsPage.hpp"
namespace chatterino {
class AdvancedPage : public SettingsPage
{
public:
AdvancedPage();
};
} // namespace chatterino

View file

@ -413,6 +413,29 @@ void GeneralPage::initLayout(SettingsLayout &layout)
layout.addCheckbox("Load message history on connect",
s.loadTwitchMessageHistoryOnConnect);
layout.addTitle("Cache");
layout.addDescription(
"Files that are used often (such as emotes) are saved to disk to "
"reduce bandwidth usage and tho speed up loading.");
auto cachePathLabel = layout.addDescription("placeholder :D");
getSettings()->cachePath.connect([cachePathLabel](const auto &,
auto) mutable {
QString newPath = getPaths()->cacheDirectory();
QString pathShortened = "Cache saved at <a href=\"file:///" + newPath +
"\"><span style=\"color: white;\">" +
shortenString(newPath, 50) + "</span></a>";
cachePathLabel->setText(pathShortened);
cachePathLabel->setToolTip(newPath);
});
layout.addButton("Choose", [this]() {
getSettings()->cachePath = QFileDialog::getExistingDirectory(this);
});
layout.addButton("Reset", []() { getSettings()->cachePath = ""; });
layout.addTitle("AppData");
layout.addDescription("All local files like settings and cache files are "
"store in this directory.");

View file

@ -72,9 +72,12 @@ public:
QPushButton *addButton(const QString &text, OnClick onClick)
{
auto button = new QPushButton(text);
auto layout = new QHBoxLayout();
layout->addWidget(button);
layout->addStretch(1);
this->groups_.back().widgets.push_back({button, {text}});
QObject::connect(button, &QPushButton::clicked, onClick);
this->addWidget(button);
this->addLayout(layout);
return button;
}