From f4d96184870607078b408d4dddafa72f357a0af0 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 20 Sep 2017 13:23:57 +0300 Subject: [PATCH] Improve layer / section exchange for Info. --- .../SourceFiles/chat_helpers/tabbed_section.h | 2 + .../SourceFiles/core/click_handler_types.cpp | 2 +- Telegram/SourceFiles/facades.cpp | 47 ++++++--- Telegram/SourceFiles/facades.h | 39 +++++--- .../history/history_admin_log_section.cpp | 17 +++- .../SourceFiles/history/history_widget.cpp | 27 ++++-- Telegram/SourceFiles/info/info_layer_wrap.cpp | 14 ++- .../info/info_profile_inner_widget.cpp | 8 +- Telegram/SourceFiles/layerwidget.cpp | 91 +++++++++++------- Telegram/SourceFiles/layerwidget.h | 34 ++++--- Telegram/SourceFiles/mainwidget.cpp | 95 ++++++++++++------- Telegram/SourceFiles/mainwidget.h | 20 ++-- Telegram/SourceFiles/mainwindow.cpp | 42 ++++---- Telegram/SourceFiles/mainwindow.h | 8 +- Telegram/SourceFiles/mediaview.cpp | 12 +-- Telegram/SourceFiles/messenger.cpp | 8 +- Telegram/SourceFiles/overviewwidget.cpp | 6 +- .../platform/linux/file_utilities_linux.cpp | 2 +- .../profile/profile_block_channel_members.cpp | 9 +- .../profile/profile_block_settings.cpp | 17 +++- .../profile/profile_block_shared_media.cpp | 5 +- .../profile/profile_common_groups_section.cpp | 4 +- .../SourceFiles/profile/profile_fixed_bar.cpp | 2 +- Telegram/SourceFiles/ui/animation.h | 5 + Telegram/SourceFiles/window/main_window.cpp | 2 +- .../SourceFiles/window/window_controller.cpp | 73 +++++++++----- .../SourceFiles/window/window_controller.h | 49 +++++++--- 27 files changed, 426 insertions(+), 214 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_section.h b/Telegram/SourceFiles/chat_helpers/tabbed_section.h index 345ab5059..ef8b9e30e 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_section.h +++ b/Telegram/SourceFiles/chat_helpers/tabbed_section.h @@ -32,6 +32,8 @@ public: TabbedMemento( object_ptr selector, base::lambda)> returnMethod); + TabbedMemento(TabbedMemento &&other) = default; + TabbedMemento &operator=(TabbedMemento &&other) = default; object_ptr createWidget( QWidget *parent, diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index 0c47420ee..cf7d14aa9 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -269,5 +269,5 @@ void BotCommandClickHandler::onClick(Qt::MouseButton button) const { } TextWithEntities BotCommandClickHandler::getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const { - return simpleTextWithEntity({ EntityInTextHashtag, entityOffset, textPart.size() }); + return simpleTextWithEntity({ EntityInTextBotCommand, entityOffset, textPart.size() }); } diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index d6dc3e432..cc8d82099 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -202,9 +202,12 @@ void logOutDelayed() { namespace Ui { namespace internal { -void showBox(object_ptr content, LayerOptions options) { +void showBox( + object_ptr content, + LayerOptions options, + anim::type animated) { if (auto w = App::wnd()) { - w->ui_showBox(std::move(content), options); + w->ui_showBox(std::move(content), options, animated); } } @@ -228,19 +231,18 @@ void hideMediaPreview() { } } -void hideLayer(bool fast) { +void hideLayer(anim::type animated) { if (auto w = App::wnd()) { w->ui_showBox( { nullptr }, - LayerOption::CloseOther | (fast ? LayerOption::ForceFast : LayerOption::Animated)); + LayerOption::CloseOther, + animated); } } -void hideSettingsAndLayer(bool fast) { +void hideSettingsAndLayer(anim::type animated) { if (auto w = App::wnd()) { - w->ui_hideSettingsAndLayer(fast - ? LayerOption::ForceFast - : LayerOption::Animated); + w->ui_hideSettingsAndLayer(animated); } } @@ -257,14 +259,23 @@ void repaintHistoryItem(not_null item) { void autoplayMediaInlineAsync(const FullMsgId &msgId) { if (auto main = App::main()) { - QMetaObject::invokeMethod(main, "ui_autoplayMediaInlineAsync", Qt::QueuedConnection, Q_ARG(qint32, msgId.channel), Q_ARG(qint32, msgId.msg)); + InvokeQueued(main, [msgId] { + if (auto item = App::histItemById(msgId)) { + if (auto media = item->getMedia()) { + media->playInline(true); + } + } + }); } } void showPeerProfile(const PeerId &peer) { if (auto main = App::main()) { // main->showSection(Profile::SectionMemento(App::peer(peer))); - main->showSection(Info::Memento(peer), anim::type::normal); + main->showSection( + Info::Memento(peer), + anim::type::normal, + anim::activation::normal); } } @@ -274,14 +285,22 @@ void showPeerOverview(const PeerId &peer, MediaOverviewType type) { } } -void showPeerHistory(const PeerId &peer, MsgId msgId, ShowWay way) { - if (MainWidget *m = App::main()) m->ui_showPeerHistory(peer, msgId, way); +void showPeerHistory( + const PeerId &peer, + MsgId msgId, + ShowWay way, + anim::type animated, + anim::activation activation) { + if (MainWidget *m = App::main()) { + m->ui_showPeerHistory(peer, msgId, way, animated, activation); + } } void showPeerHistoryAsync(const PeerId &peer, MsgId msgId, ShowWay way) { if (MainWidget *m = App::main()) { - qRegisterMetaType(); - QMetaObject::invokeMethod(m, "ui_showPeerHistoryAsync", Qt::QueuedConnection, Q_ARG(quint64, peer), Q_ARG(qint32, msgId), Q_ARG(Ui::ShowWay, way)); + InvokeQueued(m, [peer, msgId, way] { + showPeerHistory(peer, msgId, way); + }); } } diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index d79598ba7..bc5b47408 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -87,9 +87,6 @@ enum class LayerOption { CloseOther = (1 << 0), KeepOther = (1 << 1), ShowAfterOther = (1 << 2), - - Animated = (1 << 3), - ForceFast = (1 << 4), }; using LayerOptions = base::flags; inline constexpr auto is_flag_type(LayerOption) { return true; }; @@ -97,7 +94,10 @@ inline constexpr auto is_flag_type(LayerOption) { return true; }; namespace Ui { namespace internal { -void showBox(object_ptr content, LayerOptions options); +void showBox( + object_ptr content, + LayerOptions options, + anim::type animated); } // namespace internal @@ -108,14 +108,15 @@ void hideMediaPreview(); template QPointer show( object_ptr content, - LayerOptions options = LayerOption::CloseOther) { + LayerOptions options = LayerOption::CloseOther, + anim::type animated = anim::type::normal) { auto result = QPointer(content.data()); - internal::showBox(std::move(content), options); + internal::showBox(std::move(content), options, animated); return result; } -void hideLayer(bool fast = false); -void hideSettingsAndLayer(bool fast = false); +void hideLayer(anim::type animated = anim::type::normal); +void hideSettingsAndLayer(anim::type animated = anim::type::normal); bool isLayerShown(); void repaintHistoryItem(not_null item); @@ -142,14 +143,28 @@ enum class ShowWay { Forward, Backward, }; -void showPeerHistory(const PeerId &peer, MsgId msgId, ShowWay way = ShowWay::ClearStack); -inline void showPeerHistory(const PeerData *peer, MsgId msgId, ShowWay way = ShowWay::ClearStack) { +void showPeerHistory( + const PeerId &peer, + MsgId msgId, + ShowWay way = ShowWay::ClearStack, + anim::type animated = anim::type::normal, + anim::activation activation = anim::activation::normal); + +inline void showPeerHistory( + const PeerData *peer, + MsgId msgId, + ShowWay way = ShowWay::ClearStack) { showPeerHistory(peer->id, msgId, way); } -inline void showPeerHistory(const History *history, MsgId msgId, ShowWay way = ShowWay::ClearStack) { +inline void showPeerHistory( + const History *history, + MsgId msgId, + ShowWay way = ShowWay::ClearStack) { showPeerHistory(history->peer->id, msgId, way); } -inline void showPeerHistoryAtItem(const HistoryItem *item, ShowWay way = ShowWay::ClearStack) { +inline void showPeerHistoryAtItem( + const HistoryItem *item, + ShowWay way = ShowWay::ClearStack) { showPeerHistory(item->history()->peer->id, item->id, way); } void showPeerHistoryAsync(const PeerId &peer, MsgId msgId, ShowWay way = ShowWay::ClearStack); diff --git a/Telegram/SourceFiles/history/history_admin_log_section.cpp b/Telegram/SourceFiles/history/history_admin_log_section.cpp index 360296675..47732b6d2 100644 --- a/Telegram/SourceFiles/history/history_admin_log_section.cpp +++ b/Telegram/SourceFiles/history/history_admin_log_section.cpp @@ -33,6 +33,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "mainwindow.h" #include "apiwrap.h" #include "window/themes/window_theme.h" +#include "window/window_controller.h" #include "boxes/confirm_box.h" #include "base/timer.h" #include "lang/lang_keys.h" @@ -41,7 +42,10 @@ namespace AdminLog { class FixedBar final : public TWidget, private base::Subscriber { public: - FixedBar(QWidget *parent, not_null channel); + FixedBar( + QWidget *parent, + not_null controller, + not_null channel); base::Observable showFilterSignal; base::Observable searchCancelledSignal; @@ -74,6 +78,7 @@ private: void applySearch(); void searchAnimationCallback(); + not_null _controller; not_null _channel; object_ptr _field; object_ptr _backButton; @@ -101,7 +106,11 @@ object_ptr SectionMemento::createWidget( return std::move(result); } -FixedBar::FixedBar(QWidget *parent, not_null channel) : TWidget(parent) +FixedBar::FixedBar( + QWidget *parent, + not_null controller, + not_null channel) : TWidget(parent) +, _controller(controller) , _channel(channel) , _field(this, st::historyAdminLogSearchField, langFactory(lng_dlg_filter)) , _backButton(this, lang(lng_admin_log_title_all)) @@ -128,7 +137,7 @@ void FixedBar::applyFilter(const FilterValue &value) { } void FixedBar::goBack() { - App::main()->showBackFromStack(); + _controller->showBackFromStack(); } void FixedBar::showSearch() { @@ -241,7 +250,7 @@ void FixedBar::mousePressEvent(QMouseEvent *e) { Widget::Widget(QWidget *parent, not_null controller, not_null channel) : Window::SectionWidget(parent, controller) , _scroll(this, st::historyScroll, false) -, _fixedBar(this, channel) +, _fixedBar(this, controller, channel) , _fixedBarShadow(this, st::shadowFg) , _whatIsThis(this, lang(lng_admin_log_about).toUpper(), st::historyComposeButton) { _fixedBar->move(0, 0); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 1ec543032..8581425ec 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -706,7 +706,7 @@ HistoryWidget::HistoryWidget(QWidget *parent, not_null cont if (update.flags & UpdateFlag::RestrictionReasonChanged) { auto restriction = _peer->restrictionReason(); if (!restriction.isEmpty()) { - App::main()->showBackFromStack(); + this->controller()->showBackFromStack(); Ui::show(Box(restriction)); return; } @@ -2217,7 +2217,7 @@ bool HistoryWidget::messagesFailed(const RPCError &error, mtpRequestId requestId if (error.type() == qstr("CHANNEL_PRIVATE") || error.type() == qstr("CHANNEL_PUBLIC_GROUP_NA") || error.type() == qstr("USER_BANNED_IN_CHANNEL")) { auto was = _peer; - App::main()->showBackFromStack(); + controller()->showBackFromStack(); Ui::show(Box(lang((was && was->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible))); return true; } @@ -2229,7 +2229,7 @@ bool HistoryWidget::messagesFailed(const RPCError &error, mtpRequestId requestId _preloadDownRequest = 0; } else if (_firstLoadRequest == requestId) { _firstLoadRequest = 0; - App::main()->showBackFromStack(); + controller()->showBackFromStack(); } else if (_delayedShowAtRequest == requestId) { _delayedShowAtRequest = 0; } @@ -3751,7 +3751,7 @@ void HistoryWidget::onModerateKeyActivate(int index, bool *outHandled) { void HistoryWidget::topBarClick() { if (Adaptive::OneColumn() || !App::main()->stackIsEmpty()) { - App::main()->showBackFromStack(); + controller()->showBackFromStack(); } else if (_peer) { controller()->showPeerInfo(_peer); } @@ -3772,19 +3772,26 @@ void HistoryWidget::pushTabbedSelectorToThirdSection() { &st::historyRecordVoiceRippleBgActive); auto destroyingPanel = std::move(_tabbedPanel); controller()->resizeForThirdSection(); - controller()->showSection(ChatHelpers::TabbedMemento( + auto memento = ChatHelpers::TabbedMemento( destroyingPanel->takeSelector(), base::lambda_guarded(this, [this]( object_ptr selector) { returnTabbedSelector(std::move(selector)); - }))); + })); + controller()->showSection( + std::move(memento), + anim::type::instant, + anim::activation::background); } void HistoryWidget::pushInfoToThirdSection() { if (!_peer) { return; } - controller()->showPeerInfo(_peer); + controller()->showPeerInfo( + _peer, + anim::type::instant, + anim::activation::background); } void HistoryWidget::toggleTabbedSelectorMode() { @@ -4527,7 +4534,7 @@ void HistoryWidget::onReportSpamClear() { }); // Invalidates _peer. - App::main()->showBackFromStack(); + controller()->showBackFromStack(); } void HistoryWidget::peerMessagesUpdated(PeerId peer) { @@ -5092,7 +5099,7 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) { if (e->key() == Qt::Key_Escape) { e->ignore(); } else if (e->key() == Qt::Key_Back) { - App::main()->showBackFromStack(); + controller()->showBackFromStack(); emit cancelled(); } else if (e->key() == Qt::Key_PageDown) { _scroll->keyPressEvent(e); @@ -5894,7 +5901,7 @@ void HistoryWidget::onCancel() { } else if (!_fieldAutocomplete->isHidden()) { _fieldAutocomplete->hideAnimated(); } else { - App::main()->showBackFromStack(); + controller()->showBackFromStack(); emit cancelled(); } } diff --git a/Telegram/SourceFiles/info/info_layer_wrap.cpp b/Telegram/SourceFiles/info/info_layer_wrap.cpp index 52f16bf3f..29ee97d2b 100644 --- a/Telegram/SourceFiles/info/info_layer_wrap.cpp +++ b/Telegram/SourceFiles/info/info_layer_wrap.cpp @@ -108,8 +108,11 @@ void LayerWrap::parentResized() { if (parentWidth < MinimalSupportedWidth()) { auto localCopy = _controller; auto memento = MoveMemento(std::move(_content), Wrap::Narrow); - localCopy->hideSpecialLayer(LayerOption::ForceFast); - localCopy->showSection(std::move(memento)); + localCopy->hideSpecialLayer(anim::type::instant); + localCopy->showSection( + std::move(memento), + anim::type::instant, + anim::activation::background); } else if (_controller->canShowThirdSectionWithoutResize()) { takeToThirdSection(); } else { @@ -123,11 +126,14 @@ void LayerWrap::parentResized() { bool LayerWrap::takeToThirdSection() { auto localCopy = _controller; auto memento = MoveMemento(std::move(_content), Wrap::Side); - localCopy->hideSpecialLayer(LayerOption::ForceFast); + localCopy->hideSpecialLayer(anim::type::instant); Auth().data().setThirdSectionInfoEnabled(true); Auth().saveDataDelayed(kThirdSectionInfoTimeoutMs); - localCopy->showSection(std::move(memento)); + localCopy->showSection( + std::move(memento), + anim::type::instant, + anim::activation::background); return true; } diff --git a/Telegram/SourceFiles/info/info_profile_inner_widget.cpp b/Telegram/SourceFiles/info/info_profile_inner_widget.cpp index a19165555..90b053503 100644 --- a/Telegram/SourceFiles/info/info_profile_inner_widget.cpp +++ b/Telegram/SourceFiles/info/info_profile_inner_widget.cpp @@ -22,6 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include #include "boxes/abstract_box.h" +#include "boxes/add_contact_box.h" #include "mainwidget.h" #include "info/info_profile_widget.h" #include "info/info_profile_lines.h" @@ -143,7 +144,12 @@ void InnerWidget::setupMainUserButtons( addContact->finishAnimations(); addContact->entity()->clicks() | rpl::start([user](auto&&) { - App::main()->shareContactLayer(user); + auto firstName = user->firstName; + auto lastName = user->lastName; + auto phone = user->phone().isEmpty() + ? App::phoneFromSharedContact(user->bareId()) + : user->phone(); + Ui::show(Box(firstName, lastName, phone)); }, addContact->lifetime()); } diff --git a/Telegram/SourceFiles/layerwidget.cpp b/Telegram/SourceFiles/layerwidget.cpp index d611dab92..4c6bdaed3 100644 --- a/Telegram/SourceFiles/layerwidget.cpp +++ b/Telegram/SourceFiles/layerwidget.cpp @@ -113,17 +113,21 @@ void LayerStackWidget::BackgroundWidget::setCacheImages(QPixmap &&bodyCache, QPi void LayerStackWidget::BackgroundWidget::startAnimation(Action action) { if (action == Action::ShowMainMenu) { setMainMenuShown(true); - } else if (action != Action::HideLayer) { + } else if (action != Action::HideLayer + && action != Action::HideSpecialLayer) { setMainMenuShown(false); } if (action == Action::ShowSpecialLayer) { setSpecialLayerShown(true); - } else if (action == Action::ShowMainMenu || action == Action::HideAll) { + } else if (action == Action::ShowMainMenu + || action == Action::HideAll + || action == Action::HideSpecialLayer) { setSpecialLayerShown(false); } if (action == Action::ShowLayer) { setLayerShown(true); - } else { + } else if (action != Action::ShowSpecialLayer + && action != Action::HideSpecialLayer) { setLayerShown(false); } _wasAnimating = true; @@ -352,37 +356,37 @@ bool LayerWidget::overlaps(const QRect &globalRect) { void LayerStackWidget::keyPressEvent(QKeyEvent *e) { if (e->key() == Qt::Key_Escape) { - hideCurrent(LayerOption::Animated); + hideCurrent(anim::type::normal); } } void LayerStackWidget::mousePressEvent(QMouseEvent *e) { - hideCurrent(LayerOption::Animated); + hideCurrent(anim::type::normal); } -void LayerStackWidget::hideCurrent(LayerOptions options) { - return currentLayer() ? hideLayers(options) : hideAll(options); +void LayerStackWidget::hideCurrent(anim::type animated) { + return currentLayer() ? hideLayers(animated) : hideAll(animated); } -void LayerStackWidget::hideLayers(LayerOptions options) { +void LayerStackWidget::hideLayers(anim::type animated) { startAnimation([] {}, [this] { clearLayers(); - }, Action::HideLayer, options); + }, Action::HideLayer, animated); } -void LayerStackWidget::hideAll(LayerOptions options) { +void LayerStackWidget::hideAll(anim::type animated) { startAnimation([] {}, [this] { clearLayers(); clearSpecialLayer(); _mainMenu.destroyDelayed(); - }, Action::HideAll, options); + }, Action::HideAll, animated); } -void LayerStackWidget::hideTopLayer(LayerOptions options) { +void LayerStackWidget::hideTopLayer(anim::type animated) { if (_specialLayer) { - hideLayers(options); + hideLayers(animated); } else { - hideAll(options); + hideAll(animated); } } @@ -430,10 +434,10 @@ void LayerStackWidget::onLayerClosed(LayerWidget *layer) { } layer->deleteLater(); if (layer == _specialLayer) { - hideAll(LayerOption::Animated); + hideAll(anim::type::normal); } else if (layer == currentLayer()) { if (_layers.size() == 1) { - hideCurrent(LayerOption::Animated); + hideCurrent(anim::type::normal); } else { if (layer->inFocusChain()) setFocus(); layer->hide(); @@ -511,10 +515,10 @@ void LayerStackWidget::startAnimation( SetupNew setupNewWidgets, ClearOld clearOldWidgets, Action action, - LayerOptions options) { + anim::type animated) { if (App::quitting()) return; - if (options & LayerOption::ForceFast) { + if (animated == anim::type::instant) { setupNewWidgets(); clearOldWidgets(); prepareForAnimation(); @@ -542,8 +546,10 @@ void LayerStackWidget::resizeEvent(QResizeEvent *e) { updateLayerBoxes(); } -void LayerStackWidget::showBox(object_ptr box) { - auto pointer = pushBox(std::move(box)); +void LayerStackWidget::showBox( + object_ptr box, + anim::type animated) { + auto pointer = pushBox(std::move(box), animated); while (!_layers.isEmpty() && _layers.front() != pointer) { auto removingLayer = _layers.front(); _layers.pop_front(); @@ -610,18 +616,26 @@ void LayerStackWidget::showFinished() { } } -void LayerStackWidget::showSpecialLayer(object_ptr layer) { +void LayerStackWidget::showSpecialLayer( + object_ptr layer, + anim::type animated) { startAnimation([this, layer = std::move(layer)]() mutable { _specialLayer.destroyDelayed(); _specialLayer = std::move(layer); initChildLayer(_specialLayer); }, [this] { - clearLayers(); _mainMenu.destroyDelayed(); - }, Action::ShowSpecialLayer, LayerOption::Animated); + }, Action::ShowSpecialLayer, animated); } -void LayerStackWidget::showMainMenu() { +void LayerStackWidget::hideSpecialLayer(anim::type animated) { + startAnimation([] {}, [this] { + clearSpecialLayer(); + _mainMenu.destroyDelayed(); + }, Action::HideSpecialLayer, animated); +} + +void LayerStackWidget::showMainMenu(anim::type animated) { startAnimation([this] { _mainMenu.create(this); _mainMenu->setGeometryToLeft(0, 0, _mainMenu->width(), height()); @@ -629,20 +643,27 @@ void LayerStackWidget::showMainMenu() { }, [this] { clearLayers(); _specialLayer.destroyDelayed(); - }, Action::ShowMainMenu, LayerOption::Animated); + }, Action::ShowMainMenu, animated); } -void LayerStackWidget::appendBox(object_ptr box) { - pushBox(std::move(box)); +void LayerStackWidget::appendBox( + object_ptr box, + anim::type animated) { + pushBox(std::move(box), animated); } -LayerWidget *LayerStackWidget::pushBox(object_ptr box) { +LayerWidget *LayerStackWidget::pushBox( + object_ptr box, + anim::type animated) { auto oldLayer = currentLayer(); if (oldLayer) { if (oldLayer->inFocusChain()) setFocus(); oldLayer->hide(); } - auto layer = object_ptr(this, _controller, std::move(box)); + auto layer = object_ptr( + this, + _controller, + std::move(box)); _layers.push_back(layer); initChildLayer(layer); @@ -654,15 +675,17 @@ LayerWidget *LayerStackWidget::pushBox(object_ptr box) { } else { startAnimation([] {}, [this] { _mainMenu.destroyDelayed(); - }, Action::ShowLayer, LayerOption::Animated); + }, Action::ShowLayer, animated); } return layer.data(); } -void LayerStackWidget::prependBox(object_ptr box) { +void LayerStackWidget::prependBox( + object_ptr box, + anim::type animated) { if (_layers.empty()) { - return showBox(std::move(box)); + return showBox(std::move(box), animated); } auto layer = object_ptr(this, _controller, std::move(box)); layer->hide(); @@ -720,7 +743,7 @@ void LayerStackWidget::sendFakeMouseEvent() { void LayerStackWidget::onLayerDestroyed(QObject *obj) { if (obj == _specialLayer) { _specialLayer = nullptr; - hideAll(LayerOption::Animated); + hideAll(anim::type::normal); } else if (obj == currentLayer()) { _layers.pop_back(); if (auto newLayer = currentLayer()) { @@ -730,7 +753,7 @@ void LayerStackWidget::onLayerDestroyed(QObject *obj) { showFinished(); } } else if (!_specialLayer) { - hideAll(LayerOption::Animated); + hideAll(anim::type::normal); } } else { for (auto i = _layers.begin(), e = _layers.end(); i != e; ++i) { diff --git a/Telegram/SourceFiles/layerwidget.h b/Telegram/SourceFiles/layerwidget.h index 653731439..444eae7cc 100644 --- a/Telegram/SourceFiles/layerwidget.h +++ b/Telegram/SourceFiles/layerwidget.h @@ -94,11 +94,19 @@ public: } void finishAnimation(); - void showBox(object_ptr box); - void showSpecialLayer(object_ptr layer); - void showMainMenu(); - void appendBox(object_ptr box); - void prependBox(object_ptr box); + void showBox( + object_ptr box, + anim::type animated); + void showSpecialLayer( + object_ptr layer, + anim::type animated); + void showMainMenu(anim::type animated); + void appendBox( + object_ptr box, + anim::type animated); + void prependBox( + object_ptr box, + anim::type animated); bool takeToThirdSection(); bool canSetFocus() const; @@ -106,9 +114,10 @@ public: bool contentOverlapped(const QRect &globalRect); - void hideLayers(LayerOptions options); - void hideAll(LayerOptions options); - void hideTopLayer(LayerOptions options); + void hideSpecialLayer(anim::type animated); + void hideLayers(anim::type animated); + void hideAll(anim::type animated); + void hideTopLayer(anim::type animated); bool layerShown() const; @@ -125,14 +134,17 @@ private slots: void onLayerResized(); private: - LayerWidget *pushBox(object_ptr box); + LayerWidget *pushBox( + object_ptr box, + anim::type animated); void showFinished(); - void hideCurrent(LayerOptions options); + void hideCurrent(anim::type animated); enum class Action { ShowMainMenu, ShowSpecialLayer, ShowLayer, + HideSpecialLayer, HideLayer, HideAll, }; @@ -141,7 +153,7 @@ private: SetupNew setupNewWidgets, ClearOld clearOldWidgets, Action action, - LayerOptions options); + anim::type animated); void prepareForAnimation(); void animationDone(); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 516581d7e..3193837df 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -1577,7 +1577,6 @@ bool MainWidget::insertBotCommand(const QString &cmd) { } void MainWidget::searchMessages(const QString &query, PeerData *inPeer) { - Messenger::Instance().hideMediaView(); _dialogs->searchMessages(query, inPeer); if (Adaptive::OneColumn()) { Ui::showChatsList(); @@ -1743,18 +1742,6 @@ void MainWidget::messagesAffected(PeerData *peer, const MTPmessages_AffectedMess } } -void MainWidget::ui_showPeerHistoryAsync(quint64 peerId, qint32 showAtMsgId, Ui::ShowWay way) { - Ui::showPeerHistory(peerId, showAtMsgId, way); -} - -void MainWidget::ui_autoplayMediaInlineAsync(qint32 channelId, qint32 msgId) { - if (HistoryItem *item = App::histItemById(channelId, msgId)) { - if (HistoryMedia *media = item->getMedia()) { - media->playInline(true); - } - } -} - void MainWidget::handleAudioUpdate(const AudioMsgId &audioId) { using State = Media::Player::State; auto state = Media::Player::mixer()->currentState(audioId.type()); @@ -2457,17 +2444,23 @@ void MainWidget::ctrlEnterSubmitUpdated() { _history->updateFieldSubmitSettings(); } -void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, Ui::ShowWay way) { +void MainWidget::ui_showPeerHistory( + PeerId peerId, + MsgId showAtMsgId, + Ui::ShowWay way, + anim::type animated, + anim::activation activation) { if (auto peer = App::peerLoaded(peerId)) { if (peer->migrateTo()) { peer = peer->migrateTo(); peerId = peer->id; if (showAtMsgId > 0) showAtMsgId = -showAtMsgId; } - QString restriction = peer->restrictionReason(); + auto restriction = peer->restrictionReason(); if (!restriction.isEmpty()) { - Ui::showChatsList(); - Ui::show(Box(restriction)); + if (activation != anim::activation::background) { + Ui::show(Box(restriction)); + } return; } } @@ -2505,8 +2498,9 @@ void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, Ui::Show } auto wasActivePeer = activePeer(); - - Ui::hideSettingsAndLayer(); + if (activation != anim::activation::background) { + Ui::hideSettingsAndLayer(); + } if (_hider) { _hider->startHide(); _hider = nullptr; @@ -2695,7 +2689,7 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool if (_overview->type() != type) { _overview->switchType(type); } else if (type == OverviewMusicFiles) { // hack for player - showBackFromStack(); + _controller->showBackFromStack(); } return; } @@ -2758,7 +2752,8 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool void MainWidget::showSection( Window::SectionMemento &&memento, - anim::type animated) { + anim::type animated, + anim::activation activation) { if (_mainSection && _mainSection->showInternal(&memento)) { return; } else if (_thirdSection && _thirdSection->showInternal(&memento)) { @@ -2770,7 +2765,12 @@ void MainWidget::showSection( // we need to update adaptive layout to Adaptive::ThirdColumn(). updateColumnLayout(); - showNewSection(std::move(memento), false, true, animated); + showNewSection( + std::move(memento), + false, + true, + animated, + activation); } void MainWidget::updateColumnLayout() { @@ -2902,7 +2902,8 @@ void MainWidget::showNewSection( Window::SectionMemento &&memento, bool back, bool saveInStack, - anim::type animated) { + anim::type animated, + anim::activation activation) { using Column = Window::Column; auto thirdSectionTop = getThirdSectionTop(); @@ -2927,6 +2928,10 @@ void MainWidget::showNewSection( } } + if (activation != anim::activation::background) { + Ui::hideSettingsAndLayer(); + } + QPixmap animCache; _controller->dialogsListFocused().set(false, true); @@ -3026,7 +3031,7 @@ void MainWidget::checkMainSectionToLayer() { dropMainSection(_mainSection); _controller->showSpecialLayer( std::move(layer), - LayerOption::ForceFast); + anim::type::instant); } } @@ -3035,7 +3040,9 @@ void MainWidget::dropMainSection(Window::SectionWidget *widget) { return; } _mainSection.destroy(); - showBackFromStack(); + _controller->showBackFromStack( + anim::type::instant, + anim::activation::background); } bool MainWidget::isMainSectionShown() const { @@ -3050,10 +3057,12 @@ bool MainWidget::stackIsEmpty() const { return _stack.empty(); } -void MainWidget::showBackFromStack() { +void MainWidget::showBackFromStack( + anim::type animated, + anim::activation activation) { if (selectingPeer()) return; if (_stack.empty()) { - Ui::showChatsList(); + _controller->clearSectionStack(animated, activation); if (App::wnd()) QTimer::singleShot(0, App::wnd(), SLOT(setInnerFocus())); return; } @@ -3076,7 +3085,12 @@ void MainWidget::showBackFromStack() { } } auto historyItem = static_cast(item.get()); - Ui::showPeerHistory(historyItem->peer->id, ShowAtUnreadMsgId, Ui::ShowWay::Backward); + _controller->showPeerHistory( + historyItem->peer->id, + Ui::ShowWay::Backward, + ShowAtUnreadMsgId, + animated, + activation); _history->setReplyReturns(historyItem->peer->id, historyItem->replyReturns); } else if (item->type() == SectionStackItem) { auto sectionItem = static_cast(item.get()); @@ -3084,10 +3098,15 @@ void MainWidget::showBackFromStack() { std::move(*sectionItem->memento()), true, false, - anim::type::normal); + animated, + activation); } else if (item->type() == OverviewStackItem) { auto overviewItem = static_cast(item.get()); - showMediaOverview(overviewItem->peer, overviewItem->mediaType, true, overviewItem->lastScrollTop); + showMediaOverview( + overviewItem->peer, + overviewItem->mediaType, + true, + overviewItem->lastScrollTop); } } @@ -3332,7 +3351,7 @@ void MainWidget::showAll() { if (_hider) _hider->offerPeer(0); }), base::lambda_guarded(this, [this] { if (_hider && _forwardConfirm) _hider->offerPeer(0); - })), LayerOption::ForceFast); + })), LayerOption::CloseOther, anim::type::instant); } } if (selectingPeer()) { @@ -3364,7 +3383,7 @@ void MainWidget::showAll() { _hider->show(); if (_forwardConfirm) { _forwardConfirm = nullptr; - Ui::hideLayer(true); + Ui::hideLayer(anim::type::instant); if (_hider->wasOffered()) { _hider->setFocus(); } @@ -3531,7 +3550,10 @@ void MainWidget::updateThirdColumnToCurrentPeer(PeerData *peer) { && Auth().data().tabbedSelectorSectionEnabled() && peer) { if (!peer->canWrite()) { - _controller->showPeerInfo(peer); + _controller->showPeerInfo( + peer, + anim::type::instant, + anim::activation::background); Auth().data().setTabbedSelectorSectionEnabled(true); Auth().data().setTabbedReplacedWithInfo(true); } else if (Auth().data().tabbedReplacedWithInfo()) { @@ -3545,7 +3567,10 @@ void MainWidget::updateThirdColumnToCurrentPeer(PeerData *peer) { _thirdShadow.destroy(); } else if (Adaptive::ThreeColumn() && Auth().data().thirdSectionInfoEnabled()) { - _controller->showPeerInfo(peer, anim::type::instant); + _controller->showPeerInfo( + peer, + anim::type::instant, + anim::activation::background); } } } @@ -3616,7 +3641,7 @@ bool MainWidget::eventFilter(QObject *o, QEvent *e) { } } else if (e->type() == QEvent::MouseButtonPress) { if (static_cast(e)->button() == Qt::BackButton) { - showBackFromStack(); + _controller->showBackFromStack(); return true; } } else if (e->type() == QEvent::Wheel && !_playerFloats.empty()) { diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 32ceddb01..0378c44b6 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -215,11 +215,14 @@ public: bool showMediaTypeSwitch() const; void showSection( Window::SectionMemento &&memento, - anim::type animated); + anim::type animated, + anim::activation activation); void updateColumnLayout(); void showMediaOverview(PeerData *peer, MediaOverviewType type, bool back = false, int32 lastScrollTop = -1); bool stackIsEmpty() const; - void showBackFromStack(); + void showBackFromStack( + anim::type animated, + anim::activation activation); void orderWidgets(); QRect historyRect() const; QPixmap grabForShowAnimation(const Window::SectionSlideParams ¶ms); @@ -391,7 +394,12 @@ public: void app_sendBotCallback(const HistoryMessageReplyMarkup::Button *button, const HistoryItem *msg, int row, int col); void ui_repaintHistoryItem(not_null item); - void ui_showPeerHistory(quint64 peer, qint32 msgId, Ui::ShowWay way); + void ui_showPeerHistory( + PeerId peer, + MsgId msgId, + Ui::ShowWay way, + anim::type animated, + anim::activation activation); PeerData *ui_getPeerForMouseAction(); void notify_botCommandsChanged(UserData *bot); @@ -448,9 +456,6 @@ public slots: void onViewsIncrement(); - void ui_showPeerHistoryAsync(quint64 peerId, qint32 showAtMsgId, Ui::ShowWay way); - void ui_autoplayMediaInlineAsync(qint32 channelId, qint32 msgId); - protected: void paintEvent(QPaintEvent *e) override; void resizeEvent(QResizeEvent *e) override; @@ -532,7 +537,8 @@ private: Window::SectionMemento &&memento, bool back, bool saveInStack, - anim::type animated); + anim::type animated, + anim::activation activation); void dropMainSection(Window::SectionWidget *widget); Window::SectionSlideParams prepareThirdSectionAnimation(Window::SectionWidget *section); diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 84a3f9919..a00d838a3 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -227,7 +227,7 @@ void MainWindow::setupPasscode() { if (_main) _main->hide(); Messenger::Instance().hideMediaView(); - Ui::hideSettingsAndLayer(true); + Ui::hideSettingsAndLayer(anim::type::instant); if (_intro) _intro->hide(); if (animated) { _passcode->showAnimated(bg); @@ -239,7 +239,7 @@ void MainWindow::setupPasscode() { void MainWindow::setupIntro() { if (_intro && !_intro->isHidden() && !_main) return; - Ui::hideSettingsAndLayer(true); + Ui::hideSettingsAndLayer(anim::type::instant); auto animated = (_main || _passcode); auto bg = animated ? grabInner() : QPixmap(); @@ -325,13 +325,14 @@ void MainWindow::showSettings() { void MainWindow::showSpecialLayer( object_ptr layer, - LayerOptions options) { + anim::type animated) { if (_passcode) return; - ensureLayerCreated(); - _layerBg->showSpecialLayer(std::move(layer)); - if (options & LayerOption::ForceFast) { - _layerBg->finishAnimation(); + if (layer) { + ensureLayerCreated(); + _layerBg->showSpecialLayer(std::move(layer), animated); + } else if (_layerBg) { + _layerBg->hideSpecialLayer(animated); } } @@ -341,7 +342,7 @@ void MainWindow::showMainMenu() { if (isHidden()) showFromTray(); ensureLayerCreated(); - _layerBg->showMainMenu(); + _layerBg->showMainMenu(anim::type::normal); } void MainWindow::ensureLayerCreated() { @@ -362,10 +363,10 @@ void MainWindow::destroyLayerDelayed() { } } -void MainWindow::ui_hideSettingsAndLayer(LayerOptions options) { +void MainWindow::ui_hideSettingsAndLayer(anim::type animated) { if (_layerBg) { - _layerBg->hideAll(options); - if (options & LayerOption::ForceFast) { + _layerBg->hideAll(animated); + if (animated == anim::type::instant) { destroyLayerDelayed(); } } @@ -403,25 +404,24 @@ PasscodeWidget *MainWindow::passcodeWidget() { void MainWindow::ui_showBox( object_ptr box, - LayerOptions options) { + LayerOptions options, + anim::type animated) { if (box) { ensureLayerCreated(); if (options & LayerOption::KeepOther) { if (options & LayerOption::ShowAfterOther) { - _layerBg->prependBox(std::move(box)); + _layerBg->prependBox(std::move(box), animated); } else { - _layerBg->appendBox(std::move(box)); + _layerBg->appendBox(std::move(box), animated); } } else { - _layerBg->showBox(std::move(box)); - } - if (options & LayerOption::ForceFast) { - _layerBg->finishAnimation(); + _layerBg->showBox(std::move(box), animated); } } else { if (_layerBg) { - _layerBg->hideTopLayer(options); - if ((options & LayerOption::ForceFast) && !_layerBg->layerShown()) { + _layerBg->hideTopLayer(animated); + if ((animated == anim::type::instant) + && !_layerBg->layerShown()) { destroyLayerDelayed(); } } @@ -978,7 +978,7 @@ QImage MainWindow::iconWithCounter(int size, int count, style::color bg, style:: void MainWindow::sendPaths() { if (App::passcoded()) return; Messenger::Instance().hideMediaView(); - Ui::hideSettingsAndLayer(true); + Ui::hideSettingsAndLayer(anim::type::instant); if (_main) { _main->activate(); } diff --git a/Telegram/SourceFiles/mainwindow.h b/Telegram/SourceFiles/mainwindow.h index c598f1a03..ff5be0d3a 100644 --- a/Telegram/SourceFiles/mainwindow.h +++ b/Telegram/SourceFiles/mainwindow.h @@ -136,12 +136,12 @@ public: void showSpecialLayer( object_ptr layer, - LayerOptions options); - + anim::type animated); void ui_showBox( object_ptr box, - LayerOptions options); - void ui_hideSettingsAndLayer(LayerOptions options); + LayerOptions options, + anim::type animated); + void ui_hideSettingsAndLayer(anim::type animated); bool ui_isLayerShown(); void ui_showMediaPreview(DocumentData *document); void ui_showMediaPreview(PhotoData *photo); diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index 35743e0c1..29a54e005 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -647,11 +647,6 @@ void MediaView::updateMixerVideoVolume() const { } void MediaView::close() { - _sharedMedia = nullptr; - _sharedMediaData = base::none; - _userPhotos = nullptr; - _userPhotosData = base::none; - if (_menu) _menu->hideMenu(true); Messenger::Instance().hideMediaView(); } @@ -1256,7 +1251,7 @@ void MediaView::displayPhoto(not_null photo, HistoryItem *item) { _caption.setMarkedText( st::mediaviewCaptionStyle, photoMsg->getCaption(), - asBot ? _captionBotOptions : _captionTextOptions); + itemTextOptions(item)); } } @@ -2728,6 +2723,11 @@ bool MediaView::eventFilter(QObject *obj, QEvent *e) { void MediaView::setVisible(bool visible) { if (!visible) { + _sharedMedia = nullptr; + _sharedMediaData = base::none; + _userPhotos = nullptr; + _userPhotosData = base::none; + if (_menu) _menu->hideMenu(true); _controlsHideTimer.stop(); _controlsState = ControlsShown; a_cOpacity = anim::value(1, 1); diff --git a/Telegram/SourceFiles/messenger.cpp b/Telegram/SourceFiles/messenger.cpp index d7043c3e2..beef25b51 100644 --- a/Telegram/SourceFiles/messenger.cpp +++ b/Telegram/SourceFiles/messenger.cpp @@ -204,14 +204,14 @@ void Messenger::showPhoto(not_null link, HistoryIt } void Messenger::showPhoto(not_null photo, HistoryItem *item) { - if (_mediaView->isHidden()) Ui::hideLayer(true); + if (_mediaView->isHidden()) Ui::hideLayer(anim::type::instant); _mediaView->showPhoto(photo, item); _mediaView->activateWindow(); _mediaView->setFocus(); } void Messenger::showPhoto(not_null photo, PeerData *peer) { - if (_mediaView->isHidden()) Ui::hideLayer(true); + if (_mediaView->isHidden()) Ui::hideLayer(anim::type::instant); _mediaView->showPhoto(photo, peer); _mediaView->activateWindow(); _mediaView->setFocus(); @@ -221,7 +221,9 @@ void Messenger::showDocument(not_null document, HistoryItem *item if (cUseExternalVideoPlayer() && document->isVideo()) { QDesktopServices::openUrl(QUrl("file:///" + document->location(false).fname)); } else { - if (_mediaView->isHidden()) Ui::hideLayer(true); + if (_mediaView->isHidden()) { + Ui::hideLayer(anim::type::instant); + } _mediaView->showDocument(document, item); _mediaView->activateWindow(); _mediaView->setFocus(); diff --git a/Telegram/SourceFiles/overviewwidget.cpp b/Telegram/SourceFiles/overviewwidget.cpp index 637b223d4..72d80557f 100644 --- a/Telegram/SourceFiles/overviewwidget.cpp +++ b/Telegram/SourceFiles/overviewwidget.cpp @@ -1131,7 +1131,7 @@ void OverviewInner::keyPressEvent(QKeyEvent *e) { if ((_search->isHidden() || !_search->hasFocus()) && !_overview->isHidden() && e->key() == Qt::Key_Escape) { onCancel(); } else if (e->key() == Qt::Key_Back) { - App::main()->showBackFromStack(); + App::main()->showBackFromStack(anim::type::normal, anim::activation::normal); } else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) { onSearchMessages(); } @@ -1527,7 +1527,7 @@ void OverviewInner::onSearchUpdate() { void OverviewInner::onCancel() { if (_selected.isEmpty()) { if (onCancelSearch()) return; - App::main()->showBackFromStack(); + App::main()->showBackFromStack(anim::type::normal, anim::activation::normal); } else { _overview->onClearSelected(); } @@ -2070,7 +2070,7 @@ bool OverviewWidget::paintTopBar(Painter &p, int decreaseWidth) { } void OverviewWidget::topBarClick() { - App::main()->showBackFromStack(); + App::main()->showBackFromStack(anim::type::normal, anim::activation::normal); } PeerData *OverviewWidget::peer() const { diff --git a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp index f847f3141..684df3e9f 100644 --- a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp @@ -62,7 +62,7 @@ QByteArray EscapeShell(const QByteArray &content) { } // namespace internal void UnsafeShowInFolder(const QString &filepath) { - Ui::hideLayer(true); // Hide mediaview to make other apps visible. + Ui::hideLayer(anim::type::instant); // Hide mediaview to make other apps visible. auto absolutePath = QFileInfo(filepath).absoluteFilePath(); QProcess process; diff --git a/Telegram/SourceFiles/profile/profile_block_channel_members.cpp b/Telegram/SourceFiles/profile/profile_block_channel_members.cpp index 957e1fea5..4f3665c9d 100644 --- a/Telegram/SourceFiles/profile/profile_block_channel_members.cpp +++ b/Telegram/SourceFiles/profile/profile_block_channel_members.cpp @@ -149,14 +149,19 @@ void ChannelMembersWidget::onMembers() { void ChannelMembersWidget::onAdmins() { if (auto channel = peer()->asChannel()) { - ParticipantsBoxController::Start(channel, ParticipantsBoxController::Role::Admins); + ParticipantsBoxController::Start( + channel, + ParticipantsBoxController::Role::Admins); } } void ChannelMembersWidget::onRecentActions() { if (auto channel = peer()->asChannel()) { if (auto main = App::main()) { - main->showSection(AdminLog::SectionMemento(channel), anim::type::normal); + main->showSection( + AdminLog::SectionMemento(channel), + anim::type::normal, + anim::activation::normal); } } } diff --git a/Telegram/SourceFiles/profile/profile_block_settings.cpp b/Telegram/SourceFiles/profile/profile_block_settings.cpp index 72a0f7e1f..1e858dcc6 100644 --- a/Telegram/SourceFiles/profile/profile_block_settings.cpp +++ b/Telegram/SourceFiles/profile/profile_block_settings.cpp @@ -212,27 +212,36 @@ void SettingsWidget::onManageAdmins() { if (auto chat = peer()->asChat()) { EditChatAdminsBoxController::Start(chat); } else if (auto channel = peer()->asChannel()) { - ParticipantsBoxController::Start(channel, ParticipantsBoxController::Role::Admins); + ParticipantsBoxController::Start( + channel, + ParticipantsBoxController::Role::Admins); } } void SettingsWidget::onRecentActions() { if (auto channel = peer()->asChannel()) { if (auto main = App::main()) { - main->showSection(AdminLog::SectionMemento(channel), anim::type::normal); + main->showSection( + AdminLog::SectionMemento(channel), + anim::type::normal, + anim::activation::normal); } } } void SettingsWidget::onManageBannedUsers() { if (auto channel = peer()->asMegagroup()) { - ParticipantsBoxController::Start(channel, ParticipantsBoxController::Role::Kicked); + ParticipantsBoxController::Start( + channel, + ParticipantsBoxController::Role::Kicked); } } void SettingsWidget::onManageRestrictedUsers() { if (auto channel = peer()->asMegagroup()) { - ParticipantsBoxController::Start(channel, ParticipantsBoxController::Role::Restricted); + ParticipantsBoxController::Start( + channel, + ParticipantsBoxController::Role::Restricted); } } diff --git a/Telegram/SourceFiles/profile/profile_block_shared_media.cpp b/Telegram/SourceFiles/profile/profile_block_shared_media.cpp index 378990ff4..caa4b92b5 100644 --- a/Telegram/SourceFiles/profile/profile_block_shared_media.cpp +++ b/Telegram/SourceFiles/profile/profile_block_shared_media.cpp @@ -201,7 +201,10 @@ void SharedMediaWidget::onShowCommonGroups() { return; } if (auto main = App::main()) { - main->showSection(Profile::CommonGroups::SectionMemento(peer()->asUser()), anim::type::normal); + main->showSection( + Profile::CommonGroups::SectionMemento(peer()->asUser()), + anim::type::normal, + anim::activation::normal); } } diff --git a/Telegram/SourceFiles/profile/profile_common_groups_section.cpp b/Telegram/SourceFiles/profile/profile_common_groups_section.cpp index 021cc2bc2..191ec5dff 100644 --- a/Telegram/SourceFiles/profile/profile_common_groups_section.cpp +++ b/Telegram/SourceFiles/profile/profile_common_groups_section.cpp @@ -59,7 +59,9 @@ FixedBar::FixedBar(QWidget *parent) : TWidget(parent) } void FixedBar::onBack() { - App::main()->showBackFromStack(); + App::main()->showBackFromStack( + anim::type::normal, + anim::activation::normal); } int FixedBar::resizeGetHeight(int newWidth) { diff --git a/Telegram/SourceFiles/profile/profile_fixed_bar.cpp b/Telegram/SourceFiles/profile/profile_fixed_bar.cpp index f2a6b5be1..35801f847 100644 --- a/Telegram/SourceFiles/profile/profile_fixed_bar.cpp +++ b/Telegram/SourceFiles/profile/profile_fixed_bar.cpp @@ -148,7 +148,7 @@ void FixedBar::addRightAction(RightActionType type, base::lambda text } void FixedBar::onBack() { - App::main()->showBackFromStack(); + App::main()->showBackFromStack(anim::type::normal, anim::activation::normal); } void FixedBar::onEditChannel() { diff --git a/Telegram/SourceFiles/ui/animation.h b/Telegram/SourceFiles/ui/animation.h index 41fe216cb..aa4f59912 100644 --- a/Telegram/SourceFiles/ui/animation.h +++ b/Telegram/SourceFiles/ui/animation.h @@ -98,6 +98,11 @@ enum class type { instant, }; +enum class activation { + normal, + background, +}; + using transition = base::lambda; extern transition linear; diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index aadf950d4..54a805fc9 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -99,7 +99,7 @@ bool MainWindow::hideNoQuit() { } void MainWindow::clearWidgets() { - Ui::hideLayer(true); + Ui::hideLayer(anim::type::instant); clearWidgetsHook(); updateGlobalMenu(); } diff --git a/Telegram/SourceFiles/window/window_controller.cpp b/Telegram/SourceFiles/window/window_controller.cpp index 10681c52d..a57318fc0 100644 --- a/Telegram/SourceFiles/window/window_controller.cpp +++ b/Telegram/SourceFiles/window/window_controller.cpp @@ -257,64 +257,93 @@ void Controller::updateColumnLayout() { void Controller::showPeerHistory( PeerId peerId, Ui::ShowWay way, - MsgId msgId) { - Ui::showPeerHistory(peerId, msgId, way); + MsgId msgId, + anim::type animated, + anim::activation activation) { + Ui::showPeerHistory( + peerId, + msgId, + way, + animated, + activation); } void Controller::showPeerHistory( not_null peer, Ui::ShowWay way, - MsgId msgId) { - showPeerHistory(peer->id, way, msgId); + MsgId msgId, + anim::type animated, + anim::activation activation) { + showPeerHistory( + peer->id, + way, + msgId, + animated, + activation); } void Controller::showPeerHistory( not_null history, Ui::ShowWay way, - MsgId msgId) { - showPeerHistory(history->peer->id, way, msgId); + MsgId msgId, + anim::type animated, + anim::activation activation) { + showPeerHistory( + history->peer->id, + way, + msgId, + animated, + activation); } void Controller::showPeerInfo( PeerId peerId, - anim::type animated) { + anim::type animated, + anim::activation activation) { if (Adaptive::ThreeColumn()) { Auth().data().setThirdSectionInfoEnabled(true); Auth().saveDataDelayed(kThirdSectionInfoTimeoutMs); } - showSection(Info::Memento(peerId), animated); + showSection( + Info::Memento(peerId), + animated, + activation); } void Controller::showPeerInfo( not_null peer, - anim::type animated) { - showPeerInfo(peer->id, animated); + anim::type animated, + anim::activation activation) { + showPeerInfo(peer->id, animated, activation); } void Controller::showPeerInfo( not_null history, - anim::type animated) { - showPeerInfo(history->peer->id, animated); + anim::type animated, + anim::activation activation) { + showPeerInfo(history->peer->id, animated, activation); } void Controller::showSection( SectionMemento &&memento, - anim::type animated) { - App::main()->showSection(std::move(memento), animated); + anim::type animated, + anim::activation activation) { + App::main()->showSection( + std::move(memento), + animated, + activation); } -void Controller::showBackFromStack() { - chats()->showBackFromStack(); +void Controller::showBackFromStack( + anim::type animated, + anim::activation activation) { + chats()->showBackFromStack(animated, activation); } void Controller::showSpecialLayer( object_ptr &&layer, - LayerOptions options) { - App::wnd()->showSpecialLayer(std::move(layer), options); -} - -void Controller::hideSpecialLayer(LayerOptions options) { - Ui::hideSettingsAndLayer(options & LayerOption::ForceFast); + anim::type animated) { + App::wnd()->showSpecialLayer(std::move(layer), animated); } not_null Controller::chats() const { diff --git a/Telegram/SourceFiles/window/window_controller.h b/Telegram/SourceFiles/window/window_controller.h index 64f25b73a..c4028ba9c 100644 --- a/Telegram/SourceFiles/window/window_controller.h +++ b/Telegram/SourceFiles/window/window_controller.h @@ -95,38 +95,65 @@ public: void closeThirdSection(); void showSection( SectionMemento &&memento, - anim::type animated = anim::type::normal); - void showBackFromStack(); + anim::type animated = anim::type::normal, + anim::activation activation = anim::activation::normal); + void showBackFromStack( + anim::type animated = anim::type::normal, + anim::activation activation = anim::activation::normal); void showSpecialLayer( object_ptr &&layer, - LayerOptions options = LayerOption::Animated); + anim::type animated = anim::type::normal); void hideSpecialLayer( - LayerOptions options = LayerOption::Animated); + anim::type animated = anim::type::normal) { + showSpecialLayer(nullptr, animated); + } void showPeerHistory( PeerId peerId, Ui::ShowWay way = Ui::ShowWay::ClearStack, - MsgId msgId = ShowAtUnreadMsgId); + MsgId msgId = ShowAtUnreadMsgId, + anim::type animated = anim::type::normal, + anim::activation activation = anim::activation::normal); void showPeerHistory( not_null peer, Ui::ShowWay way = Ui::ShowWay::ClearStack, - MsgId msgId = ShowAtUnreadMsgId); + MsgId msgId = ShowAtUnreadMsgId, + anim::type animated = anim::type::normal, + anim::activation activation = anim::activation::normal); void showPeerHistory( not_null history, Ui::ShowWay way = Ui::ShowWay::ClearStack, - MsgId msgId = ShowAtUnreadMsgId); + MsgId msgId = ShowAtUnreadMsgId, + anim::type animated = anim::type::normal, + anim::activation activation = anim::activation::normal); void showPeerInfo( PeerId peerId, - anim::type animated = anim::type::normal); + anim::type animated = anim::type::normal, + anim::activation activation = anim::activation::normal); void showPeerInfo( not_null peer, - anim::type animated = anim::type::normal); + anim::type animated = anim::type::normal, + anim::activation activation = anim::activation::normal); void showPeerInfo( not_null history, - anim::type animated = anim::type::normal); + anim::type animated = anim::type::normal, + anim::activation activation = anim::activation::normal); - void showJumpToDate(not_null peer, QDate requestedDate); + void clearSectionStack( + anim::type animated = anim::type::normal, + anim::activation activation = anim::activation::normal) { + showPeerHistory( + PeerId(0), + Ui::ShowWay::ClearStack, + ShowAtUnreadMsgId, + animated, + activation); + } + + void showJumpToDate( + not_null peer, + QDate requestedDate); base::Variable &dialogsWidthRatio() { return _dialogsWidthRatio;