From 82aa64ca0a9818e1067794e29f10abbc0dd98343 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 15 Feb 2020 22:45:50 +0400 Subject: [PATCH] Enable third column by default in Mac App Store build. --- Telegram/SourceFiles/main/main_settings.cpp | 8 ++++++++ Telegram/SourceFiles/main/main_settings.h | 6 ++++-- Telegram/SourceFiles/window/main_window.cpp | 14 ++++++++++---- Telegram/SourceFiles/window/window.style | 2 ++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/main/main_settings.cpp b/Telegram/SourceFiles/main/main_settings.cpp index 00c24c45d6..83975e9f58 100644 --- a/Telegram/SourceFiles/main/main_settings.cpp +++ b/Telegram/SourceFiles/main/main_settings.cpp @@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "support/support_common.h" #include "storage/serialize_common.h" #include "boxes/send_files_box.h" +#include "base/platform/base_platform_info.h" namespace Main { namespace { @@ -38,10 +39,17 @@ Settings::Variables::Variables() , selectorTab(ChatHelpers::SelectorTab::Emoji) , floatPlayerColumn(Window::Column::Second) , floatPlayerCorner(RectPart::TopRight) +, dialogsWidthRatio(ThirdColumnByDefault() + ? kDefaultBigDialogsWidthRatio + : kDefaultDialogsWidthRatio) , sendSubmitWay(Ui::InputSubmitSettings::Enter) , supportSwitch(Support::SwitchSettings::Next) { } +bool Settings::ThirdColumnByDefault() { + return Platform::IsMacStoreBuild(); +} + QByteArray Settings::serialize() const { const auto autoDownload = _variables.autoDownload.serialize(); auto size = sizeof(qint32) * 38; diff --git a/Telegram/SourceFiles/main/main_settings.h b/Telegram/SourceFiles/main/main_settings.h index c8cedc9d4e..020a8fc97d 100644 --- a/Telegram/SourceFiles/main/main_settings.h +++ b/Telegram/SourceFiles/main/main_settings.h @@ -254,11 +254,14 @@ public: _variables.videoPipGeometry = geometry; } + [[nodiscard]] static bool ThirdColumnByDefault(); + private: struct Variables { Variables(); static constexpr auto kDefaultDialogsWidthRatio = 5. / 14; + static constexpr auto kDefaultBigDialogsWidthRatio = 0.275; static constexpr auto kDefaultThirdColumnWidth = 0; bool lastSeenWarningSeen = false; @@ -273,8 +276,7 @@ private: bool thirdSectionInfoEnabled = true; // per-window bool smallDialogsList = false; // per-window int thirdSectionExtendedBy = -1; // per-window - rpl::variable dialogsWidthRatio - = kDefaultDialogsWidthRatio; // per-window + rpl::variable dialogsWidthRatio; // per-window rpl::variable thirdColumnWidth = kDefaultThirdColumnWidth; // per-window Ui::InputSubmitSettings sendSubmitWay; diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index a282de86ca..50b9564979 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -398,15 +398,21 @@ void MainWindow::initSize() { ? primaryScreen->availableGeometry() : QRect(0, 0, st::windowDefaultWidth, st::windowDefaultHeight); bool maximized = false; + const auto initialWidth = Main::Settings::ThirdColumnByDefault() + ? st::windowBigDefaultWidth + : st::windowDefaultWidth; + const auto initialHeight = Main::Settings::ThirdColumnByDefault() + ? st::windowBigDefaultHeight + : st::windowDefaultHeight; auto geometry = QRect( available.x() + std::max( - (available.width() - st::windowDefaultWidth) / 2, + (available.width() - initialWidth) / 2, 0), available.y() + std::max( - (available.height() - st::windowDefaultHeight) / 2, + (available.height() - initialHeight) / 2, 0), - st::windowDefaultWidth, - st::windowDefaultHeight); + initialWidth, + initialHeight); if (position.w && position.h) { for (auto screen : QGuiApplication::screens()) { if (position.moncrc == screenNameChecksum(screen->name())) { diff --git a/Telegram/SourceFiles/window/window.style b/Telegram/SourceFiles/window/window.style index bc12c5843d..140f0140a9 100644 --- a/Telegram/SourceFiles/window/window.style +++ b/Telegram/SourceFiles/window/window.style @@ -14,6 +14,8 @@ windowMinWidth: 380px; windowMinHeight: 480px; windowDefaultWidth: 800px; windowDefaultHeight: 600px; +windowBigDefaultWidth: 1024px; +windowBigDefaultHeight: 768px; columnMinimalWidthLeft: 260px; columnMaximalWidthLeft: 540px;