Perform initial refactoring work
Things that were once singletons are no longer singletons, but are instead stored in the "Application" singleton Some singletons still remain, and some renaming/renamespacing is left
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
#include "windowmanager.hpp"
|
||||
|
||||
#include "application.hpp"
|
||||
#include "debug/log.hpp"
|
||||
#include "providers/twitch/twitchserver.hpp"
|
||||
#include "singletons/fontmanager.hpp"
|
||||
@@ -18,12 +20,6 @@
|
||||
namespace chatterino {
|
||||
namespace singletons {
|
||||
|
||||
WindowManager &WindowManager::getInstance()
|
||||
{
|
||||
static WindowManager instance(ThemeManager::getInstance());
|
||||
return instance;
|
||||
}
|
||||
|
||||
void WindowManager::showSettingsDialog()
|
||||
{
|
||||
QTimer::singleShot(80, [] { widgets::SettingsDialog::showDialog(); });
|
||||
@@ -53,11 +49,9 @@ void WindowManager::showAccountSelectPopup(QPoint point)
|
||||
w->setFocus();
|
||||
}
|
||||
|
||||
WindowManager::WindowManager(ThemeManager &_themeManager)
|
||||
: themeManager(_themeManager)
|
||||
WindowManager::WindowManager()
|
||||
{
|
||||
qDebug() << "init WindowManager";
|
||||
_themeManager.repaintVisibleChatWidgets.connect([this] { this->repaintVisibleChatWidgets(); });
|
||||
}
|
||||
|
||||
void WindowManager::layoutVisibleChatWidgets(Channel *channel)
|
||||
@@ -102,7 +96,7 @@ widgets::Window &WindowManager::createWindow(widgets::Window::WindowType type)
|
||||
{
|
||||
util::assertInGuiThread();
|
||||
|
||||
auto *window = new widgets::Window(this->themeManager, type);
|
||||
auto *window = new widgets::Window(type);
|
||||
this->windows.push_back(window);
|
||||
window->show();
|
||||
|
||||
@@ -143,10 +137,14 @@ void WindowManager::initialize()
|
||||
{
|
||||
util::assertInGuiThread();
|
||||
|
||||
auto app = getApp();
|
||||
app->themes->repaintVisibleChatWidgets.connect(
|
||||
[this] { this->repaintVisibleChatWidgets(); });
|
||||
|
||||
assert(!this->initialized);
|
||||
|
||||
// load file
|
||||
QString settingsPath = PathManager::getInstance().settingsFolderPath + SETTINGS_FILENAME;
|
||||
QString settingsPath = app->paths->settingsFolderPath + SETTINGS_FILENAME;
|
||||
QFile file(settingsPath);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QByteArray data = file.readAll();
|
||||
@@ -230,6 +228,7 @@ void WindowManager::initialize()
|
||||
void WindowManager::save()
|
||||
{
|
||||
util::assertInGuiThread();
|
||||
auto app = getApp();
|
||||
|
||||
QJsonDocument document;
|
||||
|
||||
@@ -301,7 +300,7 @@ void WindowManager::save()
|
||||
document.setObject(obj);
|
||||
|
||||
// save file
|
||||
QString settingsPath = PathManager::getInstance().settingsFolderPath + SETTINGS_FILENAME;
|
||||
QString settingsPath = app->paths->settingsFolderPath + SETTINGS_FILENAME;
|
||||
QFile file(settingsPath);
|
||||
file.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||
file.write(document.toJson());
|
||||
|
||||
Reference in New Issue
Block a user