From 01c2be3f0139fc237e6286bd077d125bcaed10df Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 6 Dec 2021 12:31:08 +0400 Subject: [PATCH] Add some checks for actions in a locked state. --- .../dialogs/dialogs_inner_widget.cpp | 5 ++++- Telegram/SourceFiles/mainwidget.cpp | 8 ++++++-- .../platform/mac/main_window_mac.mm | 18 +++++++++--------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 7fdceb59f..5c575dddf 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -42,6 +42,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "main/main_session_settings.h" #include "window/notifications_manager.h" +#include "window/window_controller.h" #include "window/window_session_controller.h" #include "window/window_peer_menu.h" #include "ui/widgets/multi_select.h" @@ -3011,7 +3012,9 @@ void InnerWidget::updateRowCornerStatusShown( void InnerWidget::setupShortcuts() { Shortcuts::Requests( ) | rpl::filter([=] { - return isActiveWindow() && !Ui::isLayerShown(); + return isActiveWindow() + && !Ui::isLayerShown() + && !_controller->window().locked(); }) | rpl::start_with_next([=](not_null request) { using Command = Shortcuts::Command; diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index a36fbea4a..79e97caaa 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -1257,8 +1257,9 @@ void MainWidget::ui_showPeerHistory( PeerId peerId, const SectionShow ¶ms, MsgId showAtMsgId) { - - if (auto peer = session().data().peerLoaded(peerId)) { + if (peerId && _controller->window().locked()) { + return; + } else if (auto peer = session().data().peerLoaded(peerId)) { if (peer->migrateTo()) { peer = peer->migrateTo(); peerId = peer->id; @@ -1579,6 +1580,9 @@ void MainWidget::showNewSection( const SectionShow ¶ms) { using Column = Window::Column; + if (_controller->window().locked()) { + return; + } auto saveInStack = (params.way == SectionShow::Way::Forward); const auto thirdSectionTop = getThirdSectionTop(); const auto newThirdGeometry = QRect( diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm index c9ee23ddd..e9092ca4e 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm @@ -485,17 +485,15 @@ void MainWindow::createGlobalMenu() { QMenu *window = psMainMenu.addMenu(tr::lng_mac_menu_window(tr::now)); psContacts = window->addAction(tr::lng_mac_menu_contacts(tr::now)); connect(psContacts, &QAction::triggered, psContacts, crl::guard(this, [=] { - if (isHidden()) { - showFromTray(); - } - if (!sessionController()) { - return; - } + Expects(sessionController() != nullptr && !controller().locked()); + + ensureWindowShown(); sessionController()->show(PrepareContactsBox(sessionController())); })); { auto callback = [=] { - Expects(sessionController() != nullptr); + Expects(sessionController() != nullptr && !controller().locked()); + ensureWindowShown(); sessionController()->showAddContact(); }; @@ -507,7 +505,8 @@ void MainWindow::createGlobalMenu() { window->addSeparator(); { auto callback = [=] { - Expects(sessionController() != nullptr); + Expects(sessionController() != nullptr && !controller().locked()); + ensureWindowShown(); sessionController()->showNewGroup(); }; @@ -518,7 +517,8 @@ void MainWindow::createGlobalMenu() { } { auto callback = [=] { - Expects(sessionController() != nullptr); + Expects(sessionController() != nullptr && !controller().locked()); + ensureWindowShown(); sessionController()->showNewChannel(); };