mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
703f3717e2
Co-authored-by: LosFarmosCTL <80157503+LosFarmosCTL@users.noreply.github.com> Co-authored-by: Paweł <zneix@zneix.eu> Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com> Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <QCompleter>
|
|
#include <QKeyEvent>
|
|
#include <QTextEdit>
|
|
#include <pajlada/signals/signal.hpp>
|
|
|
|
namespace chatterino {
|
|
|
|
class ResizingTextEdit : public QTextEdit
|
|
{
|
|
public:
|
|
ResizingTextEdit();
|
|
|
|
QSize sizeHint() const override;
|
|
|
|
bool hasHeightForWidth() const override;
|
|
bool isFirstWord() const;
|
|
|
|
pajlada::Signals::Signal<QKeyEvent *> keyPressed;
|
|
pajlada::Signals::NoArgSignal focused;
|
|
pajlada::Signals::NoArgSignal focusLost;
|
|
pajlada::Signals::Signal<const QMimeData *> imagePasted;
|
|
|
|
void setCompleter(QCompleter *c);
|
|
QCompleter *getCompleter() const;
|
|
|
|
protected:
|
|
int heightForWidth(int) const override;
|
|
void keyPressEvent(QKeyEvent *event) override;
|
|
|
|
void focusInEvent(QFocusEvent *event) override;
|
|
void focusOutEvent(QFocusEvent *event) override;
|
|
|
|
bool canInsertFromMimeData(const QMimeData *source) const override;
|
|
void insertFromMimeData(const QMimeData *source) override;
|
|
|
|
private:
|
|
// hadSpace is set to true in case the "textUnderCursor" word was after a
|
|
// space
|
|
QString textUnderCursor(bool *hadSpace = nullptr) const;
|
|
|
|
QCompleter *completer_ = nullptr;
|
|
bool completionInProgress_ = false;
|
|
|
|
bool eventFilter(QObject *widget, QEvent *event) override;
|
|
private slots:
|
|
void insertCompletion(const QString &completion);
|
|
};
|
|
|
|
} // namespace chatterino
|