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

View file

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

View file

@ -77,7 +77,12 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
auto result = object_ptr<Ui::VerticalLayout>(parent);
_cover = result->add(object_ptr<Cover>(
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));
auto details = SetupDetails(_controller, parent, _peer);
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/info_memento.h"
#include "info/info_controller.h"
#include "settings/settings_common.h"
namespace Info {
@ -41,8 +42,11 @@ Widget::Widget(
: ContentWidget(parent, controller)
, _self(controller->key().settingsSelf())
, _type(controller->section().settingsType()) {
const auto inner = setInnerWidget(
::Settings::CreateSection(_type, this, _self));
const auto inner = setInnerWidget(::Settings::CreateSection(
_type,
this,
controller->parentController(),
_self));
inner->sectionShowOther(
) | rpl::start_with_next([=](Type type) {
this->controller()->showSettings(type);

View file

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

View file

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

View file

@ -11,20 +11,30 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/abstract_box.h"
#include "ui/wrap/vertical_layout.h"
#include "info/profile/info_profile_button.h"
#include "info/profile/info_profile_cover.h"
#include "lang/lang_keys.h"
#include "styles/style_settings.h"
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)
, _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 cover = content->add(object_ptr<Info::Profile::Cover>(
content,
_self,
controller));
cover->setOnlineCount(rpl::single(0));
content->add(object_ptr<BoxContentDivider>(content));
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"
namespace Window {
class Controller;
} // namespace Window
namespace Settings {
class Main : public Section {
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;
private:
void setupContent();
void setupContent(not_null<Window::Controller*> controller);
not_null<UserData*> _self;
rpl::event_stream<Type> _showOther;