mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Add simple fontChanged signal
Delete copy/move constructor of FontManager :kkona: Fix places that were using the copy constructor of the FontManager
This commit is contained in:
parent
37571ae613
commit
c08059c6a8
3 changed files with 13 additions and 4 deletions
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,15 @@
|
|||
#include <QFont>
|
||||
#include <QFontMetrics>
|
||||
#include <pajlada/settings/setting.hpp>
|
||||
#include <pajlada/signals/signal.hpp>
|
||||
|
||||
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<std::string> currentFontFamily;
|
||||
pajlada::Settings::Setting<int> currentFontSize;
|
||||
|
||||
pajlada::Signals::NoArgSignal fontChanged;
|
||||
|
||||
private:
|
||||
FontManager();
|
||||
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue