Add empty experimental settings section.

This commit is contained in:
John Preston 2022-01-25 16:25:51 +03:00
parent 3a78e94f2f
commit 4aafcebef5
10 changed files with 120 additions and 4 deletions

View File

@ -1027,6 +1027,8 @@ PRIVATE
settings/settings_codes.h
settings/settings_common.cpp
settings/settings_common.h
settings/settings_experimental.cpp
settings/settings_experimental.h
settings/settings_folders.cpp
settings/settings_folders.h
settings/settings_information.cpp

View File

@ -392,6 +392,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_settings_section_scale" = "Interface Scale";
"lng_settings_scale_auto" = "Auto ({cur})";
"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_section_chat_settings" = "Chat Settings";
"lng_settings_replace_emojis" = "Replace emoji";
"lng_settings_suggest_emoji" = "Suggest emoji replacements";

View File

@ -641,6 +641,8 @@ rpl::producer<QString> TitleValue(
return tr::lng_filters_title();
case Section::SettingsType::Calls:
return tr::lng_settings_section_call_settings();
case Section::SettingsType::Experimental:
return tr::lng_settings_experimental();
}
Unexpected("Bad settings type in Info::TitleValue()");

View File

@ -80,7 +80,9 @@ bool HasUpdate() {
return !Core::UpdaterDisabled();
}
void SetupUpdate(not_null<Ui::VerticalLayout*> container) {
void SetupUpdate(
not_null<Ui::VerticalLayout*> container,
Fn<void(Type)> showOther) {
if (!HasUpdate()) {
return;
}
@ -112,6 +114,24 @@ void SetupUpdate(not_null<Ui::VerticalLayout*> container) {
tr::lng_settings_install_beta(),
st::settingsButton).get();
if (showOther) {
const auto experimental = inner->add(
object_ptr<Ui::SlideWrap<Button>>(
inner,
object_ptr<Button>(
inner,
tr::lng_settings_experimental(),
st::settingsButton)));
if (!install) {
experimental->toggle(true, anim::type::instant);
} else {
experimental->toggleOn(install->toggledValue());
}
experimental->entity()->setClickedCallback([=] {
showOther(Type::Experimental);
});
}
const auto check = AddButton(
inner,
tr::lng_settings_check_now(),
@ -708,7 +728,9 @@ void Advanced::setupContent(not_null<Window::SessionController*> controller) {
addDivider();
AddSkip(content);
AddSubsectionTitle(content, tr::lng_settings_version_info());
SetupUpdate(content);
SetupUpdate(content, [=](Type type) {
_showOther.fire_copy(type);
});
AddSkip(content);
}
};

View File

@ -24,7 +24,9 @@ void SetupConnectionType(
not_null<Main::Account*> account,
not_null<Ui::VerticalLayout*> container);
bool HasUpdate();
void SetupUpdate(not_null<Ui::VerticalLayout*> container);
void SetupUpdate(
not_null<Ui::VerticalLayout*> container,
Fn<void(Type)> showOther);
void SetupSystemIntegrationContent(
Window::SessionController *controller,
not_null<Ui::VerticalLayout*> container);

View File

@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_privacy_security.h"
#include "settings/settings_folders.h"
#include "settings/settings_calls.h"
#include "settings/settings_experimental.h"
#include "core/application.h"
#include "ui/wrap/padding_wrap.h"
#include "ui/wrap/vertical_layout.h"
@ -59,6 +60,8 @@ object_ptr<Section> CreateSection(
return object_ptr<Chat>(parent, controller);
case Type::Calls:
return object_ptr<Calls>(parent, controller);
case Type::Experimental:
return object_ptr<Experimental>(parent, controller);
}
Unexpected("Settings section type in Widget::createInnerWidget.");
}

View File

@ -41,6 +41,7 @@ enum class Type {
Chat,
Folders,
Calls,
Experimental,
};
using Button = Ui::SettingsButton;

View File

@ -0,0 +1,56 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "settings/settings_experimental.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h"
#include "chat_helpers/tabbed_panel.h"
#include "lang/lang_keys.h"
#include "styles/style_settings.h"
#include "styles/style_layers.h"
namespace Settings {
namespace {
void SetupExperimental(
not_null<Window::SessionController*> controller,
not_null<Ui::VerticalLayout*> container) {
AddSkip(container, st::settingsCheckboxesSkip);
container->add(
object_ptr<Ui::FlatLabel>(
container,
tr::lng_settings_experimental_about(),
st::boxLabel),
st::settingsDividerLabelPadding);
AddDivider(container);
AddSkip(container, st::settingsCheckboxesSkip);
}
} // namespace
Experimental::Experimental(
QWidget *parent,
not_null<Window::SessionController*> controller)
: Section(parent) {
setupContent(controller);
}
void Experimental::setupContent(
not_null<Window::SessionController*> controller) {
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
SetupExperimental(controller, content);
Ui::ResizeFitChild(this, content);
}
} // namespace Settings

View File

@ -0,0 +1,25 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "settings/settings_common.h"
namespace Settings {
class Experimental : public Section {
public:
Experimental(
QWidget *parent,
not_null<Window::SessionController*> controller);
private:
void setupContent(not_null<Window::SessionController*> controller);
};
} // namespace Settings

View File

@ -69,7 +69,7 @@ object_ptr<Ui::RpWidget> CreateIntroSettings(
if (HasUpdate()) {
AddDivider(result);
AddSkip(result);
SetupUpdate(result);
SetupUpdate(result, nullptr);
AddSkip(result);
}
{