mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-22 03:08:48 +00:00
Implement general settings section.
This commit is contained in:
parent
9af70551f3
commit
38f788f545
@ -331,6 +331,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_settings_language" = "Language";
|
||||
"lng_settings_default_scale" = "Default interface scale";
|
||||
"lng_settings_edit_info" = "Edit information";
|
||||
"lng_settings_local_storage" = "Local storage";
|
||||
"lng_settings_connection_type" = "Connection type";
|
||||
"lng_settings_downloading_update" = "Downloading update {progress}...";
|
||||
|
||||
"lng_backgrounds_header" = "Choose your new chat background";
|
||||
"lng_theme_sure_keep" = "Keep this theme?";
|
||||
|
@ -58,6 +58,10 @@ rpl::producer<bool> Button::toggledValue() const {
|
||||
return rpl::never<bool>();
|
||||
}
|
||||
|
||||
bool Button::toggled() const {
|
||||
return _toggle ? _toggle->checked() : false;
|
||||
}
|
||||
|
||||
void Button::setColorOverride(base::optional<QColor> textColorOverride) {
|
||||
_textColorOverride = textColorOverride;
|
||||
update();
|
||||
@ -94,6 +98,7 @@ void Button::paintEvent(QPaintEvent *e) {
|
||||
|
||||
QRect Button::toggleRect() const {
|
||||
Expects(_toggle != nullptr);
|
||||
|
||||
auto size = _toggle->getSize();
|
||||
auto left = width() - _st.toggleSkip - size.width();
|
||||
auto top = (height() - size.height()) / 2;
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
|
||||
Button *toggleOn(rpl::producer<bool> &&toggled);
|
||||
rpl::producer<bool> toggledValue() const;
|
||||
bool toggled() const;
|
||||
|
||||
void setColorOverride(base::optional<QColor> textColorOverride);
|
||||
|
||||
|
@ -8,18 +8,34 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
using "basic.style";
|
||||
using "ui/widgets/widgets.style";
|
||||
using "info/info.style";
|
||||
using "boxes/boxes.style";
|
||||
|
||||
settingsSectionButton: infoProfileButton;
|
||||
settingsSectionButton: InfoProfileButton(infoProfileButton) {
|
||||
font: boxTextFont;
|
||||
}
|
||||
settingsButton: InfoProfileButton(settingsSectionButton) {
|
||||
padding: margins(28px, 10px, 8px, 8px);
|
||||
}
|
||||
settingsSectionSkip: infoProfileSkip;
|
||||
settingsButtonRightPosition: point(28px, 10px);
|
||||
settingsButtonRight: FlatLabel(defaultFlatLabel) {
|
||||
textFg: windowActiveTextFg;
|
||||
style: boxTextStyle;
|
||||
}
|
||||
settingsScalePadding: margins(79px, 10px, 28px, 8px);
|
||||
settingsSlider: SettingsSlider(defaultSettingsSlider) {
|
||||
labelFg: windowSubTextFg;
|
||||
labelFgActive: windowActiveTextFg;
|
||||
}
|
||||
settingsUpdateToggle: InfoProfileButton(settingsButton) {
|
||||
height: 38px;
|
||||
}
|
||||
settingsUpdateState: FlatLabel(defaultFlatLabel) {
|
||||
textFg: windowSubTextFg;
|
||||
}
|
||||
settingsUpdate: InfoProfileButton(infoMainButton, settingsButton) {
|
||||
}
|
||||
settingsUpdateStatePosition: point(28px, 30px);
|
||||
|
||||
settingsNotificationsCheckbox: defaultBoxCheckbox;
|
||||
settingsNotificationsCheckboxPadding: margins(22px, 10px, 10px, 10px);
|
||||
|
@ -15,6 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "settings/settings_privacy_security.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "info/profile/info_profile_button.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "mainwindow.h"
|
||||
@ -22,16 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
namespace Settings {
|
||||
|
||||
void AddSkip(not_null<Ui::VerticalLayout*> container) {
|
||||
container->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
container,
|
||||
st::settingsSectionSkip));
|
||||
}
|
||||
|
||||
void AddDivider(not_null<Ui::VerticalLayout*> container) {
|
||||
container->add(object_ptr<BoxContentDivider>(container));
|
||||
}
|
||||
|
||||
object_ptr<Section> CreateSection(
|
||||
Type type,
|
||||
not_null<QWidget*> parent,
|
||||
@ -54,6 +46,48 @@ object_ptr<Section> CreateSection(
|
||||
Unexpected("Settings section type in Widget::createInnerWidget.");
|
||||
}
|
||||
|
||||
void AddSkip(not_null<Ui::VerticalLayout*> container) {
|
||||
container->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
container,
|
||||
st::settingsSectionSkip));
|
||||
}
|
||||
|
||||
void AddDivider(not_null<Ui::VerticalLayout*> container) {
|
||||
container->add(object_ptr<BoxContentDivider>(container));
|
||||
}
|
||||
|
||||
not_null<Button*> AddButton(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
LangKey text,
|
||||
const style::InfoProfileButton &st) {
|
||||
return container->add(object_ptr<Button>(
|
||||
container,
|
||||
Lang::Viewer(text),
|
||||
st));
|
||||
}
|
||||
|
||||
not_null<Button*> AddButtonWithLabel(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
LangKey text,
|
||||
rpl::producer<QString> label,
|
||||
const style::InfoProfileButton &st) {
|
||||
const auto button = AddButton(container, text, st);
|
||||
const auto name = Ui::CreateChild<Ui::FlatLabel>(
|
||||
button.get(),
|
||||
std::move(label),
|
||||
st::settingsButtonRight);
|
||||
rpl::combine(
|
||||
name->widthValue(),
|
||||
button->widthValue()
|
||||
) | rpl::start_with_next([=] {
|
||||
name->moveToRight(
|
||||
st::settingsButtonRightPosition.x(),
|
||||
st::settingsButtonRightPosition.y());
|
||||
}, name->lifetime());
|
||||
name->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
return button;
|
||||
}
|
||||
|
||||
void FillMenu(Fn<void(Type)> showOther, MenuCallback addAction) {
|
||||
addAction(
|
||||
lang(lng_settings_edit_info),
|
||||
|
@ -9,6 +9,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "ui/rp_widget.h"
|
||||
|
||||
enum LangKey : int;
|
||||
|
||||
namespace Ui {
|
||||
class VerticalLayout;
|
||||
} // namespace Ui
|
||||
@ -23,6 +25,10 @@ class Button;
|
||||
} // namespace Profile
|
||||
} // namespace Info
|
||||
|
||||
namespace style {
|
||||
struct InfoProfileButton;
|
||||
} // namespace style
|
||||
|
||||
namespace Settings {
|
||||
|
||||
enum class Type {
|
||||
@ -54,6 +60,15 @@ object_ptr<Section> CreateSection(
|
||||
|
||||
void AddSkip(not_null<Ui::VerticalLayout*> container);
|
||||
void AddDivider(not_null<Ui::VerticalLayout*> container);
|
||||
not_null<Button*> AddButton(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
LangKey text,
|
||||
const style::InfoProfileButton &st);
|
||||
not_null<Button*> AddButtonWithLabel(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
LangKey text,
|
||||
rpl::producer<QString> label,
|
||||
const style::InfoProfileButton &st);
|
||||
|
||||
using MenuCallback = Fn<QAction*(
|
||||
const QString &text,
|
||||
|
@ -8,12 +8,374 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "settings/settings_general.h"
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/wrap/slide_wrap.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "boxes/local_storage_box.h"
|
||||
#include "boxes/connection_box.h"
|
||||
#include "boxes/about_box.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "info/profile/info_profile_button.h"
|
||||
#include "info/profile/info_profile_values.h"
|
||||
#include "data/data_session.h"
|
||||
#include "platform/platform_specific.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "core/update_checker.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "auth_session.h"
|
||||
#include "layout.h"
|
||||
#include "styles/style_settings.h"
|
||||
|
||||
namespace Settings {
|
||||
namespace {
|
||||
|
||||
void SetupConnectionType(not_null<Ui::VerticalLayout*> container) {
|
||||
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
|
||||
const auto connectionType = [] {
|
||||
const auto transport = MTP::dctransport();
|
||||
if (!Global::UseProxy()) {
|
||||
return transport.isEmpty()
|
||||
? lang(lng_connection_auto_connecting)
|
||||
: lng_connection_auto(lt_transport, transport);
|
||||
} else {
|
||||
return transport.isEmpty()
|
||||
? lang(lng_connection_proxy_connecting)
|
||||
: lng_connection_proxy(lt_transport, transport);
|
||||
}
|
||||
};
|
||||
const auto button = AddButtonWithLabel(
|
||||
container,
|
||||
lng_settings_connection_type,
|
||||
rpl::single(
|
||||
rpl::empty_value()
|
||||
) | rpl::then(base::ObservableViewer(
|
||||
Global::RefConnectionTypeChanged()
|
||||
)) | rpl::map(connectionType),
|
||||
st::settingsButton);
|
||||
button->addClickHandler([] {
|
||||
Ui::show(ProxiesBoxController::CreateOwningBox());
|
||||
});
|
||||
#endif // TDESKTOP_DISABLE_NETWORK_PROXY
|
||||
}
|
||||
|
||||
void SetupStorageAndConnection(not_null<Ui::VerticalLayout*> container) {
|
||||
AddDivider(container);
|
||||
AddSkip(container);
|
||||
|
||||
AddButton(
|
||||
container,
|
||||
lng_settings_local_storage,
|
||||
st::settingsButton
|
||||
)->addClickHandler([] {
|
||||
LocalStorageBox::Show(&Auth().data().cache());
|
||||
});
|
||||
SetupConnectionType(container);
|
||||
|
||||
AddSkip(container);
|
||||
}
|
||||
|
||||
void SetupUpdate(not_null<Ui::VerticalLayout*> container) {
|
||||
if (Core::UpdaterDisabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
AddDivider(container);
|
||||
AddSkip(container);
|
||||
|
||||
const auto lifetime = Ui::AttachAsChild(container, rpl::lifetime());
|
||||
const auto texts = Ui::AttachAsChild(
|
||||
container,
|
||||
rpl::event_stream<QString>());
|
||||
const auto downloading = Ui::AttachAsChild(
|
||||
container,
|
||||
rpl::event_stream<bool>());
|
||||
const auto version = lng_settings_current_version(
|
||||
lt_version,
|
||||
currentVersionText());
|
||||
const auto toggle = AddButton(
|
||||
container,
|
||||
lng_settings_update_automatically,
|
||||
st::settingsUpdateToggle);
|
||||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||
toggle.get(),
|
||||
texts->events(),
|
||||
st::settingsUpdateState);
|
||||
|
||||
const auto check = container->add(object_ptr<Ui::SlideWrap<Button>>(
|
||||
container,
|
||||
object_ptr<Button>(
|
||||
container,
|
||||
Lang::Viewer(lng_settings_check_now),
|
||||
st::settingsButton)));
|
||||
const auto update = Ui::CreateChild<Button>(
|
||||
check->entity(),
|
||||
Lang::Viewer(lng_update_telegram) | Info::Profile::ToUpperValue(),
|
||||
st::settingsUpdate);
|
||||
update->hide();
|
||||
check->entity()->widthValue() | rpl::start_with_next([=](int width) {
|
||||
update->resizeToWidth(width);
|
||||
update->moveToLeft(0, 0);
|
||||
}, *lifetime);
|
||||
|
||||
AddSkip(container);
|
||||
|
||||
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(lng_settings_downloading_update(
|
||||
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:
|
||||
texts->fire(lang(lng_settings_update_ready));
|
||||
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();
|
||||
}
|
||||
setDefaultStatus(checker);
|
||||
}, *lifetime);
|
||||
|
||||
Core::UpdateChecker checker;
|
||||
check->toggleOn(rpl::combine(
|
||||
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([=] {
|
||||
check->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
texts->fire(lang(lng_settings_update_checking));
|
||||
downloading->fire(false);
|
||||
}, *lifetime);
|
||||
checker.isLatest() | rpl::start_with_next([=] {
|
||||
check->setAttribute(Qt::WA_TransparentForMouseEvents, false);
|
||||
texts->fire(lang(lng_settings_latest_installed));
|
||||
downloading->fire(false);
|
||||
}, *lifetime);
|
||||
checker.progress(
|
||||
) | rpl::start_with_next([=](Core::UpdateChecker::Progress progress) {
|
||||
showDownloadProgress(progress.already, progress.size);
|
||||
}, *lifetime);
|
||||
checker.failed() | rpl::start_with_next([=] {
|
||||
check->setAttribute(Qt::WA_TransparentForMouseEvents, false);
|
||||
texts->fire(lang(lng_settings_update_fail));
|
||||
downloading->fire(false);
|
||||
}, *lifetime);
|
||||
checker.ready() | rpl::start_with_next([=] {
|
||||
texts->fire(lang(lng_settings_update_ready));
|
||||
update->show();
|
||||
downloading->fire(false);
|
||||
}, *lifetime);
|
||||
|
||||
setDefaultStatus(checker);
|
||||
|
||||
check->entity()->addClickHandler([] {
|
||||
Core::UpdateChecker checker;
|
||||
|
||||
cSetLastUpdateCheck(0);
|
||||
checker.start();
|
||||
});
|
||||
update->addClickHandler([] {
|
||||
if (!Core::UpdaterDisabled()) {
|
||||
Core::checkReadyUpdate();
|
||||
}
|
||||
App::restart();
|
||||
});
|
||||
}
|
||||
|
||||
void SetupTray(not_null<Ui::VerticalLayout*> container) {
|
||||
if (!cSupportTray() && cPlatform() != dbipWindows) {
|
||||
return;
|
||||
}
|
||||
|
||||
AddDivider(container);
|
||||
AddSkip(container);
|
||||
|
||||
const auto lifetime = Ui::AttachAsChild(container, rpl::lifetime());
|
||||
const auto trayEnabler = Ui::AttachAsChild(
|
||||
container,
|
||||
rpl::event_stream<bool>());
|
||||
const auto trayEnabled = [] {
|
||||
const auto workMode = Global::WorkMode().value();
|
||||
return (workMode == dbiwmTrayOnly)
|
||||
|| (workMode == dbiwmWindowAndTray);
|
||||
};
|
||||
const auto tray = AddButton(
|
||||
container,
|
||||
lng_settings_workmode_tray,
|
||||
st::settingsButton
|
||||
)->toggleOn(trayEnabler->events_starting_with(trayEnabled()));
|
||||
|
||||
const auto taskbarEnabled = [] {
|
||||
const auto workMode = Global::WorkMode().value();
|
||||
return (workMode == dbiwmWindowOnly)
|
||||
|| (workMode == dbiwmWindowAndTray);
|
||||
};
|
||||
const auto taskbarEnabler = Ui::AttachAsChild(
|
||||
container,
|
||||
rpl::event_stream<bool>());
|
||||
const auto taskbar = (cPlatform() == dbipWindows)
|
||||
? AddButton(
|
||||
container,
|
||||
lng_settings_workmode_window,
|
||||
st::settingsButton
|
||||
)->toggleOn(taskbarEnabler->events_starting_with(taskbarEnabled()))
|
||||
: nullptr;
|
||||
|
||||
const auto updateWorkmode = [=] {
|
||||
const auto newMode = tray->toggled()
|
||||
? ((!taskbar || taskbar->toggled())
|
||||
? dbiwmWindowAndTray
|
||||
: dbiwmTrayOnly)
|
||||
: dbiwmWindowOnly;
|
||||
if ((newMode == dbiwmWindowAndTray || newMode == dbiwmTrayOnly)
|
||||
&& Global::WorkMode().value() != newMode) {
|
||||
cSetSeenTrayTooltip(false);
|
||||
}
|
||||
Global::RefWorkMode().set(newMode);
|
||||
Local::writeSettings();
|
||||
};
|
||||
|
||||
tray->toggledValue(
|
||||
) | rpl::filter([=](bool checked) {
|
||||
return (checked != trayEnabled());
|
||||
}) | rpl::start_with_next([=](bool checked) {
|
||||
if (!checked && taskbar && !taskbar->toggled()) {
|
||||
taskbarEnabler->fire(true);
|
||||
} else {
|
||||
updateWorkmode();
|
||||
}
|
||||
}, *lifetime);
|
||||
|
||||
if (taskbar) {
|
||||
taskbar->toggledValue(
|
||||
) | rpl::filter([=](bool checked) {
|
||||
return (checked != taskbarEnabled());
|
||||
}) | rpl::start_with_next([=](bool checked) {
|
||||
if (!checked && !tray->toggled()) {
|
||||
trayEnabler->fire(true);
|
||||
} else {
|
||||
updateWorkmode();
|
||||
}
|
||||
}, *lifetime);
|
||||
}
|
||||
|
||||
#ifndef OS_WIN_STORE
|
||||
if (cPlatform() == dbipWindows) {
|
||||
const auto autostart = AddButton(
|
||||
container,
|
||||
lng_settings_auto_start,
|
||||
st::settingsButton
|
||||
)->toggleOn(rpl::single(cAutoStart()));
|
||||
const auto minimized = container->add(
|
||||
object_ptr<Ui::SlideWrap<Button>>(
|
||||
container,
|
||||
object_ptr<Button>(
|
||||
container,
|
||||
Lang::Viewer(lng_settings_start_min),
|
||||
st::settingsButton)));
|
||||
const auto sendto = AddButton(
|
||||
container,
|
||||
lng_settings_add_sendto,
|
||||
st::settingsButton
|
||||
)->toggleOn(rpl::single(cSendToMenu()));
|
||||
|
||||
const auto minimizedToggler = Ui::AttachAsChild(
|
||||
minimized,
|
||||
rpl::event_stream<bool>());
|
||||
const auto minimizedToggled = [] {
|
||||
return cStartMinimized() && !Global::LocalPasscode();
|
||||
};
|
||||
|
||||
autostart->toggledValue(
|
||||
) | rpl::filter([](bool checked) {
|
||||
return (checked != cAutoStart());
|
||||
}) | rpl::start_with_next([=](bool checked) {
|
||||
cSetAutoStart(checked);
|
||||
psAutoStart(checked);
|
||||
if (checked) {
|
||||
Local::writeSettings();
|
||||
} else if (minimized->entity()->toggled()) {
|
||||
minimizedToggler->fire(false);
|
||||
} else {
|
||||
Local::writeSettings();
|
||||
}
|
||||
}, *lifetime);
|
||||
|
||||
minimized->entity()->toggleOn(
|
||||
minimizedToggler->events_starting_with(minimizedToggled()));
|
||||
minimized->toggleOn(autostart->toggledValue());
|
||||
minimized->entity()->toggledValue(
|
||||
) | rpl::filter([=](bool checked) {
|
||||
return (checked != minimizedToggled());
|
||||
}) | rpl::start_with_next([=](bool checked) {
|
||||
if (Global::LocalPasscode()) {
|
||||
minimizedToggler->fire(false);
|
||||
Ui::show(Box<InformBox>(
|
||||
lang(lng_error_start_minimized_passcoded)));
|
||||
} else {
|
||||
cSetStartMinimized(checked);
|
||||
Local::writeSettings();
|
||||
}
|
||||
}, *lifetime);
|
||||
|
||||
base::ObservableViewer(
|
||||
Global::RefLocalPasscodeChanged()
|
||||
) | rpl::start_with_next([=] {
|
||||
minimizedToggler->fire(minimizedToggled());
|
||||
}, *lifetime);
|
||||
|
||||
sendto->toggledValue(
|
||||
) | rpl::filter([](bool checked) {
|
||||
return (checked != cSendToMenu());
|
||||
}) | rpl::start_with_next([](bool checked) {
|
||||
cSetSendToMenu(checked);
|
||||
psSendToMenu(checked);
|
||||
Local::writeSettings();
|
||||
}, *lifetime);
|
||||
}
|
||||
#endif // OS_WIN_STORE
|
||||
|
||||
AddSkip(container);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
General::General(QWidget *parent, UserData *self)
|
||||
: Section(parent)
|
||||
@ -24,7 +386,9 @@ General::General(QWidget *parent, UserData *self)
|
||||
void General::setupContent() {
|
||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
|
||||
content->add(object_ptr<BoxContentDivider>(content));
|
||||
SetupUpdate(content);
|
||||
SetupTray(content);
|
||||
SetupStorageAndConnection(content);
|
||||
|
||||
Ui::ResizeFitChild(this, content);
|
||||
}
|
||||
|
@ -68,10 +68,10 @@ void SetupUploadPhotoButton(
|
||||
filter,
|
||||
crl::guard(container, callback));
|
||||
};
|
||||
container->add(object_ptr<Button>(
|
||||
AddButton(
|
||||
container,
|
||||
Lang::Viewer(lng_settings_upload),
|
||||
st::settingsSectionButton)
|
||||
lng_settings_upload,
|
||||
st::settingsSectionButton
|
||||
)->addClickHandler(App::LambdaDelayed(
|
||||
st::settingsSectionButton.ripple.hideDuration,
|
||||
container,
|
||||
@ -81,26 +81,15 @@ void SetupUploadPhotoButton(
|
||||
}
|
||||
|
||||
void SetupLanguageButton(not_null<Ui::VerticalLayout*> container) {
|
||||
const auto button = container->add(object_ptr<Button>(
|
||||
const auto button = AddButtonWithLabel(
|
||||
container,
|
||||
Lang::Viewer(lng_settings_language),
|
||||
st::settingsSectionButton));
|
||||
lng_settings_language,
|
||||
Lang::Viewer(lng_language_name),
|
||||
st::settingsSectionButton);
|
||||
const auto guard = Ui::AttachAsChild(button, base::binary_guard());
|
||||
button->addClickHandler([=] {
|
||||
*guard = LanguageBox::Show();
|
||||
});
|
||||
const auto name = Ui::CreateChild<Ui::FlatLabel>(
|
||||
button,
|
||||
Lang::Viewer(lng_language_name),
|
||||
st::settingsButtonRight);
|
||||
rpl::combine(
|
||||
name->widthValue(),
|
||||
button->widthValue()
|
||||
) | rpl::start_with_next([=] {
|
||||
name->moveToRight(
|
||||
st::settingsButtonRightPosition.x(),
|
||||
st::settingsButtonRightPosition.y());
|
||||
}, name->lifetime());
|
||||
}
|
||||
|
||||
void SetupSections(
|
||||
@ -110,10 +99,10 @@ void SetupSections(
|
||||
AddSkip(container);
|
||||
|
||||
const auto addSection = [&](LangKey label, Type type) {
|
||||
container->add(object_ptr<Button>(
|
||||
AddButton(
|
||||
container,
|
||||
Lang::Viewer(label),
|
||||
st::settingsSectionButton)
|
||||
label,
|
||||
st::settingsSectionButton
|
||||
)->addClickHandler([=] { showOther(type); });
|
||||
};
|
||||
addSection(lng_settings_section_info, Type::Information);
|
||||
@ -140,10 +129,10 @@ void SetupInterfaceScale(not_null<Ui::VerticalLayout*> container) {
|
||||
|
||||
const auto switched = (cConfigScale() == dbisAuto)
|
||||
|| (cConfigScale() == cScreenScale());
|
||||
const auto button = container->add(object_ptr<Button>(
|
||||
const auto button = AddButton(
|
||||
container,
|
||||
Lang::Viewer(lng_settings_default_scale),
|
||||
st::settingsSectionButton)
|
||||
lng_settings_default_scale,
|
||||
st::settingsSectionButton
|
||||
)->toggleOn(toggled->events_starting_with_copy(switched));
|
||||
|
||||
const auto slider = container->add(
|
||||
@ -243,19 +232,19 @@ void SetupHelp(not_null<Ui::VerticalLayout*> container) {
|
||||
AddDivider(container);
|
||||
AddSkip(container);
|
||||
|
||||
container->add(object_ptr<Button>(
|
||||
AddButton(
|
||||
container,
|
||||
Lang::Viewer(lng_settings_faq),
|
||||
st::settingsSectionButton)
|
||||
lng_settings_faq,
|
||||
st::settingsSectionButton
|
||||
)->addClickHandler([] {
|
||||
QDesktopServices::openUrl(telegramFaqLink());
|
||||
});
|
||||
|
||||
if (AuthSession::Exists()) {
|
||||
const auto button = container->add(object_ptr<Button>(
|
||||
const auto button = AddButton(
|
||||
container,
|
||||
Lang::Viewer(lng_settings_ask_question),
|
||||
st::settingsSectionButton));
|
||||
lng_settings_ask_question,
|
||||
st::settingsSectionButton);
|
||||
button->addClickHandler([=] {
|
||||
const auto ready = crl::guard(button, [](const MTPUser &data) {
|
||||
const auto users = MTP_vector<MTPUser>(1, data);
|
||||
|
Loading…
Reference in New Issue
Block a user