From 67c538ae8fe1db6d49c392ee219bf2afc79fdb83 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 2 Feb 2022 15:33:41 +0300 Subject: [PATCH] Add AllowLinuxNvidiaOpenGL option. --- Telegram/Resources/langs/lang.strings | 5 +- .../history/view/history_view_bottom_info.cpp | 10 ++- .../history/view/history_view_bottom_info.h | 1 + Telegram/SourceFiles/settings/settings.style | 7 ++ .../settings/settings_experimental.cpp | 87 ++++++++++++++++--- Telegram/lib_base | 2 +- Telegram/lib_ui | 2 +- 7 files changed, 97 insertions(+), 17 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index bb9111845..46da8ec3c 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -395,6 +395,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_settings_experimental" = "Experimental settings"; "lng_settings_experimental_about" = "Warning! Those are experimental settings. Some may not work. Others may break the app. Any of them may disappear in the next version without a trace. Use at your own risk."; +"lng_settings_experimental_restore" = "Restore default values"; +"lng_settings_experimental_irrelevant" = "This option isn't relevant for your system."; "lng_settings_section_chat_settings" = "Chat Settings"; "lng_settings_replace_emojis" = "Replace emoji"; @@ -734,7 +736,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_sure_logout" = "Are you sure you want to log out?"; "lng_settings_need_restart" = "You need to restart for applying some of the new settings. Restart now?"; -"lng_settings_restart_now" = "RESTART"; +"lng_settings_restart_now" = "Restart"; +"lng_settings_restart_later" = "Later"; "lng_sessions_header" = "Current session"; "lng_sessions_other_header" = "Active sessions"; diff --git a/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp b/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp index d62cd8d48..50b1aa4ef 100644 --- a/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp +++ b/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp @@ -424,7 +424,11 @@ void BottomInfo::layoutDateText() { : author; const auto full = (_data.flags & Data::Flag::Sponsored) ? tr::lng_sponsored(tr::now) - : name.isEmpty() ? date : (name + afterAuthor); + : (_data.flags & Data::Flag::Imported) + ? (date + ' ' + tr::lng_imported(tr::now)) + : name.isEmpty() + ? date + : (name + afterAuthor); _authorEditedDate.setText( st::msgDateTextStyle, full, @@ -605,6 +609,10 @@ BottomInfo::Data BottomInfoDataFromMessage(not_null message) { if (item->isSending() || item->hasFailed()) { result.flags |= Flag::Sending; } + const auto forwarded = item->Get(); + if (forwarded && forwarded->imported) { + result.flags |= Flag::Imported; + } // We don't want to pass and update it in Date for now. //if (item->unread()) { // result.flags |= Flag::Unread; diff --git a/Telegram/SourceFiles/history/view/history_view_bottom_info.h b/Telegram/SourceFiles/history/view/history_view_bottom_info.h index 5266f8ae1..62ad01f58 100644 --- a/Telegram/SourceFiles/history/view/history_view_bottom_info.h +++ b/Telegram/SourceFiles/history/view/history_view_bottom_info.h @@ -40,6 +40,7 @@ public: RepliesContext = 0x08, Sponsored = 0x10, Pinned = 0x20, + Imported = 0x40, //Unread, // We don't want to pass and update it in Date for now. }; friend inline constexpr bool is_flag_type(Flag) { return true; }; diff --git a/Telegram/SourceFiles/settings/settings.style b/Telegram/SourceFiles/settings/settings.style index 8ccbcb499..69ecc186c 100644 --- a/Telegram/SourceFiles/settings/settings.style +++ b/Telegram/SourceFiles/settings/settings.style @@ -21,6 +21,13 @@ settingsAttentionButton: SettingsButton(settingsButton) { textFg: attentionButtonFg; textFgOver: attentionButtonFgOver; } +settingsOptionDisabled: SettingsButton(settingsButton) { + textFg: windowSubTextFg; + textFgOver: windowSubTextFg; + textBg: windowBg; + textBgOver: windowBg; + toggleOver: infoProfileToggle; +} settingsSectionSkip: 9px; settingsSectionIconLeft: 22px; settingsSeparatorPadding: margins(22px, infoProfileSkip, 0px, infoProfileSkip); diff --git a/Telegram/SourceFiles/settings/settings_experimental.cpp b/Telegram/SourceFiles/settings/settings_experimental.cpp index 2ac4cdb4c..9e264f82b 100644 --- a/Telegram/SourceFiles/settings/settings_experimental.cpp +++ b/Telegram/SourceFiles/settings/settings_experimental.cpp @@ -7,13 +7,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "settings/settings_experimental.h" +#include "ui/boxes/confirm_box.h" #include "ui/wrap/vertical_layout.h" +#include "ui/wrap/slide_wrap.h" #include "ui/widgets/buttons.h" #include "ui/widgets/labels.h" +#include "ui/gl/gl_detection.h" #include "base/options.h" +#include "core/application.h" #include "chat_helpers/tabbed_panel.h" #include "lang/lang_keys.h" #include "window/window_peer_menu.h" +#include "window/window_session_controller.h" +#include "window/window_controller.h" #include "styles/style_settings.h" #include "styles/style_layers.h" @@ -21,27 +27,61 @@ namespace Settings { namespace { void AddOption( + not_null window, not_null container, - base::options::option &option) { + base::options::option &option, + rpl::producer<> resetClicks) { + auto &lifetime = container->lifetime(); const auto name = option.name().isEmpty() ? option.id() : option.name(); - AddButton( + const auto toggles = lifetime.make_state>(); + std::move( + resetClicks + ) | rpl::map_to( + option.defaultValue() + ) | rpl::start_to_stream(*toggles, lifetime); + + const auto button = AddButton( container, rpl::single(name), - st::settingsButton - )->toggleOn(rpl::single(option.value()))->toggledChanges( + option.relevant() ? st::settingsButton : st::settingsOptionDisabled + )->toggleOn(toggles->events_starting_with(option.value())); + + const auto restarter = (option.relevant() && option.restartRequired()) + ? button->lifetime().make_state() + : nullptr; + if (restarter) { + restarter->setCallback([=] { + window->show(Box( + tr::lng_settings_need_restart(tr::now), + tr::lng_settings_restart_now(tr::now), + tr::lng_settings_restart_later(tr::now), + [] { Core::Restart(); })); + }); + } + button->toggledChanges( ) | rpl::start_with_next([=, &option](bool toggled) { + if (!option.relevant() && toggled != option.defaultValue()) { + toggles->fire_copy(option.defaultValue()); + window->showToast( + tr::lng_settings_experimental_irrelevant(tr::now)); + return; + } option.set(toggled); + if (restarter) { + restarter->callOnce(st::settingsButton.toggle.duration); + } }, container->lifetime()); const auto &description = option.description(); if (!description.isEmpty()) { AddSkip(container, st::settingsCheckboxesSkip); AddDividerText(container, rpl::single(description)); + AddSkip(container, st::settingsCheckboxesSkip); } } void SetupExperimental( - not_null controller, + not_null window, not_null container) { AddSkip(container, st::settingsCheckboxesSkip); @@ -52,21 +92,42 @@ void SetupExperimental( st::boxLabel), st::settingsDividerLabelPadding); - AddDivider(container); + auto reset = (Button*)nullptr; + if (base::options::changed()) { + const auto wrap = container->add( + object_ptr>( + container, + object_ptr(container))); + const auto inner = wrap->entity(); + AddDivider(inner); + AddSkip(inner, st::settingsCheckboxesSkip); + reset = AddButton( + inner, + tr::lng_settings_experimental_restore(), + st::settingsButton); + reset->addClickHandler([=] { + base::options::reset(); + wrap->hide(anim::type::normal); + }); + AddSkip(inner, st::settingsCheckboxesSkip); + } + AddDivider(container); AddSkip(container, st::settingsCheckboxesSkip); const auto addToggle = [&](const char name[]) { - AddOption(container, base::options::lookup(name)); + AddOption( + window, + container, + base::options::lookup(name), + (reset + ? (reset->clicks() | rpl::to_empty) + : rpl::producer<>())); }; addToggle(ChatHelpers::kOptionTabbedPanelShowOnClick); - - AddSkip(container, st::settingsCheckboxesSkip); - addToggle(Window::kOptionViewProfileInChatsListContextMenu); - - AddSkip(container, st::settingsCheckboxesSkip); + addToggle(Ui::GL::kOptionAllowLinuxNvidiaOpenGL); } } // namespace @@ -82,7 +143,7 @@ void Experimental::setupContent( not_null controller) { const auto content = Ui::CreateChild(this); - SetupExperimental(controller, content); + SetupExperimental(&controller->window(), content); Ui::ResizeFitChild(this, content); } diff --git a/Telegram/lib_base b/Telegram/lib_base index a056f1dca..3b5aa5d8f 160000 --- a/Telegram/lib_base +++ b/Telegram/lib_base @@ -1 +1 @@ -Subproject commit a056f1dcafbc215d0c94215f15141e994782b46a +Subproject commit 3b5aa5d8fd1869d2e1934d45793a7f3ee4e65428 diff --git a/Telegram/lib_ui b/Telegram/lib_ui index dbbec068a..bbae1c2ae 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit dbbec068a81bb0c7a43565ce386898de3f1b537e +Subproject commit bbae1c2ae7ae3cad3c48d6903290f6c3d424e655