Remove getPaths() usage from Args

This commit is contained in:
Rasmus Karlsson 2024-01-15 23:01:26 +01:00
parent 1bf40b70a0
commit 8928f59db9
4 changed files with 12 additions and 10 deletions

View file

@ -2,6 +2,7 @@
#include "Application.hpp"
#include "common/Args.hpp"
#include "singletons/Paths.hpp"
namespace chatterino::mock {

View file

@ -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);

View file

@ -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_;
};

View file

@ -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);