mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 23:24:01 +02:00
Removed Ui::showPeerHistoryAtItem from facades.
This commit is contained in:
parent
570ed5691d
commit
7924979dfb
19 changed files with 106 additions and 28 deletions
|
@ -269,10 +269,6 @@ void showChatsList(not_null<Main::Session*> session) {
|
|||
}
|
||||
}
|
||||
|
||||
void showPeerHistoryAtItem(not_null<const HistoryItem*> item) {
|
||||
showPeerHistory(item->history()->peer, item->id);
|
||||
}
|
||||
|
||||
void showPeerHistory(not_null<const History*> history, MsgId msgId) {
|
||||
showPeerHistory(history->peer, msgId);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,6 @@ namespace Ui {
|
|||
void showPeerProfile(not_null<PeerData*> peer);
|
||||
void showPeerProfile(not_null<const History*> history);
|
||||
|
||||
void showPeerHistoryAtItem(not_null<const HistoryItem*> item);
|
||||
void showPeerHistory(not_null<const PeerData*> peer, MsgId msgId);
|
||||
void showPeerHistory(not_null<const History*> history, MsgId msgId);
|
||||
void showChatsList(not_null<Main::Session*> session);
|
||||
|
|
|
@ -5263,14 +5263,14 @@ bool HistoryWidget::replyToPreviousMessage() {
|
|||
if (const auto view = item->mainView()) {
|
||||
if (const auto previousView = view->previousDisplayedInBlocks()) {
|
||||
const auto previous = previousView->data();
|
||||
Ui::showPeerHistoryAtItem(previous);
|
||||
controller()->showPeerHistoryAtItem(previous);
|
||||
replyToMessage(previous);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (const auto previousView = _history->findLastDisplayed()) {
|
||||
const auto previous = previousView->data();
|
||||
Ui::showPeerHistoryAtItem(previous);
|
||||
controller()->showPeerHistoryAtItem(previous);
|
||||
replyToMessage(previous);
|
||||
return true;
|
||||
}
|
||||
|
@ -5288,7 +5288,7 @@ bool HistoryWidget::replyToNextMessage() {
|
|||
if (const auto view = item->mainView()) {
|
||||
if (const auto nextView = view->nextDisplayedInBlocks()) {
|
||||
const auto next = nextView->data();
|
||||
Ui::showPeerHistoryAtItem(next);
|
||||
controller()->showPeerHistoryAtItem(next);
|
||||
replyToMessage(next);
|
||||
} else {
|
||||
clearHighlightMessages();
|
||||
|
|
|
@ -73,6 +73,11 @@ bool LayerWidget::floatPlayerIsVisible(not_null<HistoryItem*> item) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void LayerWidget::floatPlayerDoubleClickEvent(
|
||||
not_null<const HistoryItem*> item) {
|
||||
_controller->showPeerHistoryAtItem(item);
|
||||
}
|
||||
|
||||
void LayerWidget::setupHeightConsumers() {
|
||||
Expects(_content != nullptr);
|
||||
|
||||
|
|
|
@ -64,6 +64,8 @@ private:
|
|||
not_null<::Media::Player::FloatSectionDelegate*> widget,
|
||||
Window::Column widgetColumn)> callback) override;
|
||||
bool floatPlayerIsVisible(not_null<HistoryItem*> item) override;
|
||||
void floatPlayerDoubleClickEvent(
|
||||
not_null<const HistoryItem*> item) override;
|
||||
|
||||
void setupHeightConsumers();
|
||||
|
||||
|
|
|
@ -1445,7 +1445,7 @@ void ListWidget::showContextMenu(
|
|||
tr::lng_context_to_msg(tr::now),
|
||||
[=] {
|
||||
if (const auto item = owner->message(itemFullId)) {
|
||||
Ui::showPeerHistoryAtItem(item);
|
||||
_controller->parentController()->showPeerHistoryAtItem(item);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "main/main_domain.h"
|
||||
#include "main/main_session.h"
|
||||
#include "mainwindow.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_countries.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
|
@ -33,6 +35,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "mtproto/mtproto_dc_options.h"
|
||||
#include "window/window_slide_animation.h"
|
||||
#include "window/window_connecting_widget.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "window/section_widget.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "api/api_text_entities.h"
|
||||
|
@ -186,6 +190,14 @@ bool Widget::floatPlayerIsVisible(not_null<HistoryItem*> item) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void Widget::floatPlayerDoubleClickEvent(not_null<const HistoryItem*> item) {
|
||||
getData()->controller->invokeForSessionController(
|
||||
&item->history()->peer->session().account(),
|
||||
[=](not_null<Window::SessionController*> controller) {
|
||||
controller->showPeerHistoryAtItem(item);
|
||||
});
|
||||
}
|
||||
|
||||
QRect Widget::floatPlayerAvailableRect() {
|
||||
return mapToGlobal(rect());
|
||||
}
|
||||
|
|
|
@ -166,6 +166,8 @@ private:
|
|||
not_null<Media::Player::FloatSectionDelegate*> widget,
|
||||
Window::Column widgetColumn)> callback) override;
|
||||
bool floatPlayerIsVisible(not_null<HistoryItem*> item) override;
|
||||
void floatPlayerDoubleClickEvent(
|
||||
not_null<const HistoryItem*> item) override;
|
||||
|
||||
// FloatSectionDelegate
|
||||
QRect floatPlayerAvailableRect() override;
|
||||
|
|
|
@ -511,6 +511,11 @@ void MainWidget::floatPlayerClosed(FullMsgId itemId) {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWidget::floatPlayerDoubleClickEvent(
|
||||
not_null<const HistoryItem*> item) {
|
||||
_controller->showPeerHistoryAtItem(item);
|
||||
}
|
||||
|
||||
bool MainWidget::setForwardDraft(PeerId peerId, MessageIdsList &&items) {
|
||||
Expects(peerId != 0);
|
||||
|
||||
|
@ -939,6 +944,10 @@ void MainWidget::createPlayer() {
|
|||
[this] { playerHeightUpdated(); },
|
||||
_player->lifetime());
|
||||
_player->entity()->setCloseCallback([=] { closeBothPlayers(); });
|
||||
_player->entity()->setShowItemCallback([=](
|
||||
not_null<const HistoryItem*> item) {
|
||||
_controller->showPeerHistoryAtItem(item);
|
||||
});
|
||||
_playerVolume.create(this, _controller);
|
||||
_player->entity()->volumeWidgetCreated(_playerVolume);
|
||||
orderWidgets();
|
||||
|
|
|
@ -319,6 +319,8 @@ private:
|
|||
Window::Column widgetColumn)> callback) override;
|
||||
bool floatPlayerIsVisible(not_null<HistoryItem*> item) override;
|
||||
void floatPlayerClosed(FullMsgId itemId);
|
||||
void floatPlayerDoubleClickEvent(
|
||||
not_null<const HistoryItem*> item) override;
|
||||
|
||||
void viewsIncrementDone(
|
||||
QVector<MTPint> ids,
|
||||
|
|
|
@ -35,15 +35,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
namespace Media {
|
||||
namespace Player {
|
||||
|
||||
using DoubleClickedCallback = Fn<void(not_null<const HistoryItem*>)>;
|
||||
|
||||
Float::Float(
|
||||
QWidget *parent,
|
||||
not_null<HistoryItem*> item,
|
||||
Fn<void(bool visible)> toggleCallback,
|
||||
Fn<void(bool closed)> draggedCallback)
|
||||
Fn<void(bool closed)> draggedCallback,
|
||||
DoubleClickedCallback doubleClickedCallback)
|
||||
: RpWidget(parent)
|
||||
, _item(item)
|
||||
, _toggleCallback(std::move(toggleCallback))
|
||||
, _draggedCallback(std::move(draggedCallback)) {
|
||||
, _draggedCallback(std::move(draggedCallback))
|
||||
, _doubleClickedCallback(std::move(doubleClickedCallback)) {
|
||||
auto media = _item->media();
|
||||
Assert(media != nullptr);
|
||||
|
||||
|
@ -131,10 +135,10 @@ void Float::finishDrag(bool closed) {
|
|||
}
|
||||
|
||||
void Float::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
if (_item) {
|
||||
if (_item && _doubleClickedCallback) {
|
||||
// Handle second click.
|
||||
pauseResume();
|
||||
Ui::showPeerHistoryAtItem(_item);
|
||||
_doubleClickedCallback(_item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,7 +279,8 @@ FloatController::Item::Item(
|
|||
not_null<QWidget*> parent,
|
||||
not_null<HistoryItem*> item,
|
||||
ToggleCallback toggle,
|
||||
DraggedCallback dragged)
|
||||
DraggedCallback dragged,
|
||||
DoubleClickedCallback doubleClicked)
|
||||
: animationSide(RectPart::Right)
|
||||
, column(Window::Column::Second)
|
||||
, corner(RectPart::TopRight)
|
||||
|
@ -287,7 +292,8 @@ FloatController::Item::Item(
|
|||
},
|
||||
[=, dragged = std::move(dragged)](bool closed) {
|
||||
dragged(this, closed);
|
||||
}) {
|
||||
},
|
||||
std::move(doubleClicked)) {
|
||||
}
|
||||
|
||||
FloatController::FloatController(not_null<FloatDelegate*> delegate)
|
||||
|
@ -394,6 +400,9 @@ void FloatController::create(not_null<HistoryItem*> item) {
|
|||
},
|
||||
[=](not_null<Item*> instance, bool closed) {
|
||||
finishDrag(instance, closed);
|
||||
},
|
||||
[=](not_null<const HistoryItem*> item) {
|
||||
_delegate->floatPlayerDoubleClickEvent(item);
|
||||
}));
|
||||
current()->column = Core::App().settings().floatPlayerColumn();
|
||||
current()->corner = Core::App().settings().floatPlayerCorner();
|
||||
|
|
|
@ -38,7 +38,8 @@ public:
|
|||
QWidget *parent,
|
||||
not_null<HistoryItem*> item,
|
||||
Fn<void(bool visible)> toggleCallback,
|
||||
Fn<void(bool closed)> draggedCallback);
|
||||
Fn<void(bool closed)> draggedCallback,
|
||||
Fn<void(not_null<const HistoryItem*>)> doubleClickedCallback);
|
||||
|
||||
[[nodiscard]] HistoryItem *item() const {
|
||||
return _item;
|
||||
|
@ -101,6 +102,7 @@ private:
|
|||
bool _drag = false;
|
||||
QPoint _dragLocalPoint;
|
||||
Fn<void(bool closed)> _draggedCallback;
|
||||
Fn<void(not_null<const HistoryItem*>)> _doubleClickedCallback;
|
||||
|
||||
};
|
||||
|
||||
|
@ -138,6 +140,9 @@ public:
|
|||
virtual rpl::producer<> floatPlayerAreaUpdates() {
|
||||
return _areaUpdates.events();
|
||||
}
|
||||
virtual void floatPlayerDoubleClickEvent(
|
||||
not_null<const HistoryItem*> item) {
|
||||
}
|
||||
|
||||
struct FloatPlayerFilterWheelEventRequest {
|
||||
not_null<QObject*> object;
|
||||
|
@ -205,7 +210,8 @@ private:
|
|||
not_null<QWidget*> parent,
|
||||
not_null<HistoryItem*> item,
|
||||
ToggleCallback toggle,
|
||||
DraggedCallback dragged);
|
||||
DraggedCallback dragged,
|
||||
Fn<void(not_null<const HistoryItem*>)> doubleClicked);
|
||||
|
||||
bool hiddenByWidget = false;
|
||||
bool hiddenByHistory = false;
|
||||
|
|
|
@ -206,6 +206,11 @@ void Widget::setCloseCallback(Fn<void()> callback) {
|
|||
_close->setClickedCallback([this] { stopAndClose(); });
|
||||
}
|
||||
|
||||
void Widget::setShowItemCallback(
|
||||
Fn<void(not_null<const HistoryItem*>)> callback) {
|
||||
_showItemCallback = std::move(callback);
|
||||
}
|
||||
|
||||
void Widget::stopAndClose() {
|
||||
_voiceIsActive = false;
|
||||
if (_type == AudioMsgId::Type::Voice) {
|
||||
|
@ -311,15 +316,16 @@ void Widget::mousePressEvent(QMouseEvent *e) {
|
|||
|
||||
void Widget::mouseReleaseEvent(QMouseEvent *e) {
|
||||
if (auto downLabels = base::take(_labelsDown)) {
|
||||
if (_labelsOver == downLabels) {
|
||||
if (_type == AudioMsgId::Type::Voice) {
|
||||
const auto current = instance()->current(_type);
|
||||
const auto document = current.audio();
|
||||
const auto context = current.contextId();
|
||||
if (document && context) {
|
||||
if (const auto item = document->owner().message(context)) {
|
||||
Ui::showPeerHistoryAtItem(item);
|
||||
}
|
||||
if (_labelsOver != downLabels) {
|
||||
return;
|
||||
}
|
||||
if (_type == AudioMsgId::Type::Voice) {
|
||||
const auto current = instance()->current(_type);
|
||||
const auto document = current.audio();
|
||||
const auto context = current.contextId();
|
||||
if (document && context && _showItemCallback) {
|
||||
if (const auto item = document->owner().message(context)) {
|
||||
_showItemCallback(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
Widget(QWidget *parent, not_null<Main::Session*> session);
|
||||
|
||||
void setCloseCallback(Fn<void()> callback);
|
||||
void setShowItemCallback(Fn<void(not_null<const HistoryItem*>)> callback);
|
||||
void stopAndClose();
|
||||
void setShadowGeometryToLeft(int x, int y, int w, int h);
|
||||
void showShadow();
|
||||
|
@ -103,6 +104,7 @@ private:
|
|||
AudioMsgId _lastSongId;
|
||||
bool _voiceIsActive = false;
|
||||
Fn<void()> _closeCallback;
|
||||
Fn<void(not_null<const HistoryItem*>)> _showItemCallback;
|
||||
|
||||
bool _labelsOver = false;
|
||||
bool _labelsDown = false;
|
||||
|
|
|
@ -1426,12 +1426,12 @@ void OverlayWidget::subscribeToScreenGeometry() {
|
|||
}
|
||||
|
||||
void OverlayWidget::toMessage() {
|
||||
if (!_session) {
|
||||
if (!_session || !_controller) {
|
||||
return;
|
||||
}
|
||||
if (const auto item = _session->data().message(_msgid)) {
|
||||
close();
|
||||
Ui::showPeerHistoryAtItem(item);
|
||||
_controller->showPeerHistoryAtItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -333,6 +333,15 @@ void Controller::preventOrInvoke(Fn<void()> &&callback) {
|
|||
_widget.preventOrInvoke(std::move(callback));
|
||||
}
|
||||
|
||||
void Controller::invokeForSessionController(
|
||||
not_null<Main::Account*> account,
|
||||
Fn<void(not_null<SessionController*>)> &&callback) {
|
||||
_account->domain().activate(std::move(account));
|
||||
if (_sessionController) {
|
||||
callback(_sessionController.get());
|
||||
}
|
||||
}
|
||||
|
||||
QPoint Controller::getPointForCallPanelCenter() const {
|
||||
Expects(_widget.windowHandle() != nullptr);
|
||||
|
||||
|
|
|
@ -83,6 +83,10 @@ public:
|
|||
|
||||
void preventOrInvoke(Fn<void()> &&callback);
|
||||
|
||||
void invokeForSessionController(
|
||||
not_null<Main::Account*> account,
|
||||
Fn<void(not_null<SessionController*>)> &&callback);
|
||||
|
||||
void openInMediaView(Media::View::OpenRequest &&request);
|
||||
[[nodiscard]] auto openInMediaViewRequests() const
|
||||
-> rpl::producer<Media::View::OpenRequest>;
|
||||
|
|
|
@ -50,6 +50,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/confirm_box.h"
|
||||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
#include "main/main_domain.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "apiwrap.h"
|
||||
|
@ -1136,6 +1137,18 @@ void SessionController::showPeerHistory(
|
|||
msgId);
|
||||
}
|
||||
|
||||
void SessionController::showPeerHistoryAtItem(
|
||||
not_null<const HistoryItem*> item) {
|
||||
_window->invokeForSessionController(
|
||||
&item->history()->peer->session().account(),
|
||||
[=](not_null<SessionController*> controller) {
|
||||
controller->showPeerHistory(
|
||||
item->history()->peer,
|
||||
SectionShow::Way::ClearStack,
|
||||
item->id);
|
||||
});
|
||||
}
|
||||
|
||||
void SessionController::showSection(
|
||||
std::shared_ptr<SectionMemento> memento,
|
||||
const SectionShow ¶ms) {
|
||||
|
|
|
@ -327,6 +327,8 @@ public:
|
|||
const SectionShow ¶ms = SectionShow::Way::ClearStack,
|
||||
MsgId msgId = ShowAtUnreadMsgId) override;
|
||||
|
||||
void showPeerHistoryAtItem(not_null<const HistoryItem*> item);
|
||||
|
||||
void showSpecialLayer(
|
||||
object_ptr<Ui::LayerWidget> &&layer,
|
||||
anim::type animated = anim::type::normal);
|
||||
|
|
Loading…
Add table
Reference in a new issue