Add cover to settings main section.

This commit is contained in:
John Preston 2018-09-05 22:39:35 +03:00
parent f0d092f126
commit a7725f03bb
8 changed files with 59 additions and 18 deletions

View File

@ -212,17 +212,17 @@ int SectionWithToggle::toggleSkip() const {
Cover::Cover( Cover::Cover(
QWidget *parent, QWidget *parent,
not_null<Controller*> controller) not_null<PeerData*> peer,
not_null<Window::Controller*> controller)
: SectionWithToggle( : SectionWithToggle(
parent, parent,
st::infoProfilePhotoTop st::infoProfilePhotoTop
+ st::infoProfilePhoto.size.height() + st::infoProfilePhoto.size.height()
+ st::infoProfilePhotoBottom) + st::infoProfilePhotoBottom)
, _controller(controller) , _peer(peer)
, _peer(_controller->key().peer())
, _userpic( , _userpic(
this, this,
controller->parentController(), controller,
_peer, _peer,
Ui::UserpicButton::Role::OpenPhoto, Ui::UserpicButton::Role::OpenPhoto,
st::infoProfilePhoto) st::infoProfilePhoto)
@ -376,9 +376,7 @@ void Cover::refreshStatusText() {
_status->setRichText(statusText); _status->setRichText(statusText);
if (hasMembersLink) { if (hasMembersLink) {
_status->setLink(1, std::make_shared<LambdaClickHandler>([=] { _status->setLink(1, std::make_shared<LambdaClickHandler>([=] {
_controller->showSection(Info::Memento( _showSection.fire(Section::Type::Members);
_controller->peerId(),
Section::Type::Members));
})); }));
} }
refreshStatusGeometry(width()); refreshStatusGeometry(width());

View File

@ -11,6 +11,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/checkbox.h" #include "ui/widgets/checkbox.h"
#include "base/timer.h" #include "base/timer.h"
namespace Window {
class Controller;
} // namespace Window
namespace style { namespace style {
struct InfoToggle; struct InfoToggle;
} // namespace style } // namespace style
@ -24,6 +28,7 @@ class SlideWrap;
namespace Info { namespace Info {
class Controller; class Controller;
class Section;
} // namespace Info } // namespace Info
namespace Info { namespace Info {
@ -52,7 +57,8 @@ class Cover : public SectionWithToggle {
public: public:
Cover( Cover(
QWidget *parent, QWidget *parent,
not_null<Controller*> controller); not_null<PeerData*> peer,
not_null<Window::Controller*> controller);
Cover *setOnlineCount(rpl::producer<int> &&count); Cover *setOnlineCount(rpl::producer<int> &&count);
@ -61,6 +67,10 @@ public:
SectionWithToggle::setToggleShown(std::move(shown))); SectionWithToggle::setToggleShown(std::move(shown)));
} }
rpl::producer<Section> showSection() const {
return _showSection.events();
}
~Cover(); ~Cover();
private: private:
@ -73,7 +83,6 @@ private:
void refreshUploadPhotoOverlay(); void refreshUploadPhotoOverlay();
void setVerified(bool verified); void setVerified(bool verified);
not_null<Controller*> _controller;
not_null<PeerData*> _peer; not_null<PeerData*> _peer;
int _onlineCount = 0; int _onlineCount = 0;
@ -84,6 +93,8 @@ private:
//object_ptr<CoverDropArea> _dropArea = { nullptr }; //object_ptr<CoverDropArea> _dropArea = { nullptr };
base::Timer _refreshStatusTimer; base::Timer _refreshStatusTimer;
rpl::event_stream<Section> _showSection;
}; };
class SharedMediaCover : public SectionWithToggle { class SharedMediaCover : public SectionWithToggle {

View File

@ -77,7 +77,12 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
auto result = object_ptr<Ui::VerticalLayout>(parent); auto result = object_ptr<Ui::VerticalLayout>(parent);
_cover = result->add(object_ptr<Cover>( _cover = result->add(object_ptr<Cover>(
result, result,
_controller)); _peer,
_controller->parentController()));
_cover->showSection(
) | rpl::start_with_next([=](Section section) {
_controller->showSection(Info::Memento(_peer->id, section));
}, _cover->lifetime());
_cover->setOnlineCount(rpl::single(0)); _cover->setOnlineCount(rpl::single(0));
auto details = SetupDetails(_controller, parent, _peer); auto details = SetupDetails(_controller, parent, _peer);
if (canHideDetailsEver()) { if (canHideDetailsEver()) {

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/settings/info_settings_widget.h" #include "info/settings/info_settings_widget.h"
#include "info/info_memento.h" #include "info/info_memento.h"
#include "info/info_controller.h"
#include "settings/settings_common.h" #include "settings/settings_common.h"
namespace Info { namespace Info {
@ -41,8 +42,11 @@ Widget::Widget(
: ContentWidget(parent, controller) : ContentWidget(parent, controller)
, _self(controller->key().settingsSelf()) , _self(controller->key().settingsSelf())
, _type(controller->section().settingsType()) { , _type(controller->section().settingsType()) {
const auto inner = setInnerWidget( const auto inner = setInnerWidget(::Settings::CreateSection(
::Settings::CreateSection(_type, this, _self)); _type,
this,
controller->parentController(),
_self));
inner->sectionShowOther( inner->sectionShowOther(
) | rpl::start_with_next([=](Type type) { ) | rpl::start_with_next([=](Type type) {
this->controller()->showSettings(type); this->controller()->showSettings(type);

View File

@ -19,10 +19,11 @@ namespace Settings {
object_ptr<Section> CreateSection( object_ptr<Section> CreateSection(
Type type, Type type,
not_null<QWidget*> parent, not_null<QWidget*> parent,
not_null<Window::Controller*> controller,
UserData *self) { UserData *self) {
switch (type) { switch (type) {
case Type::Main: case Type::Main:
return object_ptr<::Settings::Main>(parent, self); return object_ptr<::Settings::Main>(parent, controller, self);
case Type::Information: case Type::Information:
return object_ptr<::Settings::Information>(parent, self); return object_ptr<::Settings::Information>(parent, self);
case Type::Notifications: case Type::Notifications:

View File

@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/rp_widget.h" #include "ui/rp_widget.h"
namespace Window {
class Controller;
} // namespace Window
namespace Info { namespace Info {
namespace Profile { namespace Profile {
class Button; class Button;
@ -41,6 +45,7 @@ public:
object_ptr<Section> CreateSection( object_ptr<Section> CreateSection(
Type type, Type type,
not_null<QWidget*> parent, not_null<QWidget*> parent,
not_null<Window::Controller*> controller,
UserData *self = nullptr); UserData *self = nullptr);
} // namespace Settings } // namespace Settings

View File

@ -11,20 +11,30 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/abstract_box.h" #include "boxes/abstract_box.h"
#include "ui/wrap/vertical_layout.h" #include "ui/wrap/vertical_layout.h"
#include "info/profile/info_profile_button.h" #include "info/profile/info_profile_button.h"
#include "info/profile/info_profile_cover.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "styles/style_settings.h" #include "styles/style_settings.h"
namespace Settings { namespace Settings {
Main::Main(QWidget *parent, not_null<UserData*> self) Main::Main(
QWidget *parent,
not_null<Window::Controller*> controller,
not_null<UserData*> self)
: Section(parent) : Section(parent)
, _self(self) { , _self(self) {
setupContent(); setupContent(controller);
} }
void Main::setupContent() { void Main::setupContent(not_null<Window::Controller*> controller) {
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this); const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
const auto cover = content->add(object_ptr<Info::Profile::Cover>(
content,
_self,
controller));
cover->setOnlineCount(rpl::single(0));
content->add(object_ptr<BoxContentDivider>(content)); content->add(object_ptr<BoxContentDivider>(content));
const auto addSection = [&](LangKey label, Type type) { const auto addSection = [&](LangKey label, Type type) {

View File

@ -9,16 +9,23 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_common.h" #include "settings/settings_common.h"
namespace Window {
class Controller;
} // namespace Window
namespace Settings { namespace Settings {
class Main : public Section { class Main : public Section {
public: public:
Main(QWidget *parent, not_null<UserData*> self); Main(
QWidget *parent,
not_null<Window::Controller*> controller,
not_null<UserData*> self);
rpl::producer<Type> sectionShowOther() override; rpl::producer<Type> sectionShowOther() override;
private: private:
void setupContent(); void setupContent(not_null<Window::Controller*> controller);
not_null<UserData*> _self; not_null<UserData*> _self;
rpl::event_stream<Type> _showOther; rpl::event_stream<Type> _showOther;