Replace Profile::UserpicButton with one from Ui::

This commit is contained in:
John Preston 2017-11-13 19:50:10 +04:00
parent 830c6a4894
commit 8dd3f24285
15 changed files with 67 additions and 68 deletions

View File

@ -251,7 +251,10 @@ infoTabs: SettingsSlider(defaultTabsSlider) {
labelTop: 19px; labelTop: 19px;
} }
infoProfilePhotoSize: 72px; infoProfilePhoto: UserpicButton(defaultUserpicButton) {
size: size(72px, 72px);
photoSize: 72px;
}
infoProfilePhotoLeft: 19px; infoProfilePhotoLeft: 19px;
infoProfilePhotoTop: 18px; infoProfilePhotoTop: 18px;
infoProfilePhotoBottom: 18px; infoProfilePhotoBottom: 18px;

View File

@ -24,15 +24,16 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include <rpl/combine.h> #include <rpl/combine.h>
#include "data/data_photo.h" #include "data/data_photo.h"
#include "info/profile/info_profile_values.h" #include "info/profile/info_profile_values.h"
#include "info/info_controller.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "styles/style_info.h" #include "styles/style_info.h"
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
#include "ui/effects/ripple_animation.h" #include "ui/effects/ripple_animation.h"
#include "ui/special_buttons.h"
#include "observer_peer.h" #include "observer_peer.h"
#include "messenger.h" #include "messenger.h"
#include "auth_session.h" #include "auth_session.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "profile/profile_userpic_button.h"
namespace Info { namespace Info {
namespace Profile { namespace Profile {
@ -218,14 +219,22 @@ int SectionWithToggle::toggleSkip() const {
+ _toggle->checkRect().width(); + _toggle->checkRect().width();
} }
Cover::Cover(QWidget *parent, not_null<PeerData*> peer) Cover::Cover(
QWidget *parent,
not_null<Controller*> controller,
not_null<PeerData*> peer)
: SectionWithToggle( : SectionWithToggle(
parent, parent,
st::infoProfilePhotoTop st::infoProfilePhotoTop
+ st::infoProfilePhotoSize + st::infoProfilePhoto.size.height()
+ st::infoProfilePhotoBottom) + st::infoProfilePhotoBottom)
, _peer(peer) , _peer(peer)
, _userpic(this, _peer, st::infoProfilePhotoSize) , _userpic(
this,
controller->window(),
_peer,
Ui::UserpicButton::Role::OpenPhoto,
st::infoProfilePhoto)
, _name(this, st::infoProfileNameLabel) , _name(this, st::infoProfileNameLabel)
, _status(this, st::infoProfileStatusLabel) { , _status(this, st::infoProfileStatusLabel) {
_peer->updateFull(); _peer->updateFull();

View File

@ -27,16 +27,17 @@ namespace style {
struct InfoToggle; struct InfoToggle;
} // namespace style } // namespace style
namespace Profile {
class UserpicButton;
} // namespace Profile
namespace Ui { namespace Ui {
class UserpicButton;
class FlatLabel; class FlatLabel;
template <typename Widget> template <typename Widget>
class SlideWrap; class SlideWrap;
} // namespace Ui } // namespace Ui
namespace Info {
class Controller;
} // namespace Info
namespace Info { namespace Info {
namespace Profile { namespace Profile {
@ -61,7 +62,10 @@ private:
class Cover : public SectionWithToggle { class Cover : public SectionWithToggle {
public: public:
Cover(QWidget *parent, not_null<PeerData*> peer); Cover(
QWidget *parent,
not_null<Controller*> controller,
not_null<PeerData*> peer);
Cover *setOnlineCount(rpl::producer<int> &&count); Cover *setOnlineCount(rpl::producer<int> &&count);
@ -86,7 +90,7 @@ private:
not_null<PeerData*> _peer; not_null<PeerData*> _peer;
int _onlineCount = 0; int _onlineCount = 0;
object_ptr<::Profile::UserpicButton> _userpic; object_ptr<Ui::UserpicButton> _userpic;
object_ptr<Ui::FlatLabel> _name = { nullptr }; object_ptr<Ui::FlatLabel> _name = { nullptr };
object_ptr<Ui::RpWidget> _verifiedCheck = { nullptr }; object_ptr<Ui::RpWidget> _verifiedCheck = { nullptr };
object_ptr<Ui::FlatLabel> _status = { nullptr }; object_ptr<Ui::FlatLabel> _status = { nullptr };

View File

@ -89,6 +89,7 @@ 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)); _peer));
_cover->setOnlineCount(rpl::single(0)); _cover->setOnlineCount(rpl::single(0));
auto details = SetupDetails(_controller, parent, _peer); auto details = SetupDetails(_controller, parent, _peer);

View File

@ -42,7 +42,10 @@ settingsFixedBarClose: IconButton(boxTitleClose) {
} }
settingsMarginTop: 34px; settingsMarginTop: 34px;
settingsPhotoSize: 112px; settingsPhoto: UserpicButton(defaultUserpicButton) {
size: size(112px, 112px);
photoSize: 112px;
}
settingsPhotoLeft: -8px; settingsPhotoLeft: -8px;
settingsPhotoDuration: 500; settingsPhotoDuration: 500;
settingsNameLeft: 26px; settingsNameLeft: 26px;

View File

@ -23,13 +23,13 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "data/data_photo.h" #include "data/data_photo.h"
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/special_buttons.h"
#include "observer_peer.h" #include "observer_peer.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "messenger.h" #include "messenger.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "auth_session.h" #include "auth_session.h"
#include "profile/profile_userpic_button.h"
#include "profile/profile_cover_drop_area.h" #include "profile/profile_cover_drop_area.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "boxes/photo_crop_box.h" #include "boxes/photo_crop_box.h"
@ -40,9 +40,15 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
namespace Settings { namespace Settings {
CoverWidget::CoverWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, QString()) CoverWidget::CoverWidget(QWidget *parent, UserData *self)
: BlockWidget(parent, self, QString())
, _self(App::self()) , _self(App::self())
, _userpicButton(this, _self) , _userpicButton(
this,
App::wnd()->controller(),
_self,
Ui::UserpicButton::Role::OpenPhoto,
st::settingsPhoto)
, _name(this, st::settingsNameLabel) , _name(this, st::settingsNameLabel)
, _editNameInline(this, st::settingsEditButton) , _editNameInline(this, st::settingsEditButton)
, _setPhoto(this, langFactory(lng_settings_upload), st::settingsPrimaryButton) , _setPhoto(this, langFactory(lng_settings_upload), st::settingsPrimaryButton)
@ -123,7 +129,7 @@ int CoverWidget::resizeGetHeight(int newWidth) {
refreshButtonsGeometry(newWidth); refreshButtonsGeometry(newWidth);
refreshNameGeometry(newWidth); refreshNameGeometry(newWidth);
newHeight += st::settingsPhotoSize; newHeight += st::settingsPhoto.size.height();
newHeight += st::settingsMarginBottom; newHeight += st::settingsMarginBottom;
_dividerTop = newHeight; _dividerTop = newHeight;
@ -175,10 +181,6 @@ void CoverWidget::refreshNameGeometry(int newWidth) {
_editNameInline->setVisible(editNameInlineVisible); _editNameInline->setVisible(editNameInlineVisible);
} }
void CoverWidget::showFinished() {
_userpicButton->showFinished();
}
void CoverWidget::paintContents(Painter &p) { void CoverWidget::paintContents(Painter &p) {
p.setFont(st::settingsStatusFont); p.setFont(st::settingsStatusFont);
p.setPen(_statusTextIsOnline ? st::settingsStatusFgActive : st::settingsStatusFg); p.setPen(_statusTextIsOnline ? st::settingsStatusFgActive : st::settingsStatusFg);

View File

@ -27,6 +27,7 @@ namespace Ui {
class FlatLabel; class FlatLabel;
class RoundButton; class RoundButton;
class IconButton; class IconButton;
class UserpicButton;
} // namespace Ui } // namespace Ui
namespace Notify { namespace Notify {
@ -34,7 +35,6 @@ struct PeerUpdate;
} // namespace Notify } // namespace Notify
namespace Profile { namespace Profile {
class UserpicButton;
class CoverDropArea; class CoverDropArea;
} // namespace Profile } // namespace Profile
@ -46,8 +46,6 @@ class CoverWidget : public BlockWidget {
public: public:
CoverWidget(QWidget *parent, UserData *self); CoverWidget(QWidget *parent, UserData *self);
void showFinished();
private slots: private slots:
void onPhotoShow(); void onPhotoShow();
void onPhotoUploadStatusChanged(PeerId peerId = 0); void onPhotoUploadStatusChanged(PeerId peerId = 0);
@ -86,7 +84,7 @@ private:
UserData *_self; UserData *_self;
object_ptr<Profile::UserpicButton> _userpicButton; object_ptr<Ui::UserpicButton> _userpicButton;
object_ptr<Profile::CoverDropArea> _dropArea = { nullptr }; object_ptr<Profile::CoverDropArea> _dropArea = { nullptr };
object_ptr<Ui::FlatLabel> _name; object_ptr<Ui::FlatLabel> _name;

View File

@ -77,9 +77,6 @@ void InnerWidget::refreshBlocks() {
if (_cover) { if (_cover) {
_cover->show(); _cover->show();
if (_showFinished) {
_cover->showFinished();
}
} }
_blocks->show(); _blocks->show();
_blocks->heightValue() _blocks->heightValue()
@ -88,13 +85,6 @@ void InnerWidget::refreshBlocks() {
}, lifetime()); }, lifetime());
} }
void InnerWidget::showFinished() {
_showFinished = true;
if (_cover) {
_cover->showFinished();
}
}
int InnerWidget::resizeGetHeight(int newWidth) { int InnerWidget::resizeGetHeight(int newWidth) {
if (_cover) { if (_cover) {
_cover->setContentLeft(_contentLeft); _cover->setContentLeft(_contentLeft);

View File

@ -38,8 +38,6 @@ public:
return TWidget::resizeToWidth(newWidth); return TWidget::resizeToWidth(newWidth);
} }
void showFinished();
protected: protected:
int resizeGetHeight(int newWidth) override; int resizeGetHeight(int newWidth) override;
void visibleTopBottomUpdated( void visibleTopBottomUpdated(
@ -56,7 +54,6 @@ private:
UserData *_self = nullptr; UserData *_self = nullptr;
int _contentLeft = 0; int _contentLeft = 0;
bool _showFinished = false;
}; };

View File

@ -209,10 +209,6 @@ void Widget::refreshLang() {
update(); update();
} }
void Widget::showFinished() {
_inner->showFinished();
}
void Widget::keyPressEvent(QKeyEvent *e) { void Widget::keyPressEvent(QKeyEvent *e) {
codesFeedString(e->text()); codesFeedString(e->text());
return LayerWidget::keyPressEvent(e); return LayerWidget::keyPressEvent(e);

View File

@ -32,7 +32,6 @@ public:
void refreshLang(); void refreshLang();
void showFinished() override;
void parentResized() override; void parentResized() override;
protected: protected:

View File

@ -609,9 +609,6 @@ void LayerStackWidget::showFinished() {
fixOrder(); fixOrder();
sendFakeMouseEvent(); sendFakeMouseEvent();
updateLayerBoxes(); updateLayerBoxes();
if (_mainMenu) {
_mainMenu->showFinished();
}
if (_specialLayer) { if (_specialLayer) {
_specialLayer->showFinished(); _specialLayer->showFinished();
} }
@ -653,7 +650,7 @@ void LayerStackWidget::hideSpecialLayer(anim::type animated) {
void LayerStackWidget::showMainMenu(anim::type animated) { void LayerStackWidget::showMainMenu(anim::type animated) {
startAnimation([this] { startAnimation([this] {
_mainMenu.create(this); _mainMenu.create(this, _controller);
_mainMenu->setGeometryToLeft(0, 0, _mainMenu->width(), height()); _mainMenu->setGeometryToLeft(0, 0, _mainMenu->width(), height());
_mainMenu->setParent(this); _mainMenu->setParent(this);
}, [this] { }, [this] {

View File

@ -104,7 +104,10 @@ mainMenuWidth: 274px;
mainMenuCoverHeight: 134px; mainMenuCoverHeight: 134px;
mainMenuUserpicLeft: 24px; mainMenuUserpicLeft: 24px;
mainMenuUserpicTop: 20px; mainMenuUserpicTop: 20px;
mainMenuUserpicSize: 48px; mainMenuUserpic: UserpicButton(defaultUserpicButton) {
size: size(48px, 48px);
photoSize: 48px;
}
mainMenuCloudButton: IconButton { mainMenuCloudButton: IconButton {
width: 64px; width: 64px;
height: 64px; height: 64px;

View File

@ -22,11 +22,11 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "styles/style_window.h" #include "styles/style_window.h"
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
#include "profile/profile_userpic_button.h"
#include "window/themes/window_theme.h" #include "window/themes/window_theme.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
#include "ui/widgets/menu.h" #include "ui/widgets/menu.h"
#include "ui/special_buttons.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "boxes/about_box.h" #include "boxes/about_box.h"
@ -40,7 +40,11 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
namespace Window { namespace Window {
MainMenu::MainMenu(QWidget *parent) : TWidget(parent) MainMenu::MainMenu(
QWidget *parent,
not_null<Controller*> controller)
: TWidget(parent)
, _controller(controller)
, _menu(this, st::mainMenu) , _menu(this, st::mainMenu)
, _telegram(this, st::mainMenuTelegramLabel) , _telegram(this, st::mainMenuTelegramLabel)
, _version(this, st::mainMenuVersionLabel) { , _version(this, st::mainMenuVersionLabel) {
@ -136,7 +140,12 @@ void MainMenu::checkSelf() {
App::main()->choosePeer(self->id, ShowAtUnreadMsgId); App::main()->choosePeer(self->id, ShowAtUnreadMsgId);
} }
}; };
_userpicButton.create(this, self, st::mainMenuUserpicSize); _userpicButton.create(
this,
_controller,
self,
Ui::UserpicButton::Role::Custom,
st::mainMenuUserpic);
_userpicButton->setClickedCallback(showSelfChat); _userpicButton->setClickedCallback(showSelfChat);
_userpicButton->show(); _userpicButton->show();
_cloudButton.create(this, st::mainMenuCloudButton); _cloudButton.create(this, st::mainMenuCloudButton);
@ -144,22 +153,12 @@ void MainMenu::checkSelf() {
_cloudButton->show(); _cloudButton->show();
update(); update();
updateControlsGeometry(); updateControlsGeometry();
if (_showFinished) {
_userpicButton->showFinished();
}
} else { } else {
_userpicButton.destroy(); _userpicButton.destroy();
_cloudButton.destroy(); _cloudButton.destroy();
} }
} }
void MainMenu::showFinished() {
_showFinished = true;
if (_userpicButton) {
_userpicButton->showFinished();
}
}
void MainMenu::resizeEvent(QResizeEvent *e) { void MainMenu::resizeEvent(QResizeEvent *e) {
_menu->setForceWidth(width()); _menu->setForceWidth(width());
updateControlsGeometry(); updateControlsGeometry();

View File

@ -26,22 +26,20 @@ namespace Ui {
class IconButton; class IconButton;
class FlatLabel; class FlatLabel;
class Menu; class Menu;
} // namespace Ui
namespace Profile {
class UserpicButton; class UserpicButton;
} // namespace Profile } // namespace Ui
namespace Window { namespace Window {
class Controller;
class MainMenu : public TWidget, private base::Subscriber { class MainMenu : public TWidget, private base::Subscriber {
public: public:
MainMenu(QWidget *parent); MainMenu(QWidget *parent, not_null<Controller*> controller);
void setInnerFocus() { void setInnerFocus() {
setFocus(); setFocus();
} }
void showFinished();
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
@ -53,7 +51,8 @@ private:
void updatePhone(); void updatePhone();
void refreshMenu(); void refreshMenu();
object_ptr<Profile::UserpicButton> _userpicButton = { nullptr }; not_null<Controller*> _controller;
object_ptr<Ui::UserpicButton> _userpicButton = { nullptr };
object_ptr<Ui::IconButton> _cloudButton = { nullptr }; object_ptr<Ui::IconButton> _cloudButton = { nullptr };
object_ptr<Ui::Menu> _menu; object_ptr<Ui::Menu> _menu;
object_ptr<Ui::FlatLabel> _telegram; object_ptr<Ui::FlatLabel> _telegram;
@ -61,7 +60,6 @@ private:
std::shared_ptr<QPointer<QAction>> _nightThemeAction; std::shared_ptr<QPointer<QAction>> _nightThemeAction;
base::Timer _nightThemeSwitch; base::Timer _nightThemeSwitch;
bool _showFinished = false;
QString _phoneText; QString _phoneText;
}; };