diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index 19af8f2ba..a0be0a20a 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -346,6 +346,7 @@ bool ResolveSettings( if (!controller) { return false; } + controller->window().activate(); const auto section = match->captured(1).mid(1).toLower(); if (section.isEmpty()) { controller->window().showSettings(); diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index bc542e29e..c35948c2e 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -229,12 +229,6 @@ void searchByHashtag(const QString &tag, PeerData *inPeer) { } } -void showSettings() { - if (auto w = App::wnd()) { - w->showSettings(); - } -} - } // namespace App namespace Ui { diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index 353d26352..a9ef5be1b 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -48,7 +48,6 @@ void activateBotCommand( int row, int column); void searchByHashtag(const QString &tag, PeerData *inPeer); -void showSettings(); } // namespace App diff --git a/Telegram/SourceFiles/intro/intro_widget.cpp b/Telegram/SourceFiles/intro/intro_widget.cpp index 0d2afd9b7..d9ef403d5 100644 --- a/Telegram/SourceFiles/intro/intro_widget.cpp +++ b/Telegram/SourceFiles/intro/intro_widget.cpp @@ -121,8 +121,6 @@ Widget::Widget( _next->entity()->setClickedCallback([=] { getStep()->submit(); }); - _settings->entity()->setClickedCallback([] { App::wnd()->showSettings(); }); - if (_changeLanguage) { _changeLanguage->finishAnimating(); } @@ -153,6 +151,10 @@ Widget::Widget( } } +rpl::producer<> Widget::showSettingsRequested() const { + return _settings->entity()->clicks() | rpl::to_empty; +} + not_null Widget::floatPlayerDelegate() { return static_cast(this); } diff --git a/Telegram/SourceFiles/intro/intro_widget.h b/Telegram/SourceFiles/intro/intro_widget.h index 001409dfc..59be97a2e 100644 --- a/Telegram/SourceFiles/intro/intro_widget.h +++ b/Telegram/SourceFiles/intro/intro_widget.h @@ -99,6 +99,8 @@ public: void setInnerFocus(); + [[nodiscard]] rpl::producer<> showSettingsRequested() const; + ~Widget(); protected: diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 24a2fc724..743fa3fd0 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -289,6 +289,11 @@ void MainWindow::setupIntro(Intro::EnterPoint point) { destroyLayer(); auto created = object_ptr(bodyWidget(), &account(), point); + created->showSettingsRequested( + ) | rpl::start_with_next([=] { + showSettings(); + }, created->lifetime()); + clearWidgets(); _intro = std::move(created); if (_passcodeLock) { @@ -342,9 +347,6 @@ void MainWindow::setupMain() { } void MainWindow::showSettings() { - if (isHidden()) { - showFromTray(); - } if (_passcodeLock) { return; } diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index 0abc1995d..8c022e7d7 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -1043,8 +1043,11 @@ void MainWindow::createGlobalMenu() { auto prefs = edit->addAction( tr::lng_mac_menu_preferences(tr::now), - App::wnd(), - [=] { App::wnd()->showSettings(); }, + this, + [=] { + ensureWindowShown(); + controller().showSettings(); + }, QKeySequence(Qt::ControlModifier | Qt::Key_Comma)); prefs->setMenuRole(QAction::PreferencesRole); diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm index 3d4919191..37b2e7ef8 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm @@ -699,10 +699,18 @@ void MainWindow::createGlobalMenu() { about->setMenuRole(QAction::AboutQtRole); main->addSeparator(); - QAction *prefs = main->addAction(tr::lng_mac_menu_preferences(tr::now), App::wnd(), [=] { - App::wnd()->showSettings(); - }, QKeySequence(Qt::ControlModifier | Qt::Key_Comma)); - prefs->setMenuRole(QAction::PreferencesRole); + { + auto callback = [=] { + ensureWindowShown(); + controller().showSettings(); + }; + main->addAction( + tr::lng_mac_menu_preferences(tr::now), + this, + std::move(callback), + QKeySequence(Qt::ControlModifier | Qt::Key_Comma)) + ->setMenuRole(QAction::PreferencesRole); + } QMenu *file = psMainMenu.addMenu(tr::lng_mac_menu_file(tr::now)); psLogout = file->addAction(tr::lng_mac_menu_logout(tr::now)); diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index b8840574e..8a6cd9aa4 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -930,8 +930,8 @@ void MainMenu::refreshMenu() { _controller->session().supportTemplates().reload(); }, &st::mainMenuReload, &st::mainMenuReloadOver); } - _menu->addAction(tr::lng_menu_settings(tr::now), [] { - App::wnd()->showSettings(); + _menu->addAction(tr::lng_menu_settings(tr::now), [=] { + controller->showSettings(); }, &st::mainMenuSettings, &st::mainMenuSettingsOver); _nightThemeAction = std::make_shared>();