mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Added ability to show popup selector for top peers from fast share.
This commit is contained in:
@@ -1751,3 +1751,4 @@ topPeersSelectorUserpicSize: 30px;
|
||||
topPeersSelectorUserpicGap: 8px;
|
||||
topPeersSelectorPadding: 6px;
|
||||
topPeersSelectorUserpicExpand: 0.1;
|
||||
topPeersSelectorSkip: point(11px, -5px);
|
||||
|
||||
@@ -18,6 +18,7 @@ constexpr auto kReactionsCountEmojiProperty = 0x05;
|
||||
constexpr auto kDocumentFilenameTooltipProperty = 0x06;
|
||||
constexpr auto kPhoneNumberLinkProperty = 0x07;
|
||||
constexpr auto kTodoListItemIdProperty = 0x08;
|
||||
constexpr auto kFastShareProperty = 0x09;
|
||||
|
||||
namespace Ui {
|
||||
class Show;
|
||||
|
||||
@@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "history/view/history_view_reaction_preview.h"
|
||||
#include "history/view/history_view_quick_action.h"
|
||||
#include "history/view/history_view_emoji_interactions.h"
|
||||
#include "history/view/history_view_top_peers_selector.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "history/history_item_text.h"
|
||||
#include "payments/payments_reaction_process.h"
|
||||
@@ -2307,6 +2308,24 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||
e,
|
||||
session().data().reactions().favoriteId())) {
|
||||
return;
|
||||
} else if (link && link->property(kFastShareProperty).value<bool>()) {
|
||||
if (const auto item = _dragStateItem) {
|
||||
const auto view = viewByItem(item);
|
||||
const auto rightSize = view->rightActionSize().value_or(QSize());
|
||||
const auto top = itemTop(view)
|
||||
+ view->height()
|
||||
- _visibleAreaTop
|
||||
- rightSize.height();
|
||||
const auto right = rect::right(view->innerGeometry())
|
||||
- st::historyFastShareLeft
|
||||
- rightSize.width();
|
||||
HistoryView::ShowTopPeersSelector(
|
||||
this,
|
||||
_controller->uiShow(),
|
||||
item->fullId(),
|
||||
parentWidget()->mapToGlobal(QPoint(right, top)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
auto selectedState = getSelectionState();
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "history/view/history_view_service_message.h"
|
||||
#include "history/view/history_view_cursor_state.h"
|
||||
#include "history/view/history_view_translate_tracker.h"
|
||||
#include "history/view/history_view_top_peers_selector.h"
|
||||
#include "history/view/history_view_quick_action.h"
|
||||
#include "chat_helpers/message_field.h"
|
||||
#include "mainwindow.h"
|
||||
@@ -55,6 +56,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/chat/chat_theme.h"
|
||||
#include "ui/chat/chat_style.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "boxes/delete_messages_box.h"
|
||||
@@ -2849,6 +2851,26 @@ void ListWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||
: _overElement
|
||||
? _overElement->data().get()
|
||||
: nullptr;
|
||||
if (link
|
||||
&& link->property(kFastShareProperty).value<bool>()
|
||||
&& overItem) {
|
||||
if (const auto view = viewForItem(overItem)) {
|
||||
const auto rightSize = view->rightActionSize().value_or(QSize());
|
||||
const auto top = itemTop(view)
|
||||
+ view->height()
|
||||
- _visibleTop
|
||||
- rightSize.height();
|
||||
const auto right = rect::right(view->innerGeometry())
|
||||
- st::historyFastShareLeft
|
||||
- rightSize.width();
|
||||
ShowTopPeersSelector(
|
||||
this,
|
||||
controller()->uiShow(),
|
||||
overItem->fullId(),
|
||||
parentWidget()->mapToGlobal(QPoint(right, top)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
const auto clickedReaction = Reactions::ReactionIdOfLink(link);
|
||||
const auto linkPhoneNumber = link
|
||||
? link->property(kPhoneNumberLinkProperty).toString()
|
||||
|
||||
@@ -4017,7 +4017,7 @@ ClickHandlerPtr Message::prepareRightActionLink() const {
|
||||
}
|
||||
};
|
||||
};
|
||||
return std::make_shared<LambdaClickHandler>([=](
|
||||
const auto result = std::make_shared<LambdaClickHandler>([=](
|
||||
ClickContext context) {
|
||||
const auto controller = ExtractController(context);
|
||||
if (!controller || controller->session().uniqueId() != sessionId) {
|
||||
@@ -4039,6 +4039,8 @@ ClickHandlerPtr Message::prepareRightActionLink() const {
|
||||
}
|
||||
}
|
||||
});
|
||||
result->setProperty(kFastShareProperty, QVariant::fromValue(true));
|
||||
return result;
|
||||
}
|
||||
|
||||
ClickHandlerPtr Message::fastReplyLink() const {
|
||||
|
||||
@@ -49,7 +49,8 @@ constexpr auto kMaxPeers = 5;
|
||||
void ShowTopPeersSelector(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
FullMsgId fullId) {
|
||||
FullMsgId fullId,
|
||||
QPoint globalPos) {
|
||||
const auto session = &show->session();
|
||||
const auto peers = CollectPeers(session);
|
||||
auto thumbnails = std::vector<std::shared_ptr<Ui::DynamicImage>>();
|
||||
@@ -108,7 +109,9 @@ void ShowTopPeersSelector(
|
||||
});
|
||||
userpicsWidget->setCursor(style::cur_pointer);
|
||||
selector->updateShowState(0, 0, true);
|
||||
selector->popup(QCursor::pos());
|
||||
selector->popup((!globalPos.isNull() ? globalPos : QCursor::pos())
|
||||
- QPoint(selector->width() / 2, selector->height())
|
||||
+ st::topPeersSelectorSkip);
|
||||
|
||||
auto animation
|
||||
= selector->lifetime().make_state<Ui::Animations::Simple>();
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace HistoryView {
|
||||
void ShowTopPeersSelector(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
FullMsgId fullId);
|
||||
FullMsgId fullId,
|
||||
QPoint globalPos);
|
||||
|
||||
} // namespace HistoryView
|
||||
|
||||
Reference in New Issue
Block a user