mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add "show" button for last seen hidden.
This commit is contained in:
parent
ca25ad57b1
commit
33643ff7fc
3 changed files with 51 additions and 0 deletions
|
@ -304,6 +304,9 @@ InfoProfileCover {
|
||||||
status: FlatLabel;
|
status: FlatLabel;
|
||||||
statusLeft: pixels;
|
statusLeft: pixels;
|
||||||
statusTop: pixels;
|
statusTop: pixels;
|
||||||
|
showLastSeen: RoundButton;
|
||||||
|
showLastSeenPosition: point;
|
||||||
|
showLastSeenVisible: bool;
|
||||||
rightSkip: pixels;
|
rightSkip: pixels;
|
||||||
}
|
}
|
||||||
infoProfilePhotoInnerSize: 72px;
|
infoProfilePhotoInnerSize: 72px;
|
||||||
|
@ -334,6 +337,14 @@ infoProfileCover: InfoProfileCover {
|
||||||
status: infoProfileStatus;
|
status: infoProfileStatus;
|
||||||
statusLeft: 109px;
|
statusLeft: 109px;
|
||||||
statusTop: 58px;
|
statusTop: 58px;
|
||||||
|
showLastSeen: RoundButton(defaultActiveButton) {
|
||||||
|
width: -12px;
|
||||||
|
height: 20px;
|
||||||
|
textTop: 2px;
|
||||||
|
font: font(11px semibold);
|
||||||
|
}
|
||||||
|
showLastSeenPosition: point(4px, 56px);
|
||||||
|
showLastSeenVisible: true;
|
||||||
rightSkip: 20px;
|
rightSkip: 20px;
|
||||||
}
|
}
|
||||||
infoProfileMegagroupCover: InfoProfileCover(infoProfileCover) {
|
infoProfileMegagroupCover: InfoProfileCover(infoProfileCover) {
|
||||||
|
|
|
@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/view/media/history_view_sticker_player.h"
|
#include "history/view/media/history_view_sticker_player.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/controls/userpic_button.h"
|
#include "ui/controls/userpic_button.h"
|
||||||
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
|
@ -323,6 +324,7 @@ Cover::Cover(
|
||||||
: nullptr)
|
: nullptr)
|
||||||
, _name(this, _st.name)
|
, _name(this, _st.name)
|
||||||
, _status(this, _st.status)
|
, _status(this, _st.status)
|
||||||
|
, _showLastSeen(this, tr::lng_status_lastseen_show(), _st.showLastSeen)
|
||||||
, _refreshStatusTimer([this] { refreshStatusText(); }) {
|
, _refreshStatusTimer([this] { refreshStatusText(); }) {
|
||||||
_peer->updateFull();
|
_peer->updateFull();
|
||||||
|
|
||||||
|
@ -333,6 +335,8 @@ Cover::Cover(
|
||||||
_status->setAttribute(Qt::WA_TransparentForMouseEvents);
|
_status->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupShowLastSeen();
|
||||||
|
|
||||||
_badge->setPremiumClickCallback([=] {
|
_badge->setPremiumClickCallback([=] {
|
||||||
if (const auto panel = _emojiStatusPanel.get()) {
|
if (const auto panel = _emojiStatusPanel.get()) {
|
||||||
panel->show(_controller, _badge->widget(), _badge->sizeTag());
|
panel->show(_controller, _badge->widget(), _badge->sizeTag());
|
||||||
|
@ -361,6 +365,34 @@ Cover::Cover(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Cover::setupShowLastSeen() {
|
||||||
|
const auto user = _peer->asUser();
|
||||||
|
if (_st.showLastSeenVisible
|
||||||
|
&& user
|
||||||
|
&& !user->isSelf()
|
||||||
|
&& !user->isBot()
|
||||||
|
&& !user->isServiceUser()
|
||||||
|
&& user->session().premiumPossible()) {
|
||||||
|
rpl::combine(
|
||||||
|
user->session().changes().peerFlagsValue(
|
||||||
|
user,
|
||||||
|
Data::PeerUpdate::Flag::OnlineStatus),
|
||||||
|
Data::AmPremiumValue(&user->session())
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
_showLastSeen->setVisible(
|
||||||
|
(user->onlineTill == kOnlineHidden)
|
||||||
|
&& !user->session().premium()
|
||||||
|
&& user->session().premiumPossible());
|
||||||
|
}, _showLastSeen->lifetime());
|
||||||
|
} else {
|
||||||
|
_showLastSeen->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
_showLastSeen->setClickedCallback([=] {
|
||||||
|
::Settings::ShowPremium(_controller, u"lastseen_hidden"_q);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void Cover::setupChildGeometry() {
|
void Cover::setupChildGeometry() {
|
||||||
widthValue(
|
widthValue(
|
||||||
) | rpl::start_with_next([this](int newWidth) {
|
) | rpl::start_with_next([this](int newWidth) {
|
||||||
|
@ -577,6 +609,11 @@ void Cover::refreshStatusGeometry(int newWidth) {
|
||||||
auto statusWidth = newWidth - _st.statusLeft - _st.rightSkip;
|
auto statusWidth = newWidth - _st.statusLeft - _st.rightSkip;
|
||||||
_status->resizeToWidth(statusWidth);
|
_status->resizeToWidth(statusWidth);
|
||||||
_status->moveToLeft(_st.statusLeft, _st.statusTop, newWidth);
|
_status->moveToLeft(_st.statusLeft, _st.statusTop, newWidth);
|
||||||
|
const auto left = _st.statusLeft + _status->textMaxWidth();
|
||||||
|
_showLastSeen->moveToLeft(
|
||||||
|
left + _st.showLastSeenPosition.x(),
|
||||||
|
_st.showLastSeenPosition.y(),
|
||||||
|
newWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Info::Profile
|
} // namespace Info::Profile
|
||||||
|
|
|
@ -20,6 +20,7 @@ class UserpicButton;
|
||||||
class FlatLabel;
|
class FlatLabel;
|
||||||
template <typename Widget>
|
template <typename Widget>
|
||||||
class SlideWrap;
|
class SlideWrap;
|
||||||
|
class RoundButton;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
|
@ -126,6 +127,7 @@ private:
|
||||||
Role role,
|
Role role,
|
||||||
rpl::producer<QString> title);
|
rpl::producer<QString> title);
|
||||||
|
|
||||||
|
void setupShowLastSeen();
|
||||||
void setupChildGeometry();
|
void setupChildGeometry();
|
||||||
void initViewers(rpl::producer<QString> title);
|
void initViewers(rpl::producer<QString> title);
|
||||||
void refreshStatusText();
|
void refreshStatusText();
|
||||||
|
@ -149,6 +151,7 @@ private:
|
||||||
object_ptr<TopicIconButton> _iconButton;
|
object_ptr<TopicIconButton> _iconButton;
|
||||||
object_ptr<Ui::FlatLabel> _name = { nullptr };
|
object_ptr<Ui::FlatLabel> _name = { nullptr };
|
||||||
object_ptr<Ui::FlatLabel> _status = { nullptr };
|
object_ptr<Ui::FlatLabel> _status = { nullptr };
|
||||||
|
object_ptr<Ui::RoundButton> _showLastSeen = { nullptr };
|
||||||
//object_ptr<CoverDropArea> _dropArea = { nullptr };
|
//object_ptr<CoverDropArea> _dropArea = { nullptr };
|
||||||
base::Timer _refreshStatusTimer;
|
base::Timer _refreshStatusTimer;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue