Add AllowLinuxNvidiaOpenGL option.

This commit is contained in:
John Preston 2022-02-02 15:33:41 +03:00
parent 38137e16a0
commit 67c538ae8f
7 changed files with 97 additions and 17 deletions

View file

@ -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";

View file

@ -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*> message) {
if (item->isSending() || item->hasFailed()) {
result.flags |= Flag::Sending;
}
const auto forwarded = item->Get<HistoryMessageForwarded>();
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;

View file

@ -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; };

View file

@ -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);

View file

@ -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::Controller*> window,
not_null<Ui::VerticalLayout*> container,
base::options::option<bool> &option) {
base::options::option<bool> &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<rpl::event_stream<bool>>();
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<base::Timer>()
: nullptr;
if (restarter) {
restarter->setCallback([=] {
window->show(Box<Ui::ConfirmBox>(
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<Window::SessionController*> controller,
not_null<Window::Controller*> window,
not_null<Ui::VerticalLayout*> 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<Ui::SlideWrap<Ui::VerticalLayout>>(
container,
object_ptr<Ui::VerticalLayout>(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<bool>(name));
AddOption(
window,
container,
base::options::lookup<bool>(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<Window::SessionController*> controller) {
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
SetupExperimental(controller, content);
SetupExperimental(&controller->window(), content);
Ui::ResizeFitChild(this, content);
}

@ -1 +1 @@
Subproject commit a056f1dcafbc215d0c94215f15141e994782b46a
Subproject commit 3b5aa5d8fd1869d2e1934d45793a7f3ee4e65428

@ -1 +1 @@
Subproject commit dbbec068a81bb0c7a43565ce386898de3f1b537e
Subproject commit bbae1c2ae7ae3cad3c48d6903290f6c3d424e655