This commit is contained in:
Neurotoxin001 2025-07-29 02:28:34 +03:00 committed by GitHub
commit 20c1f165c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 153 additions and 0 deletions

View file

@ -6911,6 +6911,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ayu_SettingsShowID" = "Show Peer ID";
"ayu_SettingsShowID_Hide" = "Hide";
"ayu_SettingsShowMessageShot" = "Show Message Shot";
"ayu_ShowForwardsCount" = "Show Forwards";
"ayu_ShowForwardsRatio" = "Show Forward Ratio";
"ayu_SettingsRecentStickersCount" = "Recent Stickers Count";
"ayu_SettingsCustomizationHint" = "You must restart the application after making changes in the \"Customization\" section.";
"ayu_SettingsContextMenuTitle" = "Choose when to show the item";

View file

@ -296,6 +296,8 @@ AyuGramSettings::AyuGramSettings() {
showPeerId = 2;
showMessageSeconds = false;
showMessageShot = true;
showForwards = true;
showForwardsRatio = false;
// ~ Confirmations
stickerConfirmation = false;
@ -565,6 +567,14 @@ void set_showMessageShot(bool val) {
settings->showMessageShot = val;
}
void set_showForwards(bool val) {
settings->showForwards = val;
}
void set_showForwardsRatio(bool val) {
settings->showForwardsRatio = val;
}
void set_stickerConfirmation(bool val) {
settings->stickerConfirmation = val;
}

View file

@ -120,6 +120,8 @@ public:
int showPeerId;
bool showMessageSeconds;
bool showMessageShot;
bool showForwards;
bool showForwardsRatio;
bool stickerConfirmation;
bool gifConfirmation;
@ -204,6 +206,8 @@ void set_channelBottomButton(int val);
void set_showPeerId(int val);
void set_showMessageSeconds(bool val);
void set_showMessageShot(bool val);
void set_showForwards(bool val);
void set_showForwardsRatio(bool val);
void set_stickerConfirmation(bool val);
void set_gifConfirmation(bool val);
@ -269,6 +273,8 @@ inline void to_json(nlohmann::json &nlohmann_json_j, const AyuGramSettings &nloh
NLOHMANN_JSON_TO(showMessageSeconds)
NLOHMANN_JSON_TO(showMessageShot)
NLOHMANN_JSON_TO(stickerConfirmation)
NLOHMANN_JSON_TO(showForwards)
NLOHMANN_JSON_TO(showForwardsRatio)
NLOHMANN_JSON_TO(gifConfirmation)
NLOHMANN_JSON_TO(voiceConfirmation)
}
@ -334,6 +340,8 @@ inline void from_json(const nlohmann::json &nlohmann_json_j, AyuGramSettings &nl
NLOHMANN_JSON_FROM_WITH_DEFAULT(showMessageSeconds)
NLOHMANN_JSON_FROM_WITH_DEFAULT(showMessageShot)
NLOHMANN_JSON_FROM_WITH_DEFAULT(stickerConfirmation)
NLOHMANN_JSON_FROM_WITH_DEFAULT(showForwards)
NLOHMANN_JSON_FROM_WITH_DEFAULT(showForwardsRatio)
NLOHMANN_JSON_FROM_WITH_DEFAULT(gifConfirmation)
NLOHMANN_JSON_FROM_WITH_DEFAULT(voiceConfirmation)
}

View file

@ -887,6 +887,44 @@ void SetupQoLToggles(not_null<Ui::VerticalLayout*> container) {
AyuSettings::save();
},
container->lifetime());
AddButtonWithIcon(
container,
tr::ayu_ShowForwardsCount(),
st::settingsButtonNoIcon
)->toggleOn(
rpl::single(settings->showForwards)
)->toggledValue(
) | rpl::filter(
[=](bool enabled)
{
return (enabled != settings->showForwards);
}) | start_with_next(
[=](bool enabled)
{
AyuSettings::set_showForwards(enabled);
AyuSettings::save();
},
container->lifetime());
AddButtonWithIcon(
container,
tr::ayu_ShowForwardsRatio(),
st::settingsButtonNoIcon
)->toggleOn(
rpl::single(settings->showForwardsRatio)
)->toggledValue(
) | rpl::filter(
[=](bool enabled)
{
return (enabled != settings->showForwardsRatio);
}) | start_with_next(
[=](bool enabled)
{
AyuSettings::set_showForwardsRatio(enabled);
AyuSettings::save();
},
container->lifetime());
}
void SetupAppIcon(not_null<Ui::VerticalLayout*> container) {

View file

@ -112,6 +112,7 @@ bool BottomInfo::isWide() const {
return (_data.flags & Data::Flag::Edited)
|| !_data.author.isEmpty()
|| !_views.isEmpty()
|| !_forwards.isEmpty()
|| !_replies.isEmpty()
|| _effect;
}
@ -159,6 +160,38 @@ TextState BottomInfo::textState(
result.customTooltipText = fullViews + fullForwards;
}
}
if (!_forwards.isEmpty()) {
const auto forwardsWidth = _forwards.maxWidth();
auto right = width()
- withTicksWidth
- ((_data.flags & Data::Flag::Pinned) ? st::historyPinWidth : 0);
if (!_views.isEmpty()) {
right -= st::historyViewsSpace + st::historyViewsWidth + _views.maxWidth();
}
right -= st::historyViewsSpace + st::historyViewsWidth + forwardsWidth;
const auto inForwards = QRect(
right,
0,
withTicksWidth + st::historyViewsWidth,
st::msgDateFont->height
).contains(position);
if (inForwards) {
result.customTooltip = true;
const auto fullViews = _data.views
? tr::lng_views_tooltip(
tr::now,
lt_count_decimal,
*_data.views)
: QString();
const auto fullForwards = _data.forwardsCount
? ('\n' + tr::lng_forwards_tooltip(
tr::now,
lt_count_decimal,
*_data.forwardsCount))
: QString();
result.customTooltipText = fullViews + fullForwards;
}
}
const auto inTime = QRect(
width() - withTicksWidth,
0,
@ -284,6 +317,21 @@ void BottomInfo::paint(
firstLineBottom + st::historyViewsTop,
outerWidth);
}
if (!_forwards.isEmpty()) {
const auto forwardsWidth = _forwards.maxWidth();
right -= st::historyViewsSpace + forwardsWidth;
_forwards.drawLeft(p, right, position.y(), forwardsWidth, outerWidth);
const auto &icon = inverted
? st->historyForwardsInvertedIcon()
: stm->historyForwardsIcon;
right -= st::historyViewsWidth;
icon.paint(
p,
right,
firstLineBottom + st::historyViewsTop,
outerWidth);
}
if (!_replies.isEmpty()) {
const auto repliesWidth = _replies.maxWidth();
right -= st::historyViewsSpace + repliesWidth;
@ -410,6 +458,7 @@ QSize BottomInfo::countCurrentSize(int newWidth) {
void BottomInfo::layout() {
layoutDateText();
layoutViewsText();
layoutForwardsText();
layoutRepliesText();
layoutEffectText();
initDimensions();
@ -540,6 +589,28 @@ void BottomInfo::layoutViewsText() {
Ui::NameTextOptions());
}
void BottomInfo::layoutForwardsText() {
const auto& settings = AyuSettings::getInstance();
if (!settings.showForwards
|| !_data.forwardsCount
|| !_data.forwardsCount.value()
|| (_data.flags & Data::Flag::Sending)) {
_forwards.clear();
return;
}
auto text = Lang::FormatCountToShort(*_data.forwardsCount).string;
if (settings.showForwardsRatio && _data.views && *_data.views > 0) {
const auto percent = (*_data.forwardsCount * 100)
/ std::max(*_data.views, 1);
text += " (" + QString::number(percent) + '%';
text += ')';
}
_forwards.setText(
st::msgDateTextStyle,
text,
Ui::NameTextOptions());
}
void BottomInfo::layoutRepliesText() {
if (!_data.replies
|| !*_data.replies
@ -577,6 +648,11 @@ QSize BottomInfo::countOptimalSize() {
+ _views.maxWidth()
+ st::historyViewsWidth;
}
if (!_forwards.isEmpty()) {
width += st::historyViewsSpace
+ _forwards.maxWidth()
+ st::historyViewsWidth;
}
if (!_replies.isEmpty()) {
width += st::historyViewsSpace
+ _replies.maxWidth()

View file

@ -93,6 +93,7 @@ private:
void layout();
void layoutDateText();
void layoutViewsText();
void layoutForwardsText();
void layoutRepliesText();
void layoutEffectText();
@ -121,6 +122,7 @@ private:
Ui::Text::String _authorEditedDate;
Ui::Text::String _views;
Ui::Text::String _replies;
Ui::Text::String _forwards;
std::unique_ptr<Effect> _effect;
mutable ClickHandlerPtr _replayLink;
int _effectMaxWidth = 0;

View file

@ -300,6 +300,11 @@ historyViewsInSelectedIcon: icon {{ "history_views", msgInDateFgSelected }};
historyViewsOutIcon: icon {{ "history_views", historyOutIconFg }};
historyViewsOutSelectedIcon: icon {{ "history_views", historyOutIconFgSelected }};
historyViewsInvertedIcon: icon {{ "history_views", historySendingInvertedIconFg }};
historyForwardsInIcon: icon {{ "inline_button_switch", msgInDateFg }};
historyForwardsInSelectedIcon: icon {{ "inline_button_switch", msgInDateFgSelected }};
historyForwardsOutIcon: icon {{ "inline_button_switch", historyOutIconFg }};
historyForwardsOutSelectedIcon: icon {{ "inline_button_switch", historyOutIconFgSelected }};
historyForwardsInvertedIcon: icon {{ "inline_button_switch", historySendingInvertedIconFg }};
historyRepliesInIcon: icon {{ "history_replies", msgInDateFg }};
historyRepliesInSelectedIcon: icon {{ "history_replies", msgInDateFgSelected }};
historyRepliesOutIcon: icon {{ "history_replies", historyOutIconFg }};

View file

@ -185,6 +185,7 @@ ChatStyle::ChatStyle(rpl::producer<ColorIndicesCompressed> colorIndices) {
make(_priceTagTextPalette, st::priceTagTextPalette);
make(_historyRepliesInvertedIcon, st::historyRepliesInvertedIcon);
make(_historyViewsInvertedIcon, st::historyViewsInvertedIcon);
make(_historyForwardsInvertedIcon, st::historyForwardsInvertedIcon);
make(_historyViewsSendingIcon, st::historyViewsSendingIcon);
make(
_historyViewsSendingInvertedIcon,
@ -346,6 +347,12 @@ ChatStyle::ChatStyle(rpl::producer<ColorIndicesCompressed> colorIndices) {
st::historyViewsInSelectedIcon,
st::historyViewsOutIcon,
st::historyViewsOutSelectedIcon);
make(
&MessageStyle::historyForwardsIcon,
st::historyForwardsInIcon,
st::historyForwardsInSelectedIcon,
st::historyForwardsOutIcon,
st::historyForwardsOutSelectedIcon);
make(
&MessageStyle::historyPinIcon,
st::historyPinInIcon,

View file

@ -69,6 +69,7 @@ struct MessageStyle {
style::icon tailRight = { Qt::Uninitialized };
style::icon historyRepliesIcon = { Qt::Uninitialized };
style::icon historyViewsIcon = { Qt::Uninitialized };
style::icon historyForwardsIcon = {Qt::Uninitialized};
style::icon historyPinIcon = { Qt::Uninitialized };
style::icon historySentIcon = { Qt::Uninitialized };
style::icon historyReceivedIcon = { Qt::Uninitialized };
@ -365,6 +366,9 @@ public:
[[nodiscard]] const style::icon &historyViewsInvertedIcon() const {
return _historyViewsInvertedIcon;
}
[[nodiscard]] const style::icon &historyForwardsInvertedIcon() const {
return _historyForwardsInvertedIcon;
}
[[nodiscard]] const style::icon &historyViewsSendingIcon() const {
return _historyViewsSendingIcon;
}
@ -534,6 +538,7 @@ private:
style::icon _historyViewsInvertedIcon = { Qt::Uninitialized };
style::icon _historyViewsSendingIcon = { Qt::Uninitialized };
style::icon _historyViewsSendingInvertedIcon = { Qt::Uninitialized };
style::icon _historyForwardsInvertedIcon = {Qt::Uninitialized};
style::icon _historyPinInvertedIcon = { Qt::Uninitialized };
style::icon _historySendingIcon = { Qt::Uninitialized };
style::icon _historySendingInvertedIcon = { Qt::Uninitialized };