Skip to content

Commit

Permalink
added sender's userpic in group + improved online indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
xmdnx committed Feb 25, 2024
1 parent cfd205e commit 1a51b07
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 20 deletions.
72 changes: 53 additions & 19 deletions Telegram/SourceFiles/dialogs/dialogs_row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ For license and copyright information please follow this link:
*/
#include "dialogs/dialogs_row.h"

#include "rabbit/settings/rabbit_settings.h"

#include "ui/chat/chat_theme.h" // CountAverageColor.
#include "ui/color_contrast.h"
#include "ui/effects/outline_segments.h"
Expand Down Expand Up @@ -308,11 +310,14 @@ void Row::updateCornerBadgeShown(
} else if (peer->isChannel()
&& Data::ChannelHasActiveCall(peer->asChannel())) {
return kTopLayer;
} else if (!peer->isForum() && (peer->isChat() || peer->isMegagroup()) && RabbitSettings::JsonSettings::GetBool("show_sender_userpic")){
return kTopLayer;
} else if (peer->messagesTTL()) {
return kBottomLayer;
}
return kNoneLayer;
}();
const_cast<Row*>(this)->_hasVideoCall = peer->isChannel() && Data::ChannelHasActiveCall(peer->asChannel());
setCornerBadgeShown(nextLayer, std::move(updateCallback));
if ((nextLayer == kTopLayer) && user) {
peer->owner().watchForOffline(user, now);
Expand Down Expand Up @@ -427,16 +432,41 @@ void Row::PaintCornerBadgeFrame(
q.setBrush(data->active
? st::dialogsOnlineBadgeFgActive
: st::dialogsOnlineBadgeFg);
q.drawEllipse(QRectF(
46 - size -
(RabbitSettings::JsonSettings::GetInt("userpic_roundness") == 100
? skip.x() : -(stroke / 2)),
46 - size -
(RabbitSettings::JsonSettings::GetInt("userpic_roundness") == 100
? skip.y() : -(stroke / 2)),
size,
size
).marginsRemoved({ shrink, shrink, shrink, shrink }));
if ((peer->isChannel() && Data::ChannelHasActiveCall(peer->asChannel())) || online) {
if (!RabbitSettings::JsonSettings::GetBool("general_roundness")) {
q.drawEllipse(
QRectF(
(46 - size -
(RabbitSettings::JsonSettings::GetInt("userpic_roundness") == 50
? skip.x()
: -(stroke / 2))),
(46 - size -
(RabbitSettings::JsonSettings::GetInt("userpic_roundness") == 50
? skip.y()
: -(stroke / 2))),
size,
size
).marginsRemoved({ shrink, shrink, shrink, shrink })
);
} else {
q.drawRoundedRect(
QRectF(
(46 - size -
(RabbitSettings::JsonSettings::GetInt("userpic_roundness") == 50
? skip.x()
: -(stroke / 2))),
(46 - size -
(RabbitSettings::JsonSettings::GetInt("userpic_roundness") == 50
? skip.y()
: -(stroke / 2))),
size,
size
).marginsRemoved({ shrink, shrink, shrink, shrink }),
size * RabbitSettings::JsonSettings::GetInt("userpic_roundness") / 100,
size * RabbitSettings::JsonSettings::GetInt("userpic_roundness") / 100
);
}
}
}

void Row::paintUserpic(
Expand Down Expand Up @@ -555,15 +585,19 @@ void Row::paintUserpic(
p.setOpacity(
_cornerBadgeUserpic->layersManager.progressForLayer(kTopLayer));
p.translate(context.st->padding.left(), context.st->padding.top());
actionPainter->paintSpeaking(
p,
context.st->photoSize - size - (RabbitSettings::JsonSettings::GetInt("userpic_roundness") == 50
? skip.x() : -(stroke / 2)),
context.st->photoSize - size - (RabbitSettings::JsonSettings::GetInt("userpic_roundness") == 50
? skip.y() : -(stroke / 2)),
context.width,
bg,
context.now);
if(_hasVideoCall){
actionPainter->paintSpeaking(
p,
context.st->photoSize - skip.x() - size,
context.st->photoSize - skip.y() - size,
context.width,
bg,
context.now);
}
else {
const auto lastMessageFrom = history->lastMessage()->from();
lastMessageFrom->paintUserpic(p, userpicCornerView(), context.st->photoSize - skip.x() - size, context.st->photoSize - skip.y() - size, size);
}
p.translate(-context.st->padding.left(), -context.st->padding.top());
p.setOpacity(1.);
}
Expand Down
5 changes: 5 additions & 0 deletions Telegram/SourceFiles/dialogs/dialogs_row.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ class BasicRow {
[[nodiscard]] Ui::PeerUserpicView &userpicView() const {
return _userpic;
}
[[nodiscard]] Ui::PeerUserpicView &userpicCornerView() const {
return _userpicCorner;
}

private:
mutable Ui::PeerUserpicView _userpic;
mutable Ui::PeerUserpicView _userpicCorner;
mutable std::unique_ptr<Ui::RippleAnimation> _ripple;

};
Expand Down Expand Up @@ -201,6 +205,7 @@ class Row final : public BasicRow {
uint32 _index : 30 = 0;
uint32 _cornerBadgeShown : 1 = 0;
uint32 _topicJumpRipple : 1 = 0;
uint32 _hasVideoCall : 1 = 0;

};

Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/rabbit/settings/rabbit_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ const std::map<QString, Definition, std::greater<QString>> DefinitionMap {
{ "show_seconds", {
.type = SettingType::BoolSetting,
.defaultValue = false, }},
{ "show_sender_userpic", {
.type = SettingType::BoolSetting,
.defaultValue = false, }},
{ "comma_after_mention", {
.type = SettingType::BoolSetting,
.defaultValue = false, }},
Expand Down
15 changes: 15 additions & 0 deletions Telegram/SourceFiles/rabbit/settings_menu/rabbit_settings_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,21 @@ namespace Settings {
::RabbitSettings::JsonSettings::Set("show_seconds", enabled);
::RabbitSettings::JsonSettings::Write();
}, container->lifetime());

AddButtonWithIcon(
container,
rktr("rtg_profile_mention_user"),
st::settingsButton,
IconDescriptor{ &st::menuIconDockBounce }
)->toggleOn(
rpl::single(::RabbitSettings::JsonSettings::GetBool("show_sender_userpic"))
)->toggledValue(
) | rpl::filter([](bool enabled) {
return (enabled != ::RabbitSettings::JsonSettings::GetBool("show_sender_userpic"));
}) | rpl::start_with_next([](bool enabled) {
::RabbitSettings::JsonSettings::Set("show_sender_userpic", enabled);
::RabbitSettings::JsonSettings::Write();
}, container->lifetime());

SettingsMenuJsonSwitch(rtg_settings_comma_after_mention, comma_after_mention);
}
Expand Down
2 changes: 1 addition & 1 deletion Telegram/build/setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define MyAppId "4356CE01-4137-4C55-9F8B-FB4EEBB6EC0C"
#define CurrentYear GetDateTimeString('yyyy','','')
#define MyBuildTarget "win64"
#define MyAppVersionFull "4.15-24022024"
#define MyAppVersionFull "4.15-25022024"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
Expand Down

0 comments on commit 1a51b07

Please sign in to comment.