mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Allow float video player across accounts.
This commit is contained in:
parent
8171ed6c12
commit
bf7aae5fc6
38 changed files with 257 additions and 176 deletions
|
@ -61,12 +61,12 @@ bool TabbedSection::showInternal(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TabbedSection::wheelEventFromFloatPlayer(QEvent *e) {
|
bool TabbedSection::floatPlayerHandleWheelEvent(QEvent *e) {
|
||||||
return _selector->wheelEventFromFloatPlayer(e);
|
return _selector->floatPlayerHandleWheelEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect TabbedSection::rectForFloatPlayer() const {
|
QRect TabbedSection::floatPlayerAvailableRect() {
|
||||||
return _selector->rectForFloatPlayer();
|
return _selector->floatPlayerAvailableRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
TabbedSection::~TabbedSection() {
|
TabbedSection::~TabbedSection() {
|
||||||
|
|
|
@ -44,8 +44,8 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Float player interface.
|
// Float player interface.
|
||||||
bool wheelEventFromFloatPlayer(QEvent *e) override;
|
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
||||||
QRect rectForFloatPlayer() const override;
|
QRect floatPlayerAvailableRect() override;
|
||||||
|
|
||||||
~TabbedSection();
|
~TabbedSection();
|
||||||
|
|
||||||
|
|
|
@ -608,11 +608,11 @@ QImage TabbedSelector::grabForAnimation() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TabbedSelector::wheelEventFromFloatPlayer(QEvent *e) {
|
bool TabbedSelector::floatPlayerHandleWheelEvent(QEvent *e) {
|
||||||
return _scroll->viewportEvent(e);
|
return _scroll->viewportEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect TabbedSelector::rectForFloatPlayer() const {
|
QRect TabbedSelector::floatPlayerAvailableRect() const {
|
||||||
return mapToGlobal(_scroll->geometry());
|
return mapToGlobal(_scroll->geometry());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,8 +98,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Float player interface.
|
// Float player interface.
|
||||||
bool wheelEventFromFloatPlayer(QEvent *e);
|
bool floatPlayerHandleWheelEvent(QEvent *e);
|
||||||
QRect rectForFloatPlayer() const;
|
QRect floatPlayerAvailableRect() const;
|
||||||
|
|
||||||
auto showRequests() const {
|
auto showRequests() const {
|
||||||
return _showRequests.events();
|
return _showRequests.events();
|
||||||
|
|
|
@ -46,6 +46,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "media/audio/media_audio.h"
|
#include "media/audio/media_audio.h"
|
||||||
#include "media/audio/media_audio_track.h"
|
#include "media/audio/media_audio_track.h"
|
||||||
#include "media/player/media_player_instance.h"
|
#include "media/player/media_player_instance.h"
|
||||||
|
#include "media/player/media_player_float.h"
|
||||||
#include "media/clip/media_clip_reader.h" // For Media::Clip::Finish().
|
#include "media/clip/media_clip_reader.h" // For Media::Clip::Finish().
|
||||||
#include "window/notifications_manager.h"
|
#include "window/notifications_manager.h"
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
|
@ -512,6 +513,44 @@ void Application::startEmojiImageLoader() {
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::setDefaultFloatPlayerDelegate(
|
||||||
|
not_null<Media::Player::FloatDelegate*> delegate) {
|
||||||
|
Expects(!_defaultFloatPlayerDelegate == !_floatPlayers);
|
||||||
|
|
||||||
|
_defaultFloatPlayerDelegate = delegate;
|
||||||
|
_replacementFloatPlayerDelegate = nullptr;
|
||||||
|
if (_floatPlayers) {
|
||||||
|
_floatPlayers->replaceDelegate(delegate);
|
||||||
|
} else {
|
||||||
|
_floatPlayers = std::make_unique<Media::Player::FloatController>(
|
||||||
|
delegate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::replaceFloatPlayerDelegate(
|
||||||
|
not_null<Media::Player::FloatDelegate*> replacement) {
|
||||||
|
Expects(_floatPlayers != nullptr);
|
||||||
|
|
||||||
|
_replacementFloatPlayerDelegate = replacement;
|
||||||
|
_floatPlayers->replaceDelegate(replacement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::restoreFloatPlayerDelegate(
|
||||||
|
not_null<Media::Player::FloatDelegate*> replacement) {
|
||||||
|
Expects(_floatPlayers != nullptr);
|
||||||
|
|
||||||
|
if (_replacementFloatPlayerDelegate == replacement) {
|
||||||
|
_replacementFloatPlayerDelegate = nullptr;
|
||||||
|
_floatPlayers->replaceDelegate(_defaultFloatPlayerDelegate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<FullMsgId> Application::floatPlayerClosed() const {
|
||||||
|
Expects(_floatPlayers != nullptr);
|
||||||
|
|
||||||
|
return _floatPlayers->closeEvents();
|
||||||
|
}
|
||||||
|
|
||||||
void Application::logout(Main::Account *account) {
|
void Application::logout(Main::Account *account) {
|
||||||
if (account) {
|
if (account) {
|
||||||
account->logOut();
|
account->logOut();
|
||||||
|
|
|
@ -71,6 +71,10 @@ class Instance;
|
||||||
namespace View {
|
namespace View {
|
||||||
class OverlayWidget;
|
class OverlayWidget;
|
||||||
} // namespace View
|
} // namespace View
|
||||||
|
namespace Player {
|
||||||
|
class FloatController;
|
||||||
|
class FloatDelegate;
|
||||||
|
} // namespace Player
|
||||||
} // namespace Media
|
} // namespace Media
|
||||||
|
|
||||||
namespace Lang {
|
namespace Lang {
|
||||||
|
@ -218,6 +222,15 @@ public:
|
||||||
bool openLocalUrl(const QString &url, QVariant context);
|
bool openLocalUrl(const QString &url, QVariant context);
|
||||||
bool openInternalUrl(const QString &url, QVariant context);
|
bool openInternalUrl(const QString &url, QVariant context);
|
||||||
|
|
||||||
|
// Float player.
|
||||||
|
void setDefaultFloatPlayerDelegate(
|
||||||
|
not_null<Media::Player::FloatDelegate*> delegate);
|
||||||
|
void replaceFloatPlayerDelegate(
|
||||||
|
not_null<Media::Player::FloatDelegate*> replacement);
|
||||||
|
void restoreFloatPlayerDelegate(
|
||||||
|
not_null<Media::Player::FloatDelegate*> replacement);
|
||||||
|
[[nodiscard]] rpl::producer<FullMsgId> floatPlayerClosed() const;
|
||||||
|
|
||||||
void logout(Main::Account *account = nullptr);
|
void logout(Main::Account *account = nullptr);
|
||||||
void forceLogOut(
|
void forceLogOut(
|
||||||
not_null<Main::Account*> account,
|
not_null<Main::Account*> account,
|
||||||
|
@ -320,6 +333,10 @@ private:
|
||||||
|
|
||||||
const std::unique_ptr<Media::Audio::Instance> _audio;
|
const std::unique_ptr<Media::Audio::Instance> _audio;
|
||||||
|
|
||||||
|
std::unique_ptr<Media::Player::FloatController> _floatPlayers;
|
||||||
|
Media::Player::FloatDelegate *_defaultFloatPlayerDelegate = nullptr;
|
||||||
|
Media::Player::FloatDelegate *_replacementFloatPlayerDelegate = nullptr;
|
||||||
|
|
||||||
// Notifications should be destroyed before _audio.
|
// Notifications should be destroyed before _audio.
|
||||||
// Mutable because is created in run() after OpenSSL is inited.
|
// Mutable because is created in run() after OpenSSL is inited.
|
||||||
std::unique_ptr<Window::Notifications::System> _notifications;
|
std::unique_ptr<Window::Notifications::System> _notifications;
|
||||||
|
|
|
@ -671,11 +671,11 @@ void Widget::startSlideAnimation() {
|
||||||
_a_show.start([=] { animationCallback(); }, 0., 1., st::slideDuration, Window::SlideAnimation::transition());
|
_a_show.start([=] { animationCallback(); }, 0., 1., st::slideDuration, Window::SlideAnimation::transition());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Widget::wheelEventFromFloatPlayer(QEvent *e) {
|
bool Widget::floatPlayerHandleWheelEvent(QEvent *e) {
|
||||||
return _scroll->viewportEvent(e);
|
return _scroll->viewportEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect Widget::rectForFloatPlayer() const {
|
QRect Widget::floatPlayerAvailableRect() {
|
||||||
return mapToGlobal(_scroll->geometry());
|
return mapToGlobal(_scroll->geometry());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1596,7 +1596,7 @@ void Widget::updateControlsGeometry() {
|
||||||
_scroll->setGeometry(0, scrollTop, width(), scrollHeight);
|
_scroll->setGeometry(0, scrollTop, width(), scrollHeight);
|
||||||
_inner->resize(width(), _inner->height());
|
_inner->resize(width(), _inner->height());
|
||||||
if (scrollHeight != wasScrollHeight) {
|
if (scrollHeight != wasScrollHeight) {
|
||||||
controller()->floatPlayerAreaUpdated().notify(true);
|
controller()->floatPlayerAreaUpdated();
|
||||||
}
|
}
|
||||||
if (_topDelta) {
|
if (_topDelta) {
|
||||||
_scroll->scrollToY(newScrollTop);
|
_scroll->scrollToY(newScrollTop);
|
||||||
|
|
|
@ -83,8 +83,8 @@ public:
|
||||||
void onSearchMore();
|
void onSearchMore();
|
||||||
|
|
||||||
// Float player interface.
|
// Float player interface.
|
||||||
bool wheelEventFromFloatPlayer(QEvent *e) override;
|
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
||||||
QRect rectForFloatPlayer() const override;
|
QRect floatPlayerAvailableRect() override;
|
||||||
|
|
||||||
~Widget();
|
~Widget();
|
||||||
|
|
||||||
|
|
|
@ -52,10 +52,11 @@ void SuggestBox::prepare() {
|
||||||
setTitle(tr::lng_export_suggest_title());
|
setTitle(tr::lng_export_suggest_title());
|
||||||
|
|
||||||
addButton(tr::lng_box_ok(), [=] {
|
addButton(tr::lng_box_ok(), [=] {
|
||||||
|
const auto session = _session;
|
||||||
closeBox();
|
closeBox();
|
||||||
Core::App().exportManager().start(
|
Core::App().exportManager().start(
|
||||||
_session,
|
session,
|
||||||
_session->local().readExportSettings().singlePeer);
|
session->local().readExportSettings().singlePeer);
|
||||||
});
|
});
|
||||||
addButton(tr::lng_export_suggest_cancel(), [=] { closeBox(); });
|
addButton(tr::lng_export_suggest_cancel(), [=] { closeBox(); });
|
||||||
setCloseByOutsideClick(false);
|
setCloseByOutsideClick(false);
|
||||||
|
|
|
@ -326,7 +326,7 @@ void InnerWidget::visibleTopBottomUpdated(
|
||||||
} else {
|
} else {
|
||||||
scrollDateHideByTimer();
|
scrollDateHideByTimer();
|
||||||
}
|
}
|
||||||
_controller->floatPlayerAreaUpdated().notify(true);
|
_controller->floatPlayerAreaUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::updateVisibleTopItem() {
|
void InnerWidget::updateVisibleTopItem() {
|
||||||
|
|
|
@ -453,11 +453,11 @@ void Widget::showFinishedHook() {
|
||||||
_fixedBar->setAnimatingMode(false);
|
_fixedBar->setAnimatingMode(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Widget::wheelEventFromFloatPlayer(QEvent *e) {
|
bool Widget::floatPlayerHandleWheelEvent(QEvent *e) {
|
||||||
return _scroll->viewportEvent(e);
|
return _scroll->viewportEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect Widget::rectForFloatPlayer() const {
|
QRect Widget::floatPlayerAvailableRect() {
|
||||||
return mapToGlobal(_scroll->geometry());
|
return mapToGlobal(_scroll->geometry());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,8 @@ public:
|
||||||
void setInternalState(const QRect &geometry, not_null<SectionMemento*> memento);
|
void setInternalState(const QRect &geometry, not_null<SectionMemento*> memento);
|
||||||
|
|
||||||
// Float player interface.
|
// Float player interface.
|
||||||
bool wheelEventFromFloatPlayer(QEvent *e) override;
|
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
||||||
QRect rectForFloatPlayer() const override;
|
QRect floatPlayerAvailableRect() override;
|
||||||
|
|
||||||
void applyFilter(FilterValue &&value);
|
void applyFilter(FilterValue &&value);
|
||||||
|
|
||||||
|
|
|
@ -2011,6 +2011,7 @@ void HistoryWidget::showHistory(
|
||||||
FullMsgId(_history->channelId(), _showAtMsgId) });
|
FullMsgId(_history->channelId(), _showAtMsgId) });
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
|
controller()->floatPlayerAreaUpdated();
|
||||||
|
|
||||||
crl::on_main(App::wnd(), [] { App::wnd()->setInnerFocus(); });
|
crl::on_main(App::wnd(), [] { App::wnd()->setInnerFocus(); });
|
||||||
}
|
}
|
||||||
|
@ -2889,7 +2890,7 @@ void HistoryWidget::visibleAreaUpdated() {
|
||||||
const auto scrollTop = _scroll->scrollTop();
|
const auto scrollTop = _scroll->scrollTop();
|
||||||
const auto scrollBottom = scrollTop + _scroll->height();
|
const auto scrollBottom = scrollTop + _scroll->height();
|
||||||
_list->visibleAreaUpdated(scrollTop, scrollBottom);
|
_list->visibleAreaUpdated(scrollTop, scrollBottom);
|
||||||
controller()->floatPlayerAreaUpdated().notify(true);
|
controller()->floatPlayerAreaUpdated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3846,12 +3847,12 @@ bool HistoryWidget::eventFilter(QObject *obj, QEvent *e) {
|
||||||
return TWidget::eventFilter(obj, e);
|
return TWidget::eventFilter(obj, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::wheelEventFromFloatPlayer(QEvent *e) {
|
bool HistoryWidget::floatPlayerHandleWheelEvent(QEvent *e) {
|
||||||
return _scroll->viewportEvent(e);
|
return _peer ? _scroll->viewportEvent(e) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect HistoryWidget::rectForFloatPlayer() const {
|
QRect HistoryWidget::floatPlayerAvailableRect() {
|
||||||
return mapToGlobal(_scroll->geometry());
|
return _peer ? mapToGlobal(_scroll->geometry()) : mapToGlobal(rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::updateDragAreas() {
|
void HistoryWidget::updateDragAreas() {
|
||||||
|
@ -5116,7 +5117,7 @@ void HistoryWidget::updateHistoryGeometry(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
controller()->floatPlayerAreaUpdated().notify(true);
|
controller()->floatPlayerAreaUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateListSize();
|
updateListSize();
|
||||||
|
|
|
@ -264,8 +264,8 @@ public:
|
||||||
bool returnTabbedSelector() override;
|
bool returnTabbedSelector() override;
|
||||||
|
|
||||||
// Float player interface.
|
// Float player interface.
|
||||||
bool wheelEventFromFloatPlayer(QEvent *e) override;
|
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
||||||
QRect rectForFloatPlayer() const override;
|
QRect floatPlayerAvailableRect() override;
|
||||||
|
|
||||||
void app_sendBotCallback(
|
void app_sendBotCallback(
|
||||||
not_null<const HistoryMessageMarkupButton*> button,
|
not_null<const HistoryMessageMarkupButton*> button,
|
||||||
|
|
|
@ -602,7 +602,7 @@ void ListWidget::visibleTopBottomUpdated(
|
||||||
} else {
|
} else {
|
||||||
scrollDateHideByTimer();
|
scrollDateHideByTimer();
|
||||||
}
|
}
|
||||||
_controller->floatPlayerAreaUpdated().notify(true);
|
_controller->floatPlayerAreaUpdated();
|
||||||
_applyUpdatedScrollState.call();
|
_applyUpdatedScrollState.call();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -882,11 +882,11 @@ void ScheduledWidget::showFinishedHook() {
|
||||||
_composeControls->showFinished();
|
_composeControls->showFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScheduledWidget::wheelEventFromFloatPlayer(QEvent *e) {
|
bool ScheduledWidget::floatPlayerHandleWheelEvent(QEvent *e) {
|
||||||
return _scroll->viewportEvent(e);
|
return _scroll->viewportEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect ScheduledWidget::rectForFloatPlayer() const {
|
QRect ScheduledWidget::floatPlayerAvailableRect() {
|
||||||
return mapToGlobal(_scroll->geometry());
|
return mapToGlobal(_scroll->geometry());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,8 @@ public:
|
||||||
bool returnTabbedSelector() override;
|
bool returnTabbedSelector() override;
|
||||||
|
|
||||||
// Float player interface.
|
// Float player interface.
|
||||||
bool wheelEventFromFloatPlayer(QEvent *e) override;
|
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
||||||
QRect rectForFloatPlayer() const override;
|
QRect floatPlayerAvailableRect() override;
|
||||||
|
|
||||||
// ListDelegate interface.
|
// ListDelegate interface.
|
||||||
Context listContext() override;
|
Context listContext() override;
|
||||||
|
|
|
@ -214,11 +214,11 @@ void ContentWidget::scrollTo(const Ui::ScrollToRequest &request) {
|
||||||
_scroll->scrollTo(request);
|
_scroll->scrollTo(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContentWidget::wheelEventFromFloatPlayer(QEvent *e) {
|
bool ContentWidget::floatPlayerHandleWheelEvent(QEvent *e) {
|
||||||
return _scroll->viewportEvent(e);
|
return _scroll->viewportEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect ContentWidget::rectForFloatPlayer() const {
|
QRect ContentWidget::floatPlayerAvailableRect() const {
|
||||||
return mapToGlobal(_scroll->geometry());
|
return mapToGlobal(_scroll->geometry());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,8 @@ public:
|
||||||
rpl::producer<int> scrollTillBottomChanges() const;
|
rpl::producer<int> scrollTillBottomChanges() const;
|
||||||
|
|
||||||
// Float player interface.
|
// Float player interface.
|
||||||
bool wheelEventFromFloatPlayer(QEvent *e);
|
bool floatPlayerHandleWheelEvent(QEvent *e);
|
||||||
QRect rectForFloatPlayer() const;
|
QRect floatPlayerAvailableRect() const;
|
||||||
|
|
||||||
virtual rpl::producer<SelectedItems> selectedListValue() const;
|
virtual rpl::producer<SelectedItems> selectedListValue() const;
|
||||||
virtual void cancelSelection() {
|
virtual void cancelSelection() {
|
||||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/main_window.h"
|
#include "window/main_window.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
|
#include "core/application.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
#include "styles/style_window.h"
|
#include "styles/style_window.h"
|
||||||
|
@ -31,7 +32,7 @@ LayerWidget::LayerWidget(
|
||||||
: _controller(controller)
|
: _controller(controller)
|
||||||
, _content(this, controller, Wrap::Layer, memento) {
|
, _content(this, controller, Wrap::Layer, memento) {
|
||||||
setupHeightConsumers();
|
setupHeightConsumers();
|
||||||
_controller->replaceFloatPlayerDelegate(floatPlayerDelegate());
|
Core::App().replaceFloatPlayerDelegate(floatPlayerDelegate());
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerWidget::LayerWidget(
|
LayerWidget::LayerWidget(
|
||||||
|
@ -40,7 +41,7 @@ LayerWidget::LayerWidget(
|
||||||
: _controller(controller)
|
: _controller(controller)
|
||||||
, _content(memento->takeContent(this, Wrap::Layer)) {
|
, _content(memento->takeContent(this, Wrap::Layer)) {
|
||||||
setupHeightConsumers();
|
setupHeightConsumers();
|
||||||
_controller->replaceFloatPlayerDelegate(floatPlayerDelegate());
|
Core::App().replaceFloatPlayerDelegate(floatPlayerDelegate());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto LayerWidget::floatPlayerDelegate()
|
auto LayerWidget::floatPlayerDelegate()
|
||||||
|
@ -52,19 +53,15 @@ not_null<Ui::RpWidget*> LayerWidget::floatPlayerWidget() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<Window::SessionController*> LayerWidget::floatPlayerController() {
|
auto LayerWidget::floatPlayerGetSection(Window::Column column)
|
||||||
return _controller;
|
-> not_null<::Media::Player::FloatSectionDelegate*> {
|
||||||
}
|
|
||||||
|
|
||||||
not_null<Window::AbstractSectionWidget*> LayerWidget::floatPlayerGetSection(
|
|
||||||
Window::Column column) {
|
|
||||||
Expects(_content != nullptr);
|
Expects(_content != nullptr);
|
||||||
|
|
||||||
return _content;
|
return _content;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerWidget::floatPlayerEnumerateSections(Fn<void(
|
void LayerWidget::floatPlayerEnumerateSections(Fn<void(
|
||||||
not_null<Window::AbstractSectionWidget*> widget,
|
not_null<::Media::Player::FloatSectionDelegate*> widget,
|
||||||
Window::Column widgetColumn)> callback) {
|
Window::Column widgetColumn)> callback) {
|
||||||
Expects(_content != nullptr);
|
Expects(_content != nullptr);
|
||||||
|
|
||||||
|
@ -285,7 +282,7 @@ void LayerWidget::paintEvent(QPaintEvent *e) {
|
||||||
void LayerWidget::restoreFloatPlayerDelegate() {
|
void LayerWidget::restoreFloatPlayerDelegate() {
|
||||||
if (!_floatPlayerDelegateRestored) {
|
if (!_floatPlayerDelegateRestored) {
|
||||||
_floatPlayerDelegateRestored = true;
|
_floatPlayerDelegateRestored = true;
|
||||||
_controller->restoreFloatPlayerDelegate(floatPlayerDelegate());
|
Core::App().restoreFloatPlayerDelegate(floatPlayerDelegate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,11 +58,10 @@ private:
|
||||||
void restoreFloatPlayerDelegate();
|
void restoreFloatPlayerDelegate();
|
||||||
not_null<::Media::Player::FloatDelegate*> floatPlayerDelegate();
|
not_null<::Media::Player::FloatDelegate*> floatPlayerDelegate();
|
||||||
not_null<Ui::RpWidget*> floatPlayerWidget() override;
|
not_null<Ui::RpWidget*> floatPlayerWidget() override;
|
||||||
not_null<Window::SessionController*> floatPlayerController() override;
|
not_null<::Media::Player::FloatSectionDelegate*> floatPlayerGetSection(
|
||||||
not_null<Window::AbstractSectionWidget*> floatPlayerGetSection(
|
|
||||||
Window::Column column) override;
|
Window::Column column) override;
|
||||||
void floatPlayerEnumerateSections(Fn<void(
|
void floatPlayerEnumerateSections(Fn<void(
|
||||||
not_null<Window::AbstractSectionWidget*> widget,
|
not_null<::Media::Player::FloatSectionDelegate*> widget,
|
||||||
Window::Column widgetColumn)> callback) override;
|
Window::Column widgetColumn)> callback) override;
|
||||||
bool floatPlayerIsVisible(not_null<HistoryItem*> item) override;
|
bool floatPlayerIsVisible(not_null<HistoryItem*> item) override;
|
||||||
|
|
||||||
|
|
|
@ -108,12 +108,12 @@ object_ptr<Ui::LayerWidget> SectionWidget::moveContentToLayer(
|
||||||
bodyGeometry);
|
bodyGeometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SectionWidget::wheelEventFromFloatPlayer(QEvent *e) {
|
bool SectionWidget::floatPlayerHandleWheelEvent(QEvent *e) {
|
||||||
return _content->wheelEventFromFloatPlayer(e);
|
return _content->floatPlayerHandleWheelEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect SectionWidget::rectForFloatPlayer() const {
|
QRect SectionWidget::floatPlayerAvailableRect() {
|
||||||
return _content->rectForFloatPlayer();
|
return _content->floatPlayerAvailableRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Info
|
} // namespace Info
|
||||||
|
|
|
@ -54,8 +54,8 @@ public:
|
||||||
QRect bodyGeometry) override;
|
QRect bodyGeometry) override;
|
||||||
|
|
||||||
// Float player interface.
|
// Float player interface.
|
||||||
bool wheelEventFromFloatPlayer(QEvent *e) override;
|
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
||||||
QRect rectForFloatPlayer() const override;
|
QRect floatPlayerAvailableRect() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void doSetInnerFocus() override;
|
void doSetInnerFocus() override;
|
||||||
|
|
|
@ -1026,12 +1026,12 @@ void WrapWidget::updateContentGeometry() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WrapWidget::wheelEventFromFloatPlayer(QEvent *e) {
|
bool WrapWidget::floatPlayerHandleWheelEvent(QEvent *e) {
|
||||||
return _content->wheelEventFromFloatPlayer(e);
|
return _content->floatPlayerHandleWheelEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect WrapWidget::rectForFloatPlayer() const {
|
QRect WrapWidget::floatPlayerAvailableRect() {
|
||||||
return _content->rectForFloatPlayer();
|
return _content->floatPlayerAvailableRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
object_ptr<Ui::RpWidget> WrapWidget::createTopBarSurrogate(
|
object_ptr<Ui::RpWidget> WrapWidget::createTopBarSurrogate(
|
||||||
|
|
|
@ -108,8 +108,8 @@ public:
|
||||||
void updateInternalState(not_null<Memento*> memento);
|
void updateInternalState(not_null<Memento*> memento);
|
||||||
|
|
||||||
// Float player interface.
|
// Float player interface.
|
||||||
bool wheelEventFromFloatPlayer(QEvent *e) override;
|
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
||||||
QRect rectForFloatPlayer() const override;
|
QRect floatPlayerAvailableRect() override;
|
||||||
|
|
||||||
object_ptr<Ui::RpWidget> createTopBarSurrogate(QWidget *parent);
|
object_ptr<Ui::RpWidget> createTopBarSurrogate(QWidget *parent);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "mtproto/mtproto_dc_options.h"
|
#include "mtproto/mtproto_dc_options.h"
|
||||||
#include "window/window_slide_animation.h"
|
#include "window/window_slide_animation.h"
|
||||||
#include "window/window_connecting_widget.h"
|
#include "window/window_connecting_widget.h"
|
||||||
|
#include "window/section_widget.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "api/api_text_entities.h"
|
#include "api/api_text_entities.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
@ -62,6 +63,8 @@ Widget::Widget(
|
||||||
this,
|
this,
|
||||||
account,
|
account,
|
||||||
rpl::single(true))) {
|
rpl::single(true))) {
|
||||||
|
Core::App().setDefaultFloatPlayerDelegate(floatPlayerDelegate());
|
||||||
|
|
||||||
switch (point) {
|
switch (point) {
|
||||||
case EnterPoint::Start:
|
case EnterPoint::Start:
|
||||||
appendStep(new StartWidget(this, _account, getData()));
|
appendStep(new StartWidget(this, _account, getData()));
|
||||||
|
@ -130,6 +133,42 @@ Widget::Widget(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
not_null<Media::Player::FloatDelegate*> Widget::floatPlayerDelegate() {
|
||||||
|
return static_cast<Media::Player::FloatDelegate*>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Widget::floatPlayerSectionDelegate()
|
||||||
|
-> not_null<Media::Player::FloatSectionDelegate*> {
|
||||||
|
return static_cast<Media::Player::FloatSectionDelegate*>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
not_null<Ui::RpWidget*> Widget::floatPlayerWidget() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Widget::floatPlayerGetSection(Window::Column column)
|
||||||
|
-> not_null<Media::Player::FloatSectionDelegate*> {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::floatPlayerEnumerateSections(Fn<void(
|
||||||
|
not_null<Media::Player::FloatSectionDelegate*> widget,
|
||||||
|
Window::Column widgetColumn)> callback) {
|
||||||
|
callback(this, Window::Column::Second);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Widget::floatPlayerIsVisible(not_null<HistoryItem*> item) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect Widget::floatPlayerAvailableRect() {
|
||||||
|
return mapToGlobal(rect());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Widget::floatPlayerHandleWheelEvent(QEvent *e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Widget::refreshLang() {
|
void Widget::refreshLang() {
|
||||||
_changeLanguage.destroy();
|
_changeLanguage.destroy();
|
||||||
createLanguageLink();
|
createLanguageLink();
|
||||||
|
@ -310,6 +349,7 @@ void Widget::fixOrder() {
|
||||||
if (_changeLanguage) _changeLanguage->raise();
|
if (_changeLanguage) _changeLanguage->raise();
|
||||||
_settings->raise();
|
_settings->raise();
|
||||||
_back->raise();
|
_back->raise();
|
||||||
|
floatPlayerRaiseAll();
|
||||||
_connecting->raise();
|
_connecting->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,8 +650,10 @@ void Widget::showAnimated(const QPixmap &bgAnimCache, bool back) {
|
||||||
|
|
||||||
_a_show.stop();
|
_a_show.stop();
|
||||||
showControls();
|
showControls();
|
||||||
|
floatPlayerHideAll();
|
||||||
(_showBack ? _cacheUnder : _cacheOver) = Ui::GrabWidget(this);
|
(_showBack ? _cacheUnder : _cacheOver) = Ui::GrabWidget(this);
|
||||||
hideControls();
|
hideControls();
|
||||||
|
floatPlayerShowVisible();
|
||||||
|
|
||||||
_a_show.start(
|
_a_show.start(
|
||||||
[=] { animationCallback(); },
|
[=] { animationCallback(); },
|
||||||
|
@ -665,6 +707,7 @@ void Widget::resizeEvent(QResizeEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
|
floatPlayerAreaUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::updateControlsGeometry() {
|
void Widget::updateControlsGeometry() {
|
||||||
|
@ -732,7 +775,6 @@ Widget::~Widget() {
|
||||||
for (auto step : base::take(_stepHistory)) {
|
for (auto step : base::take(_stepHistory)) {
|
||||||
delete step;
|
delete step;
|
||||||
}
|
}
|
||||||
if (App::wnd()) App::wnd()->noIntro(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Intro
|
} // namespace Intro
|
||||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
#include "window/window_lock_widgets.h"
|
#include "window/window_lock_widgets.h"
|
||||||
#include "core/core_cloud_password.h"
|
#include "core/core_cloud_password.h"
|
||||||
|
#include "media/player/media_player_float.h"
|
||||||
|
|
||||||
namespace Main {
|
namespace Main {
|
||||||
class Account;
|
class Account;
|
||||||
|
@ -83,7 +84,11 @@ enum class EnterPoint : uchar {
|
||||||
Qr,
|
Qr,
|
||||||
};
|
};
|
||||||
|
|
||||||
class Widget : public Ui::RpWidget, private base::Subscriber {
|
class Widget
|
||||||
|
: public Ui::RpWidget
|
||||||
|
, private Media::Player::FloatDelegate
|
||||||
|
, private Media::Player::FloatSectionDelegate
|
||||||
|
, private base::Subscriber {
|
||||||
public:
|
public:
|
||||||
Widget(
|
Widget(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
|
@ -143,6 +148,23 @@ private:
|
||||||
void getNearestDC();
|
void getNearestDC();
|
||||||
void showTerms(Fn<void()> callback);
|
void showTerms(Fn<void()> callback);
|
||||||
|
|
||||||
|
// FloatDelegate
|
||||||
|
[[nodiscard]] auto floatPlayerDelegate()
|
||||||
|
-> not_null<Media::Player::FloatDelegate*>;
|
||||||
|
[[nodiscard]] auto floatPlayerSectionDelegate()
|
||||||
|
-> not_null<Media::Player::FloatSectionDelegate*>;
|
||||||
|
not_null<Ui::RpWidget*> floatPlayerWidget() override;
|
||||||
|
not_null<Media::Player::FloatSectionDelegate*> floatPlayerGetSection(
|
||||||
|
Window::Column column) override;
|
||||||
|
void floatPlayerEnumerateSections(Fn<void(
|
||||||
|
not_null<Media::Player::FloatSectionDelegate*> widget,
|
||||||
|
Window::Column widgetColumn)> callback) override;
|
||||||
|
bool floatPlayerIsVisible(not_null<HistoryItem*> item) override;
|
||||||
|
|
||||||
|
// FloatSectionDelegate
|
||||||
|
QRect floatPlayerAvailableRect() override;
|
||||||
|
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
||||||
|
|
||||||
const not_null<Main::Account*> _account;
|
const not_null<Main::Account*> _account;
|
||||||
std::optional<MTP::Sender> _api;
|
std::optional<MTP::Sender> _api;
|
||||||
|
|
||||||
|
|
|
@ -239,12 +239,6 @@ MainWidget::MainWidget(
|
||||||
, _cacheBackgroundTimer([=] { cacheBackground(); })
|
, _cacheBackgroundTimer([=] { cacheBackground(); })
|
||||||
, _viewsIncrementTimer([=] { viewsIncrement(); })
|
, _viewsIncrementTimer([=] { viewsIncrement(); })
|
||||||
, _changelogs(Core::Changelogs::Create(&controller->session())) {
|
, _changelogs(Core::Changelogs::Create(&controller->session())) {
|
||||||
_controller->setDefaultFloatPlayerDelegate(floatPlayerDelegate());
|
|
||||||
_controller->floatPlayerClosed(
|
|
||||||
) | rpl::start_with_next([=](FullMsgId itemId) {
|
|
||||||
floatPlayerClosed(itemId);
|
|
||||||
}, lifetime());
|
|
||||||
|
|
||||||
updateScrollColors();
|
updateScrollColors();
|
||||||
setupConnectingWidget();
|
setupConnectingWidget();
|
||||||
|
|
||||||
|
@ -255,6 +249,12 @@ MainWidget::MainWidget(
|
||||||
setCurrentCall(call);
|
setCurrentCall(call);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Core::App().setDefaultFloatPlayerDelegate(floatPlayerDelegate());
|
||||||
|
Core::App().floatPlayerClosed(
|
||||||
|
) | rpl::start_with_next([=](FullMsgId itemId) {
|
||||||
|
floatPlayerClosed(itemId);
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
Core::App().exportManager().currentView(
|
Core::App().exportManager().currentView(
|
||||||
) | rpl::start_with_next([=](Export::View::PanelController *view) {
|
) | rpl::start_with_next([=](Export::View::PanelController *view) {
|
||||||
setCurrentExportView(view);
|
setCurrentExportView(view);
|
||||||
|
@ -396,12 +396,8 @@ not_null<Ui::RpWidget*> MainWidget::floatPlayerWidget() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<Window::SessionController*> MainWidget::floatPlayerController() {
|
auto MainWidget::floatPlayerGetSection(Window::Column column)
|
||||||
return _controller;
|
-> not_null<Media::Player::FloatSectionDelegate*> {
|
||||||
}
|
|
||||||
|
|
||||||
not_null<Window::AbstractSectionWidget*> MainWidget::floatPlayerGetSection(
|
|
||||||
Window::Column column) {
|
|
||||||
if (Adaptive::ThreeColumn()) {
|
if (Adaptive::ThreeColumn()) {
|
||||||
if (column == Window::Column::First) {
|
if (column == Window::Column::First) {
|
||||||
return _dialogs;
|
return _dialogs;
|
||||||
|
@ -432,7 +428,7 @@ not_null<Window::AbstractSectionWidget*> MainWidget::floatPlayerGetSection(
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::floatPlayerEnumerateSections(Fn<void(
|
void MainWidget::floatPlayerEnumerateSections(Fn<void(
|
||||||
not_null<Window::AbstractSectionWidget*> widget,
|
not_null<Media::Player::FloatSectionDelegate*> widget,
|
||||||
Window::Column widgetColumn)> callback) {
|
Window::Column widgetColumn)> callback) {
|
||||||
if (Adaptive::ThreeColumn()) {
|
if (Adaptive::ThreeColumn()) {
|
||||||
callback(_dialogs, Window::Column::First);
|
callback(_dialogs, Window::Column::First);
|
||||||
|
@ -1967,8 +1963,10 @@ void MainWidget::showAnimated(const QPixmap &bgAnimCache, bool back) {
|
||||||
_a_show.stop();
|
_a_show.stop();
|
||||||
|
|
||||||
showAll();
|
showAll();
|
||||||
|
floatPlayerHideAll();
|
||||||
(_showBack ? _cacheUnder : _cacheOver) = Ui::GrabWidget(this);
|
(_showBack ? _cacheUnder : _cacheOver) = Ui::GrabWidget(this);
|
||||||
hideAll();
|
hideAll();
|
||||||
|
floatPlayerShowVisible();
|
||||||
|
|
||||||
_a_show.start(
|
_a_show.start(
|
||||||
[this] { animationCallback(); },
|
[this] { animationCallback(); },
|
||||||
|
@ -2038,7 +2036,6 @@ void MainWidget::hideAll() {
|
||||||
_player->setVisible(false);
|
_player->setVisible(false);
|
||||||
_playerHeight = 0;
|
_playerHeight = 0;
|
||||||
}
|
}
|
||||||
floatPlayerHideAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::showAll() {
|
void MainWidget::showAll() {
|
||||||
|
@ -2096,7 +2093,6 @@ void MainWidget::showAll() {
|
||||||
}
|
}
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
floatPlayerCheckVisibility();
|
floatPlayerCheckVisibility();
|
||||||
floatPlayerShowVisible();
|
|
||||||
|
|
||||||
App::wnd()->checkHistoryActivation();
|
App::wnd()->checkHistoryActivation();
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,8 +99,8 @@ class ItemBase;
|
||||||
|
|
||||||
class MainWidget
|
class MainWidget
|
||||||
: public Ui::RpWidget
|
: public Ui::RpWidget
|
||||||
, private base::Subscriber
|
, private Media::Player::FloatDelegate
|
||||||
, private Media::Player::FloatDelegate {
|
, private base::Subscriber {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -234,6 +234,8 @@ public:
|
||||||
void notify_inlineKeyboardMoved(not_null<const HistoryItem*> item, int oldKeyboardTop, int newKeyboardTop);
|
void notify_inlineKeyboardMoved(not_null<const HistoryItem*> item, int oldKeyboardTop, int newKeyboardTop);
|
||||||
bool notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo);
|
bool notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo);
|
||||||
|
|
||||||
|
using FloatDelegate::floatPlayerAreaUpdated;
|
||||||
|
|
||||||
void closeBothPlayers();
|
void closeBothPlayers();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -314,13 +316,13 @@ private:
|
||||||
void cacheBackground();
|
void cacheBackground();
|
||||||
void clearCachedBackground();
|
void clearCachedBackground();
|
||||||
|
|
||||||
not_null<Media::Player::FloatDelegate*> floatPlayerDelegate();
|
[[nodiscard]] auto floatPlayerDelegate()
|
||||||
|
-> not_null<Media::Player::FloatDelegate*>;
|
||||||
not_null<Ui::RpWidget*> floatPlayerWidget() override;
|
not_null<Ui::RpWidget*> floatPlayerWidget() override;
|
||||||
not_null<Window::SessionController*> floatPlayerController() override;
|
not_null<Media::Player::FloatSectionDelegate*> floatPlayerGetSection(
|
||||||
not_null<Window::AbstractSectionWidget*> floatPlayerGetSection(
|
|
||||||
Window::Column column) override;
|
Window::Column column) override;
|
||||||
void floatPlayerEnumerateSections(Fn<void(
|
void floatPlayerEnumerateSections(Fn<void(
|
||||||
not_null<Window::AbstractSectionWidget*> widget,
|
not_null<Media::Player::FloatSectionDelegate*> widget,
|
||||||
Window::Column widgetColumn)> callback) override;
|
Window::Column widgetColumn)> callback) override;
|
||||||
bool floatPlayerIsVisible(not_null<HistoryItem*> item) override;
|
bool floatPlayerIsVisible(not_null<HistoryItem*> item) override;
|
||||||
void floatPlayerClosed(FullMsgId itemId);
|
void floatPlayerClosed(FullMsgId itemId);
|
||||||
|
|
|
@ -262,8 +262,10 @@ void MainWindow::setupIntro(Intro::EnterPoint point) {
|
||||||
auto animated = (_main || _passcodeLock);
|
auto animated = (_main || _passcodeLock);
|
||||||
auto bg = animated ? grabInner() : QPixmap();
|
auto bg = animated ? grabInner() : QPixmap();
|
||||||
|
|
||||||
|
destroyLayer();
|
||||||
|
auto created = object_ptr<Intro::Widget>(bodyWidget(), &account(), point);
|
||||||
clearWidgets();
|
clearWidgets();
|
||||||
_intro.create(bodyWidget(), &account(), point);
|
_intro = std::move(created);
|
||||||
if (_passcodeLock) {
|
if (_passcodeLock) {
|
||||||
_intro->hide();
|
_intro->hide();
|
||||||
} else {
|
} else {
|
||||||
|
@ -284,6 +286,7 @@ void MainWindow::setupMain() {
|
||||||
auto animated = (_intro || _passcodeLock);
|
auto animated = (_intro || _passcodeLock);
|
||||||
auto bg = animated ? grabInner() : QPixmap();
|
auto bg = animated ? grabInner() : QPixmap();
|
||||||
|
|
||||||
|
destroyLayer();
|
||||||
auto created = object_ptr<MainWidget>(bodyWidget(), sessionController());
|
auto created = object_ptr<MainWidget>(bodyWidget(), sessionController());
|
||||||
clearWidgets();
|
clearWidgets();
|
||||||
_main = std::move(created);
|
_main = std::move(created);
|
||||||
|
@ -711,12 +714,6 @@ void MainWindow::activate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::noIntro(Intro::Widget *was) {
|
|
||||||
if (was == _intro) {
|
|
||||||
_intro = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MainWindow::takeThirdSectionFromLayer() {
|
bool MainWindow::takeThirdSectionFromLayer() {
|
||||||
return _layer ? _layer->takeToThirdSection() : false;
|
return _layer ? _layer->takeToThirdSection() : false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,6 @@ public:
|
||||||
|
|
||||||
void activate();
|
void activate();
|
||||||
|
|
||||||
void noIntro(Intro::Widget *was);
|
|
||||||
bool takeThirdSectionFromLayer();
|
bool takeThirdSectionFromLayer();
|
||||||
|
|
||||||
void checkHistoryActivation();
|
void checkHistoryActivation();
|
||||||
|
|
|
@ -286,12 +286,7 @@ FloatController::Item::Item(
|
||||||
|
|
||||||
FloatController::FloatController(not_null<FloatDelegate*> delegate)
|
FloatController::FloatController(not_null<FloatDelegate*> delegate)
|
||||||
: _delegate(delegate)
|
: _delegate(delegate)
|
||||||
, _parent(_delegate->floatPlayerWidget())
|
, _parent(_delegate->floatPlayerWidget()) {
|
||||||
, _controller(_delegate->floatPlayerController()) {
|
|
||||||
subscribe(_controller->floatPlayerAreaUpdated(), [=] {
|
|
||||||
checkVisibility();
|
|
||||||
});
|
|
||||||
|
|
||||||
subscribe(Media::Player::instance()->trackChangedNotifier(), [=](
|
subscribe(Media::Player::instance()->trackChangedNotifier(), [=](
|
||||||
AudioMsgId::Type type) {
|
AudioMsgId::Type type) {
|
||||||
if (type == AudioMsgId::Type::Voice) {
|
if (type == AudioMsgId::Type::Voice) {
|
||||||
|
@ -347,6 +342,11 @@ void FloatController::startDelegateHandling() {
|
||||||
const FloatDelegate::FloatPlayerFilterWheelEventRequest &request) {
|
const FloatDelegate::FloatPlayerFilterWheelEventRequest &request) {
|
||||||
*request.result = filterWheelEvent(request.object, request.event);
|
*request.result = filterWheelEvent(request.object, request.event);
|
||||||
}, _delegateLifetime);
|
}, _delegateLifetime);
|
||||||
|
|
||||||
|
_delegate->floatPlayerAreaUpdates(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
checkVisibility();
|
||||||
|
}, _delegateLifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FloatController::checkCurrent() {
|
void FloatController::checkCurrent() {
|
||||||
|
@ -457,7 +457,7 @@ std::optional<bool> FloatController::filterWheelEvent(
|
||||||
if (instance->widget == object) {
|
if (instance->widget == object) {
|
||||||
const auto section = _delegate->floatPlayerGetSection(
|
const auto section = _delegate->floatPlayerGetSection(
|
||||||
instance->column);
|
instance->column);
|
||||||
return section->wheelEventFromFloatPlayer(event);
|
return section->floatPlayerHandleWheelEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
@ -517,7 +517,7 @@ QPoint FloatController::getHiddenPosition(
|
||||||
|
|
||||||
QPoint FloatController::getPosition(not_null<Item*> instance) const {
|
QPoint FloatController::getPosition(not_null<Item*> instance) const {
|
||||||
const auto section = _delegate->floatPlayerGetSection(instance->column);
|
const auto section = _delegate->floatPlayerGetSection(instance->column);
|
||||||
const auto rect = section->rectForFloatPlayer();
|
const auto rect = section->floatPlayerAvailableRect();
|
||||||
auto position = rect.topLeft();
|
auto position = rect.topLeft();
|
||||||
if (IsBottomCorner(instance->corner)) {
|
if (IsBottomCorner(instance->corner)) {
|
||||||
position.setY(position.y() + rect.height() - instance->widget->height());
|
position.setY(position.y() + rect.height() - instance->widget->height());
|
||||||
|
@ -566,9 +566,10 @@ void FloatController::updateColumnCorner(QPoint center) {
|
||||||
auto column = Core::App().settings().floatPlayerColumn();
|
auto column = Core::App().settings().floatPlayerColumn();
|
||||||
auto corner = Core::App().settings().floatPlayerCorner();
|
auto corner = Core::App().settings().floatPlayerCorner();
|
||||||
auto checkSection = [&](
|
auto checkSection = [&](
|
||||||
not_null<Window::AbstractSectionWidget*> widget,
|
not_null<FloatSectionDelegate*> widget,
|
||||||
Window::Column widgetColumn) {
|
Window::Column widgetColumn) {
|
||||||
auto rect = _parent->mapFromGlobal(widget->rectForFloatPlayer());
|
auto rect = _parent->mapFromGlobal(
|
||||||
|
widget->floatPlayerAvailableRect());
|
||||||
auto left = rect.x() + (size.width() / 2);
|
auto left = rect.x() + (size.width() / 2);
|
||||||
auto right = rect.x() + rect.width() - (size.width() / 2);
|
auto right = rect.x() + rect.width() - (size.width() / 2);
|
||||||
auto top = rect.y() + (size.height() / 2);
|
auto top = rect.y() + (size.height() / 2);
|
||||||
|
|
|
@ -14,7 +14,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
class SessionController;
|
class SessionController;
|
||||||
class AbstractSectionWidget;
|
|
||||||
enum class Column;
|
enum class Column;
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
||||||
|
@ -105,14 +104,19 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FloatSectionDelegate {
|
||||||
|
public:
|
||||||
|
virtual QRect floatPlayerAvailableRect() = 0;
|
||||||
|
virtual bool floatPlayerHandleWheelEvent(QEvent *e) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
class FloatDelegate {
|
class FloatDelegate {
|
||||||
public:
|
public:
|
||||||
virtual not_null<Ui::RpWidget*> floatPlayerWidget() = 0;
|
virtual not_null<Ui::RpWidget*> floatPlayerWidget() = 0;
|
||||||
virtual not_null<Window::SessionController*> floatPlayerController() = 0;
|
virtual not_null<FloatSectionDelegate*> floatPlayerGetSection(
|
||||||
virtual not_null<Window::AbstractSectionWidget*> floatPlayerGetSection(
|
|
||||||
Window::Column column) = 0;
|
Window::Column column) = 0;
|
||||||
virtual void floatPlayerEnumerateSections(Fn<void(
|
virtual void floatPlayerEnumerateSections(Fn<void(
|
||||||
not_null<Window::AbstractSectionWidget*> widget,
|
not_null<FloatSectionDelegate*> widget,
|
||||||
Window::Column widgetColumn)> callback) = 0;
|
Window::Column widgetColumn)> callback) = 0;
|
||||||
virtual bool floatPlayerIsVisible(not_null<HistoryItem*> item) = 0;
|
virtual bool floatPlayerIsVisible(not_null<HistoryItem*> item) = 0;
|
||||||
|
|
||||||
|
@ -129,7 +133,10 @@ public:
|
||||||
return _raiseAll.events();
|
return _raiseAll.events();
|
||||||
}
|
}
|
||||||
virtual rpl::producer<> floatPlayerUpdatePositionsRequests() {
|
virtual rpl::producer<> floatPlayerUpdatePositionsRequests() {
|
||||||
return _updatePositions.events();;
|
return _updatePositions.events();
|
||||||
|
}
|
||||||
|
virtual rpl::producer<> floatPlayerAreaUpdates() {
|
||||||
|
return _areaUpdates.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FloatPlayerFilterWheelEventRequest {
|
struct FloatPlayerFilterWheelEventRequest {
|
||||||
|
@ -160,6 +167,9 @@ protected:
|
||||||
void floatPlayerUpdatePositions() {
|
void floatPlayerUpdatePositions() {
|
||||||
_updatePositions.fire({});
|
_updatePositions.fire({});
|
||||||
}
|
}
|
||||||
|
void floatPlayerAreaUpdated() {
|
||||||
|
_areaUpdates.fire({});
|
||||||
|
}
|
||||||
std::optional<bool> floatPlayerFilterWheelEvent(
|
std::optional<bool> floatPlayerFilterWheelEvent(
|
||||||
not_null<QObject*> object,
|
not_null<QObject*> object,
|
||||||
not_null<QEvent*> event) {
|
not_null<QEvent*> event) {
|
||||||
|
@ -174,6 +184,7 @@ private:
|
||||||
rpl::event_stream<> _showVisible;
|
rpl::event_stream<> _showVisible;
|
||||||
rpl::event_stream<> _raiseAll;
|
rpl::event_stream<> _raiseAll;
|
||||||
rpl::event_stream<> _updatePositions;
|
rpl::event_stream<> _updatePositions;
|
||||||
|
rpl::event_stream<> _areaUpdates;
|
||||||
rpl::event_stream<FloatPlayerFilterWheelEventRequest> _filterWheelEvent;
|
rpl::event_stream<FloatPlayerFilterWheelEventRequest> _filterWheelEvent;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -240,7 +251,6 @@ private:
|
||||||
|
|
||||||
not_null<FloatDelegate*> _delegate;
|
not_null<FloatDelegate*> _delegate;
|
||||||
not_null<Ui::RpWidget*> _parent;
|
not_null<Ui::RpWidget*> _parent;
|
||||||
not_null<Window::SessionController*> _controller;
|
|
||||||
std::vector<std::unique_ptr<Item>> _items;
|
std::vector<std::unique_ptr<Item>> _items;
|
||||||
|
|
||||||
rpl::event_stream<FullMsgId> _closeEvents;
|
rpl::event_stream<FullMsgId> _closeEvents;
|
||||||
|
|
|
@ -228,6 +228,8 @@ void Instance::clearStreamed(not_null<Data*> data, bool savePosition) {
|
||||||
requestRoundVideoResize();
|
requestRoundVideoResize();
|
||||||
emitUpdate(data->type);
|
emitUpdate(data->type);
|
||||||
data->streamed = nullptr;
|
data->streamed = nullptr;
|
||||||
|
|
||||||
|
_roundPlaying = false;
|
||||||
App::wnd()->sessionController()->disableGifPauseReason(
|
App::wnd()->sessionController()->disableGifPauseReason(
|
||||||
Window::GifPauseReason::RoundPlaying);
|
Window::GifPauseReason::RoundPlaying);
|
||||||
}
|
}
|
||||||
|
@ -729,6 +731,10 @@ void Instance::setupShortcuts() {
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Instance::pauseGifByRoundVideo() const {
|
||||||
|
return _roundPlaying;
|
||||||
|
}
|
||||||
|
|
||||||
void Instance::handleStreamingUpdate(
|
void Instance::handleStreamingUpdate(
|
||||||
not_null<Data*> data,
|
not_null<Data*> data,
|
||||||
Streaming::Update &&update) {
|
Streaming::Update &&update) {
|
||||||
|
@ -741,6 +747,7 @@ void Instance::handleStreamingUpdate(
|
||||||
float64) {
|
float64) {
|
||||||
requestRoundVideoRepaint();
|
requestRoundVideoRepaint();
|
||||||
});
|
});
|
||||||
|
_roundPlaying = true;
|
||||||
App::wnd()->sessionController()->enableGifPauseReason(
|
App::wnd()->sessionController()->enableGifPauseReason(
|
||||||
Window::GifPauseReason::RoundPlaying);
|
Window::GifPauseReason::RoundPlaying);
|
||||||
requestRoundVideoResize();
|
requestRoundVideoResize();
|
||||||
|
|
|
@ -158,6 +158,7 @@ public:
|
||||||
return _updatedNotifier.events();
|
return _updatedNotifier.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pauseGifByRoundVideo() const;
|
||||||
|
|
||||||
void documentLoadProgress(DocumentData *document);
|
void documentLoadProgress(DocumentData *document);
|
||||||
|
|
||||||
|
@ -254,12 +255,12 @@ private:
|
||||||
void requestRoundVideoResize() const;
|
void requestRoundVideoResize() const;
|
||||||
void requestRoundVideoRepaint() const;
|
void requestRoundVideoRepaint() const;
|
||||||
|
|
||||||
|
|
||||||
void setHistory(not_null<Data*> data, History *history);
|
void setHistory(not_null<Data*> data, History *history);
|
||||||
void setSession(not_null<Data*> data, Main::Session *session);
|
void setSession(not_null<Data*> data, Main::Session *session);
|
||||||
|
|
||||||
Data _songData;
|
Data _songData;
|
||||||
Data _voiceData;
|
Data _voiceData;
|
||||||
|
bool _roundPlaying = false;
|
||||||
|
|
||||||
base::Observable<Switch> _switchToNextNotifier;
|
base::Observable<Switch> _switchToNextNotifier;
|
||||||
base::Observable<bool> _playerWidgetOver;
|
base::Observable<bool> _playerWidgetOver;
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/rp_widget.h"
|
||||||
#include "dialogs/dialogs_key.h"
|
#include "dialogs/dialogs_key.h"
|
||||||
|
#include "media/player/media_player_float.h" // FloatSectionDelegate
|
||||||
#include "base/object_ptr.h"
|
#include "base/object_ptr.h"
|
||||||
|
|
||||||
namespace Main {
|
namespace Main {
|
||||||
|
@ -34,6 +35,7 @@ enum class Column {
|
||||||
|
|
||||||
class AbstractSectionWidget
|
class AbstractSectionWidget
|
||||||
: public Ui::RpWidget
|
: public Ui::RpWidget
|
||||||
|
, public Media::Player::FloatSectionDelegate
|
||||||
, protected base::Subscriber {
|
, protected base::Subscriber {
|
||||||
public:
|
public:
|
||||||
AbstractSectionWidget(
|
AbstractSectionWidget(
|
||||||
|
@ -58,14 +60,6 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Float player interface.
|
|
||||||
virtual bool wheelEventFromFloatPlayer(QEvent *e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
[[nodiscard]] virtual QRect rectForFloatPlayer() const {
|
|
||||||
return mapToGlobal(rect());
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const not_null<Window::SessionController*> _controller;
|
const not_null<Window::SessionController*> _controller;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "history/view/history_view_element.h"
|
#include "history/view/history_view_element.h"
|
||||||
//#include "history/feed/history_feed_section.h" // #feed
|
//#include "history/feed/history_feed_section.h" // #feed
|
||||||
|
#include "media/player/media_player_instance.h"
|
||||||
#include "data/data_media_types.h"
|
#include "data/data_media_types.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
|
@ -128,6 +129,10 @@ SessionController::SessionController(
|
||||||
this)) {
|
this)) {
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
if (Media::Player::instance()->pauseGifByRoundVideo()) {
|
||||||
|
enableGifPauseReason(GifPauseReason::RoundPlaying);
|
||||||
|
}
|
||||||
|
|
||||||
subscribe(session->api().fullPeerUpdated(), [=](PeerData *peer) {
|
subscribe(session->api().fullPeerUpdated(), [=](PeerData *peer) {
|
||||||
if (peer == _showEditPeer) {
|
if (peer == _showEditPeer) {
|
||||||
_showEditPeer = nullptr;
|
_showEditPeer = nullptr;
|
||||||
|
@ -414,6 +419,12 @@ bool SessionController::isGifPausedAtLeastFor(GifPauseReason reason) const {
|
||||||
return (static_cast<int>(_gifPauseReasons) >= 2 * static_cast<int>(reason)) || !widget()->isActive();
|
return (static_cast<int>(_gifPauseReasons) >= 2 * static_cast<int>(reason)) || !widget()->isActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SessionController::floatPlayerAreaUpdated() {
|
||||||
|
if (const auto main = widget()->sessionContent()) {
|
||||||
|
main->floatPlayerAreaUpdated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int SessionController::dialogsSmallColumnWidth() const {
|
int SessionController::dialogsSmallColumnWidth() const {
|
||||||
return st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x();
|
return st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x();
|
||||||
}
|
}
|
||||||
|
@ -781,39 +792,6 @@ not_null<MainWidget*> SessionController::content() const {
|
||||||
return widget()->sessionContent();
|
return widget()->sessionContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionController::setDefaultFloatPlayerDelegate(
|
|
||||||
not_null<Media::Player::FloatDelegate*> delegate) {
|
|
||||||
Expects(_defaultFloatPlayerDelegate == nullptr);
|
|
||||||
|
|
||||||
_defaultFloatPlayerDelegate = delegate;
|
|
||||||
_floatPlayers = std::make_unique<Media::Player::FloatController>(
|
|
||||||
delegate);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SessionController::replaceFloatPlayerDelegate(
|
|
||||||
not_null<Media::Player::FloatDelegate*> replacement) {
|
|
||||||
Expects(_floatPlayers != nullptr);
|
|
||||||
|
|
||||||
_replacementFloatPlayerDelegate = replacement;
|
|
||||||
_floatPlayers->replaceDelegate(replacement);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SessionController::restoreFloatPlayerDelegate(
|
|
||||||
not_null<Media::Player::FloatDelegate*> replacement) {
|
|
||||||
Expects(_floatPlayers != nullptr);
|
|
||||||
|
|
||||||
if (_replacementFloatPlayerDelegate == replacement) {
|
|
||||||
_replacementFloatPlayerDelegate = nullptr;
|
|
||||||
_floatPlayers->replaceDelegate(_defaultFloatPlayerDelegate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rpl::producer<FullMsgId> SessionController::floatPlayerClosed() const {
|
|
||||||
Expects(_floatPlayers != nullptr);
|
|
||||||
|
|
||||||
return _floatPlayers->closeEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
int SessionController::filtersWidth() const {
|
int SessionController::filtersWidth() const {
|
||||||
return _filters ? st::windowFiltersWidth : 0;
|
return _filters ? st::windowFiltersWidth : 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,13 +37,6 @@ namespace Settings {
|
||||||
enum class Type;
|
enum class Type;
|
||||||
} // namespace Settings
|
} // namespace Settings
|
||||||
|
|
||||||
namespace Media {
|
|
||||||
namespace Player {
|
|
||||||
class FloatController;
|
|
||||||
class FloatDelegate;
|
|
||||||
} // namespace Player
|
|
||||||
} // namespace Media
|
|
||||||
|
|
||||||
namespace Passport {
|
namespace Passport {
|
||||||
struct FormRequest;
|
struct FormRequest;
|
||||||
class FormController;
|
class FormController;
|
||||||
|
@ -208,9 +201,7 @@ public:
|
||||||
return _gifPauseLevelChanged;
|
return _gifPauseLevelChanged;
|
||||||
}
|
}
|
||||||
bool isGifPausedAtLeastFor(GifPauseReason reason) const;
|
bool isGifPausedAtLeastFor(GifPauseReason reason) const;
|
||||||
base::Observable<void> &floatPlayerAreaUpdated() {
|
void floatPlayerAreaUpdated();
|
||||||
return _floatPlayerAreaUpdated;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ColumnLayout {
|
struct ColumnLayout {
|
||||||
int bodyWidth;
|
int bodyWidth;
|
||||||
|
@ -289,14 +280,6 @@ public:
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDefaultFloatPlayerDelegate(
|
|
||||||
not_null<Media::Player::FloatDelegate*> delegate);
|
|
||||||
void replaceFloatPlayerDelegate(
|
|
||||||
not_null<Media::Player::FloatDelegate*> replacement);
|
|
||||||
void restoreFloatPlayerDelegate(
|
|
||||||
not_null<Media::Player::FloatDelegate*> replacement);
|
|
||||||
rpl::producer<FullMsgId> floatPlayerClosed() const;
|
|
||||||
|
|
||||||
[[nodiscard]] int filtersWidth() const;
|
[[nodiscard]] int filtersWidth() const;
|
||||||
[[nodiscard]] rpl::producer<FilterId> activeChatsFilter() const;
|
[[nodiscard]] rpl::producer<FilterId> activeChatsFilter() const;
|
||||||
[[nodiscard]] FilterId activeChatsFilterCurrent() const;
|
[[nodiscard]] FilterId activeChatsFilterCurrent() const;
|
||||||
|
@ -342,7 +325,6 @@ private:
|
||||||
|
|
||||||
GifPauseReasons _gifPauseReasons = 0;
|
GifPauseReasons _gifPauseReasons = 0;
|
||||||
base::Observable<void> _gifPauseLevelChanged;
|
base::Observable<void> _gifPauseLevelChanged;
|
||||||
base::Observable<void> _floatPlayerAreaUpdated;
|
|
||||||
|
|
||||||
// Depends on _gifPause*.
|
// Depends on _gifPause*.
|
||||||
const std::unique_ptr<ChatHelpers::TabbedSelector> _tabbedSelector;
|
const std::unique_ptr<ChatHelpers::TabbedSelector> _tabbedSelector;
|
||||||
|
@ -355,10 +337,6 @@ private:
|
||||||
|
|
||||||
rpl::variable<FilterId> _activeChatsFilter;
|
rpl::variable<FilterId> _activeChatsFilter;
|
||||||
|
|
||||||
std::unique_ptr<Media::Player::FloatController> _floatPlayers;
|
|
||||||
Media::Player::FloatDelegate *_defaultFloatPlayerDelegate = nullptr;
|
|
||||||
Media::Player::FloatDelegate *_replacementFloatPlayerDelegate = nullptr;
|
|
||||||
|
|
||||||
PeerData *_showEditPeer = nullptr;
|
PeerData *_showEditPeer = nullptr;
|
||||||
rpl::variable<Data::Folder*> _openedFolder;
|
rpl::variable<Data::Folder*> _openedFolder;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue