From e1ba9f8ff8c211ebaf23392fa15ea199004f0cb4 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 20 Sep 2017 21:40:23 +0300 Subject: [PATCH] Hide send message in Info for current chat. --- .../chat_helpers/stickers_list_widget.cpp | 2 +- .../SourceFiles/dialogs/dialogs_widget.cpp | 2 +- .../history/history_inner_widget.cpp | 2 +- .../SourceFiles/history/history_widget.cpp | 7 ++-- .../SourceFiles/info/info_narrow_wrap.cpp | 21 +++++++++--- Telegram/SourceFiles/info/info_narrow_wrap.h | 8 ++--- .../info/info_profile_inner_widget.cpp | 16 +++++++--- .../SourceFiles/info/info_profile_lines.cpp | 15 ++++++--- Telegram/SourceFiles/mainwidget.cpp | 21 ++++++------ Telegram/SourceFiles/mainwidget.h | 4 ++- Telegram/SourceFiles/stdafx.h | 4 +++ Telegram/SourceFiles/ui/abstract_button.cpp | 2 +- Telegram/SourceFiles/ui/animation.cpp | 3 ++ Telegram/SourceFiles/ui/widgets/buttons.cpp | 6 ++-- Telegram/SourceFiles/ui/widgets/buttons.h | 9 ++---- Telegram/SourceFiles/ui/widgets/labels.cpp | 4 ++- .../SourceFiles/window/top_bar_widget.cpp | 32 +++++++++++++------ Telegram/SourceFiles/window/top_bar_widget.h | 1 - .../SourceFiles/window/window_controller.h | 17 +++------- 19 files changed, 111 insertions(+), 65 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index 4b32ea3db..e65b0846d 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -335,7 +335,7 @@ bool StickersListWidget::Footer::event(QEvent *e) { } } } - return TWidget::event(e); + return InnerFooter::event(e); } void StickersListWidget::Footer::updateSelected() { diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 1fb4c63db..f00dfd1ee 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -843,7 +843,7 @@ void DialogsWidget::setSearchInPeer(PeerData *peer, UserData *from) { if (searchInPeerUpdated) { _searchInPeer = newSearchInPeer; from = nullptr; - controller()->searchInPeerChanged().notify(_searchInPeer, true); + controller()->searchInPeer = _searchInPeer; updateJumpToDateVisibility(); } else if (!_searchInPeer) { from = nullptr; diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index f83b174db..74d6278af 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -578,7 +578,7 @@ bool HistoryInner::event(QEvent *e) { return true; } } - return QWidget::event(e); + return TWidget::event(e); } void HistoryInner::onTouchScrollTimer() { diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 0bbd73bf1..11391f9c9 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1817,7 +1817,8 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re App::main()->dlgUpdated(wasHistory ? wasHistory->peer : nullptr, wasMsgId); emit historyShown(_history, _showAtMsgId); - controller()->historyPeerChanged().notify(_peer, true); + controller()->historyCanWrite = _canSendMessages; + controller()->historyPeer = _peer; update(); } @@ -5913,7 +5914,7 @@ void HistoryWidget::fullPeerUpdated(PeerData *peer) { bool newCanSendMessages = canSendMessages(_peer); if (newCanSendMessages != _canSendMessages) { _canSendMessages = newCanSendMessages; - controller()->historyPeerCanWriteChanged().notify(_peer); + controller()->historyCanWrite = _canSendMessages; if (!_canSendMessages) { cancelReply(); } @@ -5952,7 +5953,7 @@ void HistoryWidget::handlePeerUpdate() { bool newCanSendMessages = canSendMessages(_peer); if (newCanSendMessages != _canSendMessages) { _canSendMessages = newCanSendMessages; - controller()->historyPeerCanWriteChanged().notify(_peer); + controller()->historyCanWrite = _canSendMessages; if (!_canSendMessages) { cancelReply(); } diff --git a/Telegram/SourceFiles/info/info_narrow_wrap.cpp b/Telegram/SourceFiles/info/info_narrow_wrap.cpp index d39ead1b7..4179e7f6a 100644 --- a/Telegram/SourceFiles/info/info_narrow_wrap.cpp +++ b/Telegram/SourceFiles/info/info_narrow_wrap.cpp @@ -30,6 +30,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "ui/widgets/discrete_sliders.h" #include "ui/widgets/shadow.h" #include "ui/widgets/buttons.h" +#include "ui/effects/widget_fade_wrap.h" #include "window/window_controller.h" #include "window/main_window.h" #include "mainwindow.h" @@ -44,7 +45,10 @@ NarrowWrap::NarrowWrap( QWidget *parent, not_null controller, not_null memento) -: Window::SectionWidget(parent, controller) { +: Window::SectionWidget(parent, controller) +, _topShadow(this, object_ptr(this, st::shadowFg)) { + _topShadow->hideFast(); + _topShadow->raise(); setInternalState(geometry(), memento); } @@ -52,7 +56,10 @@ NarrowWrap::NarrowWrap( QWidget *parent, not_null controller, not_null memento) -: Window::SectionWidget(parent, controller) { +: Window::SectionWidget(parent, controller) +, _topShadow(this, object_ptr(this, st::shadowFg)) { + _topShadow->hideFast(); + _topShadow->raise(); restoreState(memento); } @@ -102,9 +109,11 @@ rpl::producer NarrowWrap::desiredHeightForContent() const { QPixmap NarrowWrap::grabForShowAnimation( const Window::SectionSlideParams ¶ms) { -// if (params.withTopBarShadow) _topShadow->hide(); + anim::SetDisabled(true); + if (params.withTopBarShadow) _topShadow->hide(); auto result = myGrab(this); -// if (params.withTopBarShadow) _topShadow->show(); + if (params.withTopBarShadow) _topShadow->show(); + anim::SetDisabled(false); return result; } @@ -112,6 +121,10 @@ void NarrowWrap::doSetInnerFocus() { // _content->setInnerFocus(); } +bool NarrowWrap::hasTopBarShadow() const { + return !_topShadow->isHidden() && !_topShadow->animating(); +} + bool NarrowWrap::showInternal( not_null memento) { if (auto infoMemento = dynamic_cast(memento.get())) { diff --git a/Telegram/SourceFiles/info/info_narrow_wrap.h b/Telegram/SourceFiles/info/info_narrow_wrap.h index b94090573..2ea397d12 100644 --- a/Telegram/SourceFiles/info/info_narrow_wrap.h +++ b/Telegram/SourceFiles/info/info_narrow_wrap.h @@ -26,6 +26,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org namespace Ui { class PlainShadow; class SettingsSlider; +template +class WidgetFadeWrap; } // namespace Ui namespace Info { @@ -58,9 +60,7 @@ public: return peer(); } - bool hasTopBarShadow() const override { - return true; - } + bool hasTopBarShadow() const override; QPixmap grabForShowAnimation( const Window::SectionSlideParams ¶ms) override; @@ -99,7 +99,7 @@ private: void showContent(object_ptr content); object_ptr createTopBar(); - object_ptr _topShadow = { nullptr }; + object_ptr> _topShadow = { nullptr }; object_ptr _content = { nullptr }; object_ptr _topBar = { nullptr }; diff --git a/Telegram/SourceFiles/info/info_profile_inner_widget.cpp b/Telegram/SourceFiles/info/info_profile_inner_widget.cpp index 90b053503..1f8b28deb 100644 --- a/Telegram/SourceFiles/info/info_profile_inner_widget.cpp +++ b/Telegram/SourceFiles/info/info_profile_inner_widget.cpp @@ -120,16 +120,24 @@ object_ptr InnerWidget::setupMuteToggle( void InnerWidget::setupMainUserButtons( Ui::VerticalLayout *wrap, not_null user) const { - auto sendMessage = wrap->add(object_ptr