This commit is contained in:
fourtf
2018-06-26 13:24:55 +02:00
parent ec04f10895
commit c9722b9780
301 changed files with 0 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
#pragma once
#include <QCompleter>
#include <QKeyEvent>
#include <QTextEdit>
#include <pajlada/signals/signal.hpp>
class ResizingTextEdit : public QTextEdit
{
public:
ResizingTextEdit();
QSize sizeHint() const override;
bool hasHeightForWidth() const override;
pajlada::Signals::Signal<QKeyEvent *> keyPressed;
pajlada::Signals::NoArgSignal focused;
pajlada::Signals::NoArgSignal focusLost;
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;
private:
QCompleter *completer = nullptr;
bool completionInProgress = false;
// hadSpace is set to true in case the "textUnderCursor" word was after a space
QString textUnderCursor(bool *hadSpace = nullptr) const;
private slots:
void insertCompletion(const QString &completion);
};