From ad1694234d56690b8f4b0ef7d6f503a456275072 Mon Sep 17 00:00:00 2001 From: CLouDY Date: Tue, 29 Aug 2017 18:57:53 +0100 Subject: [PATCH] Moved font logic into ResizingTextEdit, added namespaces Couldn't use FontManager without including the namespaces (shouldn't they have been there in the first place?) --- src/widgets/resizingtextedit.cpp | 11 +++++++++++ src/widgets/resizingtextedit.hpp | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/widgets/resizingtextedit.cpp b/src/widgets/resizingtextedit.cpp index c4d2718f4..b08c57d9a 100644 --- a/src/widgets/resizingtextedit.cpp +++ b/src/widgets/resizingtextedit.cpp @@ -1,5 +1,8 @@ #include "widgets/resizingtextedit.hpp" +namespace chatterino { +namespace widgets { + ResizingTextEdit::ResizingTextEdit() { auto sizePolicy = this->sizePolicy(); @@ -30,6 +33,11 @@ int ResizingTextEdit::heightForWidth(int) const return margins.top() + document()->size().height() + margins.bottom() + 5; } +QFont &ResizingTextEdit::getFont() const +{ + return FontManager::getInstance().getFont(_font); +} + QString ResizingTextEdit::textUnderCursor(bool *hadSpace) const { auto currentText = this->toPlainText(); @@ -161,3 +169,6 @@ QCompleter *ResizingTextEdit::getCompleter() const { return this->completer; } + +} // namespace widgets +} // namespace chatterino diff --git a/src/widgets/resizingtextedit.hpp b/src/widgets/resizingtextedit.hpp index 59098b4ca..42847e50f 100644 --- a/src/widgets/resizingtextedit.hpp +++ b/src/widgets/resizingtextedit.hpp @@ -1,15 +1,23 @@ #pragma once +#include "fontmanager.hpp" + +#include #include #include #include #include +namespace chatterino { +namespace widgets { + class ResizingTextEdit : public QTextEdit { public: ResizingTextEdit(); + QFont &getFont() const; + QSize sizeHint() const override; bool hasHeightForWidth() const override; @@ -26,6 +34,8 @@ protected: private: QCompleter *completer = nullptr; + FontManager::Type _font = FontManager::Small; + // hadSpace is set to true in case the "textUnderCursor" word was after a space QString textUnderCursor(bool *hadSpace = nullptr) const; @@ -34,3 +44,6 @@ private: private slots: void insertCompletion(const QString &completion); }; + +} // namespace widgets +} // namespace chatterino