init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
This commit is contained in:
42
Telegram/SourceFiles/profile/profile.style
Normal file
42
Telegram/SourceFiles/profile/profile.style
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
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 "ui/basic.style";
|
||||
|
||||
using "ui/widgets/widgets.style";
|
||||
using "info/info.style";
|
||||
|
||||
profileBg: windowBg;
|
||||
|
||||
profileTopBarHeight: topBarHeight;
|
||||
|
||||
profileDropAreaBg: profileBg;
|
||||
profileDropAreaFg: lightButtonFg;
|
||||
profileDropAreaPadding: margins(25px, 3px, 25px, 20px);
|
||||
profileDropAreaTitleFont: font(24px);
|
||||
profileDropAreaTitleTop: 30px;
|
||||
profileDropAreaSubtitleFont: font(16px);
|
||||
profileDropAreaSubtitleTop: 68px;
|
||||
profileDropAreaBorderFg: profileDropAreaFg;
|
||||
profileDropAreaBorderWidth: 3px;
|
||||
profileDropAreaDuration: 200;
|
||||
|
||||
profileBlockMarginTop: 14px;
|
||||
profileBlockTitleHeight: 24px;
|
||||
profileBlockTitleFont: font(14px semibold);
|
||||
profileBlockTitleFg: windowBoldFg;
|
||||
profileBlockTitlePosition: point(24px, 0px);
|
||||
profileBlockTextPart: FlatLabel(defaultFlatLabel) {
|
||||
minWidth: 180px;
|
||||
margin: margins(5px, 5px, 5px, 5px);
|
||||
}
|
||||
profileBlockOneLineTextPart: FlatLabel(profileBlockTextPart) {
|
||||
minWidth: 0px; // No need to set minWidth in one-line text.
|
||||
maxHeight: 20px;
|
||||
}
|
||||
|
||||
profileMemberNameFg: windowBoldFg;
|
||||
75
Telegram/SourceFiles/profile/profile_back_button.cpp
Normal file
75
Telegram/SourceFiles/profile/profile_back_button.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
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 "profile/profile_back_button.h"
|
||||
|
||||
//#include "history/view/history_view_top_bar_widget.h"
|
||||
#include "main/main_session.h"
|
||||
#include "data/data_session.h"
|
||||
#include "ui/painter.h"
|
||||
#include "styles/style_widgets.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "styles/style_profile.h"
|
||||
#include "styles/style_info.h"
|
||||
|
||||
namespace Profile {
|
||||
|
||||
BackButton::BackButton(
|
||||
QWidget *parent,
|
||||
not_null<Main::Session*> session,
|
||||
const QString &text,
|
||||
rpl::producer<bool> oneColumnValue)
|
||||
: Ui::AbstractButton(parent)
|
||||
, _session(session)
|
||||
, _text(text) {
|
||||
setCursor(style::cur_pointer);
|
||||
|
||||
std::move(
|
||||
oneColumnValue
|
||||
) | rpl::on_next([=](bool oneColumn) {
|
||||
if (!oneColumn) {
|
||||
_unreadBadgeLifetime.destroy();
|
||||
} else if (!_unreadBadgeLifetime) {
|
||||
_session->data().unreadBadgeChanges(
|
||||
) | rpl::on_next([=] {
|
||||
rtlupdate(
|
||||
0,
|
||||
0,
|
||||
st::titleUnreadCounterRight,
|
||||
st::titleUnreadCounterTop);
|
||||
}, _unreadBadgeLifetime);
|
||||
}
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void BackButton::setText(const QString &text) {
|
||||
_text = text;
|
||||
update();
|
||||
}
|
||||
|
||||
int BackButton::resizeGetHeight(int newWidth) {
|
||||
return st::profileTopBarHeight;
|
||||
}
|
||||
|
||||
void BackButton::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
|
||||
p.fillRect(e->rect(), st::profileBg);
|
||||
st::topBarBack.paint(p, (st::topBarArrowPadding.left() - st::topBarBack.width()) / 2, (st::topBarHeight - st::topBarBack.height()) / 2, width());
|
||||
|
||||
p.setFont(st::topBarButton.style.font);
|
||||
p.setPen(st::topBarButton.textFg);
|
||||
p.drawTextLeft(st::topBarArrowPadding.left(), st::topBarButton.padding.top() + st::topBarButton.textTop, width(), _text);
|
||||
}
|
||||
|
||||
void BackButton::onStateChanged(State was, StateChangeSource source) {
|
||||
if (isDown() && !(was & StateFlag::Down)) {
|
||||
clicked(Qt::KeyboardModifiers(), Qt::LeftButton);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Profile
|
||||
42
Telegram/SourceFiles/profile/profile_back_button.h
Normal file
42
Telegram/SourceFiles/profile/profile_back_button.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
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/abstract_button.h"
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Profile {
|
||||
|
||||
class BackButton final : public Ui::AbstractButton {
|
||||
public:
|
||||
BackButton(
|
||||
QWidget *parent,
|
||||
not_null<Main::Session*> session,
|
||||
const QString &text,
|
||||
rpl::producer<bool> oneColumnValue);
|
||||
|
||||
void setText(const QString &text);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
int resizeGetHeight(int newWidth) override;
|
||||
void onStateChanged(State was, StateChangeSource source) override;
|
||||
|
||||
private:
|
||||
const not_null<Main::Session*> _session;
|
||||
|
||||
rpl::lifetime _unreadBadgeLifetime;
|
||||
QString _text;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Profile
|
||||
45
Telegram/SourceFiles/profile/profile_block_widget.cpp
Normal file
45
Telegram/SourceFiles/profile/profile_block_widget.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
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 "profile/profile_block_widget.h"
|
||||
|
||||
#include "ui/painter.h"
|
||||
#include "styles/style_profile.h"
|
||||
#include "styles/style_widgets.h"
|
||||
|
||||
namespace Profile {
|
||||
|
||||
BlockWidget::BlockWidget(
|
||||
QWidget *parent,
|
||||
PeerData *peer,
|
||||
const QString &title) : RpWidget(parent)
|
||||
, _peer(peer)
|
||||
, _title(title) {
|
||||
}
|
||||
|
||||
int BlockWidget::contentTop() const {
|
||||
return emptyTitle() ? 0 : (st::profileBlockMarginTop + st::profileBlockTitleHeight);
|
||||
}
|
||||
|
||||
void BlockWidget::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
|
||||
paintTitle(p);
|
||||
paintContents(p);
|
||||
}
|
||||
|
||||
void BlockWidget::paintTitle(Painter &p) {
|
||||
if (emptyTitle()) return;
|
||||
|
||||
p.setFont(st::profileBlockTitleFont);
|
||||
p.setPen(st::profileBlockTitleFg);
|
||||
int titleLeft = st::profileBlockTitlePosition.x();
|
||||
int titleTop = st::profileBlockMarginTop + st::profileBlockTitlePosition.y();
|
||||
p.drawTextLeft(titleLeft, titleTop, width(), _title);
|
||||
}
|
||||
|
||||
} // namespace Profile
|
||||
59
Telegram/SourceFiles/profile/profile_block_widget.h
Normal file
59
Telegram/SourceFiles/profile/profile_block_widget.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
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 Profile {
|
||||
|
||||
class SectionMemento;
|
||||
|
||||
class BlockWidget : public Ui::RpWidget {
|
||||
public:
|
||||
BlockWidget(QWidget *parent, PeerData *peer, const QString &title);
|
||||
|
||||
virtual void showFinished() {
|
||||
}
|
||||
|
||||
virtual void saveState(not_null<SectionMemento*> memento) {
|
||||
}
|
||||
virtual void restoreState(not_null<SectionMemento*> memento) {
|
||||
}
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
virtual void paintContents(Painter &p) {
|
||||
}
|
||||
|
||||
// Where does the block content start (after the title).
|
||||
int contentTop() const;
|
||||
|
||||
// Resizes content and counts natural widget height for the desired width.
|
||||
int resizeGetHeight(int newWidth) override = 0;
|
||||
|
||||
void contentSizeUpdated() {
|
||||
resizeToWidth(width());
|
||||
}
|
||||
|
||||
PeerData *peer() const {
|
||||
return _peer;
|
||||
}
|
||||
|
||||
bool emptyTitle() const {
|
||||
return _title.isEmpty();
|
||||
}
|
||||
|
||||
private:
|
||||
void paintTitle(Painter &p);
|
||||
|
||||
PeerData *_peer;
|
||||
QString _title;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Profile
|
||||
96
Telegram/SourceFiles/profile/profile_cover_drop_area.cpp
Normal file
96
Telegram/SourceFiles/profile/profile_cover_drop_area.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
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 "profile/profile_cover_drop_area.h"
|
||||
|
||||
#include "ui/ui_utility.h"
|
||||
#include "styles/style_profile.h"
|
||||
|
||||
namespace Profile {
|
||||
|
||||
CoverDropArea::CoverDropArea(
|
||||
QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &subtitle)
|
||||
: RpWidget(parent)
|
||||
, _title(title)
|
||||
, _subtitle(subtitle)
|
||||
, _titleWidth(st::profileDropAreaTitleFont->width(_title))
|
||||
, _subtitleWidth(st::profileDropAreaSubtitleFont->width(_subtitle)) {
|
||||
}
|
||||
|
||||
void CoverDropArea::showAnimated() {
|
||||
show();
|
||||
_hiding = false;
|
||||
setupAnimation();
|
||||
}
|
||||
|
||||
void CoverDropArea::hideAnimated(HideFinishCallback &&callback) {
|
||||
_hideFinishCallback = std::move(callback);
|
||||
_hiding = true;
|
||||
setupAnimation();
|
||||
}
|
||||
|
||||
void CoverDropArea::paintEvent(QPaintEvent *e) {
|
||||
auto p = QPainter(this);
|
||||
|
||||
if (_a_appearance.animating()) {
|
||||
p.setOpacity(_a_appearance.value(_hiding ? 0. : 1.));
|
||||
p.drawPixmap(0, 0, _cache);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_cache.isNull()) {
|
||||
_cache = QPixmap();
|
||||
if (_hiding) {
|
||||
hide();
|
||||
if (_hideFinishCallback) {
|
||||
_hideFinishCallback(this);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
p.fillRect(e->rect(), st::profileDropAreaBg);
|
||||
|
||||
if (width() < st::profileDropAreaPadding.left() + st::profileDropAreaPadding.right()) return;
|
||||
if (height() < st::profileDropAreaPadding.top() + st::profileDropAreaPadding.bottom()) return;
|
||||
|
||||
auto border = st::profileDropAreaBorderWidth;
|
||||
auto &borderFg = st::profileDropAreaBorderFg;
|
||||
auto inner = rect().marginsRemoved(st::profileDropAreaPadding);
|
||||
p.fillRect(inner.x(), inner.y(), inner.width(), border, borderFg);
|
||||
p.fillRect(inner.x(), inner.y() + inner.height() - border, inner.width(), border, borderFg);
|
||||
p.fillRect(inner.x(), inner.y() + border, border, inner.height() - 2 * border, borderFg);
|
||||
p.fillRect(inner.x() + inner.width() - border, inner.y() + border, border, inner.height() - 2 * border, borderFg);
|
||||
|
||||
int titleLeft = inner.x() + (inner.width() - _titleWidth) / 2;
|
||||
int titleTop = inner.y() + st::profileDropAreaTitleTop + st::profileDropAreaTitleFont->ascent;
|
||||
p.setFont(st::profileDropAreaTitleFont);
|
||||
p.setPen(st::profileDropAreaFg);
|
||||
p.drawText(titleLeft, titleTop, _title);
|
||||
|
||||
int subtitleLeft = inner.x() + (inner.width() - _subtitleWidth) / 2;
|
||||
int subtitleTop = inner.y() + st::profileDropAreaSubtitleTop + st::profileDropAreaSubtitleFont->ascent;
|
||||
p.setFont(st::profileDropAreaSubtitleFont);
|
||||
p.setPen(st::profileDropAreaFg);
|
||||
p.drawText(subtitleLeft, subtitleTop, _subtitle);
|
||||
}
|
||||
|
||||
void CoverDropArea::setupAnimation() {
|
||||
if (_cache.isNull()) {
|
||||
_cache = Ui::GrabWidget(this);
|
||||
}
|
||||
auto from = _hiding ? 1. : 0., to = _hiding ? 0. : 1.;
|
||||
_a_appearance.start(
|
||||
[=] { update(); },
|
||||
from,
|
||||
to,
|
||||
st::profileDropAreaDuration);
|
||||
}
|
||||
|
||||
} // namespace Profile
|
||||
44
Telegram/SourceFiles/profile/profile_cover_drop_area.h
Normal file
44
Telegram/SourceFiles/profile/profile_cover_drop_area.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
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/effects/animations.h"
|
||||
#include "ui/rp_widget.h"
|
||||
|
||||
namespace Profile {
|
||||
|
||||
class CoverDropArea : public Ui::RpWidget {
|
||||
public:
|
||||
CoverDropArea(QWidget *parent, const QString &title, const QString &subtitle);
|
||||
|
||||
void showAnimated();
|
||||
|
||||
using HideFinishCallback = Fn<void(CoverDropArea*)>;
|
||||
void hideAnimated(HideFinishCallback &&callback);
|
||||
|
||||
bool hiding() const {
|
||||
return _hiding;
|
||||
}
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
private:
|
||||
void setupAnimation();
|
||||
|
||||
QString _title, _subtitle;
|
||||
int _titleWidth, _subtitleWidth;
|
||||
|
||||
QPixmap _cache;
|
||||
Ui::Animations::Simple _a_appearance;
|
||||
bool _hiding = false;
|
||||
HideFinishCallback _hideFinishCallback;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Profile
|
||||
Reference in New Issue
Block a user