Added ability to player to go to message for songs from another session.

This commit is contained in:
23rd 2024-08-28 08:49:34 +03:00
parent 1840da1d68
commit ad3e447f08
2 changed files with 10 additions and 3 deletions

View File

@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item_helpers.h" #include "history/history_item_helpers.h"
#include "storage/storage_account.h" #include "storage/storage_account.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "window/window_session_controller.h"
#include "styles/style_media_player.h" #include "styles/style_media_player.h"
#include "styles/style_media_view.h" #include "styles/style_media_view.h"
#include "styles/style_chat.h" // expandedMenuSeparator. #include "styles/style_chat.h" // expandedMenuSeparator.
@ -443,7 +444,8 @@ void Widget::mouseReleaseEvent(QMouseEvent *e) {
if (_labelsOver != downLabels) { if (_labelsOver != downLabels) {
return; return;
} }
if (_type == AudioMsgId::Type::Voice) { if ((_type == AudioMsgId::Type::Voice)
|| _lastSongFromAnotherSession) {
const auto current = instance()->current(_type); const auto current = instance()->current(_type);
const auto document = current.audio(); const auto document = current.audio();
const auto context = current.contextId(); const auto context = current.contextId();
@ -469,7 +471,9 @@ void Widget::updateOverLabelsState(QPoint pos) {
void Widget::updateOverLabelsState(bool over) { void Widget::updateOverLabelsState(bool over) {
_labelsOver = 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); setCursor(pressShowsItem ? style::cur_pointer : style::cur_default);
_togglePlaylistRequests.fire(over && (_type == AudioMsgId::Type::Song)); _togglePlaylistRequests.fire(over && (_type == AudioMsgId::Type::Song));
} }
@ -666,6 +670,8 @@ void Widget::updateTimeLabel() {
void Widget::handleSongChange() { void Widget::handleSongChange() {
const auto current = instance()->current(_type); const auto current = instance()->current(_type);
const auto document = current.audio(); const auto document = current.audio();
_lastSongFromAnotherSession = (document->session().uniqueId()
!= _controller->session().uniqueId());
if (!current if (!current
|| !document || !document
|| ((_lastSongId.audio() == document) || ((_lastSongId.audio() == document)
@ -674,7 +680,7 @@ void Widget::handleSongChange() {
} }
_lastSongId = current; _lastSongId = current;
TextWithEntities textWithEntities; auto textWithEntities = TextWithEntities();
if (document->isVoiceMessage() || document->isVideoMessage()) { if (document->isVoiceMessage() || document->isVideoMessage()) {
if (const auto item = document->owner().message(current.contextId())) { if (const auto item = document->owner().message(current.contextId())) {
const auto name = (!item->out() || item->isPost()) const auto name = (!item->out() || item->isPost())

View File

@ -127,6 +127,7 @@ private:
// We change _voiceIsActive to false only manually or from tracksFinished(). // We change _voiceIsActive to false only manually or from tracksFinished().
AudioMsgId::Type _type = AudioMsgId::Type::Unknown; AudioMsgId::Type _type = AudioMsgId::Type::Unknown;
AudioMsgId _lastSongId; AudioMsgId _lastSongId;
bool _lastSongFromAnotherSession = false;
bool _voiceIsActive = false; bool _voiceIsActive = false;
Fn<void()> _closeCallback; Fn<void()> _closeCallback;
Fn<void(not_null<const HistoryItem*>)> _showItemCallback; Fn<void(not_null<const HistoryItem*>)> _showItemCallback;