mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
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?)
This commit is contained in:
parent
91dda9483b
commit
ad1694234d
2 changed files with 24 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -1,15 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include "fontmanager.hpp"
|
||||
|
||||
#include <QFont>
|
||||
#include <QCompleter>
|
||||
#include <QKeyEvent>
|
||||
#include <QTextEdit>
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue