mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Fixed filling context menu in TabbedPanel between sections.
Fixed #10082.
This commit is contained in:
parent
8ae1b10b91
commit
a030911ad5
4 changed files with 26 additions and 21 deletions
|
@ -877,11 +877,8 @@ void TabbedSelector::scrollToY(int y) {
|
|||
}
|
||||
}
|
||||
|
||||
void TabbedSelector::contextMenuEvent(QContextMenuEvent *e) {
|
||||
void TabbedSelector::showMenuWithType(SendMenu::Type type) {
|
||||
_menu = base::make_unique_q<Ui::PopupMenu>(this);
|
||||
const auto type = _sendMenuType
|
||||
? _sendMenuType()
|
||||
: SendMenu::Type::Disabled;
|
||||
currentTab()->widget()->fillContextMenu(_menu, type);
|
||||
|
||||
if (!_menu->actions().empty()) {
|
||||
|
@ -889,6 +886,13 @@ void TabbedSelector::contextMenuEvent(QContextMenuEvent *e) {
|
|||
}
|
||||
}
|
||||
|
||||
rpl::producer<> TabbedSelector::contextMenuRequested() const {
|
||||
return events(
|
||||
) | rpl::filter([=](not_null<QEvent*> e) {
|
||||
return e->type() == QEvent::ContextMenu;
|
||||
}) | rpl::to_empty;
|
||||
}
|
||||
|
||||
TabbedSelector::Inner::Inner(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller)
|
||||
|
|
|
@ -82,6 +82,7 @@ public:
|
|||
rpl::producer<> cancelled() const;
|
||||
rpl::producer<> checkForHide() const;
|
||||
rpl::producer<> slideFinished() const;
|
||||
rpl::producer<> contextMenuRequested() const;
|
||||
|
||||
void setRoundRadius(int radius);
|
||||
void refreshStickers();
|
||||
|
@ -109,9 +110,7 @@ public:
|
|||
_beforeHidingCallback = std::move(callback);
|
||||
}
|
||||
|
||||
void setSendMenuType(Fn<SendMenu::Type()> &&callback) {
|
||||
_sendMenuType = std::move(callback);
|
||||
}
|
||||
void showMenuWithType(SendMenu::Type type);
|
||||
|
||||
// Float player interface.
|
||||
bool floatPlayerHandleWheelEvent(QEvent *e);
|
||||
|
@ -127,7 +126,6 @@ public:
|
|||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||
|
||||
private:
|
||||
class Tab {
|
||||
|
@ -228,8 +226,6 @@ private:
|
|||
Fn<void(SelectorTab)> _afterShownCallback;
|
||||
Fn<void(SelectorTab)> _beforeHidingCallback;
|
||||
|
||||
Fn<SendMenu::Type()> _sendMenuType;
|
||||
|
||||
rpl::event_stream<> _showRequests;
|
||||
rpl::event_stream<> _slideFinished;
|
||||
|
||||
|
|
|
@ -846,6 +846,11 @@ void HistoryWidget::initTabbedSelector() {
|
|||
return base::EventFilterResult::Continue;
|
||||
});
|
||||
|
||||
auto filter = rpl::filter([=] {
|
||||
return !isHidden();
|
||||
});
|
||||
using Selector = TabbedSelector;
|
||||
|
||||
selector->emojiChosen(
|
||||
) | rpl::filter([=] {
|
||||
return !isHidden() && !_field->isHidden();
|
||||
|
@ -854,27 +859,24 @@ void HistoryWidget::initTabbedSelector() {
|
|||
}, lifetime());
|
||||
|
||||
selector->fileChosen(
|
||||
) | rpl::filter([=] {
|
||||
return !isHidden();
|
||||
}) | rpl::start_with_next([=](TabbedSelector::FileChosen data) {
|
||||
) | filter | rpl::start_with_next([=](Selector::FileChosen data) {
|
||||
sendExistingDocument(data.document, data.options);
|
||||
}, lifetime());
|
||||
|
||||
selector->photoChosen(
|
||||
) | rpl::filter([=] {
|
||||
return !isHidden();
|
||||
}) | rpl::start_with_next([=](TabbedSelector::PhotoChosen data) {
|
||||
) | filter | rpl::start_with_next([=](Selector::PhotoChosen data) {
|
||||
sendExistingPhoto(data.photo, data.options);
|
||||
}, lifetime());
|
||||
|
||||
selector->inlineResultChosen(
|
||||
) | rpl::filter([=] {
|
||||
return !isHidden();
|
||||
}) | rpl::start_with_next([=](TabbedSelector::InlineChosen data) {
|
||||
) | filter | rpl::start_with_next([=](Selector::InlineChosen data) {
|
||||
sendInlineResult(data);
|
||||
}, lifetime());
|
||||
|
||||
selector->setSendMenuType([=] { return sendMenuType(); });
|
||||
selector->contextMenuRequested(
|
||||
) | filter | rpl::start_with_next([=] {
|
||||
selector->showMenuWithType(sendMenuType());
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void HistoryWidget::supportInitAutocomplete() {
|
||||
|
|
|
@ -1410,7 +1410,10 @@ void ComposeControls::initTabbedSelector() {
|
|||
selector->inlineResultChosen(
|
||||
) | rpl::start_to_stream(_inlineResultChosen, wrap->lifetime());
|
||||
|
||||
selector->setSendMenuType([=] { return sendMenuType(); });
|
||||
selector->contextMenuRequested(
|
||||
) | rpl::start_with_next([=] {
|
||||
selector->showMenuWithType(sendMenuType());
|
||||
}, wrap->lifetime());
|
||||
}
|
||||
|
||||
void ComposeControls::initSendButton() {
|
||||
|
|
Loading…
Add table
Reference in a new issue