refactor: Un-singletonize Paths & Updates (#5092)

This commit is contained in:
pajlada
2024-01-16 21:56:43 +01:00
committed by GitHub
parent 7f935665f9
commit 718696db53
60 changed files with 237 additions and 165 deletions
+8 -7
View File
@@ -791,9 +791,10 @@ void GeneralPage::initLayout(GeneralPageView &layout)
"store in this directory.");
layout.addButton("Open AppData directory", [] {
#ifdef Q_OS_DARWIN
QDesktopServices::openUrl("file://" + getPaths()->rootAppDataDirectory);
QDesktopServices::openUrl("file://" +
getIApp()->getPaths().rootAppDataDirectory);
#else
QDesktopServices::openUrl(getPaths()->rootAppDataDirectory);
QDesktopServices::openUrl(getIApp()->getPaths().rootAppDataDirectory);
#endif
});
@@ -805,7 +806,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
auto *cachePathLabel = layout.addDescription("placeholder :D");
getSettings()->cachePath.connect([cachePathLabel](const auto &,
auto) mutable {
QString newPath = getPaths()->cacheDirectory();
QString newPath = getIApp()->getPaths().cacheDirectory();
QString pathShortened = "Cache saved at <a href=\"file:///" + newPath +
"\"><span style=\"color: white;\">" +
@@ -833,9 +834,9 @@ void GeneralPage::initLayout(GeneralPageView &layout)
if (reply == QMessageBox::Yes)
{
auto cacheDir = QDir(getPaths()->cacheDirectory());
auto cacheDir = QDir(getIApp()->getPaths().cacheDirectory());
cacheDir.removeRecursively();
cacheDir.mkdir(getPaths()->cacheDirectory());
cacheDir.mkdir(getIApp()->getPaths().cacheDirectory());
}
}));
box->addStretch(1);
@@ -947,7 +948,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
"When possible, restart Chatterino if the program crashes");
#if defined(Q_OS_LINUX) && !defined(NO_QTKEYCHAIN)
if (!getPaths()->isPortable())
if (!getIApp()->getPaths().isPortable())
{
layout.addCheckbox(
"Use libsecret/KWallet/Gnome keychain to secure passwords",
@@ -1232,7 +1233,7 @@ void GeneralPage::initExtra()
{
getSettings()->cachePath.connect(
[cachePath = this->cachePath_](const auto &, auto) mutable {
QString newPath = getPaths()->cacheDirectory();
QString newPath = getIApp()->getPaths().cacheDirectory();
QString pathShortened = "Current location: <a href=\"file:///" +
newPath + "\">" +
+3 -2
View File
@@ -54,7 +54,7 @@ QString formatSize(qint64 size)
QString fetchLogDirectorySize()
{
QString logsDirectoryPath = getSettings()->logPath.getValue().isEmpty()
? getPaths()->messageLogDirectory
? getIApp()->getPaths().messageLogDirectory
: getSettings()->logPath;
auto logsSize = dirSize(logsDirectoryPath);
@@ -82,7 +82,8 @@ ModerationPage::ModerationPage()
getSettings()->logPath.connect([logsPathLabel](const QString &logPath,
auto) mutable {
QString pathOriginal =
logPath.isEmpty() ? getPaths()->messageLogDirectory : logPath;
logPath.isEmpty() ? getIApp()->getPaths().messageLogDirectory
: logPath;
QString pathShortened =
"Logs are saved at <a href=\"file:///" + pathOriginal +
+6 -5
View File
@@ -37,11 +37,12 @@ PluginsPage::PluginsPage()
auto group = layout.emplace<QGroupBox>("General plugin settings");
this->generalGroup = group.getElement();
auto groupLayout = group.setLayoutType<QFormLayout>();
auto *description = new QLabel(
"You can load plugins by putting them into " +
formatRichNamedLink("file:///" + getPaths()->pluginsDirectory,
"the Plugins directory") +
". Each one is a new directory.");
auto *description =
new QLabel("You can load plugins by putting them into " +
formatRichNamedLink(
"file:///" + getIApp()->getPaths().pluginsDirectory,
"the Plugins directory") +
". Each one is a new directory.");
description->setOpenExternalLinks(true);
description->setWordWrap(true);
description->setStyleSheet("color: #bbb");