mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added ability to pass SendMenuType to TabbedSelector.
This commit is contained in:
parent
7db9843543
commit
43056107fd
7 changed files with 36 additions and 10 deletions
|
@ -347,7 +347,9 @@ void GifsListWidget::mousePressEvent(QMouseEvent *e) {
|
||||||
_previewTimer.callOnce(QApplication::startDragTime());
|
_previewTimer.callOnce(QApplication::startDragTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GifsListWidget::fillContextMenu(not_null<Ui::PopupMenu*> menu) {
|
void GifsListWidget::fillContextMenu(
|
||||||
|
not_null<Ui::PopupMenu*> menu,
|
||||||
|
SendMenuType type) {
|
||||||
if (_selected < 0 || _pressed >= 0) {
|
if (_selected < 0 || _pressed >= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -362,13 +364,13 @@ void GifsListWidget::fillContextMenu(not_null<Ui::PopupMenu*> menu) {
|
||||||
Ui::show(
|
Ui::show(
|
||||||
HistoryView::PrepareScheduleBox(
|
HistoryView::PrepareScheduleBox(
|
||||||
this,
|
this,
|
||||||
SendMenuType::Scheduled,
|
type,
|
||||||
[=](Api::SendOptions options) { send(options); }),
|
[=](Api::SendOptions options) { send(options); }),
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
};
|
};
|
||||||
FillSendMenu(
|
FillSendMenu(
|
||||||
menu,
|
menu,
|
||||||
[] { return SendMenuType::Scheduled; },
|
[&] { return type; },
|
||||||
silent,
|
silent,
|
||||||
schedule);
|
schedule);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@ namespace Window {
|
||||||
class SessionController;
|
class SessionController;
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
||||||
|
enum class SendMenuType;
|
||||||
|
|
||||||
namespace ChatHelpers {
|
namespace ChatHelpers {
|
||||||
|
|
||||||
class GifsListWidget
|
class GifsListWidget
|
||||||
|
@ -71,7 +73,9 @@ public:
|
||||||
void cancelled();
|
void cancelled();
|
||||||
rpl::producer<> cancelRequests() const;
|
rpl::producer<> cancelRequests() const;
|
||||||
|
|
||||||
void fillContextMenu(not_null<Ui::PopupMenu*> menu) override;
|
void fillContextMenu(
|
||||||
|
not_null<Ui::PopupMenu*> menu,
|
||||||
|
SendMenuType type) override;
|
||||||
|
|
||||||
~GifsListWidget();
|
~GifsListWidget();
|
||||||
|
|
||||||
|
|
|
@ -2046,7 +2046,9 @@ QPoint StickersListWidget::buttonRippleTopLeft(int section) const {
|
||||||
return myrtlrect(removeButtonRect(section)).topLeft() + st::stickerPanRemoveSet.rippleAreaPosition;
|
return myrtlrect(removeButtonRect(section)).topLeft() + st::stickerPanRemoveSet.rippleAreaPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListWidget::fillContextMenu(not_null<Ui::PopupMenu*> menu) {
|
void StickersListWidget::fillContextMenu(
|
||||||
|
not_null<Ui::PopupMenu*> menu,
|
||||||
|
SendMenuType type) {
|
||||||
auto selected = _selected;
|
auto selected = _selected;
|
||||||
auto &sets = shownSets();
|
auto &sets = shownSets();
|
||||||
if (!selected || _pressed) {
|
if (!selected || _pressed) {
|
||||||
|
@ -2068,13 +2070,13 @@ void StickersListWidget::fillContextMenu(not_null<Ui::PopupMenu*> menu) {
|
||||||
checkHideWithBox(Ui::show(
|
checkHideWithBox(Ui::show(
|
||||||
HistoryView::PrepareScheduleBox(
|
HistoryView::PrepareScheduleBox(
|
||||||
this,
|
this,
|
||||||
SendMenuType::Scheduled,
|
type,
|
||||||
[=](Api::SendOptions options) { send(options); }),
|
[=](Api::SendOptions options) { send(options); }),
|
||||||
Ui::LayerOption::KeepOther).data());
|
Ui::LayerOption::KeepOther).data());
|
||||||
};
|
};
|
||||||
FillSendMenu(
|
FillSendMenu(
|
||||||
menu,
|
menu,
|
||||||
[] { return SendMenuType::Scheduled; },
|
[&] { return type; },
|
||||||
silent,
|
silent,
|
||||||
schedule);
|
schedule);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,9 @@ public:
|
||||||
|
|
||||||
std::shared_ptr<Lottie::FrameRenderer> getLottieRenderer();
|
std::shared_ptr<Lottie::FrameRenderer> getLottieRenderer();
|
||||||
|
|
||||||
void fillContextMenu(not_null<Ui::PopupMenu*> menu) override;
|
void fillContextMenu(
|
||||||
|
not_null<Ui::PopupMenu*> menu,
|
||||||
|
SendMenuType type) override;
|
||||||
|
|
||||||
~StickersListWidget();
|
~StickersListWidget();
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "chat_helpers/tabbed_selector.h"
|
#include "chat_helpers/tabbed_selector.h"
|
||||||
|
|
||||||
|
#include "chat_helpers/message_field.h"
|
||||||
#include "chat_helpers/emoji_list_widget.h"
|
#include "chat_helpers/emoji_list_widget.h"
|
||||||
#include "chat_helpers/stickers_list_widget.h"
|
#include "chat_helpers/stickers_list_widget.h"
|
||||||
#include "chat_helpers/gifs_list_widget.h"
|
#include "chat_helpers/gifs_list_widget.h"
|
||||||
|
@ -876,7 +877,10 @@ void TabbedSelector::scrollToY(int y) {
|
||||||
|
|
||||||
void TabbedSelector::contextMenuEvent(QContextMenuEvent *e) {
|
void TabbedSelector::contextMenuEvent(QContextMenuEvent *e) {
|
||||||
_menu = base::make_unique_q<Ui::PopupMenu>(this);
|
_menu = base::make_unique_q<Ui::PopupMenu>(this);
|
||||||
currentTab()->widget()->fillContextMenu(_menu);
|
const auto type = _sendMenuType
|
||||||
|
? _sendMenuType()
|
||||||
|
: SendMenuType::Disabled;
|
||||||
|
currentTab()->widget()->fillContextMenu(_menu, type);
|
||||||
|
|
||||||
if (!_menu->actions().empty()) {
|
if (!_menu->actions().empty()) {
|
||||||
_menu->popup(QCursor::pos());
|
_menu->popup(QCursor::pos());
|
||||||
|
|
|
@ -34,6 +34,8 @@ namespace Window {
|
||||||
class SessionController;
|
class SessionController;
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
||||||
|
enum class SendMenuType;
|
||||||
|
|
||||||
namespace ChatHelpers {
|
namespace ChatHelpers {
|
||||||
|
|
||||||
enum class SelectorTab {
|
enum class SelectorTab {
|
||||||
|
@ -104,6 +106,10 @@ public:
|
||||||
_beforeHidingCallback = std::move(callback);
|
_beforeHidingCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setSendMenuType(Fn<SendMenuType()> callback) {
|
||||||
|
_sendMenuType = std::move(callback);
|
||||||
|
}
|
||||||
|
|
||||||
// Float player interface.
|
// Float player interface.
|
||||||
bool floatPlayerHandleWheelEvent(QEvent *e);
|
bool floatPlayerHandleWheelEvent(QEvent *e);
|
||||||
QRect floatPlayerAvailableRect() const;
|
QRect floatPlayerAvailableRect() const;
|
||||||
|
@ -219,6 +225,8 @@ private:
|
||||||
Fn<void(SelectorTab)> _afterShownCallback;
|
Fn<void(SelectorTab)> _afterShownCallback;
|
||||||
Fn<void(SelectorTab)> _beforeHidingCallback;
|
Fn<void(SelectorTab)> _beforeHidingCallback;
|
||||||
|
|
||||||
|
Fn<SendMenuType()> _sendMenuType;
|
||||||
|
|
||||||
rpl::event_stream<> _showRequests;
|
rpl::event_stream<> _showRequests;
|
||||||
rpl::event_stream<> _slideFinished;
|
rpl::event_stream<> _slideFinished;
|
||||||
|
|
||||||
|
@ -251,7 +259,9 @@ public:
|
||||||
}
|
}
|
||||||
virtual void beforeHiding() {
|
virtual void beforeHiding() {
|
||||||
}
|
}
|
||||||
virtual void fillContextMenu(not_null<Ui::PopupMenu*> menu) {
|
virtual void fillContextMenu(
|
||||||
|
not_null<Ui::PopupMenu*> menu,
|
||||||
|
SendMenuType type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<int> scrollToRequests() const;
|
rpl::producer<int> scrollToRequests() const;
|
||||||
|
|
|
@ -835,6 +835,8 @@ void HistoryWidget::initTabbedSelector() {
|
||||||
}) | rpl::start_with_next([=](TabbedSelector::InlineChosen data) {
|
}) | rpl::start_with_next([=](TabbedSelector::InlineChosen data) {
|
||||||
sendInlineResult(data.result, data.bot);
|
sendInlineResult(data.result, data.bot);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
selector->setSendMenuType([=] { return sendMenuType(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::supportInitAutocomplete() {
|
void HistoryWidget::supportInitAutocomplete() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue