From f0d092f1267688491fcf297c6aea20b66cd400b3 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 5 Sep 2018 22:05:49 +0300 Subject: [PATCH] Section dummies for new Settings. --- Telegram/SourceFiles/core/update_checker.cpp | 1 + .../SourceFiles/info/info_content_widget.cpp | 18 +++- .../SourceFiles/info/info_content_widget.h | 13 ++- Telegram/SourceFiles/info/info_controller.cpp | 17 +++- Telegram/SourceFiles/info/info_controller.h | 38 +++++++- Telegram/SourceFiles/info/info_memento.cpp | 15 +++ Telegram/SourceFiles/info/info_memento.h | 12 ++- Telegram/SourceFiles/info/info_top_bar.cpp | 16 ++++ .../SourceFiles/info/info_wrap_widget.cpp | 6 ++ .../info/media/info_media_widget.cpp | 2 +- .../info/settings/info_settings_widget.cpp | 91 +++++++++++++++++++ .../info/settings/info_settings_widget.h | 74 +++++++++++++++ Telegram/SourceFiles/mainwindow.cpp | 7 +- Telegram/SourceFiles/settings/settings.style | 12 +++ .../SourceFiles/settings/settings_chat.cpp | 32 +++++++ Telegram/SourceFiles/settings/settings_chat.h | 25 +++++ .../SourceFiles/settings/settings_common.cpp | 40 ++++++++ .../SourceFiles/settings/settings_common.h | 46 ++++++++++ .../SourceFiles/settings/settings_general.cpp | 32 +++++++ .../SourceFiles/settings/settings_general.h | 25 +++++ .../settings/settings_information.cpp | 32 +++++++ .../settings/settings_information.h | 25 +++++ .../SourceFiles/settings/settings_main.cpp | 52 +++++++++++ Telegram/SourceFiles/settings/settings_main.h | 28 ++++++ .../settings/settings_notifications.cpp | 32 +++++++ .../settings/settings_notifications.h | 25 +++++ .../settings/settings_privacy_security.cpp | 32 +++++++ .../settings/settings_privacy_security.h | 25 +++++ Telegram/SourceFiles/ui/rp_widget.cpp | 14 +++ Telegram/SourceFiles/ui/rp_widget.h | 6 ++ .../SourceFiles/window/window_controller.cpp | 22 +++++ .../SourceFiles/window/window_controller.h | 9 ++ Telegram/gyp/Telegram.gyp | 1 + Telegram/gyp/telegram_sources.txt | 16 ++++ 34 files changed, 823 insertions(+), 18 deletions(-) create mode 100644 Telegram/SourceFiles/info/settings/info_settings_widget.cpp create mode 100644 Telegram/SourceFiles/info/settings/info_settings_widget.h create mode 100644 Telegram/SourceFiles/settings/settings.style create mode 100644 Telegram/SourceFiles/settings/settings_chat.cpp create mode 100644 Telegram/SourceFiles/settings/settings_chat.h create mode 100644 Telegram/SourceFiles/settings/settings_common.cpp create mode 100644 Telegram/SourceFiles/settings/settings_common.h create mode 100644 Telegram/SourceFiles/settings/settings_general.cpp create mode 100644 Telegram/SourceFiles/settings/settings_general.h create mode 100644 Telegram/SourceFiles/settings/settings_information.cpp create mode 100644 Telegram/SourceFiles/settings/settings_information.h create mode 100644 Telegram/SourceFiles/settings/settings_main.cpp create mode 100644 Telegram/SourceFiles/settings/settings_main.h create mode 100644 Telegram/SourceFiles/settings/settings_notifications.cpp create mode 100644 Telegram/SourceFiles/settings/settings_notifications.h create mode 100644 Telegram/SourceFiles/settings/settings_privacy_security.cpp create mode 100644 Telegram/SourceFiles/settings/settings_privacy_security.h diff --git a/Telegram/SourceFiles/core/update_checker.cpp b/Telegram/SourceFiles/core/update_checker.cpp index e0a2483c68..c72383f2e6 100644 --- a/Telegram/SourceFiles/core/update_checker.cpp +++ b/Telegram/SourceFiles/core/update_checker.cpp @@ -2127,6 +2127,7 @@ void UpdateApplication() { cSetLastUpdateCheck(0); Core::UpdateChecker().start(); if (const auto window = App::wnd()) { + // #TODO settings auto settings = Box(); const auto weak = make_weak(settings.data()); window->showSpecialLayer(std::move(settings), anim::type::normal); diff --git a/Telegram/SourceFiles/info/info_content_widget.cpp b/Telegram/SourceFiles/info/info_content_widget.cpp index 585543b07c..f0f5d808df 100644 --- a/Telegram/SourceFiles/info/info_content_widget.cpp +++ b/Telegram/SourceFiles/info/info_content_widget.cpp @@ -160,10 +160,6 @@ void ContentWidget::setScrollTopSkip(int scrollTopSkip) { _scrollTopSkip = scrollTopSkip; } -rpl::producer
ContentWidget::sectionRequest() const { - return rpl::never
(); -} - rpl::producer ContentWidget::scrollHeightValue() const { return _scroll->heightValue(); } @@ -253,4 +249,18 @@ void ContentWidget::refreshSearchField(bool shown) { } } +Key ContentMemento::key() const { + if (const auto peerId = this->peerId()) { + return Key(App::peer(peerId)); + } else if (const auto feed = this->feed()) { + return Key(feed); + } else { + return Settings::Tag{ settingsSelf() }; + } +} + +ContentMemento::ContentMemento(Settings::Tag settings) +: _settingsSelf(settings.self.get()) { +} + } // namespace Info diff --git a/Telegram/SourceFiles/info/info_content_widget.h b/Telegram/SourceFiles/info/info_content_widget.h index f0053ca20f..7b97a8b994 100644 --- a/Telegram/SourceFiles/info/info_content_widget.h +++ b/Telegram/SourceFiles/info/info_content_widget.h @@ -28,6 +28,9 @@ class Feed; } // namespace Data namespace Info { +namespace Settings { +struct Tag; +} // namespace Settings class ContentMemento; class Controller; @@ -42,7 +45,6 @@ public: not_null memento) = 0; std::unique_ptr createMemento(); - virtual rpl::producer
sectionRequest() const; virtual void setIsStackBottom(bool isStackBottom) { } @@ -119,9 +121,9 @@ public: : _peerId(peerId) , _migratedPeerId(migratedPeerId) { } - explicit ContentMemento(not_null feed) - : _feed(feed) { + explicit ContentMemento(not_null feed) : _feed(feed) { } + explicit ContentMemento(Settings::Tag settings); virtual object_ptr createWidget( QWidget *parent, @@ -137,6 +139,10 @@ public: Data::Feed *feed() const { return _feed; } + UserData *settingsSelf() const { + return _settingsSelf; + } + Key key() const; virtual Section section() const = 0; @@ -171,6 +177,7 @@ private: const PeerId _peerId = 0; const PeerId _migratedPeerId = 0; Data::Feed * const _feed = nullptr; + UserData * const _settingsSelf = nullptr; int _scrollTop = 0; QString _searchFieldQuery; bool _searchEnabledByContent = false; diff --git a/Telegram/SourceFiles/info/info_controller.cpp b/Telegram/SourceFiles/info/info_controller.cpp index 8c169840ab..4a8835486a 100644 --- a/Telegram/SourceFiles/info/info_controller.cpp +++ b/Telegram/SourceFiles/info/info_controller.cpp @@ -38,6 +38,9 @@ Key::Key(not_null peer) : _value(peer) { Key::Key(not_null feed) : _value(feed) { } +Key::Key(Settings::Tag settings) : _value(settings) { +} + PeerData *Key::peer() const { if (const auto peer = base::get_if>(&_value)) { return *peer; @@ -52,6 +55,13 @@ Data::Feed *Key::feed() const { return nullptr; } +UserData *Key::settingsSelf() const { + if (const auto tag = base::get_if(&_value)) { + return tag->self; + } + return nullptr; +} + rpl::producer AbstractController::mediaSource( SparseIdsMergedSlice::UniversalMsgId aroundId, int limitBefore, @@ -88,9 +98,7 @@ Controller::Controller( not_null memento) : AbstractController(window) , _widget(widget) -, _key(memento->peerId() - ? Key(App::peer(memento->peerId())) - : Key(memento->feed())) +, _key(memento->key()) , _migrated(memento->migratedPeerId() ? App::peer(memento->migratedPeerId()) : nullptr) @@ -135,7 +143,8 @@ bool Controller::validateMementoPeer( not_null memento) const { return memento->peerId() == peerId() && memento->migratedPeerId() == migratedPeerId() - && memento->feed() == feed(); + && memento->feed() == feed() + && memento->settingsSelf() == settingsSelf(); } void Controller::setSection(not_null memento) { diff --git a/Telegram/SourceFiles/info/info_controller.h b/Telegram/SourceFiles/info/info_controller.h index d4ed642ab0..e6094b2b3b 100644 --- a/Telegram/SourceFiles/info/info_controller.h +++ b/Telegram/SourceFiles/info/info_controller.h @@ -10,23 +10,39 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include "data/data_search_controller.h" #include "window/window_controller.h" +#include "settings/settings_common.h" namespace Ui { class SearchFieldController; } // namespace Ui namespace Info { +namespace Settings { + +struct Tag { + explicit Tag(not_null self) : self(self) { + } + + not_null self; +}; + +} // namespace Settings class Key { public: Key(not_null peer); Key(not_null feed); + Key(Settings::Tag settings); PeerData *peer() const; Data::Feed *feed() const; + UserData *settingsSelf() const; private: - base::variant, not_null> _value; + base::variant< + not_null, + not_null, + Settings::Tag> _value; }; @@ -43,28 +59,41 @@ public: CommonGroups, Members, Channels, + Settings, }; + using SettingsType = ::Settings::Type; using MediaType = Storage::SharedMediaType; Section(Type type) : _type(type) { - Expects(type != Type::Media); + Expects(type != Type::Media && type != Type::Settings); } Section(MediaType mediaType) : _type(Type::Media) , _mediaType(mediaType) { } + Section(SettingsType settingsType) + : _type(Type::Settings) + , _settingsType(settingsType) { + } Type type() const { return _type; } MediaType mediaType() const { Expects(_type == Type::Media); + return _mediaType; } + SettingsType settingsType() const { + Expects(_type == Type::Settings); + + return _settingsType; + } private: Type _type; - Storage::SharedMediaType _mediaType; + MediaType _mediaType = MediaType(); + SettingsType _settingsType = SettingsType(); }; @@ -93,6 +122,9 @@ public: Data::Feed *feed() const { return key().feed(); } + UserData *settingsSelf() const { + return key().settingsSelf(); + } virtual void setSearchEnabledByContent(bool enabled) { } diff --git a/Telegram/SourceFiles/info/info_memento.cpp b/Telegram/SourceFiles/info/info_memento.cpp index 57206bf09d..2427fb4478 100644 --- a/Telegram/SourceFiles/info/info_memento.cpp +++ b/Telegram/SourceFiles/info/info_memento.cpp @@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/channels/info_channels_widget.h" #include "info/common_groups/info_common_groups_widget.h" #include "info/feed/info_feed_profile_widget.h" +#include "info/settings/info_settings_widget.h" #include "info/info_section_widget.h" #include "info/info_layer_widget.h" #include "info/info_controller.h" @@ -32,6 +33,10 @@ Memento::Memento(not_null feed, Section section) : Memento(DefaultStack(feed, section)) { } +Memento::Memento(Settings::Tag settings, Section section) +: Memento(DefaultStack(settings, section)) { +} + Memento::Memento(std::vector> stack) : _stack(std::move(stack)) { } @@ -52,6 +57,16 @@ std::vector> Memento::DefaultStack( return result; } +std::vector> Memento::DefaultStack( + Settings::Tag settings, + Section section) { + auto result = std::vector>(); + result.push_back(std::make_unique( + settings.self, + section.settingsType())); + return result; +} + Section Memento::DefaultSection(Dialogs::Key key) { if (const auto peer = key.peer()) { if (peer->isSelf()) { diff --git a/Telegram/SourceFiles/info/info_memento.h b/Telegram/SourceFiles/info/info_memento.h index 29b0c12b37..5dd4849912 100644 --- a/Telegram/SourceFiles/info/info_memento.h +++ b/Telegram/SourceFiles/info/info_memento.h @@ -26,16 +26,20 @@ struct ScrollToRequest; } // namespace Ui namespace Info { +namespace Settings { +struct Tag; +} // namespace Settings class ContentMemento; class WrapWidget; class Memento final : public Window::SectionMemento { public: - Memento(PeerId peerId); + explicit Memento(PeerId peerId); Memento(PeerId peerId, Section section); Memento(not_null feed, Section section); - Memento(std::vector> stack); + Memento(Settings::Tag settings, Section section); + explicit Memento(std::vector> stack); object_ptr createWidget( QWidget *parent, @@ -54,6 +58,7 @@ public: not_null content() { Expects(!_stack.empty()); + return _stack.back().get(); } @@ -69,6 +74,9 @@ private: static std::vector> DefaultStack( not_null feed, Section section); + static std::vector> DefaultStack( + Settings::Tag settings, + Section section); static std::unique_ptr DefaultContent( not_null feed, Section section); diff --git a/Telegram/SourceFiles/info/info_top_bar.cpp b/Telegram/SourceFiles/info/info_top_bar.cpp index cc81e2e1b4..2aa23e5775 100644 --- a/Telegram/SourceFiles/info/info_top_bar.cpp +++ b/Telegram/SourceFiles/info/info_top_bar.cpp @@ -587,6 +587,22 @@ rpl::producer TitleValue( case Section::Type::Channels: return lng_info_feed_channels; + case Section::Type::Settings: + switch (section.settingsType()) { + case Section::SettingsType::Main: + return lng_menu_settings; + case Section::SettingsType::Information: + return lng_settings_section_info; + case Section::SettingsType::Notifications: + return lng_settings_section_notify; + case Section::SettingsType::PrivacySecurity: + return lng_settings_section_privacy; + case Section::SettingsType::General: + return lng_settings_section_general; + case Section::SettingsType::Chat: + return lng_settings_section_chat_settings; + } + Unexpected("Bad settings type in Info::TitleValue()"); } Unexpected("Bad section type in Info::TitleValue()"); }()); diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index 51a05ba052..424d9f256f 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -200,6 +200,8 @@ Dialogs::RowDescriptor WrapWidget::activeChat() const { return Dialogs::RowDescriptor(App::history(peer), FullMsgId()); } else if (const auto feed = key().feed()) { return Dialogs::RowDescriptor(feed, FullMsgId()); + } else if (key().settingsSelf()) { + return Dialogs::RowDescriptor(); } Unexpected("Owner in WrapWidget::activeChat()."); } @@ -512,6 +514,10 @@ void WrapWidget::showProfileMenu() { feed, addAction, Window::PeerMenuSource::Profile); + } else if (const auto self = key().settingsSelf()) { + // #TODO settings top menu + _topBarMenu = nullptr; + return; } else { _topBarMenu = nullptr; return; diff --git a/Telegram/SourceFiles/info/media/info_media_widget.cpp b/Telegram/SourceFiles/info/media/info_media_widget.cpp index 2d4d9674e5..bcfb88399c 100644 --- a/Telegram/SourceFiles/info/media/info_media_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_widget.cpp @@ -97,7 +97,7 @@ bool Widget::showInternal(not_null memento) { if (!controller()->validateMementoPeer(memento)) { return false; } - if (auto mediaMemento = dynamic_cast(memento.get())) { + if (const auto mediaMemento = dynamic_cast(memento.get())) { if (_inner->showInternal(mediaMemento)) { return true; } diff --git a/Telegram/SourceFiles/info/settings/info_settings_widget.cpp b/Telegram/SourceFiles/info/settings/info_settings_widget.cpp new file mode 100644 index 0000000000..022d4e8103 --- /dev/null +++ b/Telegram/SourceFiles/info/settings/info_settings_widget.cpp @@ -0,0 +1,91 @@ +/* +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 +*/ +#include "info/settings/info_settings_widget.h" + +#include "info/info_memento.h" +#include "settings/settings_common.h" + +namespace Info { +namespace Settings { + +Memento::Memento(not_null self, Type type) +: ContentMemento(Tag{ self }) +, _type(type) { +} + +Section Memento::section() const { + return Section(_type); +} + +object_ptr Memento::createWidget( + QWidget *parent, + not_null controller, + const QRect &geometry) { + auto result = object_ptr( + parent, + controller); + result->setInternalState(geometry, this); + return std::move(result); +} + +Memento::~Memento() = default; + +Widget::Widget( + QWidget *parent, + not_null controller) +: ContentWidget(parent, controller) +, _self(controller->key().settingsSelf()) +, _type(controller->section().settingsType()) { + const auto inner = setInnerWidget( + ::Settings::CreateSection(_type, this, _self)); + inner->sectionShowOther( + ) | rpl::start_with_next([=](Type type) { + this->controller()->showSettings(type); + }, inner->lifetime()); +} + +not_null Widget::self() const { + return _self; +} + +bool Widget::showInternal(not_null memento) { + //if (const auto myMemento = dynamic_cast(memento.get())) { + // Assert(myMemento->self() == self()); + + // if (_inner->showInternal(myMemento)) { + // return true; + // } + //} + return false; +} + +void Widget::setInternalState( + const QRect &geometry, + not_null memento) { + setGeometry(geometry); + Ui::SendPendingMoveResizeEvents(this); + restoreState(memento); +} + +std::unique_ptr Widget::doCreateMemento() { + auto result = std::make_unique(self(), _type); + saveState(result.get()); + return std::move(result); +} + +void Widget::saveState(not_null memento) { + memento->setScrollTop(scrollTopSave()); +} + +void Widget::restoreState(not_null memento) { + const auto scrollTop = memento->scrollTop(); + scrollTopRestore(memento->scrollTop()); +} + +} // namespace Settings +} // namespace Info diff --git a/Telegram/SourceFiles/info/settings/info_settings_widget.h b/Telegram/SourceFiles/info/settings/info_settings_widget.h new file mode 100644 index 0000000000..e4eaba05c1 --- /dev/null +++ b/Telegram/SourceFiles/info/settings/info_settings_widget.h @@ -0,0 +1,74 @@ +/* +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 +*/ +#pragma once + +#include "info/info_content_widget.h" +#include "info/info_controller.h" + +namespace Info { +namespace Settings { + +using Type = Section::SettingsType; + +struct Tag; +class InnerWidget; + +class Memento final : public ContentMemento { +public: + Memento(not_null self, Type type); + + object_ptr createWidget( + QWidget *parent, + not_null controller, + const QRect &geometry) override; + + Section section() const override; + + Type type() const { + return _type; + } + + not_null self() const { + return settingsSelf(); + } + + ~Memento(); + +private: + Type _type = Type(); + +}; + +class Widget final : public ContentWidget { +public: + Widget( + QWidget *parent, + not_null controller); + + not_null self() const; + + bool showInternal( + not_null memento) override; + + void setInternalState( + const QRect &geometry, + not_null memento); + +private: + void saveState(not_null memento); + void restoreState(not_null memento); + + std::unique_ptr doCreateMemento() override; + + not_null _self; + Type _type = Type(); + +}; + +} // namespace Settings +} // namespace Info diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 213e359de6..5196dc042f 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -302,7 +302,12 @@ void MainWindow::setupMain(const MTPUser *self) { void MainWindow::showSettings() { if (isHidden()) showFromTray(); - controller()->showSpecialLayer(Box()); + if (const auto controller = this->controller()) { + controller->showSettings(); + } else { + // #TODO settings + showSpecialLayer(Box(), anim::type::normal); + } } void MainWindow::showSpecialLayer( diff --git a/Telegram/SourceFiles/settings/settings.style b/Telegram/SourceFiles/settings/settings.style new file mode 100644 index 0000000000..1ad80c9cf3 --- /dev/null +++ b/Telegram/SourceFiles/settings/settings.style @@ -0,0 +1,12 @@ +/* +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 +*/ +using "basic.style"; +using "ui/widgets/widgets.style"; +using "info/info.style"; + +settingsSectionButton: infoProfileButton; diff --git a/Telegram/SourceFiles/settings/settings_chat.cpp b/Telegram/SourceFiles/settings/settings_chat.cpp new file mode 100644 index 0000000000..8eddbff240 --- /dev/null +++ b/Telegram/SourceFiles/settings/settings_chat.cpp @@ -0,0 +1,32 @@ +/* +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 +*/ +#include "settings/settings_chat.h" + +#include "settings/settings_common.h" +#include "boxes/abstract_box.h" +#include "ui/wrap/vertical_layout.h" +#include "lang/lang_keys.h" +#include "styles/style_settings.h" + +namespace Settings { + +Chat::Chat(QWidget *parent, not_null self) +: Section(parent) +, _self(self) { + setupContent(); +} + +void Chat::setupContent() { + const auto content = Ui::CreateChild(this); + + content->add(object_ptr(content)); + + Ui::ResizeFitChild(this, content); +} + +} // namespace Settings diff --git a/Telegram/SourceFiles/settings/settings_chat.h b/Telegram/SourceFiles/settings/settings_chat.h new file mode 100644 index 0000000000..ec1f577f33 --- /dev/null +++ b/Telegram/SourceFiles/settings/settings_chat.h @@ -0,0 +1,25 @@ +/* +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 +*/ +#pragma once + +#include "settings/settings_common.h" + +namespace Settings { + +class Chat : public Section { +public: + Chat(QWidget *parent, not_null self); + +private: + void setupContent(); + + not_null _self; + +}; + +} // namespace Settings diff --git a/Telegram/SourceFiles/settings/settings_common.cpp b/Telegram/SourceFiles/settings/settings_common.cpp new file mode 100644 index 0000000000..17fe2b1289 --- /dev/null +++ b/Telegram/SourceFiles/settings/settings_common.cpp @@ -0,0 +1,40 @@ +/* +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 +*/ +#include "settings/settings_common.h" + +#include "settings/settings_chat.h" +#include "settings/settings_general.h" +#include "settings/settings_information.h" +#include "settings/settings_main.h" +#include "settings/settings_notifications.h" +#include "settings/settings_privacy_security.h" + +namespace Settings { + +object_ptr
CreateSection( + Type type, + not_null parent, + UserData *self) { + switch (type) { + case Type::Main: + return object_ptr<::Settings::Main>(parent, self); + case Type::Information: + return object_ptr<::Settings::Information>(parent, self); + case Type::Notifications: + return object_ptr<::Settings::Notifications>(parent, self); + case Type::PrivacySecurity: + return object_ptr<::Settings::PrivacySecurity>(parent, self); + case Type::General: + return object_ptr<::Settings::General>(parent, self); + case Type::Chat: + return object_ptr<::Settings::Chat>(parent, self); + } + Unexpected("Settings section type in Widget::createInnerWidget."); +} + +} // namespace Settings diff --git a/Telegram/SourceFiles/settings/settings_common.h b/Telegram/SourceFiles/settings/settings_common.h new file mode 100644 index 0000000000..bdaa21ff2a --- /dev/null +++ b/Telegram/SourceFiles/settings/settings_common.h @@ -0,0 +1,46 @@ +/* +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 +*/ +#pragma once + +#include "ui/rp_widget.h" + +namespace Info { +namespace Profile { +class Button; +} // namespace Profile +} // namespace Info + +namespace Settings { + +enum class Type { + Main, + Information, + Notifications, + PrivacySecurity, + General, + Chat, +}; + +using Button = Info::Profile::Button; + +class Section : public Ui::RpWidget { +public: + using RpWidget::RpWidget; + + virtual rpl::producer sectionShowOther() { + return rpl::never(); + } + +}; + +object_ptr
CreateSection( + Type type, + not_null parent, + UserData *self = nullptr); + +} // namespace Settings diff --git a/Telegram/SourceFiles/settings/settings_general.cpp b/Telegram/SourceFiles/settings/settings_general.cpp new file mode 100644 index 0000000000..8244ee5dd0 --- /dev/null +++ b/Telegram/SourceFiles/settings/settings_general.cpp @@ -0,0 +1,32 @@ +/* +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 +*/ +#include "settings/settings_general.h" + +#include "settings/settings_common.h" +#include "boxes/abstract_box.h" +#include "ui/wrap/vertical_layout.h" +#include "lang/lang_keys.h" +#include "styles/style_settings.h" + +namespace Settings { + +General::General(QWidget *parent, UserData *self) +: Section(parent) +, _self(self) { + setupContent(); +} + +void General::setupContent() { + const auto content = Ui::CreateChild(this); + + content->add(object_ptr(content)); + + Ui::ResizeFitChild(this, content); +} + +} // namespace Settings diff --git a/Telegram/SourceFiles/settings/settings_general.h b/Telegram/SourceFiles/settings/settings_general.h new file mode 100644 index 0000000000..3eacd95d28 --- /dev/null +++ b/Telegram/SourceFiles/settings/settings_general.h @@ -0,0 +1,25 @@ +/* +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 +*/ +#pragma once + +#include "settings/settings_common.h" + +namespace Settings { + +class General : public Section { +public: + explicit General(QWidget *parent, UserData *self = nullptr); + +private: + void setupContent(); + + UserData *_self = nullptr; + +}; + +} // namespace Settings diff --git a/Telegram/SourceFiles/settings/settings_information.cpp b/Telegram/SourceFiles/settings/settings_information.cpp new file mode 100644 index 0000000000..341314deda --- /dev/null +++ b/Telegram/SourceFiles/settings/settings_information.cpp @@ -0,0 +1,32 @@ +/* +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 +*/ +#include "settings/settings_information.h" + +#include "settings/settings_common.h" +#include "boxes/abstract_box.h" +#include "ui/wrap/vertical_layout.h" +#include "lang/lang_keys.h" +#include "styles/style_settings.h" + +namespace Settings { + +Information::Information(QWidget *parent, not_null self) +: Section(parent) +, _self(self) { + setupContent(); +} + +void Information::setupContent() { + const auto content = Ui::CreateChild(this); + + content->add(object_ptr(content)); + + Ui::ResizeFitChild(this, content); +} + +} // namespace Settings diff --git a/Telegram/SourceFiles/settings/settings_information.h b/Telegram/SourceFiles/settings/settings_information.h new file mode 100644 index 0000000000..c5150e2ee8 --- /dev/null +++ b/Telegram/SourceFiles/settings/settings_information.h @@ -0,0 +1,25 @@ +/* +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 +*/ +#pragma once + +#include "settings/settings_common.h" + +namespace Settings { + +class Information : public Section { +public: + Information(QWidget *parent, not_null self); + +private: + void setupContent(); + + not_null _self; + +}; + +} // namespace Settings diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp new file mode 100644 index 0000000000..80f817f8cb --- /dev/null +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -0,0 +1,52 @@ +/* +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 +*/ +#include "settings/settings_main.h" + +#include "settings/settings_common.h" +#include "boxes/abstract_box.h" +#include "ui/wrap/vertical_layout.h" +#include "info/profile/info_profile_button.h" +#include "lang/lang_keys.h" +#include "styles/style_settings.h" + +namespace Settings { + +Main::Main(QWidget *parent, not_null self) +: Section(parent) +, _self(self) { + setupContent(); +} + +void Main::setupContent() { + const auto content = Ui::CreateChild(this); + + content->add(object_ptr(content)); + + const auto addSection = [&](LangKey label, Type type) { + content->add(object_ptr