mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
f2b2e3142f
This commit implements a simpler fix for the problem described in #1209. The setting's signal is connected to a reset of `completionInProgress_` so that the completion model is updated on the next word already. This commit also removes the older approach tackling this issue.
49 lines
1.2 KiB
C++
49 lines
1.2 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;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
private slots:
|
|
void insertCompletion(const QString &completion);
|
|
};
|
|
|
|
} // namespace chatterino
|