mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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 {
|
TextWithEntities ComposeControls::prepareTextForEditMsg() const {
|
||||||
if (!_history) {
|
if (!_history) {
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -249,6 +249,8 @@ public:
|
||||||
|
|
||||||
Fn<void()> restoreTextCallback(const QString &insertTextOnCancel) const;
|
Fn<void()> restoreTextCallback(const QString &insertTextOnCancel) const;
|
||||||
|
|
||||||
|
[[nodiscard]] Ui::InputField *fieldForMention() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class TextUpdateEvent {
|
enum class TextUpdateEvent {
|
||||||
SaveDraft = (1 << 0),
|
SaveDraft = (1 << 0),
|
||||||
|
|
|
@ -161,6 +161,8 @@ private:
|
||||||
bool listShowReactPremiumError(
|
bool listShowReactPremiumError(
|
||||||
not_null<HistoryItem*> item,
|
not_null<HistoryItem*> item,
|
||||||
const Data::ReactionId &id) override;
|
const Data::ReactionId &id) override;
|
||||||
|
base::unique_qptr<Ui::PopupMenu> listFillSenderUserpicMenu(
|
||||||
|
PeerId userpicPeerId) override;
|
||||||
void listWindowSetInnerFocus() override;
|
void listWindowSetInnerFocus() override;
|
||||||
bool listAllowsDragForward() override;
|
bool listAllowsDragForward() override;
|
||||||
void listLaunchDrag(
|
void listLaunchDrag(
|
||||||
|
@ -828,6 +830,11 @@ bool Item::listShowReactPremiumError(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base::unique_qptr<Ui::PopupMenu> Item::listFillSenderUserpicMenu(
|
||||||
|
PeerId userpicPeerId) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void Item::listWindowSetInnerFocus() {
|
void Item::listWindowSetInnerFocus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "chat_helpers/message_field.h"
|
#include "chat_helpers/message_field.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "core/click_handler_types.h"
|
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
#include "core/click_handler_types.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
|
#include "core/phone_click_handler.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "api/api_who_reacted.h"
|
#include "api/api_who_reacted.h"
|
||||||
#include "api/api_views.h"
|
#include "api/api_views.h"
|
||||||
|
@ -171,6 +172,11 @@ bool WindowListDelegate::listShowReactPremiumError(
|
||||||
return Window::ShowReactPremiumError(_window, item, id);
|
return Window::ShowReactPremiumError(_window, item, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto WindowListDelegate::listFillSenderUserpicMenu(PeerId userpicPeerId)
|
||||||
|
-> base::unique_qptr<Ui::PopupMenu> {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void WindowListDelegate::listWindowSetInnerFocus() {
|
void WindowListDelegate::listWindowSetInnerFocus() {
|
||||||
_window->widget()->setInnerFocus();
|
_window->widget()->setInnerFocus();
|
||||||
}
|
}
|
||||||
|
@ -2794,6 +2800,12 @@ void ListWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
? _overElement->data().get()
|
? _overElement->data().get()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
const auto clickedReaction = Reactions::ReactionIdOfLink(link);
|
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();
|
_whoReactedMenuLifetime.destroy();
|
||||||
if (!clickedReaction.empty()
|
if (!clickedReaction.empty()
|
||||||
&& overItem
|
&& overItem
|
||||||
|
@ -2808,6 +2820,19 @@ void ListWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
_whoReactedMenuLifetime);
|
_whoReactedMenuLifetime);
|
||||||
e->accept();
|
e->accept();
|
||||||
return;
|
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());
|
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(
|
int ListWidget::SelectionViewOffset(
|
||||||
not_null<const ListWidget*> inner,
|
not_null<const ListWidget*> inner,
|
||||||
not_null<const Element*> view) {
|
not_null<const Element*> view) {
|
||||||
|
@ -3629,6 +3663,7 @@ void ListWidget::mouseActionUpdate() {
|
||||||
auto inTextSelection = (_overState.pointState != PointState::Outside)
|
auto inTextSelection = (_overState.pointState != PointState::Outside)
|
||||||
&& (_overState.itemId == _pressState.itemId)
|
&& (_overState.itemId == _pressState.itemId)
|
||||||
&& hasSelectedText();
|
&& hasSelectedText();
|
||||||
|
auto dragStateUserpic = false;
|
||||||
const auto overReaction = reactionView && reactionState.link;
|
const auto overReaction = reactionView && reactionState.link;
|
||||||
if (overReaction) {
|
if (overReaction) {
|
||||||
dragState = reactionState;
|
dragState = reactionState;
|
||||||
|
@ -3727,6 +3762,7 @@ void ListWidget::mouseActionUpdate() {
|
||||||
// stop enumeration if we've found a userpic under the cursor
|
// stop enumeration if we've found a userpic under the cursor
|
||||||
if (point.y() >= userpicTop && point.y() < userpicTop + st::msgPhotoSize) {
|
if (point.y() >= userpicTop && point.y() < userpicTop + st::msgPhotoSize) {
|
||||||
dragState = TextState(nullptr, view->fromPhotoLink());
|
dragState = TextState(nullptr, view->fromPhotoLink());
|
||||||
|
dragStateUserpic = true;
|
||||||
_overItemExact = nullptr;
|
_overItemExact = nullptr;
|
||||||
lnkhost = view;
|
lnkhost = view;
|
||||||
return false;
|
return false;
|
||||||
|
@ -3738,6 +3774,7 @@ void ListWidget::mouseActionUpdate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const auto lnkChanged = ClickHandler::setActive(dragState.link, lnkhost);
|
const auto lnkChanged = ClickHandler::setActive(dragState.link, lnkhost);
|
||||||
|
_overSenderUserpic = dragStateUserpic;
|
||||||
if (lnkChanged || dragState.cursor != _mouseCursorState) {
|
if (lnkChanged || dragState.cursor != _mouseCursorState) {
|
||||||
Ui::Tooltip::Hide();
|
Ui::Tooltip::Hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,6 +185,8 @@ public:
|
||||||
virtual bool listShowReactPremiumError(
|
virtual bool listShowReactPremiumError(
|
||||||
not_null<HistoryItem*> item,
|
not_null<HistoryItem*> item,
|
||||||
const Data::ReactionId &id) = 0;
|
const Data::ReactionId &id) = 0;
|
||||||
|
virtual base::unique_qptr<Ui::PopupMenu> listFillSenderUserpicMenu(
|
||||||
|
PeerId userpicPeerId) = 0;
|
||||||
virtual void listWindowSetInnerFocus() = 0;
|
virtual void listWindowSetInnerFocus() = 0;
|
||||||
virtual bool listAllowsDragForward() = 0;
|
virtual bool listAllowsDragForward() = 0;
|
||||||
virtual void listLaunchDrag(
|
virtual void listLaunchDrag(
|
||||||
|
@ -218,6 +220,8 @@ public:
|
||||||
bool listShowReactPremiumError(
|
bool listShowReactPremiumError(
|
||||||
not_null<HistoryItem*> item,
|
not_null<HistoryItem*> item,
|
||||||
const Data::ReactionId &id) override;
|
const Data::ReactionId &id) override;
|
||||||
|
base::unique_qptr<Ui::PopupMenu> listFillSenderUserpicMenu(
|
||||||
|
PeerId userpicPeerId) override;
|
||||||
void listWindowSetInnerFocus() override;
|
void listWindowSetInnerFocus() override;
|
||||||
bool listAllowsDragForward() override;
|
bool listAllowsDragForward() override;
|
||||||
void listLaunchDrag(
|
void listLaunchDrag(
|
||||||
|
@ -356,6 +360,9 @@ public:
|
||||||
int top) const;
|
int top) const;
|
||||||
[[nodiscard]] ClickHandlerContext prepareClickHandlerContext(
|
[[nodiscard]] ClickHandlerContext prepareClickHandlerContext(
|
||||||
FullMsgId id);
|
FullMsgId id);
|
||||||
|
[[nodiscard]] ClickContext prepareClickContext(
|
||||||
|
Qt::MouseButton button,
|
||||||
|
FullMsgId itemId);
|
||||||
|
|
||||||
// AbstractTooltipShower interface
|
// AbstractTooltipShower interface
|
||||||
QString tooltipText() const override;
|
QString tooltipText() const override;
|
||||||
|
@ -808,6 +815,7 @@ private:
|
||||||
CursorState _mouseCursorState = CursorState();
|
CursorState _mouseCursorState = CursorState();
|
||||||
uint16 _mouseTextSymbol = 0;
|
uint16 _mouseTextSymbol = 0;
|
||||||
bool _pressWasInactive = false;
|
bool _pressWasInactive = false;
|
||||||
|
bool _overSenderUserpic = false;
|
||||||
|
|
||||||
bool _selectEnabled = false;
|
bool _selectEnabled = false;
|
||||||
HistoryItem *_selectedTextItem = nullptr;
|
HistoryItem *_selectedTextItem = nullptr;
|
||||||
|
|
|
@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history_view_swipe.h"
|
#include "history/history_view_swipe.h"
|
||||||
#include "ui/chat/pinned_bar.h"
|
#include "ui/chat/pinned_bar.h"
|
||||||
#include "ui/chat/chat_style.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/buttons.h"
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
|
@ -2705,6 +2706,23 @@ Ui::ChatPaintContext RepliesWidget::listPreparePaintContext(
|
||||||
return context;
|
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() {
|
void RepliesWidget::setupEmptyPainter() {
|
||||||
Expects(_topic != nullptr);
|
Expects(_topic != nullptr);
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,8 @@ public:
|
||||||
not_null<TranslateTracker*> tracker) override;
|
not_null<TranslateTracker*> tracker) override;
|
||||||
Ui::ChatPaintContext listPreparePaintContext(
|
Ui::ChatPaintContext listPreparePaintContext(
|
||||||
Ui::ChatPaintContextArgs &&args) override;
|
Ui::ChatPaintContextArgs &&args) override;
|
||||||
|
base::unique_qptr<Ui::PopupMenu> listFillSenderUserpicMenu(
|
||||||
|
PeerId userpicPeerId) override;
|
||||||
|
|
||||||
// CornerButtonsDelegate delegate.
|
// CornerButtonsDelegate delegate.
|
||||||
void cornerButtonsShowAtPosition(
|
void cornerButtonsShowAtPosition(
|
||||||
|
|
Loading…
Add table
Reference in a new issue