From 573abe9f4008b973547e26473db278409c426342 Mon Sep 17 00:00:00 2001 From: fourtf Date: Sun, 24 Jun 2018 13:32:56 +0200 Subject: [PATCH] fixed #486 --- src/widgets/basewidget.hpp | 2 +- src/widgets/basewindow.cpp | 5 +++++ src/widgets/basewindow.hpp | 2 ++ src/widgets/label.cpp | 2 +- src/widgets/label.hpp | 4 ++++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/widgets/basewidget.hpp b/src/widgets/basewidget.hpp index f69676002..66017bac1 100644 --- a/src/widgets/basewidget.hpp +++ b/src/widgets/basewidget.hpp @@ -20,7 +20,7 @@ public: explicit BaseWidget(QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags()); virtual ~BaseWidget() override; - float getScale() const; + virtual float getScale() const; pajlada::Signals::Signal scaleChanged; QSize getScaleIndependantSize() const; diff --git a/src/widgets/basewindow.cpp b/src/widgets/basewindow.cpp index c53656ee1..d6e1500cc 100644 --- a/src/widgets/basewindow.cpp +++ b/src/widgets/basewindow.cpp @@ -65,6 +65,11 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags) CreateWindowShortcut(this, "CTRL+0", [] { getApp()->settings->uiScale.setValue(0); }); } +float BaseWindow::getScale() const +{ + return this->scale; +} + BaseWindow::Flags BaseWindow::getFlags() { return this->flags_; diff --git a/src/widgets/basewindow.hpp b/src/widgets/basewindow.hpp index 409d63dc8..37b98570f 100644 --- a/src/widgets/basewindow.hpp +++ b/src/widgets/basewindow.hpp @@ -42,6 +42,8 @@ public: void moveTo(QWidget *widget, QPoint point, bool offset = true); + virtual float getScale() const override; + Flags getFlags(); protected: diff --git a/src/widgets/label.cpp b/src/widgets/label.cpp index e8ef84161..0a0fcd133 100644 --- a/src/widgets/label.cpp +++ b/src/widgets/label.cpp @@ -20,7 +20,7 @@ Label::Label(BaseWidget *parent, QString text, FontStyle style) { auto app = getApp(); - app->fonts->fontChanged.connect([=] { this->updateSize(); }); + this->connections_.managedConnect(app->fonts->fontChanged, [this] { this->updateSize(); }); } const QString &Label::getText() const diff --git a/src/widgets/label.hpp b/src/widgets/label.hpp index a4dc0b886..9e4ef4b97 100644 --- a/src/widgets/label.hpp +++ b/src/widgets/label.hpp @@ -3,6 +3,8 @@ #include "singletons/fontmanager.hpp" #include "widgets/basewidget.hpp" +#include + namespace chatterino { namespace widgets { @@ -33,6 +35,8 @@ protected: virtual QSize minimumSizeHint() const override; private: + pajlada::Signals::SignalHolder connections_; + QString text_; FontStyle fontStyle_; QSize preferedSize_;