Some settings reordered in sections.

This commit is contained in:
John Preston 2018-09-17 13:52:34 +03:00
parent 97a4c76043
commit 130aa67ba0
10 changed files with 163 additions and 187 deletions

View File

@ -354,8 +354,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_settings_peer_to_peer_about" = "Disabling peer-to-peer will relay all calls through Telegram servers to avoid revealing your IP address, but may slightly decrease audio quality.";
"lng_settings_advanced" = "Advanced";
"lng_settings_stickers_emoji" = "Stickers and emoji";
"lng_settings_messages" = "Messages";
"lng_settings_themes" = "Themes";
"lng_settings_chat_other" = "Other";
"lng_settings_data_storage" = "Data and storage";
"lng_settings_information" = "Edit profile";
"lng_settings_passcode_title" = "Local passcode";
"lng_settings_password_title" = "Two-step verification";
@ -369,10 +370,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_theme_keep_changes" = "Keep changes";
"lng_theme_revert" = "Revert";
"lng_download_path_dont_ask" = "Don't ask download path for each file";
"lng_download_path_label" = "Download path:";
"lng_download_path_temp" = "temp folder";
"lng_download_path_default" = "default folder";
"lng_download_path_ask" = "Ask download path for each file";
"lng_download_path" = "Download path";
"lng_download_path_temp" = "Temp folder";
"lng_download_path_default" = "Default folder";
"lng_download_path_clear" = "Clear all";
"lng_download_path_header" = "Choose download path";
"lng_download_path_default_radio" = "Telegram folder in system «Downloads»";

View File

