Compare commits

...

12 Commits

Author SHA1 Message Date
Ivan Romanov ba8c1a6b0f fix: saving hide premium statuses to config file 2026-07-02 18:03:27 +03:00
AlexeyZavar 0b02f28818 fix: possible translator crash 2026-07-02 16:53:53 +03:00
AlexeyZavar 9d5fa2358b fix: possible AyuForward crash 2026-07-02 16:53:53 +03:00
AlexeyZavar 6faf41994e fix: apply message rounding in more places 2026-07-02 16:53:53 +03:00
AlexeyZavar 34bfeb7058 fix: avoid opening scheduled section 2026-07-02 16:50:55 +03:00
AlexeyZavar d83cb2cd72 fix: confirmation box overlap 2026-07-02 16:50:55 +03:00
AlexeyZavar dc437d43f2 feat: avoid closing context menu/reaction selector with CTRL/SHIFT 2026-07-02 16:50:55 +03:00
Ireina 21775bd509 feat: add disable Greeting Sticker 2026-06-17 09:45:46 +03:00
Ireina f3f6b349ea feat: filter inline bot messages from blocked bots 2026-06-17 09:45:46 +03:00
Ireina 4de4665fc3 chore: disable phone sharing by default when adding contacts 2026-06-17 09:45:46 +03:00
Ireina 3c50e06dcc fix: copy summary text instead of original when summary is shown 2026-06-17 09:45:46 +03:00
Ireina 4a277eee39 fix: subtract one hour from message date in bubble preview 2026-06-17 09:04:19 +03:00
20 changed files with 167 additions and 59 deletions
+1
View File
@@ -8050,6 +8050,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ayu_HideReactionsInGroups" = "Groups";
"ayu_HideReactionsInPrivateChats" = "Private Chats";
"ayu_QuickAdminShortcuts" = "Quick Admin Shortcuts";
"ayu_DisableGreetingSticker" = "Disable Greeting Sticker";
"ayu_TranslationProvider" = "Translation Provider";
"ayu_LinksHeader" = "Links";
"ayu_LinksChannel" = "Channel";
+10
View File
@@ -963,6 +963,12 @@ void AyuSettings::setQuickAdminShortcuts(bool val) {
save();
}
void AyuSettings::setDisableGreetingSticker(bool val) {
if (_disableGreetingSticker.current() == val) return;
_disableGreetingSticker = val;
save();
}
void AyuSettings::setShowPeerId(PeerIdDisplay val) {
if (_showPeerId.current() == val) return;
_showPeerId = val;
@@ -1070,6 +1076,7 @@ void to_json(nlohmann::json &j, const AyuSettings &s) {
{"disableAds", s._disableAds.current()},
{"disableStories", s._disableStories.current()},
{"disableCustomBackgrounds", s._disableCustomBackgrounds.current()},
{"hidePremiumStatuses", s._hidePremiumStatuses.current()},
{"showOnlyAddedEmojisAndStickers", s._showOnlyAddedEmojisAndStickers.current()},
{"collapseSimilarChannels", s._collapseSimilarChannels.current()},
{"hideSimilarChannels", s._hideSimilarChannels.current()},
@@ -1129,6 +1136,7 @@ void to_json(nlohmann::json &j, const AyuSettings &s) {
{"hideAllChatsFolder", s._hideAllChatsFolder.current()},
{"channelBottomButton", s._channelBottomButton.current()},
{"quickAdminShortcuts", s._quickAdminShortcuts.current()},
{"disableGreetingSticker", s._disableGreetingSticker.current()},
{"showPeerId", s._showPeerId.current()},
{"showMessageSeconds", s._showMessageSeconds.current()},
{"showMessageShot", s._showMessageShot.current()},
@@ -1170,6 +1178,7 @@ void from_json(const nlohmann::json &j, AyuSettings &s) {
s._disableAds = j.value("disableAds", defaults._disableAds.current());
s._disableStories = j.value("disableStories", defaults._disableStories.current());
s._disableCustomBackgrounds = j.value("disableCustomBackgrounds", defaults._disableCustomBackgrounds.current());
s._hidePremiumStatuses = j.value("hidePremiumStatuses", defaults._hidePremiumStatuses.current());
s._showOnlyAddedEmojisAndStickers = j.value("showOnlyAddedEmojisAndStickers", defaults._showOnlyAddedEmojisAndStickers.current());
s._collapseSimilarChannels = j.value("collapseSimilarChannels", defaults._collapseSimilarChannels.current());
s._hideSimilarChannels = j.value("hideSimilarChannels", defaults._hideSimilarChannels.current());
@@ -1229,6 +1238,7 @@ void from_json(const nlohmann::json &j, AyuSettings &s) {
s._hideAllChatsFolder = j.value("hideAllChatsFolder", defaults._hideAllChatsFolder.current());
s._channelBottomButton = j.value("channelBottomButton", defaults._channelBottomButton.current());
s._quickAdminShortcuts = j.value("quickAdminShortcuts", defaults._quickAdminShortcuts.current());
s._disableGreetingSticker = j.value("disableGreetingSticker", defaults._disableGreetingSticker.current());
s._showPeerId = j.value("showPeerId", defaults._showPeerId.current());
s._showMessageSeconds = j.value("showMessageSeconds", defaults._showMessageSeconds.current());
s._showMessageShot = j.value("showMessageShot", defaults._showMessageShot.current());
+5
View File
@@ -337,6 +337,7 @@ public:
[[nodiscard]] bool hideAllChatsFolder() const { return _hideAllChatsFolder.current(); }
[[nodiscard]] ChannelBottomButton channelBottomButton() const { return _channelBottomButton.current(); }
[[nodiscard]] bool quickAdminShortcuts() const { return _quickAdminShortcuts.current(); }
[[nodiscard]] bool disableGreetingSticker() const { return _disableGreetingSticker.current(); }
[[nodiscard]] PeerIdDisplay showPeerId() const { return _showPeerId.current(); }
[[nodiscard]] bool showMessageSeconds() const { return _showMessageSeconds.current(); }
[[nodiscard]] bool showMessageShot() const { return _showMessageShot.current(); }
@@ -421,6 +422,7 @@ public:
void setHideAllChatsFolder(bool val);
void setChannelBottomButton(ChannelBottomButton val);
void setQuickAdminShortcuts(bool val);
void setDisableGreetingSticker(bool val);
void setShowPeerId(PeerIdDisplay val);
void setShowMessageSeconds(bool val);
void setShowMessageShot(bool val);
@@ -577,6 +579,8 @@ public:
[[nodiscard]] rpl::producer<ChannelBottomButton> channelBottomButtonChanges() const { return _channelBottomButton.changes(); }
[[nodiscard]] rpl::producer<bool> quickAdminShortcutsValue() const { return _quickAdminShortcuts.value(); }
[[nodiscard]] rpl::producer<bool> quickAdminShortcutsChanges() const { return _quickAdminShortcuts.changes(); }
[[nodiscard]] rpl::producer<bool> disableGreetingStickerValue() const { return _disableGreetingSticker.value(); }
[[nodiscard]] rpl::producer<bool> disableGreetingStickerChanges() const { return _disableGreetingSticker.changes(); }
[[nodiscard]] rpl::producer<PeerIdDisplay> showPeerIdValue() const { return _showPeerId.value(); }
[[nodiscard]] rpl::producer<PeerIdDisplay> showPeerIdChanges() const { return _showPeerId.changes(); }
[[nodiscard]] rpl::producer<bool> showMessageSecondsValue() const { return _showMessageSeconds.value(); }
@@ -683,6 +687,7 @@ private:
rpl::variable<bool> _hideAllChatsFolder = false;
rpl::variable<ChannelBottomButton> _channelBottomButton = ChannelBottomButton::DiscussWithFallback;
rpl::variable<bool> _quickAdminShortcuts = true;
rpl::variable<bool> _disableGreetingSticker = false;
rpl::variable<PeerIdDisplay> _showPeerId = PeerIdDisplay::BotApi;
rpl::variable<bool> _showMessageSeconds = false;
rpl::variable<bool> _showMessageShot = true;
@@ -33,6 +33,11 @@ bool filterBlocked(const not_null<HistoryItem*> item) {
return true;
}
}
if (const auto bot = item->viaBot()) {
if (isBlocked(bot)) {
return true;
}
}
return false;
}
@@ -190,7 +190,7 @@ void loadPhotoSync(not_null<Main::Session*> session, const std::pair<not_null<Ph
const auto finalCheck = [=]
{
return !photo.first->loading();
return view->loaded();
};
const auto saveToFiles = [=]
@@ -8,6 +8,7 @@
#include "api/api_text_entities.h"
#include "ayu/features/translator/ayu_translator.h"
#include "base/weak_ptr.h"
#include "data/data_msg_id.h"
#include "data/data_peer.h"
#include "data/data_session.h"
@@ -17,7 +18,9 @@
namespace {
class AyuTranslateProvider final : public Ui::TranslateProvider {
class AyuTranslateProvider final
: public Ui::TranslateProvider
, public base::has_weak_ptr {
public:
AyuTranslateProvider(
not_null<Main::Session*> session,
@@ -48,6 +51,18 @@ public:
const LanguageId &to,
Fn<void(int, Ui::TranslateProviderResult)> doneOne,
Fn<void()> doneAll) override {
doneOne = [weak = base::make_weak(this), doneOne = std::move(doneOne)](
int index,
Ui::TranslateProviderResult result) {
if (weak) {
doneOne(index, std::move(result));
}
};
doneAll = [weak = base::make_weak(this), doneAll = std::move(doneAll)] {
if (weak) {
doneAll();
}
};
if (requests.empty()) {
doneAll();
return;
@@ -85,7 +85,7 @@ MessagePreview::MessagePreview(
.replyTo = FullReplyTo{
.messageId = _state->reply->data()->fullId(),
},
.date = base::unixtime::now(),
.date = base::unixtime::now() - 3600,
}, TextWithEntities{ u"You need to go outside and touch some grass..."_q },
MTP_messageMediaEmpty());
@@ -204,7 +204,6 @@ void BuildAppearance(SectionBuilder &builder, AyuSectionBuilder &ayu) {
.getter = &AyuSettings::disableCustomBackgrounds,
.setter = &AyuSettings::setDisableCustomBackgrounds,
});
ayu.addSettingToggle({
.id = u"ayu/hidePremiumStatuses"_q,
.title = tr::ayu_HidePremiumStatuses(),
@@ -117,6 +117,12 @@ void BuildGroupsAndChannels(SectionBuilder &builder, AyuSectionBuilder &ayu) {
.getter = &AyuSettings::quickAdminShortcuts,
.setter = &AyuSettings::setQuickAdminShortcuts,
});
ayu.addSettingToggle({
.id = u"ayu/disableGreetingSticker"_q,
.title = tr::ayu_DisableGreetingSticker(),
.getter = &AyuSettings::disableGreetingSticker,
.setter = &AyuSettings::setDisableGreetingSticker,
});
ayu.addSettingToggle({
.id = u"ayu/showMessageShot"_q,
.title = tr::ayu_SettingsShowMessageShot(),
@@ -783,7 +783,7 @@ void Controller::setupSharePhoneNumber() {
object_ptr<Ui::Checkbox>(
_box,
tr::lng_contact_share_phone(tr::now),
true,
false,
st::defaultBoxCheckbox),
st::addContactWarningMargin);
_box->addRow(
@@ -548,7 +548,7 @@ void GifsListWidget::selectInlineResult(
const auto &settings = AyuSettings::getInstance();
if (settings.gifConfirmation()) {
Ui::show(Ui::MakeConfirmBox({
_show->showBox(Ui::MakeConfirmBox({
.text = tr::ayu_ConfirmationGIF(),
.confirmed = sendGIFCallback,
.confirmText = tr::lng_send_button()
@@ -2300,7 +2300,7 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
});
if (settings.stickerConfirmation() && (_mode == Mode::Full || _mode == Mode::ChatIntro) && _requireConfirmation) {
Ui::show(Ui::MakeConfirmBox({
_show->showBox(Ui::MakeConfirmBox({
.text = tr::ayu_ConfirmationSticker(),
.confirmed = sendStickerCallback,
.confirmText = tr::lng_send_button()
@@ -16,7 +16,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "ui/text/text_options.h"
// AyuGram includes
#include "api/api_transcribes.h"
TextForMimeData HistoryItemText(not_null<HistoryItem*> item) {
const auto &summary = item->summaryEntry();
if (!summary.result.empty() && summary.shown) {
return TextForMimeData::WithExpandedLinks(summary.result);
}
const auto media = item->media();
auto mediaResult = media ? media->clipboardText() : TextForMimeData();
@@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "api/api_premium.h"
#include "api/api_sending.h"
#include "apiwrap.h"
#include "ayu/ayu_settings.h"
#include "base/random.h"
#include "base/unixtime.h"
#include "ui/effects/premium_stars.h"
@@ -268,6 +269,7 @@ auto GenerateChatIntro(
st::defaultTextStyle,
links));
};
const auto disableGreeting = AyuSettings::getInstance().disableGreetingSticker();
const auto title = data.customPhrases()
? data.title
: tr::lng_chat_intro_default_title(tr::now);
@@ -275,37 +277,41 @@ auto GenerateChatIntro(
? data.description
: tr::lng_chat_intro_default_message(tr::now);
pushText(tr::bold(title), st::chatIntroTitleMargin);
pushText({ description }, title.isEmpty()
? st::chatIntroTitleMargin
: st::chatIntroMargin);
const auto sticker = [=] {
using Tag = ChatHelpers::StickerLottieSize;
auto sticker = data.sticker;
if (!sticker) {
const auto api = &parent->history()->session().api();
const auto &list = api->premium().helloStickers();
if (!list.empty()) {
sticker = list[base::RandomIndex(list.size())];
if (helloChosen) {
helloChosen(sticker);
if (!disableGreeting || data.customPhrases()) {
pushText({ description }, title.isEmpty()
? st::chatIntroTitleMargin
: st::chatIntroMargin);
}
if (!disableGreeting || data.sticker) {
const auto sticker = [=] {
using Tag = ChatHelpers::StickerLottieSize;
auto sticker = data.sticker;
if (!sticker && !disableGreeting) {
const auto api = &parent->history()->session().api();
const auto &list = api->premium().helloStickers();
if (!list.empty()) {
sticker = list[base::RandomIndex(list.size())];
if (helloChosen) {
helloChosen(sticker);
}
}
}
}
const auto send = [=] {
sendIntroSticker(sticker);
const auto send = [=] {
sendIntroSticker(sticker);
};
return StickerInBubblePart::Data{
.sticker = sticker,
.size = st::chatIntroStickerSize,
.cacheTag = Tag::ChatIntroHelloSticker,
.link = std::make_shared<LambdaClickHandler>(send),
};
};
return StickerInBubblePart::Data{
.sticker = sticker,
.size = st::chatIntroStickerSize,
.cacheTag = Tag::ChatIntroHelloSticker,
.link = std::make_shared<LambdaClickHandler>(send),
};
};
push(std::make_unique<StickerInBubblePart>(
parent,
replacing,
sticker,
st::chatIntroStickerPadding));
push(std::make_unique<StickerInBubblePart>(
parent,
replacing,
sticker,
st::chatIntroStickerPadding));
}
};
}
@@ -753,7 +759,7 @@ bool AboutView::refresh() {
makeIntro(user);
} else if (const auto stars = user->starsPerMessageChecked()) {
setItem(makeStarsPerMessage(stars), nullptr);
} else {
} else if (!AyuSettings::getInstance().disableGreetingSticker()) {
makeIntro(user);
}
return true;
@@ -95,6 +95,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtCore/QMimeData>
// AyuGram includes
#include "ayu/ayu_settings.h"
#include "ayu/features/message_shot/message_shot.h"
#include "base/unixtime.h"
@@ -459,10 +460,13 @@ ChatWidget::ChatWidget(
}) | rpl::on_next([=](const Api::SendAction &action) {
if (action.options.scheduled) {
_composeControls->cancelReplyMessage();
crl::on_main(this, [=, t = _topic] {
controller->showSection(
std::make_shared<HistoryView::ScheduledMemento>(t));
});
const auto &ghost = AyuSettings::ghost(&session());
if (!ghost.isUseScheduledMessages()) {
crl::on_main(this, [=, t = _topic] {
controller->showSection(
std::make_shared<HistoryView::ScheduledMemento>(t));
});
}
}
}, lifetime());
}
@@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_info.h"
// AyuGram includes
#include "ayu/ayu_settings.h"
#include "ayu/utils/telegram_helpers.h"
#include "styles/style_ayu_styles.h"
@@ -998,6 +999,9 @@ EmptyPainter::EmptyPainter(not_null<History*> history)
, _text(st::msgMinWidth) {
if (NeedAboutGroup(_history)) {
fillAboutGroup();
} else if (_history->peer->isUser()
&& AyuSettings::getInstance().disableGreetingSticker()) {
SetText(_header, tr::lng_chat_intro_default_title(tr::now));
}
}
@@ -1049,7 +1053,33 @@ void EmptyPainter::paint(
not_null<const Ui::ChatStyle*> st,
int width,
int height) {
if (_phrases.empty() && _text.isEmpty() && _header.isEmpty()) {
return;
}
if (_phrases.empty() && _text.isEmpty()) {
const auto w = st::msgServiceFont->width(_header.toString())
+ st::msgPadding.left()
+ st::msgPadding.right();
const auto h = st::msgServiceFont->height
+ st::msgServicePadding.top()
+ st::msgServicePadding.bottom();
const auto rect = QRect(
(width - w) / 2,
(height - h) / 2,
w,
h);
ServiceMessagePainter::PaintBubble(
p,
st->msgServiceBg(),
st->serviceBgCornersNormal(),
rect);
p.setPen(st->msgServiceFg());
p.setFont(st::msgServiceFont->f);
p.drawTextLeft(
rect.left() + st::msgPadding.left(),
rect.top() + st::msgServicePadding.top(),
width,
_header.toString());
return;
}
constexpr auto kMaxTextLines = 3;
@@ -35,6 +35,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_chat.h"
#include "styles/style_polls.h"
// AyuGram includes
#include "ui/chat/chat_style_radius.h"
namespace HistoryView {
namespace {
@@ -302,7 +306,7 @@ void SimilarChannels::draw(Painter &p, const PaintContext &context) const {
if (cachedp) {
q->setCompositionMode(QPainter::CompositionMode_DestinationIn);
const auto corners = _roundedCorners.data();
const auto side = st::bubbleRadiusLarge;
const auto side = Ui::BubbleRadiusLarge();
q->drawImage(0, 0, corners[Images::kTopLeft]);
q->drawImage(width() - side, 0, corners[Images::kTopRight]);
q->drawImage(0, height() - side, corners[Images::kBottomLeft]);
@@ -473,7 +477,7 @@ void SimilarChannels::ensureCacheReady(QSize size) const {
QImage::Format_ARGB32_Premultiplied);
_roundedCache.setDevicePixelRatio(ratio);
}
const auto radius = st::bubbleRadiusLarge;
const auto radius = Ui::BubbleRadiusLarge();
if (_roundedCorners.front().size() != QSize(radius, radius) * ratio) {
_roundedCorners = Images::CornersMask(radius);
}
@@ -43,6 +43,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
// AyuGram includes
#include "ayu/ui/context_menu/context_menu.h"
#include "ayu/ayu_settings.h"
#include "ayu/utils/qt_key_modifiers_extended.h"
namespace HistoryView::Reactions {
@@ -1415,7 +1416,9 @@ AttachSelectorResult AttachSelectorToMenu(
const auto itemId = item->fullId();
selector->chosen() | rpl::on_next([=](ChosenReaction reaction) {
menu->hideMenu();
if (!base::IsExtendedContextMenuModifierPressed()) {
menu->hideMenu();
}
reaction.context = itemId;
chosen(std::move(reaction));
}, selector->lifetime());
@@ -32,7 +32,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtGui/QScreen>
// AyuGram includes
#include "ayu/ayu_settings.h"
#include "ayu/ui/ayu_userpic.h"
#include "ui/chat/chat_style_radius.h"
namespace Settings {
@@ -704,13 +706,15 @@ void Preview::paintReply(Painter &p, QRect clip) {
outline,
_replyRect.height());
p.drawRoundedRect(_replyRect, radius, radius);
p.setOpacity(Ui::kDefaultBgOpacity);
p.setClipRect(
_replyRect.x() + outline,
_replyRect.y(),
_replyRect.width() - outline,
_replyRect.height());
p.drawRoundedRect(_replyRect, radius, radius);
if (!AyuSettings::getInstance().simpleQuotesAndReplies()) {
p.setOpacity(Ui::kDefaultBgOpacity);
p.setClipRect(
_replyRect.x() + outline,
_replyRect.y(),
_replyRect.width() - outline,
_replyRect.height());
p.drawRoundedRect(_replyRect, radius, radius);
}
}
p.setOpacity(1.);
p.setClipping(false);
@@ -769,7 +773,7 @@ void Preview::validateBubbleCache() {
if (!_bubbleCorners.p[0].isNull()) {
return;
}
const auto radius = scaled(16); // st::bubbleRadiusLarge
const auto radius = scaled(Ui::BubbleRadiusLarge());
_bubbleCorners = Ui::PrepareCornerPixmaps(radius, st::msgInBg);
_bubbleCorners.p[2] = {};
_bubbleTail = scaled(st::historyBubbleTailInLeft, st::msgInBg->c);
@@ -28,6 +28,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtGui/QFontDatabase>
// AyuGram includes
#include "ayu/ayu_settings.h"
#include "ui/chat/chat_style_radius.h"
namespace Ui {
namespace {
@@ -638,7 +643,7 @@ void PreviewPainter::validateBubbleCache() {
if (!_bubbleCorners.p[0].isNull()) {
return;
}
const auto radius = st::bubbleRadiusLarge;
const auto radius = Ui::BubbleRadiusLarge();
_bubbleCorners = Ui::PrepareCornerPixmaps(radius, _msgBg.color());
_bubbleCorners.p[2] = {};
_bubbleShadowBottomRight
@@ -669,13 +674,15 @@ void PreviewPainter::paintReply(Painter &p) {
outline,
_replyRect.height());
p.drawRoundedRect(_replyRect, radius, radius);
p.setOpacity(Ui::kDefaultBgOpacity);
p.setClipRect(
_replyRect.x() + outline,
_replyRect.y(),
_replyRect.width() - outline,
_replyRect.height());
p.drawRoundedRect(_replyRect, radius, radius);
if (!AyuSettings::getInstance().simpleQuotesAndReplies()) {
p.setOpacity(Ui::kDefaultBgOpacity);
p.setClipRect(
_replyRect.x() + outline,
_replyRect.y(),
_replyRect.width() - outline,
_replyRect.height());
p.drawRoundedRect(_replyRect, radius, radius);
}
}
p.setOpacity(1.);
p.setClipping(false);