mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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);
|
_menu = base::make_unique_q<Ui::PopupMenu>(this);
|
||||||
const auto type = _sendMenuType
|
|
||||||
? _sendMenuType()
|
|
||||||
: SendMenu::Type::Disabled;
|
|
||||||
currentTab()->widget()->fillContextMenu(_menu, type);
|
currentTab()->widget()->fillContextMenu(_menu, type);
|
||||||
|
|
||||||
if (!_menu->actions().empty()) {
|
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(
|
TabbedSelector::Inner::Inner(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<Window::SessionController*> controller)
|
not_null<Window::SessionController*> controller)
|
||||||
|
|
|
@ -82,6 +82,7 @@ public:
|
||||||
rpl::producer<> cancelled() const;
|
rpl::producer<> cancelled() const;
|
||||||
rpl::producer<> checkForHide() const;
|
rpl::producer<> checkForHide() const;
|
||||||
rpl::producer<> slideFinished() const;
|
rpl::producer<> slideFinished() const;
|
||||||
|
rpl::producer<> contextMenuRequested() const;
|
||||||
|
|
||||||
void setRoundRadius(int radius);
|
void setRoundRadius(int radius);
|
||||||
void refreshStickers();
|
void refreshStickers();
|
||||||
|
@ -109,9 +110,7 @@ public:
|
||||||
_beforeHidingCallback = std::move(callback);
|
_beforeHidingCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSendMenuType(Fn<SendMenu::Type()> &&callback) {
|
void showMenuWithType(SendMenu::Type type);
|
||||||
_sendMenuType = std::move(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float player interface.
|
// Float player interface.
|
||||||
bool floatPlayerHandleWheelEvent(QEvent *e);
|
bool floatPlayerHandleWheelEvent(QEvent *e);
|
||||||
|
@ -127,7 +126,6 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
void contextMenuEvent(QContextMenuEvent *e) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Tab {
|
class Tab {
|
||||||
|
@ -228,8 +226,6 @@ private:
|
||||||
Fn<void(SelectorTab)> _afterShownCallback;
|
Fn<void(SelectorTab)> _afterShownCallback;
|
||||||
Fn<void(SelectorTab)> _beforeHidingCallback;
|
Fn<void(SelectorTab)> _beforeHidingCallback;
|
||||||
|
|
||||||
Fn<SendMenu::Type()> _sendMenuType;
|
|
||||||
|
|
||||||
rpl::event_stream<> _showRequests;
|
rpl::event_stream<> _showRequests;
|
||||||
rpl::event_stream<> _slideFinished;
|
rpl::event_stream<> _slideFinished;
|
||||||
|
|
||||||
|
|
|
@ -846,6 +846,11 @@ void HistoryWidget::initTabbedSelector() {
|
||||||
return base::EventFilterResult::Continue;
|
return base::EventFilterResult::Continue;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
auto filter = rpl::filter([=] {
|
||||||
|
return !isHidden();
|
||||||
|
});
|
||||||
|
using Selector = TabbedSelector;
|
||||||
|
|
||||||
selector->emojiChosen(
|
selector->emojiChosen(
|
||||||
) | rpl::filter([=] {
|
) | rpl::filter([=] {
|
||||||
return !isHidden() && !_field->isHidden();
|
return !isHidden() && !_field->isHidden();
|
||||||
|
@ -854,27 +859,24 @@ void HistoryWidget::initTabbedSelector() {
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
selector->fileChosen(
|
selector->fileChosen(
|
||||||
) | rpl::filter([=] {
|
) | filter | rpl::start_with_next([=](Selector::FileChosen data) {
|
||||||
return !isHidden();
|
|
||||||
}) | rpl::start_with_next([=](TabbedSelector::FileChosen data) {
|
|
||||||
sendExistingDocument(data.document, data.options);
|
sendExistingDocument(data.document, data.options);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
selector->photoChosen(
|
selector->photoChosen(
|
||||||
) | rpl::filter([=] {
|
) | filter | rpl::start_with_next([=](Selector::PhotoChosen data) {
|
||||||
return !isHidden();
|
|
||||||
}) | rpl::start_with_next([=](TabbedSelector::PhotoChosen data) {
|
|
||||||
sendExistingPhoto(data.photo, data.options);
|
sendExistingPhoto(data.photo, data.options);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
selector->inlineResultChosen(
|
selector->inlineResultChosen(
|
||||||
) | rpl::filter([=] {
|
) | filter | rpl::start_with_next([=](Selector::InlineChosen data) {
|
||||||
return !isHidden();
|
|
||||||
}) | rpl::start_with_next([=](TabbedSelector::InlineChosen data) {
|
|
||||||
sendInlineResult(data);
|
sendInlineResult(data);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
selector->setSendMenuType([=] { return sendMenuType(); });
|
selector->contextMenuRequested(
|
||||||
|
) | filter | rpl::start_with_next([=] {
|
||||||
|
selector->showMenuWithType(sendMenuType());
|
||||||
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::supportInitAutocomplete() {
|
void HistoryWidget::supportInitAutocomplete() {
|
||||||
|
|
|
@ -1410,7 +1410,10 @@ void ComposeControls::initTabbedSelector() {
|
||||||
selector->inlineResultChosen(
|
selector->inlineResultChosen(
|
||||||
) | rpl::start_to_stream(_inlineResultChosen, wrap->lifetime());
|
) | 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() {
|
void ComposeControls::initSendButton() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue