Provide menu shown signal from InputField.
This commit is contained in:
parent
39d440f774
commit
079d966e45
2 changed files with 17 additions and 0 deletions
|
|
@ -1278,6 +1278,15 @@ void InputField::scrollTo(int top) {
|
||||||
_inner->verticalScrollBar()->setValue(top);
|
_inner->verticalScrollBar()->setValue(top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool InputField::menuShown() const {
|
||||||
|
return _contextMenu != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<bool> InputField::menuShownValue() const {
|
||||||
|
return _menuShownChanges.events_starting_with(menuShown());
|
||||||
|
}
|
||||||
|
|
||||||
bool InputField::viewportEventInner(QEvent *e) {
|
bool InputField::viewportEventInner(QEvent *e) {
|
||||||
if (e->type() == QEvent::TouchBegin
|
if (e->type() == QEvent::TouchBegin
|
||||||
|| e->type() == QEvent::TouchUpdate
|
|| e->type() == QEvent::TouchUpdate
|
||||||
|
|
@ -3634,6 +3643,10 @@ void InputField::contextMenuEventInner(QContextMenuEvent *e, QMenu *m) {
|
||||||
if (const auto menu = m ? m : _inner->createStandardContextMenu()) {
|
if (const auto menu = m ? m : _inner->createStandardContextMenu()) {
|
||||||
addMarkdownActions(menu, e);
|
addMarkdownActions(menu, e);
|
||||||
_contextMenu = base::make_unique_q<PopupMenu>(this, menu, _st.menu);
|
_contextMenu = base::make_unique_q<PopupMenu>(this, menu, _st.menu);
|
||||||
|
QObject::connect(_contextMenu.get(), &QObject::destroyed, [=] {
|
||||||
|
_menuShownChanges.fire(false);
|
||||||
|
});
|
||||||
|
_menuShownChanges.fire(true);
|
||||||
_contextMenu->popup(e->globalPos());
|
_contextMenu->popup(e->globalPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -312,6 +312,9 @@ public:
|
||||||
return _markdownTagApplies.events();
|
return _markdownTagApplies.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool menuShown() const;
|
||||||
|
[[nodiscard]] rpl::producer<bool> menuShownValue() const;
|
||||||
|
|
||||||
~InputField();
|
~InputField();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
|
|
@ -543,6 +546,7 @@ private:
|
||||||
|
|
||||||
bool _correcting = false;
|
bool _correcting = false;
|
||||||
MimeDataHook _mimeDataHook;
|
MimeDataHook _mimeDataHook;
|
||||||
|
rpl::event_stream<bool> _menuShownChanges;
|
||||||
base::unique_qptr<PopupMenu> _contextMenu;
|
base::unique_qptr<PopupMenu> _contextMenu;
|
||||||
|
|
||||||
QTextCharFormat _defaultCharFormat;
|
QTextCharFormat _defaultCharFormat;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue