refactor(WindowManager): remove some getApp uses (#6194)

This commit is contained in:
pajlada
2025-05-06 00:23:13 +02:00
committed by GitHub
parent 0cfe65410d
commit 9e600a8fb8
7 changed files with 24 additions and 16 deletions
+1
View File
@@ -35,6 +35,7 @@
- Dev: Added a `run-and-kill.sh` script to help debug crash-on-exit bugs. (#6188) - Dev: Added a `run-and-kill.sh` script to help debug crash-on-exit bugs. (#6188)
- Dev: Updated GoogleTest to v1.17.0. (#6180) - Dev: Updated GoogleTest to v1.17.0. (#6180)
- Dev: Mini refactor of `TwitchAccount`. (#6182) - Dev: Mini refactor of `TwitchAccount`. (#6182)
- Dev: Refactored away some `getApp` usages in `WindowManager`. (#6194)
- Dev: Simplified string literals to be a re-export of Qt functions. (#6175) - Dev: Simplified string literals to be a re-export of Qt functions. (#6175)
## 2.5.3 ## 2.5.3
+2 -1
View File
@@ -166,7 +166,8 @@ Application::Application(Settings &_settings, const Paths &paths,
, accounts(new AccountController) , accounts(new AccountController)
, eventSub(makeEventSubController(_settings)) , eventSub(makeEventSubController(_settings))
, hotkeys(new HotkeyController) , hotkeys(new HotkeyController)
, windows(new WindowManager(paths, _settings, *this->themes, *this->fonts)) , windows(new WindowManager(_args, paths, _settings, *this->themes,
*this->fonts))
, toasts(new Toasts) , toasts(new Toasts)
, imageUploader(new ImageUploader) , imageUploader(new ImageUploader)
, seventvAPI(new SeventvAPI) , seventvAPI(new SeventvAPI)
+11 -10
View File
@@ -72,7 +72,7 @@ using SplitNode = SplitContainer::Node;
void WindowManager::showSettingsDialog(QWidget *parent, void WindowManager::showSettingsDialog(QWidget *parent,
SettingsDialogPreference preference) SettingsDialogPreference preference)
{ {
if (getApp()->getArgs().dontSaveSettings) if (this->appArgs.dontSaveSettings)
{ {
QMessageBox::critical(parent, "Chatterino - Editing Settings Forbidden", QMessageBox::critical(parent, "Chatterino - Editing Settings Forbidden",
"Settings cannot be edited when running with\n" "Settings cannot be edited when running with\n"
@@ -103,9 +103,10 @@ void WindowManager::showAccountSelectPopup(QPoint point)
w->setFocus(); w->setFocus();
} }
WindowManager::WindowManager(const Paths &paths, Settings &settings, WindowManager::WindowManager(const Args &appArgs_, const Paths &paths,
Theme &themes_, Fonts &fonts) Settings &settings, Theme &themes_, Fonts &fonts)
: themes(themes_) : themes(themes_)
, appArgs(appArgs_)
, windowLayoutFilePath(combinePath(paths.settingsDirectory, , windowLayoutFilePath(combinePath(paths.settingsDirectory,
WindowManager::WINDOW_LAYOUT_FILENAME)) WindowManager::WINDOW_LAYOUT_FILENAME))
, updateWordTypeMaskListener([this] { , updateWordTypeMaskListener([this] {
@@ -411,16 +412,16 @@ void WindowManager::initialize()
{ {
WindowLayout windowLayout; WindowLayout windowLayout;
if (getApp()->getArgs().customChannelLayout) if (this->appArgs.customChannelLayout)
{ {
windowLayout = getApp()->getArgs().customChannelLayout.value(); windowLayout = this->appArgs.customChannelLayout.value();
} }
else else
{ {
windowLayout = this->loadWindowLayoutFromFile(); windowLayout = this->loadWindowLayoutFromFile();
} }
auto desired = getApp()->getArgs().activateChannel; auto desired = this->appArgs.activateChannel;
if (desired) if (desired)
{ {
windowLayout.activateOrAddChannel(desired->provider, desired->name); windowLayout.activateOrAddChannel(desired->provider, desired->name);
@@ -431,7 +432,7 @@ void WindowManager::initialize()
this->applyWindowLayout(windowLayout); this->applyWindowLayout(windowLayout);
} }
if (getApp()->getArgs().isFramelessEmbed) if (this->appArgs.isFramelessEmbed)
{ {
this->framelessEmbedWindow_.reset(new FramelessEmbedWindow); this->framelessEmbedWindow_.reset(new FramelessEmbedWindow);
this->framelessEmbedWindow_->show(); this->framelessEmbedWindow_->show();
@@ -444,7 +445,7 @@ void WindowManager::initialize()
this->mainWindow_->getNotebook().addPage(true); this->mainWindow_->getNotebook().addPage(true);
// TODO: don't create main window if it's a frameless embed // TODO: don't create main window if it's a frameless embed
if (getApp()->getArgs().isFramelessEmbed) if (this->appArgs.isFramelessEmbed)
{ {
this->mainWindow_->hide(); this->mainWindow_->hide();
} }
@@ -453,7 +454,7 @@ void WindowManager::initialize()
void WindowManager::save() void WindowManager::save()
{ {
if (getApp()->getArgs().dontSaveSettings) if (this->appArgs.dontSaveSettings)
{ {
return; return;
} }
@@ -817,7 +818,7 @@ WindowLayout WindowManager::loadWindowLayoutFromFile() const
void WindowManager::applyWindowLayout(const WindowLayout &layout) void WindowManager::applyWindowLayout(const WindowLayout &layout)
{ {
if (getApp()->getArgs().dontLoadMainWindow) if (this->appArgs.dontLoadMainWindow)
{ {
return; return;
} }
+4 -2
View File
@@ -14,6 +14,7 @@
namespace chatterino { namespace chatterino {
class Settings; class Settings;
class Args;
class Paths; class Paths;
class Window; class Window;
class ChannelView; class ChannelView;
@@ -38,12 +39,13 @@ class FramelessEmbedWindow;
class WindowManager final class WindowManager final
{ {
Theme &themes; Theme &themes;
const Args &appArgs;
public: public:
static const QString WINDOW_LAYOUT_FILENAME; static const QString WINDOW_LAYOUT_FILENAME;
explicit WindowManager(const Paths &paths, Settings &settings, explicit WindowManager(const Args &appArgs_, const Paths &paths,
Theme &themes_, Fonts &fonts); Settings &settings, Theme &themes_, Fonts &fonts);
~WindowManager(); ~WindowManager();
WindowManager(const WindowManager &) = delete; WindowManager(const WindowManager &) = delete;
+2 -1
View File
@@ -26,7 +26,8 @@ class MockApplication : public mock::BaseApplication
{ {
public: public:
MockApplication() MockApplication()
: windowManager(this->paths_, this->settings, this->theme, this->fonts) : windowManager(this->args, this->paths_, this->settings, this->theme,
this->fonts)
{ {
} }
+2 -1
View File
@@ -21,7 +21,8 @@ class MockApplication : public mock::BaseApplication
{ {
public: public:
MockApplication() MockApplication()
: windowManager(this->paths_, this->settings, this->theme, this->fonts) : windowManager(this->args, this->paths_, this->settings, this->theme,
this->fonts)
{ {
} }
+2 -1
View File
@@ -28,7 +28,8 @@ class MockApplication : public mock::BaseApplication
{ {
public: public:
MockApplication() MockApplication()
: windowManager(this->paths_, this->settings, this->theme, this->fonts) : windowManager(this->args, this->paths_, this->settings, this->theme,
this->fonts)
, commands(this->paths_) , commands(this->paths_)
{ {
} }