diff --git a/Telegram/SourceFiles/boxes/abstract_box.cpp b/Telegram/SourceFiles/boxes/abstract_box.cpp index 7e0587403d..db97bfe729 100644 --- a/Telegram/SourceFiles/boxes/abstract_box.cpp +++ b/Telegram/SourceFiles/boxes/abstract_box.cpp @@ -378,11 +378,14 @@ void AbstractBox::updateButtonsPositions() { if (_leftButton) { _leftButton->moveToLeft(right, top); } - for_const (auto &button, _buttons) { + for (const auto &button : _buttons) { button->moveToRight(right, top); right += button->width() + padding.left(); } } + if (_topButton) { + _topButton->moveToRight(0, 0); + } } QPointer AbstractBox::outerContainer() { @@ -403,6 +406,7 @@ void AbstractBox::clearButtons() { button.destroy(); } _leftButton.destroy(); + _topButton = nullptr; } QPointer AbstractBox::addButton(Fn textFactory, Fn clickCallback, const style::RoundButton &st) { @@ -423,6 +427,15 @@ QPointer AbstractBox::addLeftButton(Fn textFactory, return result; } +QPointer AbstractBox::addTopButton(const style::IconButton &st, Fn clickCallback) { + _topButton = base::make_unique_q(this, st); + auto result = QPointer(_topButton.get()); + result->setClickedCallback(std::move(clickCallback)); + result->show(); + updateButtonsPositions(); + return result; +} + void AbstractBox::setDimensions(int newWidth, int maxHeight) { _maxContentHeight = maxHeight; diff --git a/Telegram/SourceFiles/boxes/abstract_box.h b/Telegram/SourceFiles/boxes/abstract_box.h index 5da8eeb8ad..45561451d0 100644 --- a/Telegram/SourceFiles/boxes/abstract_box.h +++ b/Telegram/SourceFiles/boxes/abstract_box.h @@ -8,10 +8,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "window/layer_widget.h" +#include "base/unique_qptr.h" #include "ui/rp_widget.h" namespace style { struct RoundButton; +struct IconButton; struct ScrollArea; } // namespace style @@ -35,6 +37,7 @@ public: virtual void clearButtons() = 0; virtual QPointer addButton(Fn textFactory, Fn clickCallback, const style::RoundButton &st) = 0; virtual QPointer addLeftButton(Fn textFactory, Fn clickCallback, const style::RoundButton &st) = 0; + virtual QPointer addTopButton(const style::IconButton &st, Fn clickCallback) = 0; virtual void updateButtonsPositions() = 0; virtual void showBox( @@ -102,6 +105,9 @@ public: } QPointer addButton(Fn textFactory, Fn clickCallback); QPointer addLeftButton(Fn textFactory, Fn clickCallback); + QPointer addTopButton(const style::IconButton &st, Fn clickCallback) { + return getDelegate()->addTopButton(st, std::move(clickCallback)); + } QPointer addButton(Fn textFactory, Fn clickCallback, const style::RoundButton &st) { return getDelegate()->addButton(std::move(textFactory), std::move(clickCallback), st); } @@ -251,6 +257,7 @@ public: void clearButtons() override; QPointer addButton(Fn textFactory, Fn clickCallback, const style::RoundButton &st) override; QPointer addLeftButton(Fn textFactory, Fn clickCallback, const style::RoundButton &st) override; + QPointer addTopButton(const style::IconButton &st, Fn clickCallback) override; void updateButtonsPositions() override; QPointer outerContainer() override; @@ -319,6 +326,7 @@ private: std::vector> _buttons; object_ptr _leftButton = { nullptr }; + base::unique_qptr _topButton = { nullptr }; }; diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index 7959a122b8..fa5bcf3246 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -896,3 +896,16 @@ createPollWarning: FlatLabel(defaultFlatLabel) { } } createPollWarningPosition: point(16px, 6px); + +callSettingsButton: IconButton { + width: 50px; + height: boxLayerTitleHeight; + icon: icon {{ "menu_settings", boxTitleCloseFg }}; + iconOver: icon {{ "menu_settings", boxTitleCloseFgOver }}; + iconPosition: point(8px, -1px); + rippleAreaSize: 44px; + rippleAreaPosition: point(0px, 6px); + ripple: RippleAnimation(defaultRippleAnimation) { + color: windowBgOver; + } +} diff --git a/Telegram/SourceFiles/settings/settings.style b/Telegram/SourceFiles/settings/settings.style index fe26687681..8b5dcf7cd8 100644 --- a/Telegram/SourceFiles/settings/settings.style +++ b/Telegram/SourceFiles/settings/settings.style @@ -60,7 +60,6 @@ settingsIconFaq: icon {{ "settings_faq", menuIconFg }}; settingsIconStickers: icon {{ "settings_stickers", menuIconFg }}; settingsIconEmoji: icon {{ "settings_emoji", menuIconFg }}; settingsIconThemes: icon {{ "settings_themes", menuIconFg }}; -settingsIconCalls: icon {{ "settings_phone_number", menuIconFg }}; settingsSetPhotoSkip: 7px; diff --git a/Telegram/SourceFiles/settings/settings_advanced.cpp b/Telegram/SourceFiles/settings/settings_advanced.cpp index 41d176c97e..979da5e838 100644 --- a/Telegram/SourceFiles/settings/settings_advanced.cpp +++ b/Telegram/SourceFiles/settings/settings_advanced.cpp @@ -436,11 +436,32 @@ void SetupPerformance(not_null container) { }, container->lifetime()); } +void SetupSystemIntegration( + not_null container, + Fn showOther) { + AddDivider(container); + AddSkip(container); + AddSubsectionTitle(container, lng_settings_system_integration); + AddButton( + container, + lng_settings_section_call_settings, + st::settingsButton + )->addClickHandler([=] { + showOther(Type::Calls); + }); + SetupTray(container); + AddSkip(container); +} + Advanced::Advanced(QWidget *parent, UserData *self) : Section(parent) { setupContent(); } +rpl::producer Advanced::sectionShowOther() { + return _showOther.events(); +} + void Advanced::setupContent() { const auto content = Ui::CreateChild(this); @@ -473,18 +494,16 @@ void Advanced::setupContent() { } SetupDataStorage(content); SetupAutoDownload(content); - if (HasTray()) { - addDivider(); - AddSkip(content); - AddSubsectionTitle(content, lng_settings_system_integration); - SetupTray(content); - AddSkip(content); - } - addDivider(); + SetupSystemIntegration(content, [=](Type type) { + _showOther.fire_copy(type); + }); + + AddDivider(content); AddSkip(content); AddSubsectionTitle(content, lng_settings_performance); SetupPerformance(content); AddSkip(content); + if (cAutoUpdate()) { addUpdate(); } diff --git a/Telegram/SourceFiles/settings/settings_advanced.h b/Telegram/SourceFiles/settings/settings_advanced.h index b816e136ea..60d8c3f442 100644 --- a/Telegram/SourceFiles/settings/settings_advanced.h +++ b/Telegram/SourceFiles/settings/settings_advanced.h @@ -23,9 +23,13 @@ class Advanced : public Section { public: explicit Advanced(QWidget *parent, UserData *self = nullptr); + rpl::producer sectionShowOther() override; + private: void setupContent(); + rpl::event_stream _showOther; + }; } // namespace Settings diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index 1618393b5f..a1d1874ae0 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -87,10 +87,6 @@ void SetupSections( lng_settings_section_chat_settings, Type::Chat, &st::settingsIconChat); - addSection( - lng_settings_section_call_settings, - Type::Calls, - &st::settingsIconCalls); addSection( lng_settings_advanced, Type::Advanced, diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index eb86f4d004..83a607718f 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_main_menu.h" #include "window/themes/window_theme.h" +#include "window/window_controller.h" #include "ui/widgets/buttons.h" #include "ui/widgets/labels.h" #include "ui/widgets/menu.h" @@ -16,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwindow.h" #include "storage/localstorage.h" #include "support/support_templates.h" +#include "settings/settings_common.h" #include "boxes/about_box.h" #include "boxes/peer_list_controllers.h" #include "calls/calls_box_controller.h" @@ -27,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_window.h" #include "styles/style_dialogs.h" #include "styles/style_settings.h" +#include "styles/style_boxes.h" namespace Window { namespace { @@ -193,7 +196,14 @@ void MainMenu::refreshMenu() { if (Global::PhoneCallsEnabled()) { _menu->addAction(lang(lng_menu_calls), [] { Ui::show(Box(std::make_unique(), [](not_null box) { - box->addButton(langFactory(lng_close), [box] { box->closeBox(); }); + box->addButton(langFactory(lng_close), [=] { + box->closeBox(); + }); + box->addTopButton(st::callSettingsButton, [=] { + App::wnd()->controller()->showSettings( + Settings::Type::Calls, + Window::SectionShow(anim::type::instant)); + }); })); }, &st::mainMenuCalls, &st::mainMenuCallsOver); }