2016-12-08 14:08:54 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-12-08 14:08:54 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-12-08 14:08:54 +00:00
|
|
|
*/
|
|
|
|
#include "profile/profile_back_button.h"
|
|
|
|
|
2018-01-09 17:08:31 +00:00
|
|
|
//#include "history/view/history_view_top_bar_widget.h"
|
2020-06-18 11:17:58 +00:00
|
|
|
#include "main/main_session.h"
|
|
|
|
#include "data/data_session.h"
|
2022-09-16 20:23:27 +00:00
|
|
|
#include "ui/painter.h"
|
2016-12-08 14:08:54 +00:00
|
|
|
#include "styles/style_widgets.h"
|
|
|
|
#include "styles/style_window.h"
|
|
|
|
#include "styles/style_profile.h"
|
2017-12-07 15:01:41 +00:00
|
|
|
#include "styles/style_info.h"
|
2016-12-08 14:08:54 +00:00
|
|
|
|
|
|
|
namespace Profile {
|
|
|
|
|
2020-06-18 11:17:58 +00:00
|
|
|
BackButton::BackButton(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<Main::Session*> session,
|
2021-05-26 21:39:30 +00:00
|
|
|
const QString &text,
|
|
|
|
rpl::producer<bool> oneColumnValue)
|
2020-06-18 11:17:58 +00:00
|
|
|
: Ui::AbstractButton(parent)
|
|
|
|
, _session(session)
|
2022-07-07 00:28:43 +00:00
|
|
|
, _text(text) {
|
2016-12-08 14:08:54 +00:00
|
|
|
setCursor(style::cur_pointer);
|
|
|
|
|
2021-05-26 21:39:30 +00:00
|
|
|
std::move(
|
|
|
|
oneColumnValue
|
|
|
|
) | rpl::start_with_next([=](bool oneColumn) {
|
|
|
|
if (!oneColumn) {
|
|
|
|
_unreadBadgeLifetime.destroy();
|
|
|
|
} else if (!_unreadBadgeLifetime) {
|
|
|
|
_session->data().unreadBadgeChanges(
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
rtlupdate(
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
st::titleUnreadCounterRight,
|
|
|
|
st::titleUnreadCounterTop);
|
|
|
|
}, _unreadBadgeLifetime);
|
|
|
|
}
|
|
|
|
}, lifetime());
|
2016-12-08 14:08:54 +00:00
|
|
|
}
|
|
|
|
|
2017-06-18 11:08:14 +00:00
|
|
|
void BackButton::setText(const QString &text) {
|
2022-07-07 00:28:43 +00:00
|
|
|
_text = text;
|
2017-06-18 11:08:14 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2016-12-08 14:08:54 +00:00
|
|
|
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.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)) {
|
2019-09-13 16:45:48 +00:00
|
|
|
clicked(Qt::KeyboardModifiers(), Qt::LeftButton);
|
2016-12-08 14:08:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Profile
|