mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
6baf045c4c
Fix #96
37 lines
829 B
C++
37 lines
829 B
C++
#pragma once
|
|
|
|
#include <QCompleter>
|
|
#include <QKeyEvent>
|
|
#include <QTextEdit>
|
|
#include <boost/signals2.hpp>
|
|
|
|
class ResizingTextEdit : public QTextEdit
|
|
{
|
|
public:
|
|
ResizingTextEdit();
|
|
|
|
QSize sizeHint() const override;
|
|
|
|
bool hasHeightForWidth() const override;
|
|
|
|
boost::signals2::signal<void(QKeyEvent *)> keyPressed;
|
|
|
|
void setCompleter(QCompleter *c);
|
|
QCompleter *getCompleter() const;
|
|
|
|
protected:
|
|
virtual int heightForWidth(int) const override;
|
|
virtual void keyPressEvent(QKeyEvent *event) override;
|
|
|
|
private:
|
|
QCompleter *completer = nullptr;
|
|
|
|
// hadSpace is set to true in case the "textUnderCursor" word was after a space
|
|
QString textUnderCursor(bool *hadSpace = nullptr) const;
|
|
|
|
bool nextCompletion = false;
|
|
|
|
private slots:
|
|
void insertCompletion(const QString &completion);
|
|
};
|