2018-09-05 19:05:49 +00:00
|
|
|
/*
|
|
|
|
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
|
|
|
|
*/
|
2018-09-20 16:47:02 +00:00
|
|
|
#include "settings/settings_advanced.h"
|
2018-09-05 19:05:49 +00:00
|
|
|
|
|
|
|
#include "settings/settings_common.h"
|
2018-09-19 10:29:51 +00:00
|
|
|
#include "settings/settings_chat.h"
|
2018-09-05 19:05:49 +00:00
|
|
|
#include "ui/wrap/vertical_layout.h"
|
2018-09-07 09:40:25 +00:00
|
|
|
#include "ui/wrap/slide_wrap.h"
|
|
|
|
#include "ui/widgets/labels.h"
|
2018-09-13 20:09:26 +00:00
|
|
|
#include "ui/widgets/checkbox.h"
|
2019-11-02 17:06:47 +00:00
|
|
|
#include "ui/widgets/buttons.h"
|
2019-06-17 16:59:43 +00:00
|
|
|
#include "ui/text/text_utilities.h" // Ui::Text::ToUpper
|
2018-09-07 09:40:25 +00:00
|
|
|
#include "boxes/connection_box.h"
|
|
|
|
#include "boxes/about_box.h"
|
|
|
|
#include "boxes/confirm_box.h"
|
|
|
|
#include "platform/platform_specific.h"
|
2019-09-17 16:13:12 +00:00
|
|
|
#include "base/platform/base_platform_info.h"
|
2019-07-24 14:00:30 +00:00
|
|
|
#include "window/window_session_controller.h"
|
2018-09-05 19:05:49 +00:00
|
|
|
#include "lang/lang_keys.h"
|
2018-09-07 09:40:25 +00:00
|
|
|
#include "core/update_checker.h"
|
2019-01-21 13:42:21 +00:00
|
|
|
#include "core/application.h"
|
2018-09-07 09:40:25 +00:00
|
|
|
#include "storage/localstorage.h"
|
2018-09-20 17:56:45 +00:00
|
|
|
#include "data/data_session.h"
|
2019-07-24 11:45:24 +00:00
|
|
|
#include "main/main_session.h"
|
2018-09-07 09:40:25 +00:00
|
|
|
#include "layout.h"
|
2019-09-13 06:06:02 +00:00
|
|
|
#include "facades.h"
|
|
|
|
#include "app.h"
|
2018-09-05 19:05:49 +00:00
|
|
|
#include "styles/style_settings.h"
|
|
|
|
|
|
|
|
namespace Settings {
|
2018-09-11 18:07:04 +00:00
|
|
|
|
|
|
|
bool HasConnectionType() {
|
|
|
|
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
|
|
|
|
return true;
|
|
|
|
#endif // TDESKTOP_DISABLE_NETWORK_PROXY
|
|
|
|
return false;
|
|
|
|
}
|
2018-09-07 09:40:25 +00:00
|
|
|
|
|
|
|
void SetupConnectionType(not_null<Ui::VerticalLayout*> container) {
|
2018-09-11 18:07:04 +00:00
|
|
|
if (!HasConnectionType()) {
|
|
|
|
return;
|
|
|
|
}
|
2018-09-07 09:40:25 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
|
|
|
|
const auto connectionType = [] {
|
|
|
|
const auto transport = MTP::dctransport();
|
2019-11-13 14:12:04 +00:00
|
|
|
if (Global::ProxySettings() != MTP::ProxyData::Settings::Enabled) {
|
2018-09-07 09:40:25 +00:00
|
|
|
return transport.isEmpty()
|
2019-06-19 15:09:03 +00:00
|
|
|
? tr::lng_connection_auto_connecting(tr::now)
|
2019-06-19 16:39:25 +00:00
|
|
|
: tr::lng_connection_auto(tr::now, lt_transport, transport);
|
2018-09-07 09:40:25 +00:00
|
|
|
} else {
|
|
|
|
return transport.isEmpty()
|
2019-06-19 15:09:03 +00:00
|
|
|
? tr::lng_connection_proxy_connecting(tr::now)
|
2019-06-19 16:39:25 +00:00
|
|
|
: tr::lng_connection_proxy(tr::now, lt_transport, transport);
|
2018-09-07 09:40:25 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
const auto button = AddButtonWithLabel(
|
|
|
|
container,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_settings_connection_type(),
|
2018-09-07 09:40:25 +00:00
|
|
|
rpl::single(
|
|
|
|
rpl::empty_value()
|
|
|
|
) | rpl::then(base::ObservableViewer(
|
|
|
|
Global::RefConnectionTypeChanged()
|
|
|
|
)) | rpl::map(connectionType),
|
2018-09-17 10:52:34 +00:00
|
|
|
st::settingsButton);
|
2018-09-07 09:40:25 +00:00
|
|
|
button->addClickHandler([] {
|
|
|
|
Ui::show(ProxiesBoxController::CreateOwningBox());
|
|
|
|
});
|
|
|
|
#endif // TDESKTOP_DISABLE_NETWORK_PROXY
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:07:04 +00:00
|
|
|
bool HasUpdate() {
|
|
|
|
return !Core::UpdaterDisabled();
|
|
|
|
}
|
|
|
|
|
2018-09-07 09:40:25 +00:00
|
|
|
void SetupUpdate(not_null<Ui::VerticalLayout*> container) {
|
2018-09-11 18:07:04 +00:00
|
|
|
if (!HasUpdate()) {
|
2018-09-07 09:40:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-11-21 10:09:46 +00:00
|
|
|
const auto texts = Ui::CreateChild<rpl::event_stream<QString>>(
|
|
|
|
container.get());
|
|
|
|
const auto downloading = Ui::CreateChild<rpl::event_stream<bool>>(
|
|
|
|
container.get());
|
2019-06-19 16:39:25 +00:00
|
|
|
const auto version = tr::lng_settings_current_version(
|
|
|
|
tr::now,
|
2018-09-07 09:40:25 +00:00
|
|
|
lt_version,
|
|
|
|
currentVersionText());
|
|
|
|
const auto toggle = AddButton(
|
|
|
|
container,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_settings_update_automatically(),
|
2018-09-07 09:40:25 +00:00
|
|
|
st::settingsUpdateToggle);
|
|
|
|
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
|
|
|
toggle.get(),
|
|
|
|
texts->events(),
|
|
|
|
st::settingsUpdateState);
|
|
|
|
|
2018-09-26 15:30:42 +00:00
|
|
|
const auto options = container->add(
|
|
|
|
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
2018-09-07 09:40:25 +00:00
|
|
|
container,
|
2018-09-26 15:30:42 +00:00
|
|
|
object_ptr<Ui::VerticalLayout>(container)));
|
|
|
|
const auto inner = options->entity();
|
|
|
|
const auto install = cAlphaVersion() ? nullptr : AddButton(
|
|
|
|
inner,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_settings_install_beta(),
|
2018-09-26 15:30:42 +00:00
|
|
|
st::settingsButton).get();
|
|
|
|
|
|
|
|
const auto check = AddButton(
|
|
|
|
inner,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_settings_check_now(),
|
2018-09-26 15:30:42 +00:00
|
|
|
st::settingsButton);
|
2018-09-07 09:40:25 +00:00
|
|
|
const auto update = Ui::CreateChild<Button>(
|
2018-09-26 15:30:42 +00:00
|
|
|
check.get(),
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_update_telegram() | Ui::Text::ToUpper(),
|
2018-09-07 09:40:25 +00:00
|
|
|
st::settingsUpdate);
|
|
|
|
update->hide();
|
2018-09-26 15:30:42 +00:00
|
|
|
check->widthValue() | rpl::start_with_next([=](int width) {
|
2018-09-07 09:40:25 +00:00
|
|
|
update->resizeToWidth(width);
|
|
|
|
update->moveToLeft(0, 0);
|
2018-09-07 12:19:56 +00:00
|
|
|
}, update->lifetime());
|
2018-09-07 09:40:25 +00:00
|
|
|
|
|
|
|
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) {
|
2019-06-19 16:39:25 +00:00
|
|
|
texts->fire(tr::lng_settings_downloading_update(
|
|
|
|
tr::now,
|
2018-09-07 09:40:25 +00:00
|
|
|
lt_progress,
|
|
|
|
formatDownloadText(ready, total)));
|
|
|
|
downloading->fire(true);
|
|
|
|
};
|
|
|
|
const auto setDefaultStatus = [=](const Core::UpdateChecker &checker) {
|
|
|
|
using State = Core::UpdateChecker::State;
|
|
|
|
const auto state = checker.state();
|
|
|
|
switch (state) {
|
|
|
|
case State::Download:
|
|
|
|
showDownloadProgress(checker.already(), checker.size());
|
|
|
|
break;
|
|
|
|
case State::Ready:
|
2019-06-19 15:09:03 +00:00
|
|
|
texts->fire(tr::lng_settings_update_ready(tr::now));
|
2018-09-07 09:40:25 +00:00
|
|
|
update->show();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
texts->fire_copy(version);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
toggle->toggleOn(rpl::single(cAutoUpdate()));
|
|
|
|
toggle->toggledValue(
|
|
|
|
) | rpl::filter([](bool toggled) {
|
|
|
|
return (toggled != cAutoUpdate());
|
|
|
|
}) | rpl::start_with_next([=](bool toggled) {
|
|
|
|
cSetAutoUpdate(toggled);
|
|
|
|
|
|
|
|
Local::writeSettings();
|
|
|
|
Core::UpdateChecker checker;
|
|
|
|
if (cAutoUpdate()) {
|
|
|
|
checker.start();
|
|
|
|
} else {
|
|
|
|
checker.stop();
|
2019-06-04 16:17:22 +00:00
|
|
|
setDefaultStatus(checker);
|
2018-09-07 09:40:25 +00:00
|
|
|
}
|
2018-09-07 12:19:56 +00:00
|
|
|
}, toggle->lifetime());
|
2018-09-07 09:40:25 +00:00
|
|
|
|
2018-09-26 15:30:42 +00:00
|
|
|
if (install) {
|
|
|
|
install->toggleOn(rpl::single(cInstallBetaVersion()));
|
|
|
|
install->toggledValue(
|
|
|
|
) | rpl::filter([](bool toggled) {
|
|
|
|
return (toggled != cInstallBetaVersion());
|
|
|
|
}) | rpl::start_with_next([=](bool toggled) {
|
|
|
|
cSetInstallBetaVersion(toggled);
|
2019-01-21 13:42:21 +00:00
|
|
|
Core::App().writeInstallBetaVersionsSetting();
|
2018-09-26 15:30:42 +00:00
|
|
|
|
|
|
|
Core::UpdateChecker checker;
|
|
|
|
checker.stop();
|
|
|
|
if (toggled) {
|
|
|
|
cSetLastUpdateCheck(0);
|
|
|
|
}
|
|
|
|
checker.start();
|
|
|
|
}, toggle->lifetime());
|
|
|
|
}
|
|
|
|
|
2018-09-07 09:40:25 +00:00
|
|
|
Core::UpdateChecker checker;
|
2018-09-26 15:30:42 +00:00
|
|
|
options->toggleOn(rpl::combine(
|
2018-09-07 09:40:25 +00:00
|
|
|
toggle->toggledValue(),
|
|
|
|
downloading->events_starting_with(
|
|
|
|
checker.state() == Core::UpdateChecker::State::Download)
|
|
|
|
) | rpl::map([](bool check, bool downloading) {
|
|
|
|
return check && !downloading;
|
|
|
|
}));
|
|
|
|
|
|
|
|
checker.checking() | rpl::start_with_next([=] {
|
2018-09-26 15:30:42 +00:00
|
|
|
options->setAttribute(Qt::WA_TransparentForMouseEvents);
|
2019-06-19 15:09:03 +00:00
|
|
|
texts->fire(tr::lng_settings_update_checking(tr::now));
|
2018-09-07 09:40:25 +00:00
|
|
|
downloading->fire(false);
|
2018-09-26 15:30:42 +00:00
|
|
|
}, options->lifetime());
|
2018-09-07 09:40:25 +00:00
|
|
|
checker.isLatest() | rpl::start_with_next([=] {
|
2018-09-26 15:30:42 +00:00
|
|
|
options->setAttribute(Qt::WA_TransparentForMouseEvents, false);
|
2019-06-19 15:09:03 +00:00
|
|
|
texts->fire(tr::lng_settings_latest_installed(tr::now));
|
2018-09-07 09:40:25 +00:00
|
|
|
downloading->fire(false);
|
2018-09-26 15:30:42 +00:00
|
|
|
}, options->lifetime());
|
2018-09-07 09:40:25 +00:00
|
|
|
checker.progress(
|
|
|
|
) | rpl::start_with_next([=](Core::UpdateChecker::Progress progress) {
|
|
|
|
showDownloadProgress(progress.already, progress.size);
|
2018-09-26 15:30:42 +00:00
|
|
|
}, options->lifetime());
|
2018-09-07 09:40:25 +00:00
|
|
|
checker.failed() | rpl::start_with_next([=] {
|
2018-09-26 15:30:42 +00:00
|
|
|
options->setAttribute(Qt::WA_TransparentForMouseEvents, false);
|
2019-06-19 15:09:03 +00:00
|
|
|
texts->fire(tr::lng_settings_update_fail(tr::now));
|
2018-09-07 09:40:25 +00:00
|
|
|
downloading->fire(false);
|
2018-09-26 15:30:42 +00:00
|
|
|
}, options->lifetime());
|
2018-09-07 09:40:25 +00:00
|
|
|
checker.ready() | rpl::start_with_next([=] {
|
2018-09-26 15:30:42 +00:00
|
|
|
options->setAttribute(Qt::WA_TransparentForMouseEvents, false);
|
2019-06-19 15:09:03 +00:00
|
|
|
texts->fire(tr::lng_settings_update_ready(tr::now));
|
2018-09-07 09:40:25 +00:00
|
|
|
update->show();
|
|
|
|
downloading->fire(false);
|
2018-09-26 15:30:42 +00:00
|
|
|
}, options->lifetime());
|
2018-09-07 09:40:25 +00:00
|
|
|
|
|
|
|
setDefaultStatus(checker);
|
|
|
|
|
2018-09-26 15:30:42 +00:00
|
|
|
check->addClickHandler([] {
|
2018-09-07 09:40:25 +00:00
|
|
|
Core::UpdateChecker checker;
|
|
|
|
|
|
|
|
cSetLastUpdateCheck(0);
|
|
|
|
checker.start();
|
|
|
|
});
|
|
|
|
update->addClickHandler([] {
|
|
|
|
if (!Core::UpdaterDisabled()) {
|
|
|
|
Core::checkReadyUpdate();
|
|
|
|
}
|
|
|
|
App::restart();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-10-05 16:38:25 +00:00
|
|
|
bool HasSystemSpellchecker() {
|
2019-11-06 07:08:58 +00:00
|
|
|
#ifdef TDESKTOP_DISABLE_SPELLCHECK
|
|
|
|
return false;
|
|
|
|
#endif // TDESKTOP_DISABLE_SPELLCHECK
|
2019-10-05 16:38:25 +00:00
|
|
|
return (Platform::IsWindows() && Platform::IsWindows8OrGreater())
|
|
|
|
|| Platform::IsMac();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetupSpellchecker(
|
|
|
|
not_null<Window::SessionController*> controller,
|
|
|
|
not_null<Ui::VerticalLayout*> container) {
|
|
|
|
const auto session = &controller->session();
|
|
|
|
AddButton(
|
|
|
|
container,
|
|
|
|
tr::lng_settings_system_spellchecker(),
|
|
|
|
st::settingsButton
|
|
|
|
)->toggleOn(
|
|
|
|
rpl::single(session->settings().spellcheckerEnabled())
|
|
|
|
)->toggledValue(
|
|
|
|
) | rpl::filter([=](bool enabled) {
|
|
|
|
return (enabled != session->settings().spellcheckerEnabled());
|
|
|
|
}) | rpl::start_with_next([=](bool enabled) {
|
|
|
|
session->settings().setSpellcheckerEnabled(enabled);
|
|
|
|
session->saveSettingsDelayed();
|
|
|
|
}, container->lifetime());
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:07:04 +00:00
|
|
|
bool HasTray() {
|
2019-06-03 14:41:23 +00:00
|
|
|
return cSupportTray() || Platform::IsWindows();
|
2018-09-11 18:07:04 +00:00
|
|
|
}
|
|
|
|
|
2018-09-13 20:09:26 +00:00
|
|
|
void SetupTrayContent(not_null<Ui::VerticalLayout*> container) {
|
2019-06-19 15:09:03 +00:00
|
|
|
const auto checkbox = [&](const QString &label, bool checked) {
|
2018-09-13 20:09:26 +00:00
|
|
|
return object_ptr<Ui::Checkbox>(
|
|
|
|
container,
|
2019-06-19 15:09:03 +00:00
|
|
|
label,
|
2018-09-13 20:09:26 +00:00
|
|
|
checked,
|
|
|
|
st::settingsCheckbox);
|
|
|
|
};
|
2019-06-19 15:09:03 +00:00
|
|
|
const auto addCheckbox = [&](const QString &label, bool checked) {
|
2018-09-13 20:09:26 +00:00
|
|
|
return container->add(
|
|
|
|
checkbox(label, checked),
|
|
|
|
st::settingsCheckboxPadding);
|
|
|
|
};
|
2019-06-19 15:09:03 +00:00
|
|
|
const auto addSlidingCheckbox = [&](const QString &label, bool checked) {
|
2018-09-13 20:09:26 +00:00
|
|
|
return container->add(
|
|
|
|
object_ptr<Ui::SlideWrap<Ui::Checkbox>>(
|
|
|
|
container,
|
|
|
|
checkbox(label, checked),
|
|
|
|
st::settingsCheckboxPadding));
|
|
|
|
};
|
2018-09-07 09:40:25 +00:00
|
|
|
|
|
|
|
const auto trayEnabled = [] {
|
|
|
|
const auto workMode = Global::WorkMode().value();
|
|
|
|
return (workMode == dbiwmTrayOnly)
|
|
|
|
|| (workMode == dbiwmWindowAndTray);
|
|
|
|
};
|
2018-09-13 20:09:26 +00:00
|
|
|
const auto tray = addCheckbox(
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_settings_workmode_tray(tr::now),
|
2018-09-13 20:09:26 +00:00
|
|
|
trayEnabled());
|
2018-09-07 09:40:25 +00:00
|
|
|
|
|
|
|
const auto taskbarEnabled = [] {
|
|
|
|
const auto workMode = Global::WorkMode().value();
|
|
|
|
return (workMode == dbiwmWindowOnly)
|
|
|
|
|| (workMode == dbiwmWindowAndTray);
|
|
|
|
};
|
2019-06-03 14:41:23 +00:00
|
|
|
const auto taskbar = Platform::IsWindows()
|
2018-09-13 20:09:26 +00:00
|
|
|
? addCheckbox(
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_settings_workmode_window(tr::now),
|
2018-09-13 20:09:26 +00:00
|
|
|
taskbarEnabled())
|
2018-09-07 09:40:25 +00:00
|
|
|
: nullptr;
|
|
|
|
|
|
|
|
const auto updateWorkmode = [=] {
|
2018-09-13 20:09:26 +00:00
|
|
|
const auto newMode = tray->checked()
|
|
|
|
? ((!taskbar || taskbar->checked())
|
2018-09-07 09:40:25 +00:00
|
|
|
? dbiwmWindowAndTray
|
|
|
|
: dbiwmTrayOnly)
|
|
|
|
: dbiwmWindowOnly;
|
|
|
|
if ((newMode == dbiwmWindowAndTray || newMode == dbiwmTrayOnly)
|
|
|
|
&& Global::WorkMode().value() != newMode) {
|
|
|
|
cSetSeenTrayTooltip(false);
|
|
|
|
}
|
|
|
|
Global::RefWorkMode().set(newMode);
|
|
|
|
Local::writeSettings();
|
|
|
|
};
|
|
|
|
|
2018-12-05 09:55:56 +00:00
|
|
|
tray->checkedChanges(
|
2018-09-07 09:40:25 +00:00
|
|
|
) | rpl::filter([=](bool checked) {
|
|
|
|
return (checked != trayEnabled());
|
|
|
|
}) | rpl::start_with_next([=](bool checked) {
|
2018-09-13 20:09:26 +00:00
|
|
|
if (!checked && taskbar && !taskbar->checked()) {
|
|
|
|
taskbar->setChecked(true);
|
2018-09-07 09:40:25 +00:00
|
|
|
} else {
|
|
|
|
updateWorkmode();
|
|
|
|
}
|
2018-09-07 12:19:56 +00:00
|
|
|
}, tray->lifetime());
|
2018-09-07 09:40:25 +00:00
|
|
|
|
|
|
|
if (taskbar) {
|
2018-12-05 09:55:56 +00:00
|
|
|
taskbar->checkedChanges(
|
2018-09-07 09:40:25 +00:00
|
|
|
) | rpl::filter([=](bool checked) {
|
|
|
|
return (checked != taskbarEnabled());
|
|
|
|
}) | rpl::start_with_next([=](bool checked) {
|
2018-09-13 20:09:26 +00:00
|
|
|
if (!checked && !tray->checked()) {
|
|
|
|
tray->setChecked(true);
|
2018-09-07 09:40:25 +00:00
|
|
|
} else {
|
|
|
|
updateWorkmode();
|
|
|
|
}
|
2018-09-07 12:19:56 +00:00
|
|
|
}, taskbar->lifetime());
|
2018-09-07 09:40:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef OS_WIN_STORE
|
2019-06-03 14:41:23 +00:00
|
|
|
if (Platform::IsWindows()) {
|
2018-09-07 09:40:25 +00:00
|
|
|
const auto minimizedToggled = [] {
|
|
|
|
return cStartMinimized() && !Global::LocalPasscode();
|
|
|
|
};
|
|
|
|
|
2018-09-13 20:09:26 +00:00
|
|
|
const auto autostart = addCheckbox(
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_settings_auto_start(tr::now),
|
2018-09-13 20:09:26 +00:00
|
|
|
cAutoStart());
|
|
|
|
const auto minimized = addSlidingCheckbox(
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_settings_start_min(tr::now),
|
2018-09-13 20:09:26 +00:00
|
|
|
minimizedToggled());
|
|
|
|
const auto sendto = addCheckbox(
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_settings_add_sendto(tr::now),
|
2018-09-13 20:09:26 +00:00
|
|
|
cSendToMenu());
|
|
|
|
|
2018-12-05 09:55:56 +00:00
|
|
|
autostart->checkedChanges(
|
2018-09-07 09:40:25 +00:00
|
|
|
) | rpl::filter([](bool checked) {
|
|
|
|
return (checked != cAutoStart());
|
|
|
|
}) | rpl::start_with_next([=](bool checked) {
|
|
|
|
cSetAutoStart(checked);
|
|
|
|
psAutoStart(checked);
|
|
|
|
if (checked) {
|
|
|
|
Local::writeSettings();
|
2018-09-13 20:09:26 +00:00
|
|
|
} else if (minimized->entity()->checked()) {
|
|
|
|
minimized->entity()->setChecked(false);
|
2018-09-07 09:40:25 +00:00
|
|
|
} else {
|
|
|
|
Local::writeSettings();
|
|
|
|
}
|
2018-09-07 12:19:56 +00:00
|
|
|
}, autostart->lifetime());
|
2018-09-07 09:40:25 +00:00
|
|
|
|
2018-12-05 09:55:56 +00:00
|
|
|
minimized->toggleOn(autostart->checkedValue());
|
|
|
|
minimized->entity()->checkedChanges(
|
2018-09-07 09:40:25 +00:00
|
|
|
) | rpl::filter([=](bool checked) {
|
|
|
|
return (checked != minimizedToggled());
|
|
|
|
}) | rpl::start_with_next([=](bool checked) {
|
|
|
|
if (Global::LocalPasscode()) {
|
2018-09-13 20:09:26 +00:00
|
|
|
minimized->entity()->setChecked(false);
|
2018-09-07 09:40:25 +00:00
|
|
|
Ui::show(Box<InformBox>(
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_error_start_minimized_passcoded(tr::now)));
|
2018-09-07 09:40:25 +00:00
|
|
|
} else {
|
|
|
|
cSetStartMinimized(checked);
|
|
|
|
Local::writeSettings();
|
|
|
|
}
|
2018-09-07 12:19:56 +00:00
|
|
|
}, minimized->lifetime());
|
2018-09-07 09:40:25 +00:00
|
|
|
|
|
|
|
base::ObservableViewer(
|
|
|
|
Global::RefLocalPasscodeChanged()
|
|
|
|
) | rpl::start_with_next([=] {
|
2018-09-13 20:09:26 +00:00
|
|
|
minimized->entity()->setChecked(minimizedToggled());
|
2018-09-07 12:19:56 +00:00
|
|
|
}, minimized->lifetime());
|
2018-09-07 09:40:25 +00:00
|
|
|
|
2018-12-05 09:55:56 +00:00
|
|
|
sendto->checkedChanges(
|
2018-09-07 09:40:25 +00:00
|
|
|
) | rpl::filter([](bool checked) {
|
|
|
|
return (checked != cSendToMenu());
|
|
|
|
}) | rpl::start_with_next([](bool checked) {
|
|
|
|
cSetSendToMenu(checked);
|
|
|
|
psSendToMenu(checked);
|
|
|
|
Local::writeSettings();
|
2018-09-07 12:19:56 +00:00
|
|
|
}, sendto->lifetime());
|
2018-09-07 09:40:25 +00:00
|
|
|
}
|
|
|
|
#endif // OS_WIN_STORE
|
|
|
|
}
|
|
|
|
|
2018-09-13 20:09:26 +00:00
|
|
|
void SetupTray(not_null<Ui::VerticalLayout*> container) {
|
|
|
|
if (!HasTray()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto wrap = object_ptr<Ui::VerticalLayout>(container);
|
|
|
|
SetupTrayContent(wrap.data());
|
|
|
|
|
|
|
|
container->add(object_ptr<Ui::OverrideMargins>(
|
|
|
|
container,
|
|
|
|
std::move(wrap)));
|
|
|
|
|
|
|
|
AddSkip(container, st::settingsCheckboxesSkip);
|
|
|
|
}
|
|
|
|
|
2018-09-20 17:56:45 +00:00
|
|
|
void SetupAnimations(not_null<Ui::VerticalLayout*> container) {
|
|
|
|
AddButton(
|
|
|
|
container,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_settings_enable_animations(),
|
2018-09-20 17:56:45 +00:00
|
|
|
st::settingsButton
|
|
|
|
)->toggleOn(
|
|
|
|
rpl::single(!anim::Disabled())
|
|
|
|
)->toggledValue(
|
|
|
|
) | rpl::filter([](bool enabled) {
|
|
|
|
return (enabled == anim::Disabled());
|
|
|
|
}) | rpl::start_with_next([](bool enabled) {
|
|
|
|
anim::SetDisabled(!enabled);
|
|
|
|
Local::writeSettings();
|
|
|
|
}, container->lifetime());
|
|
|
|
}
|
|
|
|
|
2019-07-24 14:00:30 +00:00
|
|
|
void SetupPerformance(
|
|
|
|
not_null<Window::SessionController*> controller,
|
|
|
|
not_null<Ui::VerticalLayout*> container) {
|
2018-09-20 17:56:45 +00:00
|
|
|
SetupAnimations(container);
|
|
|
|
|
2019-08-01 11:42:24 +00:00
|
|
|
const auto session = &controller->session();
|
2018-09-20 17:56:45 +00:00
|
|
|
AddButton(
|
|
|
|
container,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_settings_autoplay_gifs(),
|
2018-09-20 17:56:45 +00:00
|
|
|
st::settingsButton
|
|
|
|
)->toggleOn(
|
2019-08-01 11:42:24 +00:00
|
|
|
rpl::single(session->settings().autoplayGifs())
|
2018-09-20 17:56:45 +00:00
|
|
|
)->toggledValue(
|
2019-08-01 11:42:24 +00:00
|
|
|
) | rpl::filter([=](bool enabled) {
|
|
|
|
return (enabled != session->settings().autoplayGifs());
|
2019-07-24 14:00:30 +00:00
|
|
|
}) | rpl::start_with_next([=](bool enabled) {
|
2019-08-01 11:42:24 +00:00
|
|
|
session->settings().setAutoplayGifs(enabled);
|
|
|
|
if (!enabled) {
|
|
|
|
session->data().stopAutoplayAnimations();
|
2018-09-20 17:56:45 +00:00
|
|
|
}
|
2019-08-01 11:42:24 +00:00
|
|
|
session->saveSettingsDelayed();
|
|
|
|
}, container->lifetime());
|
2018-09-20 17:56:45 +00:00
|
|
|
}
|
|
|
|
|
2019-01-11 09:04:28 +00:00
|
|
|
void SetupSystemIntegration(
|
|
|
|
not_null<Ui::VerticalLayout*> container,
|
|
|
|
Fn<void(Type)> showOther) {
|
|
|
|
AddDivider(container);
|
|
|
|
AddSkip(container);
|
2019-06-18 12:16:43 +00:00
|
|
|
AddSubsectionTitle(container, tr::lng_settings_system_integration());
|
2019-01-11 09:04:28 +00:00
|
|
|
AddButton(
|
|
|
|
container,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_settings_section_call_settings(),
|
2019-01-11 09:04:28 +00:00
|
|
|
st::settingsButton
|
|
|
|
)->addClickHandler([=] {
|
|
|
|
showOther(Type::Calls);
|
|
|
|
});
|
|
|
|
SetupTray(container);
|
|
|
|
AddSkip(container);
|
|
|
|
}
|
|
|
|
|
2019-07-24 14:00:30 +00:00
|
|
|
Advanced::Advanced(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<Window::SessionController*> controller)
|
2018-09-11 20:02:07 +00:00
|
|
|
: Section(parent) {
|
2019-07-24 14:00:30 +00:00
|
|
|
setupContent(controller);
|
2018-09-05 19:05:49 +00:00
|
|
|
}
|
|
|
|
|
2019-01-11 09:04:28 +00:00
|
|
|
rpl::producer<Type> Advanced::sectionShowOther() {
|
|
|
|
return _showOther.events();
|
|
|
|
}
|
|
|
|
|
2019-07-24 14:00:30 +00:00
|
|
|
void Advanced::setupContent(not_null<Window::SessionController*> controller) {
|
2018-09-05 19:05:49 +00:00
|
|
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
|
|
|
|
2018-09-17 10:52:34 +00:00
|
|
|
auto empty = true;
|
|
|
|
const auto addDivider = [&] {
|
|
|
|
if (empty) {
|
|
|
|
empty = false;
|
|
|
|
} else {
|
|
|
|
AddDivider(content);
|
|
|
|
}
|
|
|
|
};
|
2018-09-19 10:29:51 +00:00
|
|
|
const auto addUpdate = [&] {
|
|
|
|
if (HasUpdate()) {
|
|
|
|
addDivider();
|
|
|
|
AddSkip(content);
|
2019-06-18 12:16:43 +00:00
|
|
|
AddSubsectionTitle(content, tr::lng_settings_version_info());
|
2018-09-19 10:29:51 +00:00
|
|
|
SetupUpdate(content);
|
|
|
|
AddSkip(content);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
if (!cAutoUpdate()) {
|
|
|
|
addUpdate();
|
|
|
|
}
|
2018-09-17 10:52:34 +00:00
|
|
|
if (HasConnectionType()) {
|
|
|
|
addDivider();
|
2018-09-11 18:07:04 +00:00
|
|
|
AddSkip(content);
|
2019-06-18 12:16:43 +00:00
|
|
|
AddSubsectionTitle(content, tr::lng_settings_network_proxy());
|
2018-09-17 10:52:34 +00:00
|
|
|
SetupConnectionType(content);
|
2018-09-11 18:07:04 +00:00
|
|
|
AddSkip(content);
|
|
|
|
}
|
2019-07-24 14:00:30 +00:00
|
|
|
SetupDataStorage(controller, content);
|
|
|
|
SetupAutoDownload(controller, content);
|
2019-01-11 09:04:28 +00:00
|
|
|
SetupSystemIntegration(content, [=](Type type) {
|
|
|
|
_showOther.fire_copy(type);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddDivider(content);
|
2018-09-20 17:56:45 +00:00
|
|
|
AddSkip(content);
|
2019-06-18 12:16:43 +00:00
|
|
|
AddSubsectionTitle(content, tr::lng_settings_performance());
|
2019-07-24 14:00:30 +00:00
|
|
|
SetupPerformance(controller, content);
|
2018-09-20 17:56:45 +00:00
|
|
|
AddSkip(content);
|
2019-01-11 09:04:28 +00:00
|
|
|
|
2019-10-05 16:38:25 +00:00
|
|
|
if (HasSystemSpellchecker()) {
|
|
|
|
AddDivider(content);
|
2019-11-05 14:44:39 +00:00
|
|
|
AddSkip(content);
|
2019-10-05 16:38:25 +00:00
|
|
|
AddSubsectionTitle(content, tr::lng_settings_spellchecker());
|
|
|
|
SetupSpellchecker(controller, content);
|
|
|
|
AddSkip(content);
|
|
|
|
}
|
|
|
|
|
2018-09-19 10:29:51 +00:00
|
|
|
if (cAutoUpdate()) {
|
|
|
|
addUpdate();
|
|
|
|
}
|
2018-09-05 19:05:49 +00:00
|
|
|
|
|
|
|
Ui::ResizeFitChild(this, content);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Settings
|