2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-29 05:37:45 +00:00

Always show experimental settings

This commit is contained in:
RadRussianRus 2022-02-17 03:55:52 +03:00
parent b77995dfc7
commit aed207de54
5 changed files with 44 additions and 34 deletions

View File

@ -264,5 +264,6 @@
"ktg_jump_to_date_button": "Jump",
"ktg_jump_to_beginning": "Jump to beginning",
"ktg_show_calendar": "Show calendar",
"ktg_in_app_update_disabled": "In-app updater is disabled.",
"dummy_last_string": ""
}

View File

@ -264,5 +264,6 @@
"ktg_jump_to_date_button": "Перейти",
"ktg_jump_to_beginning": "Перейти в начало",
"ktg_show_calendar": "Показать календарь",
"ktg_in_app_update_disabled": "Обновление внутри приложения отключено.",
"dummy_last_string": ""
}

View File

@ -86,12 +86,9 @@ bool HasUpdate() {
}
void SetupUpdate(
not_null<Window::Controller*> controller,
not_null<Ui::VerticalLayout*> container,
Fn<void(Type)> showOther) {
if (!HasUpdate()) {
return;
}
const auto texts = Ui::CreateChild<rpl::event_stream<QString>>(
container.get());
const auto downloading = Ui::CreateChild<rpl::event_stream<bool>>(
@ -114,29 +111,48 @@ void SetupUpdate(
container,
object_ptr<Ui::VerticalLayout>(container)));
const auto inner = options->entity();
const auto install = cAlphaVersion() ? nullptr : AddButton(
const auto install = (cAlphaVersion() || !HasUpdate()) ? nullptr : AddButton(
inner,
tr::lng_settings_install_beta(),
st::settingsButton).get();
if (showOther) {
const auto experimental = inner->add(
object_ptr<Ui::SlideWrap<Button>>(
inner,
const auto experimental = container->add(
object_ptr<Button>(
inner,
container,
tr::lng_settings_experimental(),
st::settingsButton)));
if (!install) {
experimental->toggle(true, anim::type::instant);
} else {
experimental->toggleOn(install->toggledValue());
}
experimental->entity()->setClickedCallback([=] {
st::settingsButton));
experimental->setClickedCallback([=] {
showOther(Type::Experimental);
});
}
rpl::combine(
toggle->widthValue(),
label->widthValue()
) | rpl::start_with_next([=] {
label->moveToLeft(
st::settingsUpdateStatePosition.x(),
st::settingsUpdateStatePosition.y());
}, label->lifetime());
label->setAttribute(Qt::WA_TransparentForMouseEvents);
if (!HasUpdate()) {
texts->fire_copy(version);
auto &lifetime = container->lifetime();
const auto toggles = lifetime.make_state<rpl::event_stream<bool>>();
toggle->toggleOn(toggles->events_starting_with(false));
toggle->toggledChanges(
) | rpl::start_with_next([=](bool value) {
if (value) {
toggles->fire_copy(false);
controller->showToast(ktr("ktg_in_app_update_disabled"));
return;
}
}, container->lifetime());
return;
}
const auto check = AddButton(
inner,
tr::lng_settings_check_now(),
@ -151,16 +167,6 @@ void SetupUpdate(
update->moveToLeft(0, 0);
}, update->lifetime());
rpl::combine(
toggle->widthValue(),
label->widthValue()
) | rpl::start_with_next([=] {
label->moveToLeft(
st::settingsUpdateStatePosition.x(),
st::settingsUpdateStatePosition.y());
}, label->lifetime());
label->setAttribute(Qt::WA_TransparentForMouseEvents);
const auto showDownloadProgress = [=](int64 ready, int64 total) {
texts->fire(tr::lng_settings_downloading_update(
tr::now,
@ -742,15 +748,16 @@ void Advanced::setupContent(not_null<Window::SessionController*> controller) {
}
};
const auto addUpdate = [&] {
if (HasUpdate()) {
addDivider();
AddSkip(content);
AddSubsectionTitle(content, tr::lng_settings_version_info());
SetupUpdate(content, [=](Type type) {
addDivider();
AddSkip(content);
AddSubsectionTitle(content, tr::lng_settings_version_info());
SetupUpdate(
&controller->window(),
content,
[=](Type type) {
_showOther.fire_copy(type);
});
AddSkip(content);
}
AddSkip(content);
};
if (!cAutoUpdate()) {
addUpdate();

View File

@ -25,6 +25,7 @@ void SetupConnectionType(
not_null<Ui::VerticalLayout*> container);
bool HasUpdate();
void SetupUpdate(
not_null<Window::Controller*> controller,
not_null<Ui::VerticalLayout*> container,
Fn<void(Type)> showOther);
void SetupSystemIntegrationContent(

View File

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