2016-08-17 15:14:08 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2016-08-17 15:14:08 +00:00
|
|
|
*/
|
|
|
|
#include "settings/settings_inner_widget.h"
|
|
|
|
|
2017-04-18 17:37:14 +00:00
|
|
|
#include "lang/lang_instance.h"
|
2016-08-19 17:26:31 +00:00
|
|
|
#include "styles/style_settings.h"
|
|
|
|
#include "settings/settings_cover.h"
|
|
|
|
#include "settings/settings_block_widget.h"
|
|
|
|
#include "settings/settings_info_widget.h"
|
|
|
|
#include "settings/settings_notifications_widget.h"
|
|
|
|
#include "settings/settings_general_widget.h"
|
|
|
|
#include "settings/settings_chat_settings_widget.h"
|
|
|
|
#include "settings/settings_scale_widget.h"
|
|
|
|
#include "settings/settings_background_widget.h"
|
|
|
|
#include "settings/settings_privacy_widget.h"
|
|
|
|
#include "settings/settings_advanced_widget.h"
|
|
|
|
|
2016-08-17 15:14:08 +00:00
|
|
|
namespace Settings {
|
|
|
|
|
2017-02-03 20:07:26 +00:00
|
|
|
InnerWidget::InnerWidget(QWidget *parent) : LayerInner(parent)
|
2017-09-18 17:04:45 +00:00
|
|
|
, _blocks(this)
|
|
|
|
, _self(App::self()) {
|
2016-08-19 17:26:31 +00:00
|
|
|
refreshBlocks();
|
2017-04-18 17:37:14 +00:00
|
|
|
subscribe(Global::RefSelfChanged(), [this] { fullRebuild(); });
|
|
|
|
subscribe(Lang::Current().updated(), [this] { fullRebuild(); });
|
2016-08-27 04:49:18 +00:00
|
|
|
}
|
|
|
|
|
2017-04-18 17:37:14 +00:00
|
|
|
void InnerWidget::fullRebuild() {
|
2016-08-27 04:49:18 +00:00
|
|
|
_self = App::self();
|
|
|
|
refreshBlocks();
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InnerWidget::refreshBlocks() {
|
2016-11-18 13:34:58 +00:00
|
|
|
if (App::quitting()) {
|
2017-09-13 16:57:44 +00:00
|
|
|
_cover.destroy();
|
|
|
|
_blocks.destroy();
|
2016-11-18 13:34:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-09-13 16:57:44 +00:00
|
|
|
_cover = _self
|
|
|
|
? object_ptr<CoverWidget>(this, _self)
|
|
|
|
: nullptr;
|
|
|
|
_blocks = object_ptr<Ui::VerticalLayout>(this);
|
|
|
|
resizeToWidth(width(), _contentLeft);
|
|
|
|
|
2016-08-19 17:26:31 +00:00
|
|
|
if (_self) {
|
2017-09-13 16:57:44 +00:00
|
|
|
_blocks->add(object_ptr<InfoWidget>(this, _self));
|
|
|
|
_blocks->add(object_ptr<NotificationsWidget>(this, _self));
|
2016-08-28 20:23:32 +00:00
|
|
|
}
|
2017-09-13 16:57:44 +00:00
|
|
|
_blocks->add(object_ptr<GeneralWidget>(this, _self));
|
2016-08-28 20:23:32 +00:00
|
|
|
if (!cRetina()) {
|
2017-09-13 16:57:44 +00:00
|
|
|
_blocks->add(object_ptr<ScaleWidget>(this, _self));
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
if (_self) {
|
2017-09-13 16:57:44 +00:00
|
|
|
_blocks->add(object_ptr<ChatSettingsWidget>(this, _self));
|
|
|
|
_blocks->add(object_ptr<BackgroundWidget>(this, _self));
|
|
|
|
_blocks->add(object_ptr<PrivacyWidget>(this, _self));
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
2017-09-13 16:57:44 +00:00
|
|
|
_blocks->add(object_ptr<AdvancedWidget>(this, _self));
|
2016-08-27 04:49:18 +00:00
|
|
|
|
|
|
|
if (_cover) {
|
|
|
|
_cover->show();
|
|
|
|
}
|
2017-09-13 16:57:44 +00:00
|
|
|
_blocks->show();
|
2017-12-22 07:05:20 +00:00
|
|
|
_blocks->heightValue(
|
|
|
|
) | rpl::start_with_next([this](int blocksHeight) {
|
|
|
|
resize(width(), _blocks->y() + blocksHeight);
|
|
|
|
}, lifetime());
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
|
2016-08-22 17:16:21 +00:00
|
|
|
int InnerWidget::resizeGetHeight(int newWidth) {
|
2016-08-19 17:26:31 +00:00
|
|
|
if (_cover) {
|
2016-08-22 17:16:21 +00:00
|
|
|
_cover->setContentLeft(_contentLeft);
|
2016-08-19 17:26:31 +00:00
|
|
|
_cover->resizeToWidth(newWidth);
|
|
|
|
}
|
2017-09-13 16:57:44 +00:00
|
|
|
_blocks->resizeToWidth(newWidth - 2 * _contentLeft);
|
|
|
|
_blocks->moveToLeft(
|
|
|
|
_contentLeft,
|
|
|
|
(_cover ? (_cover->y() + _cover->height()) : 0)
|
|
|
|
+ st::settingsBlocksTop);
|
|
|
|
return height();
|
2016-08-22 17:16:21 +00:00
|
|
|
}
|
|
|
|
|
2017-09-13 16:57:44 +00:00
|
|
|
void InnerWidget::visibleTopBottomUpdated(
|
|
|
|
int visibleTop,
|
|
|
|
int visibleBottom) {
|
|
|
|
setChildVisibleTopBottom(
|
|
|
|
_cover,
|
|
|
|
visibleTop,
|
|
|
|
visibleBottom);
|
|
|
|
setChildVisibleTopBottom(
|
|
|
|
_blocks,
|
|
|
|
visibleTop,
|
|
|
|
visibleBottom);
|
2016-08-17 15:14:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Settings
|