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;
}
infoProfilePhotoSize: 72px;
infoProfilePhoto: UserpicButton(defaultUserpicButton) {
size: size(72px, 72px);
photoSize: 72px;
}
infoProfilePhotoLeft: 19px;
infoProfilePhotoTop: 18px;
infoProfilePhotoBottom: 18px;

View File

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

View File

@ -27,16 +27,17 @@ namespace style {
struct InfoToggle;
} // namespace style
namespace Profile {
class UserpicButton;
} // namespace Profile
namespace Ui {
class UserpicButton;
class FlatLabel;
template <typename Widget>
class SlideWrap;
} // namespace Ui
namespace Info {
class Controller;
} // namespace Info
namespace Info {
namespace Profile {
@ -61,7 +62,10 @@ private:
class Cover : public SectionWithToggle {
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);
@ -86,7 +90,7 @@ private:
not_null<PeerData*> _peer;
int _onlineCount = 0;
object_ptr<::Profile::UserpicButton> _userpic;
object_ptr<Ui::UserpicButton> _userpic;
object_ptr<Ui::FlatLabel> _name = { nullptr };
object_ptr<Ui::RpWidget> _verifiedCheck = { 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);
_cover = result->add(object_ptr<Cover>(
result,
_controller,
_peer));
_cover->setOnlineCount(rpl::single(0));
auto details = SetupDetails(_controller, parent, _peer);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -104,7 +104,10 @@ mainMenuWidth: 274px;
mainMenuCoverHeight: 134px;
mainMenuUserpicLeft: 24px;
mainMenuUserpicTop: 20px;
mainMenuUserpicSize: 48px;
mainMenuUserpic: UserpicButton(defaultUserpicButton) {
size: size(48px, 48px);
photoSize: 48px;
}
mainMenuCloudButton: IconButton {
width: 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_dialogs.h"
#include "profile/profile_userpic_button.h"
#include "window/themes/window_theme.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h"
#include "ui/widgets/menu.h"
#include "ui/special_buttons.h"
#include "mainwindow.h"
#include "storage/localstorage.h"
#include "boxes/about_box.h"
@ -40,7 +40,11 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
namespace Window {
MainMenu::MainMenu(QWidget *parent) : TWidget(parent)
MainMenu::MainMenu(
QWidget *parent,
not_null<Controller*> controller)
: TWidget(parent)
, _controller(controller)
, _menu(this, st::mainMenu)
, _telegram(this, st::mainMenuTelegramLabel)
, _version(this, st::mainMenuVersionLabel) {
@ -136,7 +140,12 @@ void MainMenu::checkSelf() {
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->show();
_cloudButton.create(this, st::mainMenuCloudButton);
@ -144,22 +153,12 @@ void MainMenu::checkSelf() {
_cloudButton->show();
update();
updateControlsGeometry();
if (_showFinished) {
_userpicButton->showFinished();
}
} else {
_userpicButton.destroy();
_cloudButton.destroy();
}
}
void MainMenu::showFinished() {
_showFinished = true;
if (_userpicButton) {
_userpicButton->showFinished();
}
}
void MainMenu::resizeEvent(QResizeEvent *e) {
_menu->setForceWidth(width());
updateControlsGeometry();

View File

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