From 8928f59db9020c1b05b588b2e40d6ad1cd5a920f Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Mon, 15 Jan 2024 23:01:26 +0100 Subject: [PATCH] Remove getPaths() usage from Args --- mocks/include/mocks/EmptyApplication.hpp | 1 + src/common/Args.cpp | 13 ++++++------- src/common/Args.hpp | 6 ++++-- src/main.cpp | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/mocks/include/mocks/EmptyApplication.hpp b/mocks/include/mocks/EmptyApplication.hpp index f104d2edb..2b929aa37 100644 --- a/mocks/include/mocks/EmptyApplication.hpp +++ b/mocks/include/mocks/EmptyApplication.hpp @@ -2,6 +2,7 @@ #include "Application.hpp" #include "common/Args.hpp" +#include "singletons/Paths.hpp" namespace chatterino::mock { diff --git a/src/common/Args.cpp b/src/common/Args.cpp index 4ef1695cc..145fe6da4 100644 --- a/src/common/Args.cpp +++ b/src/common/Args.cpp @@ -66,7 +66,7 @@ QStringList extractCommandLine( namespace chatterino { -Args::Args(const QApplication &app) +Args::Args(const QApplication &app, const Paths &paths) { QCommandLineParser parser; parser.setApplicationDescription("Chatterino 2 Client for Twitch Chat"); @@ -132,7 +132,7 @@ Args::Args(const QApplication &app) if (parser.isSet(channelLayout)) { - this->applyCustomChannelLayout(parser.value(channelLayout)); + this->applyCustomChannelLayout(parser.value(channelLayout), paths); } this->verbose = parser.isSet(verboseOption); @@ -175,7 +175,7 @@ QStringList Args::currentArguments() const return this->currentArguments_; } -void Args::applyCustomChannelLayout(const QString &argValue) +void Args::applyCustomChannelLayout(const QString &argValue, const Paths &paths) { WindowLayout layout; WindowDescriptor window; @@ -187,10 +187,9 @@ void Args::applyCustomChannelLayout(const QString &argValue) window.type_ = WindowType::Main; // Load main window layout from config file so we can use the same geometry - const QRect configMainLayout = [] { - const QString windowLayoutFile = - combinePath(getPaths()->settingsDirectory, - WindowManager::WINDOW_LAYOUT_FILENAME); + const QRect configMainLayout = [paths] { + const QString windowLayoutFile = combinePath( + paths.settingsDirectory, WindowManager::WINDOW_LAYOUT_FILENAME); const WindowLayout configLayout = WindowLayout::loadFromFile(windowLayoutFile); diff --git a/src/common/Args.hpp b/src/common/Args.hpp index a60e988fc..60f606f4e 100644 --- a/src/common/Args.hpp +++ b/src/common/Args.hpp @@ -8,6 +8,8 @@ namespace chatterino { +class Paths; + /// Command line arguments passed to Chatterino. /// /// All accepted arguments: @@ -31,7 +33,7 @@ class Args { public: Args() = default; - Args(const QApplication &app); + Args(const QApplication &app, const Paths &paths); bool printVersion{}; @@ -56,7 +58,7 @@ public: QStringList currentArguments() const; private: - void applyCustomChannelLayout(const QString &argValue); + void applyCustomChannelLayout(const QString &argValue, const Paths &paths); QStringList currentArguments_; }; diff --git a/src/main.cpp b/src/main.cpp index f48034647..0555efb10 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -62,7 +62,7 @@ int main(int argc, char **argv) return 1; } - const Args args(a); + const Args args(a, *paths); #ifdef CHATTERINO_WITH_CRASHPAD const auto crashpadHandler = installCrashHandler(args);