From ad3e447f0809c2a92a74e0ba6b49a2734722d04b Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 28 Aug 2024 08:49:34 +0300 Subject: [PATCH] Added ability to player to go to message for songs from another session. --- .../SourceFiles/media/player/media_player_widget.cpp | 12 +++++++++--- .../SourceFiles/media/player/media_player_widget.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/media/player/media_player_widget.cpp b/Telegram/SourceFiles/media/player/media_player_widget.cpp index abe1c738c..05352b7f8 100644 --- a/Telegram/SourceFiles/media/player/media_player_widget.cpp +++ b/Telegram/SourceFiles/media/player/media_player_widget.cpp @@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history_item_helpers.h" #include "storage/storage_account.h" #include "main/main_session.h" +#include "window/window_session_controller.h" #include "styles/style_media_player.h" #include "styles/style_media_view.h" #include "styles/style_chat.h" // expandedMenuSeparator. @@ -443,7 +444,8 @@ void Widget::mouseReleaseEvent(QMouseEvent *e) { if (_labelsOver != downLabels) { return; } - if (_type == AudioMsgId::Type::Voice) { + if ((_type == AudioMsgId::Type::Voice) + || _lastSongFromAnotherSession) { const auto current = instance()->current(_type); const auto document = current.audio(); const auto context = current.contextId(); @@ -469,7 +471,9 @@ void Widget::updateOverLabelsState(QPoint pos) { void Widget::updateOverLabelsState(bool over) { _labelsOver = over; - auto pressShowsItem = _labelsOver && (_type == AudioMsgId::Type::Voice); + const auto pressShowsItem = _labelsOver + && ((_type == AudioMsgId::Type::Voice) + || _lastSongFromAnotherSession); setCursor(pressShowsItem ? style::cur_pointer : style::cur_default); _togglePlaylistRequests.fire(over && (_type == AudioMsgId::Type::Song)); } @@ -666,6 +670,8 @@ void Widget::updateTimeLabel() { void Widget::handleSongChange() { const auto current = instance()->current(_type); const auto document = current.audio(); + _lastSongFromAnotherSession = (document->session().uniqueId() + != _controller->session().uniqueId()); if (!current || !document || ((_lastSongId.audio() == document) @@ -674,7 +680,7 @@ void Widget::handleSongChange() { } _lastSongId = current; - TextWithEntities textWithEntities; + auto textWithEntities = TextWithEntities(); if (document->isVoiceMessage() || document->isVideoMessage()) { if (const auto item = document->owner().message(current.contextId())) { const auto name = (!item->out() || item->isPost()) diff --git a/Telegram/SourceFiles/media/player/media_player_widget.h b/Telegram/SourceFiles/media/player/media_player_widget.h index 65c179d9e..3ccc25dec 100644 --- a/Telegram/SourceFiles/media/player/media_player_widget.h +++ b/Telegram/SourceFiles/media/player/media_player_widget.h @@ -127,6 +127,7 @@ private: // We change _voiceIsActive to false only manually or from tracksFinished(). AudioMsgId::Type _type = AudioMsgId::Type::Unknown; AudioMsgId _lastSongId; + bool _lastSongFromAnotherSession = false; bool _voiceIsActive = false; Fn _closeCallback; Fn)> _showItemCallback;