mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show preview in Frequent Contacts.
This commit is contained in:
parent
4e8895ddd9
commit
f9f51b4e41
5 changed files with 65 additions and 1 deletions
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_chat_participants.h"
|
#include "api/api_chat_participants.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
|
#include "base/qt/qt_key_modifiers.h"
|
||||||
#include "boxes/peer_list_box.h"
|
#include "boxes/peer_list_box.h"
|
||||||
#include "data/components/recent_peers.h"
|
#include "data/components/recent_peers.h"
|
||||||
#include "data/components/top_peers.h"
|
#include "data/components/top_peers.h"
|
||||||
|
@ -940,6 +941,16 @@ void Suggestions::setupChats() {
|
||||||
_topPeerChosen.fire(_controller->session().data().peer(peerId));
|
_topPeerChosen.fire(_controller->session().data().peer(peerId));
|
||||||
}, _topPeers->lifetime());
|
}, _topPeers->lifetime());
|
||||||
|
|
||||||
|
_topPeers->pressed() | rpl::start_with_next([=](uint64 peerIdRaw) {
|
||||||
|
handlePressForChatPreview(PeerId(peerIdRaw), [=] {
|
||||||
|
_topPeers->cancelPress();
|
||||||
|
});
|
||||||
|
}, _topPeers->lifetime());
|
||||||
|
|
||||||
|
_topPeers->pressCancelled() | rpl::start_with_next([=] {
|
||||||
|
_controller->cancelScheduledPreview();
|
||||||
|
}, _topPeers->lifetime());
|
||||||
|
|
||||||
_topPeers->showMenuRequests(
|
_topPeers->showMenuRequests(
|
||||||
) | rpl::start_with_next([=](const ShowTopPeerMenuRequest &request) {
|
) | rpl::start_with_next([=](const ShowTopPeerMenuRequest &request) {
|
||||||
const auto weak = Ui::MakeWeak(this);
|
const auto weak = Ui::MakeWeak(this);
|
||||||
|
@ -983,6 +994,24 @@ void Suggestions::setupChats() {
|
||||||
_chatsScroll->setVisible(_tab.current() == Tab::Chats);
|
_chatsScroll->setVisible(_tab.current() == Tab::Chats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Suggestions::handlePressForChatPreview(
|
||||||
|
PeerId id,
|
||||||
|
Fn<void()> cancelPress) {
|
||||||
|
const auto callback = crl::guard(this, [=](bool shown) {
|
||||||
|
if (shown) {
|
||||||
|
cancelPress();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const auto row = RowDescriptor(
|
||||||
|
_controller->session().data().history(id),
|
||||||
|
FullMsgId());
|
||||||
|
if (base::IsAltPressed()) {
|
||||||
|
_controller->showChatPreview(row, callback);
|
||||||
|
} else {
|
||||||
|
_controller->scheduleChatPreview(row, callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Suggestions::setupChannels() {
|
void Suggestions::setupChannels() {
|
||||||
_myChannelsCount.value() | rpl::start_with_next([=](int count) {
|
_myChannelsCount.value() | rpl::start_with_next([=](int count) {
|
||||||
_myChannels->toggle(count > 0, anim::type::instant);
|
_myChannels->toggle(count > 0, anim::type::instant);
|
||||||
|
|
|
@ -122,6 +122,8 @@ private:
|
||||||
void startSlideAnimation();
|
void startSlideAnimation();
|
||||||
void finishShow();
|
void finishShow();
|
||||||
|
|
||||||
|
void handlePressForChatPreview(PeerId id, Fn<void()> cancelPress);
|
||||||
|
|
||||||
const not_null<Window::SessionController*> _controller;
|
const not_null<Window::SessionController*> _controller;
|
||||||
|
|
||||||
const std::unique_ptr<Ui::SettingsSlider> _tabs;
|
const std::unique_ptr<Ui::SettingsSlider> _tabs;
|
||||||
|
|
|
@ -286,6 +286,8 @@ void TopPeersStrip::stripMousePressEvent(QMouseEvent *e) {
|
||||||
entry.ripple->add(e->pos() - QPoint(
|
entry.ripple->add(e->pos() - QPoint(
|
||||||
x + st::topPeersMargin.left(),
|
x + st::topPeersMargin.left(),
|
||||||
y + st::topPeersMargin.top()));
|
y + st::topPeersMargin.top()));
|
||||||
|
|
||||||
|
_presses.fire_copy(entry.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,6 +306,7 @@ void TopPeersStrip::stripMouseMoveEvent(QMouseEvent *e) {
|
||||||
if (!_dragging && _mouseDownPosition) {
|
if (!_dragging && _mouseDownPosition) {
|
||||||
if ((*_lastMousePosition - *_mouseDownPosition).manhattanLength()
|
if ((*_lastMousePosition - *_mouseDownPosition).manhattanLength()
|
||||||
>= QApplication::startDragDistance()) {
|
>= QApplication::startDragDistance()) {
|
||||||
|
_pressCancelled.fire({});
|
||||||
if (!_expandAnimation.animating()) {
|
if (!_expandAnimation.animating()) {
|
||||||
_dragging = true;
|
_dragging = true;
|
||||||
_startDraggingLeft = _scrollLeft;
|
_startDraggingLeft = _scrollLeft;
|
||||||
|
@ -371,6 +374,8 @@ void TopPeersStrip::subscribeUserpic(Entry &entry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TopPeersStrip::stripMouseReleaseEvent(QMouseEvent *e) {
|
void TopPeersStrip::stripMouseReleaseEvent(QMouseEvent *e) {
|
||||||
|
_pressCancelled.fire({});
|
||||||
|
|
||||||
_lastMousePosition = e->globalPos();
|
_lastMousePosition = e->globalPos();
|
||||||
const auto guard = gsl::finally([&] {
|
const auto guard = gsl::finally([&] {
|
||||||
_mouseDownPosition = std::nullopt;
|
_mouseDownPosition = std::nullopt;
|
||||||
|
@ -428,6 +433,29 @@ rpl::producer<uint64> TopPeersStrip::clicks() const {
|
||||||
return _clicks.events();
|
return _clicks.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::producer<uint64> TopPeersStrip::pressed() const {
|
||||||
|
return _presses.events();
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<> TopPeersStrip::pressCancelled() const {
|
||||||
|
return _pressCancelled.events();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TopPeersStrip::cancelPress() {
|
||||||
|
const auto pressed = std::exchange(_pressed, -1);
|
||||||
|
if (pressed >= 0) {
|
||||||
|
Assert(pressed < _entries.size());
|
||||||
|
auto &entry = _entries[pressed];
|
||||||
|
if (entry.ripple) {
|
||||||
|
entry.ripple->lastStop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (finishDragging()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_mouseDownPosition = std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
auto TopPeersStrip::showMenuRequests() const
|
auto TopPeersStrip::showMenuRequests() const
|
||||||
-> rpl::producer<ShowTopPeerMenuRequest> {
|
-> rpl::producer<ShowTopPeerMenuRequest> {
|
||||||
return _showMenuRequests.events();
|
return _showMenuRequests.events();
|
||||||
|
|
|
@ -50,6 +50,8 @@ public:
|
||||||
[[nodiscard]] bool empty() const;
|
[[nodiscard]] bool empty() const;
|
||||||
[[nodiscard]] rpl::producer<bool> emptyValue() const;
|
[[nodiscard]] rpl::producer<bool> emptyValue() const;
|
||||||
[[nodiscard]] rpl::producer<uint64> clicks() const;
|
[[nodiscard]] rpl::producer<uint64> clicks() const;
|
||||||
|
[[nodiscard]] rpl::producer<uint64> pressed() const;
|
||||||
|
[[nodiscard]] rpl::producer<> pressCancelled() const;
|
||||||
[[nodiscard]] auto showMenuRequests() const
|
[[nodiscard]] auto showMenuRequests() const
|
||||||
-> rpl::producer<ShowTopPeerMenuRequest>;
|
-> rpl::producer<ShowTopPeerMenuRequest>;
|
||||||
[[nodiscard]] auto scrollToRequests() const
|
[[nodiscard]] auto scrollToRequests() const
|
||||||
|
@ -61,6 +63,7 @@ public:
|
||||||
bool selectByKeyboard(Qt::Key direction);
|
bool selectByKeyboard(Qt::Key direction);
|
||||||
void deselectByKeyboard();
|
void deselectByKeyboard();
|
||||||
bool chooseRow();
|
bool chooseRow();
|
||||||
|
void cancelPress();
|
||||||
|
|
||||||
uint64 updateFromParentDrag(QPoint globalPosition);
|
uint64 updateFromParentDrag(QPoint globalPosition);
|
||||||
void dragLeft();
|
void dragLeft();
|
||||||
|
@ -114,6 +117,8 @@ private:
|
||||||
rpl::variable<Ui::LinkButton*> _toggleExpanded = nullptr;
|
rpl::variable<Ui::LinkButton*> _toggleExpanded = nullptr;
|
||||||
|
|
||||||
rpl::event_stream<uint64> _clicks;
|
rpl::event_stream<uint64> _clicks;
|
||||||
|
rpl::event_stream<uint64> _presses;
|
||||||
|
rpl::event_stream<> _pressCancelled;
|
||||||
rpl::event_stream<ShowTopPeerMenuRequest> _showMenuRequests;
|
rpl::event_stream<ShowTopPeerMenuRequest> _showMenuRequests;
|
||||||
rpl::event_stream<not_null<QWheelEvent*>> _verticalScrollEvents;
|
rpl::event_stream<not_null<QWheelEvent*>> _verticalScrollEvents;
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ bool ChatPreviewManager::schedule(
|
||||||
cancelScheduled();
|
cancelScheduled();
|
||||||
_menu = nullptr;
|
_menu = nullptr;
|
||||||
});
|
});
|
||||||
} else {
|
} else if (!row.key.history()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_scheduled = std::move(row);
|
_scheduled = std::move(row);
|
||||||
|
|
Loading…
Add table
Reference in a new issue