Fix unnecessary clears of split input selection (#4197)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
kornes 2022-11-27 19:39:53 +00:00 committed by GitHub
parent a16342fd82
commit cc661d5f42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 8 deletions

View file

@ -10,6 +10,7 @@
- Bugfix: Fixed popup windows not appearing/minimizing correctly on the Windows taskbar. (#4181)
- Bugfix: Fixed white border appearing around maximized window on Windows. (#4190)
- Bugfix: Fixed window scaling being applied too many times on startup, causing windows like Settings to be slow. (#4193)
- Bugfix: Fixed input text cursor flickering when selecting text in a split. (#4197)
## 2.4.0-beta

View file

@ -116,7 +116,7 @@ Split::Split(QWidget *parent)
this->updateInputPlaceholder();
this->view_->selectionChanged.connect([this]() {
if (view_->hasSelection())
if (this->input_->hasSelection())
{
this->input_->clearSelection();
}

View file

@ -796,14 +796,16 @@ void SplitInput::insertCompletionText(const QString &input_)
}
}
void SplitInput::clearSelection()
bool SplitInput::hasSelection() const
{
QTextCursor c = this->ui_.textEdit->textCursor();
return this->ui_.textEdit->textCursor().hasSelection();
}
c.setPosition(c.position());
c.setPosition(c.position(), QTextCursor::KeepAnchor);
this->ui_.textEdit->setTextCursor(c);
void SplitInput::clearSelection() const
{
auto cursor = this->ui_.textEdit->textCursor();
cursor.clearSelection();
this->ui_.textEdit->setTextCursor(cursor);
}
bool SplitInput::isEditFirstWord() const

View file

@ -45,7 +45,9 @@ public:
SplitInput(QWidget *parent, Split *_chatWidget,
bool enableInlineReplying = true);
void clearSelection();
bool hasSelection() const;
void clearSelection() const;
bool isEditFirstWord() const;
QString getInputText() const;
void insertText(const QString &text);