diff --git a/src/fontmanager.cpp b/src/fontmanager.cpp index 71fba83d6..a35cbe178 100644 --- a/src/fontmanager.cpp +++ b/src/fontmanager.cpp @@ -11,9 +11,11 @@ FontManager::FontManager() { this->currentFontFamily.getValueChangedSignal().connect([this](const std::string &newValue) { this->currentFont.setFamily(newValue.c_str()); // + this->fontChanged.invoke(); }); this->currentFontSize.getValueChangedSignal().connect([this](const int &newValue) { this->currentFont.setSize(newValue); // + this->fontChanged.invoke(); }); } diff --git a/src/fontmanager.hpp b/src/fontmanager.hpp index 118086c6d..289514cba 100644 --- a/src/fontmanager.hpp +++ b/src/fontmanager.hpp @@ -3,11 +3,15 @@ #include #include #include +#include namespace chatterino { class FontManager { + FontManager(const FontManager &) = delete; + FontManager(FontManager &&) = delete; + public: enum Type : uint8_t { Small, @@ -42,6 +46,8 @@ public: pajlada::Settings::Setting currentFontFamily; pajlada::Settings::Setting currentFontSize; + pajlada::Signals::NoArgSignal fontChanged; + private: FontManager(); diff --git a/src/widgets/settingsdialog.cpp b/src/widgets/settingsdialog.cpp index 517bc3deb..fc517af0d 100644 --- a/src/widgets/settingsdialog.cpp +++ b/src/widgets/settingsdialog.cpp @@ -158,7 +158,7 @@ QVBoxLayout *SettingsDialog::createAccountsTab() QVBoxLayout *SettingsDialog::createAppearanceTab() { - SettingsManager &settings = SettingsManager::getInstance(); + auto &settings = SettingsManager::getInstance(); auto layout = this->createTabLayout(); { @@ -176,8 +176,9 @@ QVBoxLayout *SettingsDialog::createAppearanceTab() fontLayout->addWidget(fontFamilyLabel); fontLayout->addWidget(fontSizeLabel); + { - auto fontManager = FontManager::getInstance(); + auto &fontManager = FontManager::getInstance(); fontManager.currentFontFamily.getValueChangedSignal().connect( [fontFamilyLabel](const std::string &newValue) { @@ -191,11 +192,11 @@ QVBoxLayout *SettingsDialog::createAppearanceTab() } fontButton->connect(fontButton, &QPushButton::clicked, []() { - auto fontManager = FontManager::getInstance(); + auto &fontManager = FontManager::getInstance(); QFontDialog dialog(fontManager.getFont(FontManager::Medium)); dialog.connect(&dialog, &QFontDialog::fontSelected, [](const QFont &font) { - auto fontManager = FontManager::getInstance(); + auto &fontManager = FontManager::getInstance(); fontManager.currentFontFamily = font.family().toStdString(); fontManager.currentFontSize = font.pointSize(); });