mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 05:07:10 +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
|
||||
;
|
||||
simpleQuotesAndReplies = true;
|
||||
replaceBottomInfoWithIcons = true;
|
||||
deletedMark = "🧹";
|
||||
editedMark = Core::IsAppLaunched() ? tr::lng_edited(tr::now) : QString("edited");
|
||||
recentStickersCount = 100;
|
||||
|
@ -419,6 +420,10 @@ void AyuGramSettings::set_simpleQuotesAndReplies(bool val) {
|
|||
simpleQuotesAndReplies = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_replaceBottomInfoWithIcons(bool val) {
|
||||
replaceBottomInfoWithIcons = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_deletedMark(QString val) {
|
||||
deletedMark = std::move(val);
|
||||
deletedMarkReactive = deletedMark;
|
||||
|
|
|
@ -51,6 +51,7 @@ public:
|
|||
|
||||
QString appIcon;
|
||||
bool simpleQuotesAndReplies;
|
||||
bool replaceBottomInfoWithIcons;
|
||||
QString deletedMark;
|
||||
QString editedMark;
|
||||
int recentStickersCount;
|
||||
|
@ -130,6 +131,7 @@ public:
|
|||
|
||||
void set_appIcon(QString val);
|
||||
void set_simpleQuotesAndReplies(bool val);
|
||||
void set_replaceBottomInfoWithIcons(bool val);
|
||||
void set_deletedMark(QString val);
|
||||
void set_editedMark(QString val);
|
||||
void set_recentStickersCount(int val);
|
||||
|
@ -201,6 +203,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
|
|||
localPremium,
|
||||
appIcon,
|
||||
simpleQuotesAndReplies,
|
||||
replaceBottomInfoWithIcons,
|
||||
deletedMark,
|
||||
editedMark,
|
||||
recentStickersCount,
|
||||
|
|
|
@ -34,3 +34,9 @@ infoExteraOfficialBadge: icon {{ "ayu/extera_official", profileVerifiedCheckBg }
|
|||
infoExteraSupporterBadge: icon {{ "ayu/extera_badge", profileVerifiedCheckBg }};
|
||||
|
||||
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) {
|
||||
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(
|
||||
container,
|
||||
tr::ayu_DeletedMarkText(),
|
||||
|
|
|
@ -3092,31 +3092,7 @@ bool HistoryItem::isDeleted() const {
|
|||
|
||||
void HistoryItem::setAyuHint(const QString &hint) {
|
||||
try {
|
||||
if (!(_flags & MessageFlag::HasPostAuthor)) {
|
||||
_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 {
|
||||
if (isService()) {
|
||||
const auto data = Get<HistoryServiceData>();
|
||||
const auto postfix = QString(" (%1)").arg(hint);
|
||||
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().requestItemResize(this);
|
||||
} catch (...) {
|
||||
|
|
|
@ -33,6 +33,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
#include "ayu/features/messageshot/message_shot.h"
|
||||
#include "core/ui_integration.h"
|
||||
#include "styles/style_ayu_icons.h"
|
||||
|
||||
|
||||
namespace HistoryView {
|
||||
|
@ -412,39 +414,111 @@ void BottomInfo::layout() {
|
|||
void BottomInfo::layoutDateText() {
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
|
||||
const auto edited = (_data.flags & Data::Flag::Edited)
|
||||
? (settings->editedMark + ' ')
|
||||
: (_data.flags & Data::Flag::EstimateDate)
|
||||
? (tr::lng_approximate(tr::now) + ' ')
|
||||
: QString();
|
||||
const auto author = _data.author;
|
||||
const auto prefix = !author.isEmpty() ? (author == settings->deletedMark ? u" "_q : u", "_q) : QString();
|
||||
const auto date = edited + QLocale().toString(
|
||||
_data.date.time(),
|
||||
settings->showMessageSeconds
|
||||
? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t")
|
||||
: QLocale::system().timeFormat(QLocale::ShortFormat)
|
||||
);
|
||||
const auto afterAuthor = prefix + date;
|
||||
const auto afterAuthorWidth = st::msgDateFont->width(afterAuthor);
|
||||
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;
|
||||
const auto full = (_data.flags & Data::Flag::Sponsored)
|
||||
? QString()
|
||||
: (_data.flags & Data::Flag::Imported)
|
||||
? (date + ' ' + tr::lng_imported(tr::now))
|
||||
: name.isEmpty()
|
||||
? date
|
||||
: (name + afterAuthor);
|
||||
_authorEditedDate.setText(
|
||||
st::msgDateTextStyle,
|
||||
full,
|
||||
Ui::NameTextOptions());
|
||||
if (!settings->replaceBottomInfoWithIcons) {
|
||||
const auto deleted = (_data.flags & Data::Flag::AyuDeleted)
|
||||
? (settings->deletedMark + ' ')
|
||||
: QString();
|
||||
const auto edited = (_data.flags & Data::Flag::Edited)
|
||||
? (settings->editedMark + ' ')
|
||||
: (_data.flags & Data::Flag::EstimateDate)
|
||||
? (tr::lng_approximate(tr::now) + ' ')
|
||||
: QString();
|
||||
const auto author = _data.author;
|
||||
const auto prefix = !author.isEmpty() ? u", "_q : QString();
|
||||
const auto date = edited + QLocale().toString(
|
||||
_data.date.time(),
|
||||
settings->showMessageSeconds
|
||||
? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t")
|
||||
: QLocale::system().timeFormat(QLocale::ShortFormat)
|
||||
);
|
||||
const auto afterAuthor = prefix + date;
|
||||
const auto afterAuthorWidth = st::msgDateFont->width(afterAuthor);
|
||||
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;
|
||||
const auto full = (_data.flags & Data::Flag::Sponsored)
|
||||
? QString()
|
||||
: (_data.flags & Data::Flag::Imported)
|
||||
? (deleted + date + ' ' + tr::lng_imported(tr::now))
|
||||
: name.isEmpty()
|
||||
? (deleted + date)
|
||||
: (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() {
|
||||
|
@ -616,6 +690,9 @@ BottomInfo::Data BottomInfoDataFromMessage(not_null<Message*> message) {
|
|||
if (item->awaitingVideoProcessing()) {
|
||||
result.flags |= Flag::EstimateDate;
|
||||
}
|
||||
if (item->isDeleted()) {
|
||||
result.flags |= Flag::AyuDeleted;
|
||||
}
|
||||
// We don't want to pass and update it in Data for now.
|
||||
//if (item->unread()) {
|
||||
// result.flags |= Flag::Unread;
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
Imported = 0x040,
|
||||
Shortcut = 0x080,
|
||||
EstimateDate = 0x100,
|
||||
AyuDeleted = 0x200,
|
||||
//Unread, // We don't want to pass and update it in Date for now.
|
||||
};
|
||||
friend inline constexpr bool is_flag_type(Flag) { return true; };
|
||||
|
|
Loading…
Add table
Reference in a new issue