@ -14,13 +14,7 @@ settingsSectionButton: InfoProfileButton(infoProfileButton) {
font: boxTextFont;
padding: margins(79px, 13px, 22px, 11px);
}
settingsGeneralButton: InfoProfileButton(settingsSectionButton) {
padding: margins(24px, 13px, 22px, 11px);
}
settingsButton: InfoProfileButton(settingsSectionButton) {
padding: margins(22px, 13px, 22px, 11px);
}
settingsPrivacyButton: InfoProfileButton(settingsButton) {
padding: margins(22px, 10px, 22px, 8px);
}
settingsSectionSkip: 9px;
@ -30,24 +24,25 @@ settingsButtonRightSkip: 28px;
settingsButtonRight: FlatLabel(defaultFlatLabel) {
textFg: windowActiveTextFg;
style: boxTextStyle;
maxHeight: 20px;
}
settingsScalePadding: margins(79px, 10px, 28px, 8px);
settingsBigScalePadding: margins(24px, 10px, 24px, 8px);
settingsBigScalePadding: margins(22px, 10px, 22px, 8px);
settingsSlider: SettingsSlider(defaultSettingsSlider) {
barFg: windowBgOver;
labelFg: windowSubTextFg;
labelFgActive: windowActiveTextFg;
}
settingsUpdateToggle: InfoProfileButton(settingsGeneralButton) {
settingsUpdateToggle: InfoProfileButton(settingsButton) {
height: 40px;
padding: margins(24px, 8px, 22px, 8px);
padding: margins(22px, 8px, 22px, 8px);
}
settingsUpdateState: FlatLabel(defaultFlatLabel) {
textFg: windowSubTextFg;
}
settingsUpdate: InfoProfileButton(infoMainButton, settingsButton) {
}
settingsUpdateStatePosition: point(24px, 29px);
settingsUpdateStatePosition: point(22px, 29px);
settingsDividerLabelPadding: margins(22px, 10px, 22px, 19px);
settingsIconInformation: icon {{ "settings_information", menuIconFg }};
@ -75,9 +70,6 @@ settingsSendType: settingsCheckbox;
settingsSendTypePadding: margins(22px, 5px, 10px, 5px);
settingsSendTypeSkip: 5px;
settingsAskPathPadding: margins(22px, 10px, 10px, 0px);
settingsDownloadPathPadding: margins(22px, 1px, 10px, 0px);
settingsBackgroundThumb: 76px;
settingsThumbSkip: 16px;
settingsSubsectionTitle: FlatLabel(defaultFlatLabel) {

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/stickers_box.h"
#include "boxes/background_box.h"
#include "boxes/download_path_box.h"
#include "boxes/local_storage_box.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/wrap/slide_wrap.h"
#include "ui/widgets/checkbox.h"
@ -23,8 +24,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/profile/info_profile_button.h"
#include "storage/localstorage.h"
#include "core/file_utilities.h"
#include "data/data_session.h"
#include "auth_session.h"
#include "mainwidget.h"
#include "styles/style_settings.h"
#include "styles/style_boxes.h"
namespace Settings {
@ -55,17 +59,6 @@ private:
};
#ifndef OS_WIN_STORE
class DownloadPathRow : public Ui::RpWidget {
public:
DownloadPathRow(QWidget *parent);
private:
void setupControls();
};
#endif // OS_WIN_STORE
void ChooseFromFile(not_null<QWidget*> parent);
BackgroundRow::BackgroundRow(QWidget *parent) : RpWidget(parent)
@ -315,8 +308,6 @@ void ChooseFromFile(not_null<QWidget*> parent) {
}
#ifndef OS_WIN_STORE
QString DownloadPathText() {
if (Global::DownloadPath().isEmpty()) {
return lang(lng_download_path_default);
@ -326,49 +317,6 @@ QString DownloadPathText() {
return QDir::toNativeSeparators(Global::DownloadPath());
}
DownloadPathRow::DownloadPathRow(QWidget *parent) : RpWidget(parent) {
setupControls();
}
void DownloadPathRow::setupControls() {
const auto label = Ui::CreateChild<Ui::FlatLabel>(
this,
Lang::Viewer(lng_download_path_label),
st::settingsLinkLabel);
const auto link = Ui::CreateChild<Ui::LinkButton>(
this,
DownloadPathText(),
st::settingsLink);
base::ObservableViewer(
Global::RefDownloadPathChanged()
) | rpl::map([] {
return DownloadPathText();
}) | rpl::start_with_next([=](const QString &text) {
link->setText(text);
}, link->lifetime());
link->addClickHandler([] {
Ui::show(Box<DownloadPathBox>());
});
rpl::combine(
widthValue(),
label->sizeValue(),
link->widthValue()
) | rpl::start_with_next([=](int width, QSize labelSize, int possible) {
const auto space = st::settingsLinkLabel.style.font->spacew;
link->resizeToNaturalWidth(width - labelSize.width() - space);
if (link->width() == possible) {
label->moveToLeft(0, 0);
link->moveToLeft(labelSize.width() + space, 0);
resize(width, labelSize.height());
}
}, link->lifetime());
}
#endif // OS_WIN_STORE
void SetupStickersEmoji(not_null<Ui::VerticalLayout*> container) {
AddSkip(container, st::settingsStickersEmojiPadding);
@ -434,11 +382,11 @@ void SetupStickersEmoji(not_null<Ui::VerticalLayout*> container) {
AddSkip(container, st::settingsCheckboxesSkip);
}
void SetupChatOther(not_null<Ui::VerticalLayout*> container) {
void SetupMessages(not_null<Ui::VerticalLayout*> container) {
AddDivider(container);
AddSkip(container, st::settingsSectionSkip);
AddSubsectionTitle(container, lng_settings_chat_other);
AddSubsectionTitle(container, lng_settings_messages);
AddSkip(container, st::settingsSendTypeSkip);
@ -459,9 +407,9 @@ void SetupChatOther(not_null<Ui::VerticalLayout*> container) {
QMargins(0, skip, 0, skip)));
const auto add = [&](
SendByType value,
LangKey key,
style::margins padding) {
SendByType value,
LangKey key,
style::margins padding) {
inner->add(
object_ptr<Ui::Radioenum<SendByType>>(
inner,
@ -492,50 +440,91 @@ void SetupChatOther(not_null<Ui::VerticalLayout*> container) {
});
AddSkip(inner, st::settingsCheckboxesSkip);
}
const auto dontask = inner->add(
void SetupExport(not_null<Ui::VerticalLayout*> container) {
AddButton(
container,
lng_settings_export_data,
st::settingsButton
)->addClickHandler([] {
Ui::hideSettingsAndLayer();
App::CallDelayed(
st::boxDuration,
&Auth(),
[] { Auth().data().startExport(); });
});
}
void SetupLocalStorage(not_null<Ui::VerticalLayout*> container) {
AddButton(
container,
lng_settings_local_storage,
st::settingsButton
)->addClickHandler([] {
LocalStorageBox::Show(&Auth().data().cache());
});
}
void SetupDataStorage(not_null<Ui::VerticalLayout*> container) {
AddDivider(container);
AddSkip(container, st::settingsSectionSkip);
AddSubsectionTitle(container, lng_settings_data_storage);
auto wrap = object_ptr<Ui::VerticalLayout>(container);
const auto inner = wrap.data();
container->add(object_ptr<Ui::OverrideMargins>(
container,
std::move(wrap),
QMargins(0, 0, 0, st::settingsCheckbox.margin.bottom())));
const auto ask = inner->add(
object_ptr<Ui::Checkbox>(
inner,
lang(lng_download_path_dont_ask),
!Global::AskDownloadPath(),
lang(lng_download_path_ask),
Global::AskDownloadPath(),
st::settingsCheckbox),
#ifndef OS_WIN_STORE
st::settingsAskPathPadding);
#else // OS_WIN_STORE
st::settingsCheckboxPadding);
#endif // OS_WIN_STORE
#ifndef OS_WIN_STORE
const auto showpath = Ui::AttachAsChild(
dontask,
ask,
rpl::event_stream<bool>());
const auto padding = st::settingsDownloadPathPadding;
const auto path = container->add(
object_ptr<Ui::SlideWrap<DownloadPathRow>>(
object_ptr<Ui::SlideWrap<Button>>(
container,
object_ptr<DownloadPathRow>(container),
QMargins(
(padding.left()
+ st::settingsCheckbox.checkPosition.x()
+ st::defaultCheck.diameter
+ st::settingsCheckbox.textPosition.x()
- st::settingsCheckbox.margin.left()),
padding.top(),
padding.right(),
padding.bottom())));
AddSkip(container, st::settingsCheckboxPadding.bottom());
object_ptr<Button>(
container,
Lang::Viewer(lng_download_path),
st::settingsButton)));
auto pathtext = rpl::single(
rpl::empty_value()
) | rpl::then(base::ObservableViewer(
Global::RefDownloadPathChanged()
)) | rpl::map([] {
return DownloadPathText();
});
CreateRightLabel(
path->entity(),
std::move(pathtext),
st::settingsButton,
lng_download_path);
path->entity()->addClickHandler([] {
Ui::show(Box<DownloadPathBox>());
});
path->toggleOn(
showpath->events_starting_with(!Global::AskDownloadPath()));
showpath->events_starting_with_copy(!Global::AskDownloadPath()));
#endif // OS_WIN_STORE
base::ObservableViewer(
dontask->checkedChanged
ask->checkedChanged
) | rpl::start_with_next([=](bool checked) {
Global::SetAskDownloadPath(!checked);
Global::SetAskDownloadPath(checked);
Local::writeUserSettings();
#ifndef OS_WIN_STORE
showpath->fire_copy(checked);
showpath->fire_copy(!checked);
#endif // OS_WIN_STORE
}, inner->lifetime());
@ -548,6 +537,9 @@ void SetupChatOther(not_null<Ui::VerticalLayout*> container) {
Ui::show(Box<AutoDownloadBox>());
});
SetupExport(container);
SetupLocalStorage(container);
AddSkip(container, st::settingsCheckboxesSkip);
}
@ -702,9 +694,10 @@ void Chat::setupContent() {
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
SetupStickersEmoji(content);
SetupMessages(content);
SetupChatBackground(content);
SetupThemeOptions(content);
SetupChatOther(content);
SetupDataStorage(content);
Ui::ResizeFitChild(this, content);
}

View File

@ -120,15 +120,26 @@ not_null<Button*> AddButton(
void CreateRightLabel(
not_null<Button*> button,
rpl::producer<QString> label,
const style::InfoProfileButton &st) {
const style::InfoProfileButton &st,
LangKey buttonText) {
const auto name = Ui::CreateChild<Ui::FlatLabel>(
button.get(),
std::move(label),
st::settingsButtonRight);
rpl::combine(
name->widthValue(),
button->widthValue()
) | rpl::start_with_next([=] {
button->widthValue(),
Lang::Viewer(buttonText),
std::move(label)
) | rpl::start_with_next([=, &st](
int width,
const QString &button,
const QString &text) {
const auto available = width
- st.padding.left()
- st.padding.right()
- st.font->width(button)
- st::settingsButtonRightSkip;
name->setText(text);
name->resizeToNaturalWidth(available);
name->moveToRight(st::settingsButtonRightSkip, st.padding.top());
}, name->lifetime());
name->setAttribute(Qt::WA_TransparentForMouseEvents);
@ -141,7 +152,7 @@ not_null<Button*> AddButtonWithLabel(
const style::InfoProfileButton &st,
const style::icon *leftIcon) {
const auto button = AddButton(container, text, st, leftIcon);
CreateRightLabel(button, std::move(label), st);
CreateRightLabel(button, std::move(label), st, text);
return button;
}

View File

@ -89,7 +89,8 @@ not_null<Button*> AddButtonWithLabel(
void CreateRightLabel(
not_null<Button*> button,
rpl::producer<QString> label,
const style::InfoProfileButton &st);
const style::InfoProfileButton &st,
LangKey buttonText);
void AddSubsectionTitle(
not_null<Ui::VerticalLayout*> conatiner,
LangKey text);

View File

@ -12,18 +12,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/slide_wrap.h"
#include "ui/widgets/labels.h"
#include "ui/widgets/checkbox.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"
@ -61,28 +58,13 @@ void SetupConnectionType(not_null<Ui::VerticalLayout*> container) {
) | rpl::then(base::ObservableViewer(
Global::RefConnectionTypeChanged()
)) | rpl::map(connectionType),
st::settingsGeneralButton);
st::settingsButton);
button->addClickHandler([] {
Ui::show(ProxiesBoxController::CreateOwningBox());
});
#endif // TDESKTOP_DISABLE_NETWORK_PROXY
}
void SetupStorageAndConnection(not_null<Ui::VerticalLayout*> container) {
AddSkip(container);
AddButton(
container,
lng_settings_local_storage,
st::settingsGeneralButton
)->addClickHandler([] {
LocalStorageBox::Show(&Auth().data().cache());
});
SetupConnectionType(container);
AddSkip(container);
}
bool HasUpdate() {
return !Core::UpdaterDisabled();
}
@ -115,7 +97,7 @@ void SetupUpdate(not_null<Ui::VerticalLayout*> container) {
object_ptr<Button>(
container,
Lang::Viewer(lng_settings_check_now),
st::settingsGeneralButton)));
st::settingsButton)));
const auto update = Ui::CreateChild<Button>(
check->entity(),
Lang::Viewer(lng_update_telegram) | Info::Profile::ToUpperValue(),
@ -405,17 +387,28 @@ General::General(QWidget *parent, UserData *self)
void General::setupContent() {
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
if (!Core::UpdaterDisabled()) {
auto empty = true;
const auto addDivider = [&] {
if (empty) {
empty = false;
} else {
AddDivider(content);
}
};
if (HasConnectionType()) {
addDivider();
AddSkip(content);
SetupConnectionType(content);
AddSkip(content);
}
if (HasUpdate()) {
addDivider();
AddSkip(content);
SetupUpdate(content);
AddSkip(content);
}
if (!Core::UpdaterDisabled()) {
AddDivider(content);
}
SetupStorageAndConnection(content);
if (HasTray()) {
AddDivider(content);
addDivider();
AddSkip(content);
SetupTray(content);
AddSkip(content);

View File

@ -57,12 +57,13 @@ private:
object_ptr<Ui::RpWidget> CreateIntroSettings(QWidget *parent) {
auto result = object_ptr<Ui::VerticalLayout>(parent);
AddDivider(result);
AddSkip(result);
SetupLanguageButton(result, false);
if (HasConnectionType()) {
AddDivider(result);
AddSkip(result);
SetupConnectionType(result);
AddSkip(result);
}
AddSkip(result);
if (HasUpdate()) {
AddDivider(result);
AddSkip(result);

View File

@ -26,13 +26,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Settings {
void SetupLanguageButton(not_null<Ui::VerticalLayout*> container) {
void SetupLanguageButton(
not_null<Ui::VerticalLayout*> container,
bool icon) {
const auto button = AddButtonWithLabel(
container,
lng_settings_language,
Lang::Viewer(lng_language_name),
st::settingsSectionButton,
&st::settingsIconLanguage);
icon ? st::settingsSectionButton : st::settingsButton,
icon ? &st::settingsIconLanguage : nullptr);
const auto guard = Ui::AttachAsChild(button, base::binary_guard());
button->addClickHandler([=] {
*guard = LanguageBox::Show();
@ -102,7 +104,7 @@ void SetupInterfaceScale(
const auto button = AddButton(
container,
lng_settings_default_scale,
icon ? st::settingsSectionButton : st::settingsGeneralButton,
icon ? st::settingsSectionButton : st::settingsButton,
icon ? &st::settingsIconInterfaceScale : nullptr
)->toggleOn(toggled->events_starting_with_copy(switched));
@ -201,7 +203,7 @@ void SetupFaq(not_null<Ui::VerticalLayout*> container, bool icon) {
AddButton(
container,
lng_settings_faq,
icon ? st::settingsSectionButton : st::settingsGeneralButton,
icon ? st::settingsSectionButton : st::settingsButton,
icon ? &st::settingsIconFaq : nullptr
)->addClickHandler([] {
QDesktopServices::openUrl(telegramFaqLink());

View File

@ -19,6 +19,9 @@ class VerticalLayout;
namespace Settings {
void SetupLanguageButton(
not_null<Ui::VerticalLayout*> container,
bool icon = true);
bool HasInterfaceScale();
void SetupInterfaceScale(
not_null<Ui::VerticalLayout*> container,

View File

@ -30,7 +30,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "auth_session.h"
#include "apiwrap.h"
#include "styles/style_settings.h"
#include "styles/style_boxes.h"
namespace Settings {
namespace {
@ -63,7 +62,7 @@ void SetupPrivacy(not_null<Ui::VerticalLayout*> container) {
AddButton(
container,
lng_settings_blocked_users,
st::settingsPrivacyButton
st::settingsButton
)->addClickHandler([] {
const auto initBox = [](not_null<PeerListBox*> box) {
box->addButton(langFactory(lng_close), [=] {
@ -103,7 +102,7 @@ void SetupPrivacy(not_null<Ui::VerticalLayout*> container) {
container,
label,
PrivacyString(key),
st::settingsPrivacyButton
st::settingsButton
)->addClickHandler([=] {
Ui::show(Box<EditPrivacyBox>(
controller(),
@ -157,7 +156,7 @@ void SetupLocalPasscode(not_null<Ui::VerticalLayout*> container) {
object_ptr<Button>(
container,
std::move(text),
st::settingsPrivacyButton)
st::settingsButton)
)->addClickHandler([] {
Ui::show(Box<PasscodeBox>(false));
});
@ -171,7 +170,7 @@ void SetupLocalPasscode(not_null<Ui::VerticalLayout*> container) {
object_ptr<Button>(
inner,
Lang::Viewer(lng_settings_passcode_disable),
st::settingsPrivacyButton)
st::settingsButton)
)->addClickHandler([] {
Ui::show(Box<PasscodeBox>(true));
});
@ -187,13 +186,12 @@ void SetupLocalPasscode(not_null<Ui::VerticalLayout*> container) {
: lng_passcode_autolock_hours(lt_count, autolock / 3600);
});
const auto autolock = inner->add(
object_ptr<Button>(
inner,
Lang::Viewer(label),
st::settingsPrivacyButton));
CreateRightLabel(autolock, std::move(value), st::settingsPrivacyButton);
autolock->addClickHandler([] {
AddButtonWithLabel(
inner,
label,
std::move(value),
st::settingsButton
)->addClickHandler([] {
Ui::show(Box<AutoLockBox>());
});
@ -309,12 +307,12 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
base::duplicate(confirmation),
st::settingsCloudPasswordLabel),
QMargins(
st::settingsPrivacyButton.padding.left(),
st::settingsPrivacyButton.padding.top(),
st::settingsPrivacyButton.padding.right(),
(st::settingsPrivacyButton.height
st::settingsButton.padding.left(),
st::settingsButton.padding.top(),
st::settingsButton.padding.right(),
(st::settingsButton.height
- st::settingsCloudPasswordLabel.style.font->height
+ st::settingsPrivacyButton.padding.bottom()))));
+ st::settingsButton.padding.bottom()))));
label->toggleOn(base::duplicate(unconfirmed))->setDuration(0);
std::move(
@ -336,7 +334,7 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
object_ptr<Button>(
container,
std::move(text),
st::settingsPrivacyButton)));
st::settingsButton)));
change->toggleOn(std::move(
unconfirmed
) | rpl::map([](bool unconfirmed) {
@ -354,7 +352,7 @@ void SetupCloudPassword(not_null<Ui::VerticalLayout*> container) {
object_ptr<Button>(
container,
Lang::Viewer(lng_settings_password_disable),
st::settingsPrivacyButton)));
st::settingsButton)));
disable->toggleOn(base::duplicate(has));
disable->entity()->addClickHandler([] {
if (CheckEditCloudPassword()) {
@ -385,7 +383,7 @@ void SetupSelfDestruction(not_null<Ui::VerticalLayout*> container) {
AddButton(
container,
lng_settings_self_destruct,
st::settingsPrivacyButton
st::settingsButton
)->addClickHandler([] {
Ui::show(Box<SelfDestructionBox>());
});
@ -401,7 +399,7 @@ void SetupSessionsList(not_null<Ui::VerticalLayout*> container) {
AddButton(
container,
lng_settings_show_sessions,
st::settingsPrivacyButton
st::settingsButton
)->addClickHandler([] {
Ui::show(Box<SessionsBox>());
});
@ -435,7 +433,7 @@ void SetupCalls(not_null<Ui::VerticalLayout*> container) {
container,
lng_settings_peer_to_peer,
std::move(text),
st::settingsPrivacyButton
st::settingsButton
)->addClickHandler([=] {
Ui::show(Box<EditCallsPeerToPeer>());
});
@ -446,24 +444,6 @@ void SetupCalls(not_null<Ui::VerticalLayout*> container) {
Lang::Viewer(lng_settings_peer_to_peer_about));
}
void SetupExport(not_null<Ui::VerticalLayout*> container) {
AddSkip(container);
AddButton(
container,
lng_settings_export_data,
st::settingsPrivacyButton
)->addClickHandler([] {
Ui::hideSettingsAndLayer();
App::CallDelayed(
st::boxDuration,
&Auth(),
[] { Auth().data().startExport(); });
});
AddSkip(container);
}
} // namespace
PrivacySecurity::PrivacySecurity(QWidget *parent, not_null<UserData*> self)
@ -481,7 +461,6 @@ void PrivacySecurity::setupContent() {
SetupSessionsList(content);
SetupSelfDestruction(content);
SetupCalls(content);
SetupExport(content);
Ui::ResizeFitChild(this, content);
}