mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
feat: replace "edited" & "deleted" with icons
This commit is contained in:
parent
4926735ae1
commit
ab26e3d4fa
13 changed files with 148 additions and 58 deletions
BIN
Telegram/Resources/icons/ayu/edited.png
Normal file
BIN
Telegram/Resources/icons/ayu/edited.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 264 B |
BIN
Telegram/Resources/icons/ayu/edited@2x.png
Normal file
BIN
Telegram/Resources/icons/ayu/edited@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 401 B |
BIN
Telegram/Resources/icons/ayu/edited@3x.png
Normal file
BIN
Telegram/Resources/icons/ayu/edited@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 527 B |
BIN
Telegram/Resources/icons/ayu/trash_bin.png
Normal file
BIN
Telegram/Resources/icons/ayu/trash_bin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 285 B |
BIN
Telegram/Resources/icons/ayu/trash_bin@2x.png
Normal file
BIN
Telegram/Resources/icons/ayu/trash_bin@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 417 B |
BIN
Telegram/Resources/icons/ayu/trash_bin@3x.png
Normal file
BIN
Telegram/Resources/icons/ayu/trash_bin@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 492 B |
|
@ -240,6 +240,7 @@ AyuGramSettings::AyuGramSettings() {
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
simpleQuotesAndReplies = true;
|
simpleQuotesAndReplies = true;
|
||||||
|
replaceBottomInfoWithIcons = true;
|
||||||
deletedMark = "🧹";
|
deletedMark = "🧹";
|
||||||
editedMark = Core::IsAppLaunched() ? tr::lng_edited(tr::now) : QString("edited");
|
editedMark = Core::IsAppLaunched() ? tr::lng_edited(tr::now) : QString("edited");
|
||||||
recentStickersCount = 100;
|
recentStickersCount = 100;
|
||||||
|
@ -419,6 +420,10 @@ void AyuGramSettings::set_simpleQuotesAndReplies(bool val) {
|
||||||
simpleQuotesAndReplies = val;
|
simpleQuotesAndReplies = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AyuGramSettings::set_replaceBottomInfoWithIcons(bool val) {
|
||||||
|
replaceBottomInfoWithIcons = val;
|
||||||
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_deletedMark(QString val) {
|
void AyuGramSettings::set_deletedMark(QString val) {
|
||||||
deletedMark = std::move(val);
|
deletedMark = std::move(val);
|
||||||
deletedMarkReactive = deletedMark;
|
deletedMarkReactive = deletedMark;
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
|
|
||||||
QString appIcon;
|
QString appIcon;
|
||||||
bool simpleQuotesAndReplies;
|
bool simpleQuotesAndReplies;
|
||||||
|
bool replaceBottomInfoWithIcons;
|
||||||
QString deletedMark;
|
QString deletedMark;
|
||||||
QString editedMark;
|
QString editedMark;
|
||||||
int recentStickersCount;
|
int recentStickersCount;
|
||||||
|
@ -130,6 +131,7 @@ public:
|
||||||
|
|
||||||
void set_appIcon(QString val);
|
void set_appIcon(QString val);
|
||||||
void set_simpleQuotesAndReplies(bool val);
|
void set_simpleQuotesAndReplies(bool val);
|
||||||
|
void set_replaceBottomInfoWithIcons(bool val);
|
||||||
void set_deletedMark(QString val);
|
void set_deletedMark(QString val);
|
||||||
void set_editedMark(QString val);
|
void set_editedMark(QString val);
|
||||||
void set_recentStickersCount(int val);
|
void set_recentStickersCount(int val);
|
||||||
|
@ -201,6 +203,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
|
||||||
localPremium,
|
localPremium,
|
||||||
appIcon,
|
appIcon,
|
||||||
simpleQuotesAndReplies,
|
simpleQuotesAndReplies,
|
||||||
|
replaceBottomInfoWithIcons,
|
||||||
deletedMark,
|
deletedMark,
|
||||||
editedMark,
|
editedMark,
|
||||||
recentStickersCount,
|
recentStickersCount,
|
||||||
|
|
|
@ -34,3 +34,9 @@ infoExteraOfficialBadge: icon {{ "ayu/extera_official", profileVerifiedCheckBg }
|
||||||
infoExteraSupporterBadge: icon {{ "ayu/extera_badge", profileVerifiedCheckBg }};
|
infoExteraSupporterBadge: icon {{ "ayu/extera_badge", profileVerifiedCheckBg }};
|
||||||
|
|
||||||
winEnterWithGuestIcon: icon {{ "ayu/ghost_tray", windowFg }};
|
winEnterWithGuestIcon: icon {{ "ayu/ghost_tray", windowFg }};
|
||||||
|
|
||||||
|
editedIcon: icon {{ "ayu/edited", windowFg }};
|
||||||
|
editedIconPadding: margins(0px, 0px, 0px, 0px);
|
||||||
|
|
||||||
|
deletedIcon: icon {{ "ayu/trash_bin", windowFg }};
|
||||||
|
deletedIconPadding: margins(0px, 0px, 0px, 0px);
|
||||||
|
|
|
@ -1456,6 +1456,27 @@ void SetupSendConfirmations(not_null<Ui::VerticalLayout*> container) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupMarks(not_null<Ui::VerticalLayout*> container) {
|
void SetupMarks(not_null<Ui::VerticalLayout*> container) {
|
||||||
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
|
AddButtonWithIcon(
|
||||||
|
container,
|
||||||
|
rpl::single(QString("Replace with Icons")),
|
||||||
|
st::settingsButtonNoIcon
|
||||||
|
)->toggleOn(
|
||||||
|
rpl::single(settings->replaceBottomInfoWithIcons)
|
||||||
|
)->toggledValue(
|
||||||
|
) | rpl::filter(
|
||||||
|
[=](bool enabled)
|
||||||
|
{
|
||||||
|
return (enabled != settings->replaceBottomInfoWithIcons);
|
||||||
|
}) | start_with_next(
|
||||||
|
[=](bool enabled)
|
||||||
|
{
|
||||||
|
settings->set_replaceBottomInfoWithIcons(enabled);
|
||||||
|
AyuSettings::save();
|
||||||
|
},
|
||||||
|
container->lifetime());
|
||||||
|
|
||||||
AddButtonWithLabel(
|
AddButtonWithLabel(
|
||||||
container,
|
container,
|
||||||
tr::ayu_DeletedMarkText(),
|
tr::ayu_DeletedMarkText(),
|
||||||
|
|
|
@ -3092,31 +3092,7 @@ bool HistoryItem::isDeleted() const {
|
||||||
|
|
||||||
void HistoryItem::setAyuHint(const QString &hint) {
|
void HistoryItem::setAyuHint(const QString &hint) {
|
||||||
try {
|
try {
|
||||||
if (!(_flags & MessageFlag::HasPostAuthor)) {
|
if (isService()) {
|
||||||
_flags |= MessageFlag::HasPostAuthor;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto msgsigned = Get<HistoryMessageSigned>();
|
|
||||||
if (hint.isEmpty()) {
|
|
||||||
if (!msgsigned) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
RemoveComponents(HistoryMessageSigned::Bit());
|
|
||||||
history()->owner().requestItemResize(this);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isService()) {
|
|
||||||
if (!msgsigned) {
|
|
||||||
AddComponents(HistoryMessageSigned::Bit());
|
|
||||||
msgsigned = Get<HistoryMessageSigned>();
|
|
||||||
} else if (msgsigned->author == hint) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
msgsigned->author = hint;
|
|
||||||
msgsigned->isAnonymousRank = !isDiscussionPost()
|
|
||||||
&& this->author()->isMegagroup();
|
|
||||||
} else {
|
|
||||||
const auto data = Get<HistoryServiceData>();
|
const auto data = Get<HistoryServiceData>();
|
||||||
const auto postfix = QString(" (%1)").arg(hint);
|
const auto postfix = QString(" (%1)").arg(hint);
|
||||||
if (!_text.text.endsWith(postfix)) { // fix stacking for TTL messages
|
if (!_text.text.endsWith(postfix)) { // fix stacking for TTL messages
|
||||||
|
@ -3128,6 +3104,7 @@ void HistoryItem::setAyuHint(const QString &hint) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update bottom info
|
||||||
history()->owner().requestItemViewRefresh(this);
|
history()->owner().requestItemViewRefresh(this);
|
||||||
history()->owner().requestItemResize(this);
|
history()->owner().requestItemResize(this);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
|
@ -33,6 +33,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
// AyuGram includes
|
// AyuGram includes
|
||||||
#include "ayu/ayu_settings.h"
|
#include "ayu/ayu_settings.h"
|
||||||
#include "ayu/features/messageshot/message_shot.h"
|
#include "ayu/features/messageshot/message_shot.h"
|
||||||
|
#include "core/ui_integration.h"
|
||||||
|
#include "styles/style_ayu_icons.h"
|
||||||
|
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
|
@ -412,39 +414,111 @@ void BottomInfo::layout() {
|
||||||
void BottomInfo::layoutDateText() {
|
void BottomInfo::layoutDateText() {
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
const auto edited = (_data.flags & Data::Flag::Edited)
|
if (!settings->replaceBottomInfoWithIcons) {
|
||||||
? (settings->editedMark + ' ')
|
const auto deleted = (_data.flags & Data::Flag::AyuDeleted)
|
||||||
: (_data.flags & Data::Flag::EstimateDate)
|
? (settings->deletedMark + ' ')
|
||||||
? (tr::lng_approximate(tr::now) + ' ')
|
: QString();
|
||||||
: QString();
|
const auto edited = (_data.flags & Data::Flag::Edited)
|
||||||
const auto author = _data.author;
|
? (settings->editedMark + ' ')
|
||||||
const auto prefix = !author.isEmpty() ? (author == settings->deletedMark ? u" "_q : u", "_q) : QString();
|
: (_data.flags & Data::Flag::EstimateDate)
|
||||||
const auto date = edited + QLocale().toString(
|
? (tr::lng_approximate(tr::now) + ' ')
|
||||||
_data.date.time(),
|
: QString();
|
||||||
settings->showMessageSeconds
|
const auto author = _data.author;
|
||||||
? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t")
|
const auto prefix = !author.isEmpty() ? u", "_q : QString();
|
||||||
: QLocale::system().timeFormat(QLocale::ShortFormat)
|
const auto date = edited + QLocale().toString(
|
||||||
);
|
_data.date.time(),
|
||||||
const auto afterAuthor = prefix + date;
|
settings->showMessageSeconds
|
||||||
const auto afterAuthorWidth = st::msgDateFont->width(afterAuthor);
|
? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t")
|
||||||
const auto authorWidth = st::msgDateFont->width(author);
|
: QLocale::system().timeFormat(QLocale::ShortFormat)
|
||||||
const auto maxWidth = st::maxSignatureSize;
|
);
|
||||||
_authorElided = !author.isEmpty()
|
const auto afterAuthor = prefix + date;
|
||||||
&& (authorWidth + afterAuthorWidth > maxWidth);
|
const auto afterAuthorWidth = st::msgDateFont->width(afterAuthor);
|
||||||
const auto name = _authorElided
|
const auto authorWidth = st::msgDateFont->width(author);
|
||||||
? st::msgDateFont->elided(author, maxWidth - afterAuthorWidth)
|
const auto maxWidth = st::maxSignatureSize;
|
||||||
: author;
|
_authorElided = !author.isEmpty()
|
||||||
const auto full = (_data.flags & Data::Flag::Sponsored)
|
&& (authorWidth + afterAuthorWidth > maxWidth);
|
||||||
? QString()
|
const auto name = _authorElided
|
||||||
: (_data.flags & Data::Flag::Imported)
|
? st::msgDateFont->elided(author, maxWidth - afterAuthorWidth)
|
||||||
? (date + ' ' + tr::lng_imported(tr::now))
|
: author;
|
||||||
: name.isEmpty()
|
const auto full = (_data.flags & Data::Flag::Sponsored)
|
||||||
? date
|
? QString()
|
||||||
: (name + afterAuthor);
|
: (_data.flags & Data::Flag::Imported)
|
||||||
_authorEditedDate.setText(
|
? (deleted + date + ' ' + tr::lng_imported(tr::now))
|
||||||
st::msgDateTextStyle,
|
: name.isEmpty()
|
||||||
full,
|
? (deleted + date)
|
||||||
Ui::NameTextOptions());
|
: (deleted + name + afterAuthor);
|
||||||
|
_authorEditedDate.setText(
|
||||||
|
st::msgDateTextStyle,
|
||||||
|
full,
|
||||||
|
Ui::NameTextOptions());
|
||||||
|
} else {
|
||||||
|
TextWithEntities deleted;
|
||||||
|
if (_data.flags & Data::Flag::AyuDeleted) {
|
||||||
|
const auto &icon = st::deletedIcon;
|
||||||
|
const auto padding = st::deletedIconPadding;
|
||||||
|
const auto owner = &_reactionsOwner->owner();
|
||||||
|
auto added = Ui::Text::SingleCustomEmoji(
|
||||||
|
owner->customEmojiManager().registerInternalEmoji(icon, padding)
|
||||||
|
);
|
||||||
|
deleted = Ui::Text::Colorized(added, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextWithEntities edited;
|
||||||
|
if (_data.flags & Data::Flag::Edited) {
|
||||||
|
const auto &icon = st::editedIcon;
|
||||||
|
const auto padding = st::editedIconPadding;
|
||||||
|
const auto owner = &_reactionsOwner->owner();
|
||||||
|
auto added = Ui::Text::SingleCustomEmoji(
|
||||||
|
owner->customEmojiManager().registerInternalEmoji(icon, padding)
|
||||||
|
);
|
||||||
|
edited = Ui::Text::Colorized(added, 1);
|
||||||
|
} else if (_data.flags & Data::Flag::EstimateDate) {
|
||||||
|
edited = TextWithEntities{ tr::lng_approximate(tr::now) + ' ' };
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto author = _data.author;
|
||||||
|
const auto prefix = !author.isEmpty() ? u", "_q : QString();
|
||||||
|
|
||||||
|
const auto date = TextWithEntities{}.append(edited).append(QLocale().toString(
|
||||||
|
_data.date.time(),
|
||||||
|
settings->showMessageSeconds
|
||||||
|
? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t")
|
||||||
|
: QLocale::system().timeFormat(QLocale::ShortFormat)
|
||||||
|
));
|
||||||
|
|
||||||
|
const auto afterAuthor = TextWithEntities{}.append(prefix).append(date);
|
||||||
|
const auto afterAuthorWidth = st::msgDateFont->width(afterAuthor.text);
|
||||||
|
const auto authorWidth = st::msgDateFont->width(author);
|
||||||
|
const auto maxWidth = st::maxSignatureSize;
|
||||||
|
_authorElided = !author.isEmpty()
|
||||||
|
&& (authorWidth + afterAuthorWidth > maxWidth);
|
||||||
|
const auto name = _authorElided
|
||||||
|
? st::msgDateFont->elided(author, maxWidth - afterAuthorWidth)
|
||||||
|
: author;
|
||||||
|
|
||||||
|
auto full = TextWithEntities{};
|
||||||
|
if (_data.flags & Data::Flag::Sponsored) {
|
||||||
|
// ...
|
||||||
|
} else if (_data.flags & Data::Flag::Imported) {
|
||||||
|
full.append(deleted).append(date).append(' ').append(tr::lng_imported(tr::now));
|
||||||
|
} else if (name.isEmpty()) {
|
||||||
|
full.append(deleted).append(date);
|
||||||
|
} else {
|
||||||
|
full.append(deleted).append(name).append(afterAuthor);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto context = Core::MarkedTextContext{
|
||||||
|
.session = &_reactionsOwner->session(),
|
||||||
|
.customEmojiRepaint = [] {},
|
||||||
|
.customEmojiLoopLimit = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
_authorEditedDate.setMarkedText(
|
||||||
|
st::msgDateTextStyle,
|
||||||
|
full,
|
||||||
|
Ui::NameTextOptions(),
|
||||||
|
context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BottomInfo::layoutViewsText() {
|
void BottomInfo::layoutViewsText() {
|
||||||
|
@ -616,6 +690,9 @@ BottomInfo::Data BottomInfoDataFromMessage(not_null<Message*> message) {
|
||||||
if (item->awaitingVideoProcessing()) {
|
if (item->awaitingVideoProcessing()) {
|
||||||
result.flags |= Flag::EstimateDate;
|
result.flags |= Flag::EstimateDate;
|
||||||
}
|
}
|
||||||
|
if (item->isDeleted()) {
|
||||||
|
result.flags |= Flag::AyuDeleted;
|
||||||
|
}
|
||||||
// We don't want to pass and update it in Data for now.
|
// We don't want to pass and update it in Data for now.
|
||||||
//if (item->unread()) {
|
//if (item->unread()) {
|
||||||
// result.flags |= Flag::Unread;
|
// result.flags |= Flag::Unread;
|
||||||
|
|
|
@ -42,6 +42,7 @@ public:
|
||||||
Imported = 0x040,
|
Imported = 0x040,
|
||||||
Shortcut = 0x080,
|
Shortcut = 0x080,
|
||||||
EstimateDate = 0x100,
|
EstimateDate = 0x100,
|
||||||
|
AyuDeleted = 0x200,
|
||||||
//Unread, // We don't want to pass and update it in Date for now.
|
//Unread, // We don't want to pass and update it in Date for now.
|
||||||
};
|
};
|
||||||
friend inline constexpr bool is_flag_type(Flag) { return true; };
|
friend inline constexpr bool is_flag_type(Flag) { return true; };
|
||||||
|
|
Loading…
Add table
Reference in a new issue