Replaced Qt signals in InputField with rpl.
This commit is contained in:
parent
7a245fee51
commit
6a7718ae96
2 changed files with 45 additions and 16 deletions
|
|
@ -1538,7 +1538,7 @@ bool InputField::heightAutoupdated() {
|
|||
|
||||
void InputField::checkContentHeight() {
|
||||
if (heightAutoupdated()) {
|
||||
resized();
|
||||
_heightChanges.fire({});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1812,13 +1812,13 @@ void InputField::focusInEventInner(QFocusEvent *e) {
|
|||
: (width() / 2);
|
||||
setFocused(true);
|
||||
_inner->QTextEdit::focusInEvent(e);
|
||||
focused();
|
||||
_focusedChanges.fire(true);
|
||||
}
|
||||
|
||||
void InputField::focusOutEventInner(QFocusEvent *e) {
|
||||
setFocused(false);
|
||||
_inner->QTextEdit::focusOutEvent(e);
|
||||
blurred();
|
||||
_focusedChanges.fire(false);
|
||||
}
|
||||
|
||||
void InputField::setFocused(bool focused) {
|
||||
|
|
@ -2401,7 +2401,7 @@ void InputField::handleContentsChanged() {
|
|||
if (tagsChanged || (_lastTextWithTags.text != currentText)) {
|
||||
_lastTextWithTags.text = currentText;
|
||||
const auto weak = MakeWeak(this);
|
||||
changed();
|
||||
_changes.fire({});
|
||||
if (!weak) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -2765,15 +2765,15 @@ void InputField::keyPressEventInner(QKeyEvent *e) {
|
|||
&& revertFormatReplace()) {
|
||||
e->accept();
|
||||
} else if (enter && enterSubmit) {
|
||||
submitted(e->modifiers());
|
||||
_submits.fire(e->modifiers());
|
||||
} else if (e->key() == Qt::Key_Escape) {
|
||||
e->ignore();
|
||||
cancelled();
|
||||
_cancelled.fire({});
|
||||
} else if (e->key() == Qt::Key_Tab || e->key() == Qt::Key_Backtab) {
|
||||
if (alt || ctrl) {
|
||||
e->ignore();
|
||||
} else if (_customTab) {
|
||||
tabbed();
|
||||
_tabbed.fire({});
|
||||
} else if (!focusNextPrevChild(e->key() == Qt::Key_Tab && !shift)) {
|
||||
e->ignore();
|
||||
}
|
||||
|
|
@ -3843,6 +3843,30 @@ void InputField::setErrorShown(bool error) {
|
|||
}
|
||||
}
|
||||
|
||||
rpl::producer<> InputField::heightChanges() const {
|
||||
return _heightChanges.events();
|
||||
}
|
||||
|
||||
rpl::producer<bool> InputField::focusedChanges() const {
|
||||
return _focusedChanges.events();
|
||||
}
|
||||
|
||||
rpl::producer<> InputField::tabbed() const {
|
||||
return _tabbed.events();
|
||||
}
|
||||
|
||||
rpl::producer<> InputField::cancelled() const {
|
||||
return _cancelled.events();
|
||||
}
|
||||
|
||||
rpl::producer<> InputField::changes() const {
|
||||
return _changes.events();
|
||||
}
|
||||
|
||||
rpl::producer<Qt::KeyboardModifiers> InputField::submits() const {
|
||||
return _submits.events();
|
||||
}
|
||||
|
||||
InputField::~InputField() = default;
|
||||
|
||||
} // namespace Ui
|
||||
|
|
|
|||
|
|
@ -315,6 +315,13 @@ public:
|
|||
[[nodiscard]] bool menuShown() const;
|
||||
[[nodiscard]] rpl::producer<bool> menuShownValue() const;
|
||||
|
||||
[[nodiscard]] rpl::producer<> heightChanges() const;
|
||||
[[nodiscard]] rpl::producer<bool> focusedChanges() const;
|
||||
[[nodiscard]] rpl::producer<> tabbed() const;
|
||||
[[nodiscard]] rpl::producer<> cancelled() const;
|
||||
[[nodiscard]] rpl::producer<> changes() const;
|
||||
[[nodiscard]] rpl::producer<Qt::KeyboardModifiers> submits() const;
|
||||
|
||||
~InputField();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
|
@ -328,15 +335,6 @@ private Q_SLOTS:
|
|||
|
||||
void onFocusInner();
|
||||
|
||||
Q_SIGNALS:
|
||||
void changed();
|
||||
void submitted(Qt::KeyboardModifiers);
|
||||
void cancelled();
|
||||
void tabbed();
|
||||
void focused();
|
||||
void blurred();
|
||||
void resized();
|
||||
|
||||
protected:
|
||||
void startPlaceholderAnimation();
|
||||
void startBorderAnimation();
|
||||
|
|
@ -561,6 +559,13 @@ private:
|
|||
rpl::event_stream<DocumentChangeInfo> _documentContentsChanges;
|
||||
rpl::event_stream<MarkdownTag> _markdownTagApplies;
|
||||
|
||||
rpl::event_stream<bool> _focusedChanges;
|
||||
rpl::event_stream<> _heightChanges;
|
||||
rpl::event_stream<> _tabbed;
|
||||
rpl::event_stream<> _cancelled;
|
||||
rpl::event_stream<> _changes;
|
||||
rpl::event_stream<Qt::KeyboardModifiers> _submits;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Ui
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue