Use default color theme link in non-authed Advanced settings section.

This commit is contained in:
John Preston 2016-12-21 11:38:36 +03:00
parent 177078b0af
commit b030824ef5
5 changed files with 48 additions and 14 deletions

View File

@ -574,6 +574,8 @@ void MainWindow::themeUpdated(const Window::Theme::BackgroundUpdate &data) {
_testingThemeWarning->showAnimated();
} else if (data.type == Type::RevertingTheme || data.type == Type::ApplyingTheme) {
_testingThemeWarning->hideAnimated();
_testingThemeWarning = nullptr;
setInnerFocus();
}
}

View File

@ -29,6 +29,9 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "boxes/localstoragebox.h"
#include "mainwindow.h"
#include "ui/widgets/buttons.h"
#include "ui/effects/widget_slide_wrap.h"
#include "localstorage.h"
#include "window/window_theme.h"
namespace Settings {
@ -39,6 +42,13 @@ AdvancedWidget::AdvancedWidget(QWidget *parent, UserData *self) : BlockWidget(pa
connectionTypeUpdated();
});
#endif // !TDESKTOP_DISABLE_NETWORK_PROXY
if (!self) {
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) {
if (update.type == Window::Theme::BackgroundUpdate::Type::ApplyingTheme) {
checkNonDefaultTheme();
}
});
}
}
void AdvancedWidget::createControls() {
@ -63,6 +73,12 @@ void AdvancedWidget::createControls() {
if (self()) {
addChildRow(_askQuestion, marginSmall, lang(lng_settings_ask_question), SLOT(onAskQuestion()));
} else {
style::margins slidedPadding(0, marginLarge.bottom() / 2, 0, marginLarge.bottom() - (marginLarge.bottom() / 2));
addChildRow(_useDefaultTheme, marginLarge, slidedPadding, lang(lng_settings_bg_use_default), SLOT(onUseDefaultTheme()));
if (!Local::hasTheme()) {
_useDefaultTheme->hideFast();
}
}
addChildRow(_telegramFAQ, marginLarge, lang(lng_settings_faq), SLOT(onTelegramFAQ()));
if (self()) {
@ -71,6 +87,15 @@ void AdvancedWidget::createControls() {
}
}
void AdvancedWidget::checkNonDefaultTheme() {
if (self()) return;
if (Local::hasTheme()) {
_useDefaultTheme->slideDown();
} else {
_useDefaultTheme->slideUp();
}
}
void AdvancedWidget::onManageLocalStorage() {
Ui::show(Box<LocalStorageBox>());
}
@ -100,6 +125,10 @@ void AdvancedWidget::onConnectionType() {
}
#endif // !TDESKTOP_DISABLE_NETWORK_PROXY
void AdvancedWidget::onUseDefaultTheme() {
Window::Theme::ApplyDefault();
}
void AdvancedWidget::onAskQuestion() {
auto box = Box<ConfirmBox>(lang(lng_settings_ask_sure), lang(lng_settings_ask_ok), lang(lng_settings_faq_button), base::lambda_guarded(this, [this] {
onAskQuestionSure();

View File

@ -38,11 +38,13 @@ private slots:
#endif // !TDESKTOP_DISABLE_NETWORK_PROXY
void onAskQuestion();
void onAskQuestionSure();
void onUseDefaultTheme();
void onTelegramFAQ();
void onLogOut();
private:
void createControls();
void checkNonDefaultTheme();
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
void connectionTypeUpdated();
#endif // !TDESKTOP_DISABLE_NETWORK_PROXY
@ -52,6 +54,7 @@ private:
#ifndef TDESKTOP_DISABLE_NETWORK_PROXY
object_ptr<LabeledLink> _connectionType = { nullptr };
#endif // !TDESKTOP_DISABLE_NETWORK_PROXY
object_ptr<Ui::WidgetSlideWrap<Ui::LinkButton>> _useDefaultTheme = { nullptr };
object_ptr<Ui::LinkButton> _askQuestion = { nullptr };
object_ptr<Ui::LinkButton> _telegramFAQ = { nullptr };
object_ptr<Ui::LinkButton> _logOut = { nullptr };

View File

@ -52,14 +52,14 @@ BackgroundRow::BackgroundRow(QWidget *parent) : TWidget(parent)
void BackgroundRow::checkNonDefaultTheme() {
if (Local::hasTheme()) {
if (!_useDefault) {
_useDefault.create(this, lang(lng_settings_bg_use_default), st::boxLinkButton);
_useDefault->show();
connect(_useDefault, SIGNAL(clicked()), this, SIGNAL(useDefault()));
if (!_useDefaultTheme) {
_useDefaultTheme.create(this, lang(lng_settings_bg_use_default), st::boxLinkButton);
_useDefaultTheme->show();
connect(_useDefaultTheme, SIGNAL(clicked()), this, SIGNAL(useDefault()));
resizeToWidth(width());
}
} else if (_useDefault) {
_useDefault.destroy();
} else if (_useDefaultTheme) {
_useDefaultTheme.destroy();
resizeToWidth(width());
}
}
@ -108,10 +108,10 @@ int BackgroundRow::resizeGetHeight(int newWidth) {
auto linkWidth = newWidth - linkLeft;
_chooseFromGallery->resizeToWidth(qMin(linkWidth, _chooseFromGallery->naturalWidth()));
_chooseFromFile->resizeToWidth(qMin(linkWidth, _chooseFromFile->naturalWidth()));
if (_useDefault) {
_useDefault->resizeToWidth(qMin(linkWidth, _useDefault->naturalWidth()));
_useDefault->moveToLeft(linkLeft, linkTop, newWidth);
linkTop += _useDefault->height() + st::settingsSmallSkip;
if (_useDefaultTheme) {
_useDefaultTheme->resizeToWidth(qMin(linkWidth, _useDefaultTheme->naturalWidth()));
_useDefaultTheme->moveToLeft(linkLeft, linkTop, newWidth);
linkTop += _useDefaultTheme->height() + st::settingsSmallSkip;
}
_chooseFromGallery->moveToLeft(linkLeft, linkTop, newWidth);
linkTop += _chooseFromGallery->height() + st::settingsSmallSkip;
@ -220,7 +220,7 @@ void BackgroundWidget::createControls() {
addChildRow(_background, margin);
connect(_background, SIGNAL(chooseFromGallery()), this, SLOT(onChooseFromGallery()));
connect(_background, SIGNAL(chooseFromFile()), this, SLOT(onChooseFromFile()));
connect(_background, SIGNAL(useDefault()), this, SLOT(onUseDefault()));
connect(_background, SIGNAL(useDefault()), this, SLOT(onUseDefaultTheme()));
addChildRow(_tile, margin, lang(lng_settings_bg_tile), SLOT(onTile()), Window::Theme::Background()->tile());
addChildRow(_adaptive, margin, slidedPadding, lang(lng_settings_adaptive_wide), SLOT(onAdaptive()), Global::AdaptiveForWide());
@ -246,7 +246,7 @@ void BackgroundWidget::onChooseFromFile() {
_chooseFromFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filters.join(qsl(";;")));
}
void BackgroundWidget::onUseDefault() {
void BackgroundWidget::onUseDefaultTheme() {
Window::Theme::ApplyDefault();
}

View File

@ -55,7 +55,7 @@ private:
void step_radial(TimeMs ms, bool timer);
QPixmap _background;
object_ptr<Ui::LinkButton> _useDefault = { nullptr };
object_ptr<Ui::LinkButton> _useDefaultTheme = { nullptr };
object_ptr<Ui::LinkButton> _chooseFromGallery;
object_ptr<Ui::LinkButton> _chooseFromFile;
@ -72,7 +72,7 @@ public:
private slots:
void onChooseFromGallery();
void onChooseFromFile();
void onUseDefault();
void onUseDefaultTheme();
void onTile();
void onAdaptive();