refactor(WindowManager): remove some getApp uses (#6194)
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
- 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: 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)
|
||||
|
||||
## 2.5.3
|
||||
|
||||
+2
-1
@@ -166,7 +166,8 @@ Application::Application(Settings &_settings, const Paths &paths,
|
||||
, accounts(new AccountController)
|
||||
, eventSub(makeEventSubController(_settings))
|
||||
, 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)
|
||||
, imageUploader(new ImageUploader)
|
||||
, seventvAPI(new SeventvAPI)
|
||||
|
||||
@@ -72,7 +72,7 @@ using SplitNode = SplitContainer::Node;
|
||||
void WindowManager::showSettingsDialog(QWidget *parent,
|
||||
SettingsDialogPreference preference)
|
||||
{
|
||||
if (getApp()->getArgs().dontSaveSettings)
|
||||
if (this->appArgs.dontSaveSettings)
|
||||
{
|
||||
QMessageBox::critical(parent, "Chatterino - Editing Settings Forbidden",
|
||||
"Settings cannot be edited when running with\n"
|
||||
@@ -103,9 +103,10 @@ void WindowManager::showAccountSelectPopup(QPoint point)
|
||||
w->setFocus();
|
||||
}
|
||||
|
||||
WindowManager::WindowManager(const Paths &paths, Settings &settings,
|
||||
Theme &themes_, Fonts &fonts)
|
||||
WindowManager::WindowManager(const Args &appArgs_, const Paths &paths,
|
||||
Settings &settings, Theme &themes_, Fonts &fonts)
|
||||
: themes(themes_)
|
||||
, appArgs(appArgs_)
|
||||
, windowLayoutFilePath(combinePath(paths.settingsDirectory,
|
||||
WindowManager::WINDOW_LAYOUT_FILENAME))
|
||||
, updateWordTypeMaskListener([this] {
|
||||
@@ -411,16 +412,16 @@ void WindowManager::initialize()
|
||||
{
|
||||
WindowLayout windowLayout;
|
||||
|
||||
if (getApp()->getArgs().customChannelLayout)
|
||||
if (this->appArgs.customChannelLayout)
|
||||
{
|
||||
windowLayout = getApp()->getArgs().customChannelLayout.value();
|
||||
windowLayout = this->appArgs.customChannelLayout.value();
|
||||
}
|
||||
else
|
||||
{
|
||||
windowLayout = this->loadWindowLayoutFromFile();
|
||||
}
|
||||
|
||||
auto desired = getApp()->getArgs().activateChannel;
|
||||
auto desired = this->appArgs.activateChannel;
|
||||
if (desired)
|
||||
{
|
||||
windowLayout.activateOrAddChannel(desired->provider, desired->name);
|
||||
@@ -431,7 +432,7 @@ void WindowManager::initialize()
|
||||
this->applyWindowLayout(windowLayout);
|
||||
}
|
||||
|
||||
if (getApp()->getArgs().isFramelessEmbed)
|
||||
if (this->appArgs.isFramelessEmbed)
|
||||
{
|
||||
this->framelessEmbedWindow_.reset(new FramelessEmbedWindow);
|
||||
this->framelessEmbedWindow_->show();
|
||||
@@ -444,7 +445,7 @@ void WindowManager::initialize()
|
||||
this->mainWindow_->getNotebook().addPage(true);
|
||||
|
||||
// TODO: don't create main window if it's a frameless embed
|
||||
if (getApp()->getArgs().isFramelessEmbed)
|
||||
if (this->appArgs.isFramelessEmbed)
|
||||
{
|
||||
this->mainWindow_->hide();
|
||||
}
|
||||
@@ -453,7 +454,7 @@ void WindowManager::initialize()
|
||||
|
||||
void WindowManager::save()
|
||||
{
|
||||
if (getApp()->getArgs().dontSaveSettings)
|
||||
if (this->appArgs.dontSaveSettings)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -817,7 +818,7 @@ WindowLayout WindowManager::loadWindowLayoutFromFile() const
|
||||
|
||||
void WindowManager::applyWindowLayout(const WindowLayout &layout)
|
||||
{
|
||||
if (getApp()->getArgs().dontLoadMainWindow)
|
||||
if (this->appArgs.dontLoadMainWindow)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
namespace chatterino {
|
||||
|
||||
class Settings;
|
||||
class Args;
|
||||
class Paths;
|
||||
class Window;
|
||||
class ChannelView;
|
||||
@@ -38,12 +39,13 @@ class FramelessEmbedWindow;
|
||||
class WindowManager final
|
||||
{
|
||||
Theme &themes;
|
||||
const Args &appArgs;
|
||||
|
||||
public:
|
||||
static const QString WINDOW_LAYOUT_FILENAME;
|
||||
|
||||
explicit WindowManager(const Paths &paths, Settings &settings,
|
||||
Theme &themes_, Fonts &fonts);
|
||||
explicit WindowManager(const Args &appArgs_, const Paths &paths,
|
||||
Settings &settings, Theme &themes_, Fonts &fonts);
|
||||
~WindowManager();
|
||||
|
||||
WindowManager(const WindowManager &) = delete;
|
||||
|
||||
@@ -26,7 +26,8 @@ class MockApplication : public mock::BaseApplication
|
||||
{
|
||||
public:
|
||||
MockApplication()
|
||||
: windowManager(this->paths_, this->settings, this->theme, this->fonts)
|
||||
: windowManager(this->args, this->paths_, this->settings, this->theme,
|
||||
this->fonts)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ class MockApplication : public mock::BaseApplication
|
||||
{
|
||||
public:
|
||||
MockApplication()
|
||||
: windowManager(this->paths_, this->settings, this->theme, this->fonts)
|
||||
: windowManager(this->args, this->paths_, this->settings, this->theme,
|
||||
this->fonts)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ class MockApplication : public mock::BaseApplication
|
||||
{
|
||||
public:
|
||||
MockApplication()
|
||||
: windowManager(this->paths_, this->settings, this->theme, this->fonts)
|
||||
: windowManager(this->args, this->paths_, this->settings, this->theme,
|
||||
this->fonts)
|
||||
, commands(this->paths_)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user