mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Fix special userpic menu in topics.
This commit is contained in:
parent
7f2c98f17a
commit
efe99b3f62
7 changed files with 79 additions and 1 deletions
|
@ -3383,6 +3383,10 @@ Fn<void()> ComposeControls::restoreTextCallback(
|
|||
});
|
||||
}
|
||||
|
||||
Ui::InputField *ComposeControls::fieldForMention() const {
|
||||
return _writeRestriction.current() ? nullptr : _field.get();
|
||||
}
|
||||
|
||||
TextWithEntities ComposeControls::prepareTextForEditMsg() const {
|
||||
if (!_history) {
|
||||
return {};
|
||||
|
|
|
@ -249,6 +249,8 @@ public:
|
|||
|
||||
Fn<void()> restoreTextCallback(const QString &insertTextOnCancel) const;
|
||||
|
||||
[[nodiscard]] Ui::InputField *fieldForMention() const;
|
||||
|
||||
private:
|
||||
enum class TextUpdateEvent {
|
||||
SaveDraft = (1 << 0),
|
||||
|
|
|
@ -161,6 +161,8 @@ private:
|
|||
bool listShowReactPremiumError(
|
||||
not_null<HistoryItem*> item,
|
||||
const Data::ReactionId &id) override;
|
||||
base::unique_qptr<Ui::PopupMenu> listFillSenderUserpicMenu(
|
||||
PeerId userpicPeerId) override;
|
||||
void listWindowSetInnerFocus() override;
|
||||
bool listAllowsDragForward() override;
|
||||
void listLaunchDrag(
|
||||
|
@ -828,6 +830,11 @@ bool Item::listShowReactPremiumError(
|
|||
return false;
|
||||
}
|
||||
|
||||
base::unique_qptr<Ui::PopupMenu> Item::listFillSenderUserpicMenu(
|
||||
PeerId userpicPeerId) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Item::listWindowSetInnerFocus() {
|
||||
}
|
||||
|
||||
|
|
|
@ -30,9 +30,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "chat_helpers/message_field.h"
|
||||
#include "mainwindow.h"
|
||||
#include "mainwidget.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "core/application.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "core/phone_click_handler.h"
|
||||
#include "apiwrap.h"
|
||||
#include "api/api_who_reacted.h"
|
||||
#include "api/api_views.h"
|
||||
|
@ -171,6 +172,11 @@ bool WindowListDelegate::listShowReactPremiumError(
|
|||
return Window::ShowReactPremiumError(_window, item, id);
|
||||
}
|
||||
|
||||
auto WindowListDelegate::listFillSenderUserpicMenu(PeerId userpicPeerId)
|
||||
-> base::unique_qptr<Ui::PopupMenu> {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WindowListDelegate::listWindowSetInnerFocus() {
|
||||
_window->widget()->setInnerFocus();
|
||||
}
|
||||
|
@ -2794,6 +2800,12 @@ void ListWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
? _overElement->data().get()
|
||||
: nullptr;
|
||||
const auto clickedReaction = Reactions::ReactionIdOfLink(link);
|
||||
const auto linkPhoneNumber = link
|
||||
? link->property(kPhoneNumberLinkProperty).toString()
|
||||
: QString();
|
||||
const auto linkUserpicPeerId = (link && _overSenderUserpic)
|
||||
? PeerId(link->property(kPeerLinkPeerIdProperty).toULongLong())
|
||||
: PeerId();
|
||||
_whoReactedMenuLifetime.destroy();
|
||||
if (!clickedReaction.empty()
|
||||
&& overItem
|
||||
|
@ -2808,6 +2820,19 @@ void ListWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
_whoReactedMenuLifetime);
|
||||
e->accept();
|
||||
return;
|
||||
} else if (!linkPhoneNumber.isEmpty()) {
|
||||
PhoneClickHandler(&session(), linkPhoneNumber).onClick(
|
||||
prepareClickContext(
|
||||
Qt::LeftButton,
|
||||
_overItemExact ? _overItemExact->fullId() : FullMsgId()));
|
||||
return;
|
||||
} else if (linkUserpicPeerId) {
|
||||
_menu = _delegate->listFillSenderUserpicMenu(linkUserpicPeerId);
|
||||
if (_menu) {
|
||||
_menu->popup(e->globalPos());
|
||||
e->accept();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto request = ContextMenuRequest(controller());
|
||||
|
@ -3568,6 +3593,15 @@ ClickHandlerContext ListWidget::prepareClickHandlerContext(FullMsgId id) {
|
|||
};
|
||||
}
|
||||
|
||||
ClickContext ListWidget::prepareClickContext(
|
||||
Qt::MouseButton button,
|
||||
FullMsgId itemId) {
|
||||
return {
|
||||
button,
|
||||
QVariant::fromValue(prepareClickHandlerContext(itemId)),
|
||||
};
|
||||
}
|
||||
|
||||
int ListWidget::SelectionViewOffset(
|
||||
not_null<const ListWidget*> inner,
|
||||
not_null<const Element*> view) {
|
||||
|
@ -3629,6 +3663,7 @@ void ListWidget::mouseActionUpdate() {
|
|||
auto inTextSelection = (_overState.pointState != PointState::Outside)
|
||||
&& (_overState.itemId == _pressState.itemId)
|
||||
&& hasSelectedText();
|
||||
auto dragStateUserpic = false;
|
||||
const auto overReaction = reactionView && reactionState.link;
|
||||
if (overReaction) {
|
||||
dragState = reactionState;
|
||||
|
@ -3727,6 +3762,7 @@ void ListWidget::mouseActionUpdate() {
|
|||
// stop enumeration if we've found a userpic under the cursor
|
||||
if (point.y() >= userpicTop && point.y() < userpicTop + st::msgPhotoSize) {
|
||||
dragState = TextState(nullptr, view->fromPhotoLink());
|
||||
dragStateUserpic = true;
|
||||
_overItemExact = nullptr;
|
||||
lnkhost = view;
|
||||
return false;
|
||||
|
@ -3738,6 +3774,7 @@ void ListWidget::mouseActionUpdate() {
|
|||
}
|
||||
}
|
||||
const auto lnkChanged = ClickHandler::setActive(dragState.link, lnkhost);
|
||||
_overSenderUserpic = dragStateUserpic;
|
||||
if (lnkChanged || dragState.cursor != _mouseCursorState) {
|
||||
Ui::Tooltip::Hide();
|
||||
}
|
||||
|
|
|
@ -185,6 +185,8 @@ public:
|
|||
virtual bool listShowReactPremiumError(
|
||||
not_null<HistoryItem*> item,
|
||||
const Data::ReactionId &id) = 0;
|
||||
virtual base::unique_qptr<Ui::PopupMenu> listFillSenderUserpicMenu(
|
||||
PeerId userpicPeerId) = 0;
|
||||
virtual void listWindowSetInnerFocus() = 0;
|
||||
virtual bool listAllowsDragForward() = 0;
|
||||
virtual void listLaunchDrag(
|
||||
|
@ -218,6 +220,8 @@ public:
|
|||
bool listShowReactPremiumError(
|
||||
not_null<HistoryItem*> item,
|
||||
const Data::ReactionId &id) override;
|
||||
base::unique_qptr<Ui::PopupMenu> listFillSenderUserpicMenu(
|
||||
PeerId userpicPeerId) override;
|
||||
void listWindowSetInnerFocus() override;
|
||||
bool listAllowsDragForward() override;
|
||||
void listLaunchDrag(
|
||||
|
@ -356,6 +360,9 @@ public:
|
|||
int top) const;
|
||||
[[nodiscard]] ClickHandlerContext prepareClickHandlerContext(
|
||||
FullMsgId id);
|
||||
[[nodiscard]] ClickContext prepareClickContext(
|
||||
Qt::MouseButton button,
|
||||
FullMsgId itemId);
|
||||
|
||||
// AbstractTooltipShower interface
|
||||
QString tooltipText() const override;
|
||||
|
@ -808,6 +815,7 @@ private:
|
|||
CursorState _mouseCursorState = CursorState();
|
||||
uint16 _mouseTextSymbol = 0;
|
||||
bool _pressWasInactive = false;
|
||||
bool _overSenderUserpic = false;
|
||||
|
||||
bool _selectEnabled = false;
|
||||
HistoryItem *_selectedTextItem = nullptr;
|
||||
|
|
|
@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history_view_swipe.h"
|
||||
#include "ui/chat/pinned_bar.h"
|
||||
#include "ui/chat/chat_style.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
|
@ -2705,6 +2706,23 @@ Ui::ChatPaintContext RepliesWidget::listPreparePaintContext(
|
|||
return context;
|
||||
}
|
||||
|
||||
base::unique_qptr<Ui::PopupMenu> RepliesWidget::listFillSenderUserpicMenu(
|
||||
PeerId userpicPeerId) {
|
||||
const auto searchInEntry = _topic
|
||||
? Dialogs::Key(_topic)
|
||||
: Dialogs::Key(_history);
|
||||
auto menu = base::make_unique_q<Ui::PopupMenu>(
|
||||
this,
|
||||
st::popupMenuWithIcons);
|
||||
Window::FillSenderUserpicMenu(
|
||||
controller(),
|
||||
_history->owner().peer(userpicPeerId),
|
||||
_composeControls->fieldForMention(),
|
||||
searchInEntry,
|
||||
Ui::Menu::CreateAddActionCallback(menu.get()));
|
||||
return menu->empty() ? nullptr : std::move(menu);
|
||||
}
|
||||
|
||||
void RepliesWidget::setupEmptyPainter() {
|
||||
Expects(_topic != nullptr);
|
||||
|
||||
|
|
|
@ -183,6 +183,8 @@ public:
|
|||
not_null<TranslateTracker*> tracker) override;
|
||||
Ui::ChatPaintContext listPreparePaintContext(
|
||||
Ui::ChatPaintContextArgs &&args) override;
|
||||
base::unique_qptr<Ui::PopupMenu> listFillSenderUserpicMenu(
|
||||
PeerId userpicPeerId) override;
|
||||
|
||||
// CornerButtonsDelegate delegate.
|
||||
void cornerButtonsShowAtPosition(
|
||||
|
|
Loading…
Add table
Reference in a new issue