From b363d8bfb558971e4a427d3baf43d2a8f695c443 Mon Sep 17 00:00:00 2001 From: Grigory Date: Sat, 19 Oct 2024 20:39:44 +0500 Subject: [PATCH 001/306] fix(ui/webview_helpers): append 0 if color channel value is 1 char long --- Telegram/SourceFiles/ui/webview_helpers.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/ui/webview_helpers.cpp b/Telegram/SourceFiles/ui/webview_helpers.cpp index a0369421b..01cd56cb4 100644 --- a/Telegram/SourceFiles/ui/webview_helpers.cpp +++ b/Telegram/SourceFiles/ui/webview_helpers.cpp @@ -15,9 +15,9 @@ namespace { [[nodiscard]] QByteArray Serialize(const QColor &qt) { if (qt.alpha() == 255) { return '#' - + QByteArray::number(qt.red(), 16).right(2) - + QByteArray::number(qt.green(), 16).right(2) - + QByteArray::number(qt.blue(), 16).right(2); + + QByteArray::number(qt.red(), 16).rightJustified(2, '0') + + QByteArray::number(qt.green(), 16).rightJustified(2, '0') + + QByteArray::number(qt.blue(), 16).rightJustified(2, '0'); } return "rgba(" + QByteArray::number(qt.red()) + "," From d85b668d4fa83623930b6af8b49e7fabe5a89aa4 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 24 Oct 2024 00:51:11 +0400 Subject: [PATCH 002/306] Fix lambda execution for portal dark mode getter --- Telegram/SourceFiles/platform/linux/integration_linux.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/platform/linux/integration_linux.cpp b/Telegram/SourceFiles/platform/linux/integration_linux.cpp index 8a7db94ed..e048a2d05 100644 --- a/Telegram/SourceFiles/platform/linux/integration_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/integration_linux.cpp @@ -204,7 +204,7 @@ LinuxIntegration::LinuxIntegration() return value->get_uint32() == 1; } return std::nullopt; -}) +}()) , _darkModeWatcher( "org.freedesktop.appearance", "color-scheme", From e5886862c3cf04415fbcc9d61765f99e827d2284 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 16 Oct 2024 13:40:52 +0300 Subject: [PATCH 003/306] Changed behavior to copy phone number from profile sections as trimmed. --- .../info/profile/info_profile_actions.cpp | 14 +++++++++++++- Telegram/SourceFiles/settings/settings_main.cpp | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index 4fc4d060d..7dd61c6da 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -1150,7 +1150,19 @@ object_ptr DetailsFiller::setupInfo() { PhoneOrHiddenValue(user), tr::lng_profile_copy_phone(tr::now)).text; const auto hook = [=](Ui::FlatLabel::ContextMenuRequest request) { - phoneLabel->fillContextMenu(request); + if (request.selection.empty()) { + const auto callback = [=] { + auto phone = rpl::variable( + PhoneOrHiddenValue(user)).current().text; + phone.replace(' ', QString()).replace('-', QString()); + TextUtilities::SetClipboardText({ phone }); + }; + request.menu->addAction( + tr::lng_profile_copy_phone(tr::now), + callback); + } else { + phoneLabel->fillContextMenu(request); + } AddPhoneMenu(request.menu, user); }; phoneLabel->setContextMenuHook(hook); diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index 685f3ae57..47aafcdaa 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/wrap/slide_wrap.h" #include "ui/widgets/menu/menu_add_action_callback.h" #include "ui/widgets/continuous_sliders.h" +#include "ui/widgets/popup_menu.h" #include "ui/text/text_utilities.h" #include "ui/toast/toast.h" #include "ui/new_badges.h" @@ -144,6 +145,20 @@ Cover::Cover( _phone->setSelectable(true); _phone->setContextCopyText(tr::lng_profile_copy_phone(tr::now)); + const auto hook = [=](Ui::FlatLabel::ContextMenuRequest request) { + if (request.selection.empty()) { + const auto c = [=] { + auto phone = rpl::variable( + Info::Profile::PhoneValue(_user)).current().text; + phone.replace(' ', QString()).replace('-', QString()); + TextUtilities::SetClipboardText({ phone }); + }; + request.menu->addAction(tr::lng_profile_copy_phone(tr::now), c); + } else { + _phone->fillContextMenu(request); + } + }; + _phone->setContextMenuHook(hook); initViewers(); setupChildGeometry(); From b1e537e54eaf7ae777e504c4076462927a6ea434 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 16 Oct 2024 16:08:50 +0300 Subject: [PATCH 004/306] Added subscription icon to channel photo in ReceiptCreditsBox. --- Telegram/SourceFiles/api/api_chat_invite.cpp | 46 ++++++++++++++----- .../boxes/peers/edit_peer_invite_link.cpp | 5 +- .../settings/settings_credits_graphics.cpp | 43 +++++++++++++++-- .../settings/settings_credits_graphics.h | 5 ++ 4 files changed, 81 insertions(+), 18 deletions(-) diff --git a/Telegram/SourceFiles/api/api_chat_invite.cpp b/Telegram/SourceFiles/api/api_chat_invite.cpp index be07e72ac..0a53c61dd 100644 --- a/Telegram/SourceFiles/api/api_chat_invite.cpp +++ b/Telegram/SourceFiles/api/api_chat_invite.cpp @@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "settings/settings_credits_graphics.h" #include "ui/boxes/confirm_box.h" #include "ui/controls/userpic_button.h" +#include "ui/effects/credits_graphics.h" #include "ui/effects/premium_graphics.h" #include "ui/effects/premium_stars_colored.h" #include "ui/empty_userpic.h" @@ -129,6 +130,7 @@ void ConfirmSubscriptionBox( struct State final { std::shared_ptr photoMedia; std::unique_ptr photoEmpty; + QImage frame; std::optional api; Ui::RpWidget* saveButton = nullptr; @@ -146,25 +148,45 @@ void ConfirmSubscriptionBox( const auto userpic = userpicWrap->entity(); const auto photoSize = st::confirmInvitePhotoSize; userpic->resize(Size(photoSize)); + const auto creditsIconSize = photoSize / 3; + const auto creditsIconCallback = + Ui::PaintOutlinedColoredCreditsIconCallback( + creditsIconSize, + 1.5); + state->frame = QImage( + Size(photoSize * style::DevicePixelRatio()), + QImage::Format_ARGB32_Premultiplied); + state->frame.setDevicePixelRatio(style::DevicePixelRatio()); const auto options = Images::Option::RoundCircle; userpic->paintRequest( ) | rpl::start_with_next([=, small = Data::PhotoSize::Small] { - auto p = QPainter(userpic); - if (state->photoMedia) { - if (const auto image = state->photoMedia->image(small)) { - p.drawPixmap( + state->frame.fill(Qt::transparent); + { + auto p = QPainter(&state->frame); + if (state->photoMedia) { + if (const auto image = state->photoMedia->image(small)) { + p.drawPixmap( + 0, + 0, + image->pix(Size(photoSize), { .options = options })); + } + } else if (state->photoEmpty) { + state->photoEmpty->paintCircle( + p, 0, 0, - image->pix(Size(photoSize), { .options = options })); + userpic->width(), + photoSize); + } + if (creditsIconCallback) { + p.translate( + photoSize - creditsIconSize, + photoSize - creditsIconSize); + creditsIconCallback(p); } - } else if (state->photoEmpty) { - state->photoEmpty->paintCircle( - p, - 0, - 0, - userpic->width(), - photoSize); } + auto p = QPainter(userpic); + p.drawImage(0, 0, state->frame); }, userpicWrap->lifetime()); userpicWrap->setAttribute(Qt::WA_TransparentForMouseEvents); if (photo) { diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp index 8e1a11030..4dc7f897b 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp @@ -956,12 +956,11 @@ void Controller::rowClicked(not_null row) { Ui::AddSkip(content); Ui::AddSkip(content); - const auto &stUser = st::boostReplaceUserpic; + const auto photoSize = st::boostReplaceUserpic.photoSize; const auto session = &row->peer()->session(); content->add(object_ptr>( content, - object_ptr(content, channel, stUser)) - )->setAttribute(Qt::WA_TransparentForMouseEvents); + Settings::SubscriptionUserpic(content, channel, photoSize))); Ui::AddSkip(content); Ui::AddSkip(content); diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index 1e92b697b..7e813cf10 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -52,6 +52,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "statistics/widgets/chart_header_widget.h" #include "ui/boxes/confirm_box.h" #include "ui/controls/userpic_button.h" +#include "ui/dynamic_image.h" +#include "ui/dynamic_thumbnails.h" #include "ui/effects/credits_graphics.h" #include "ui/effects/premium_graphics.h" #include "ui/effects/premium_stars_colored.h" @@ -772,9 +774,15 @@ void ReceiptCreditsBox( GenericEntryPhoto(content, callback, stUser.photoSize))); AddViewMediaHandler(thumb->entity(), controller, e); } else if (peer && !e.gift) { - content->add(object_ptr>( - content, - object_ptr(content, peer, stUser))); + if (e.subscriptionUntil.isNull() && s.until.isNull()) { + content->add(object_ptr>( + content, + object_ptr(content, peer, stUser))); + } else { + content->add(object_ptr>( + content, + SubscriptionUserpic(content, peer, stUser.photoSize))); + } } else if (e.gift || isPrize) { struct State final { DocumentData *sticker = nullptr; @@ -1541,6 +1549,35 @@ object_ptr PaidMediaThumbnail( photoSize); } +object_ptr SubscriptionUserpic( + not_null parent, + not_null peer, + int photoSize) { + auto widget = object_ptr(parent); + const auto raw = widget.data(); + widget->resize(photoSize, photoSize); + const auto userpicMedia = Ui::MakeUserpicThumbnail(peer, false); + userpicMedia->subscribeToUpdates([=] { raw->update(); }); + const auto creditsIconSize = photoSize / 3; + const auto creditsIconCallback = + Ui::PaintOutlinedColoredCreditsIconCallback( + creditsIconSize, + 1.5); + widget->paintRequest() | rpl::start_with_next([=] { + auto p = QPainter(raw); + p.fillRect(Rect(Size(photoSize)), Qt::transparent); + auto image = userpicMedia->image(photoSize); + { + auto q = QPainter(&image); + q.translate(photoSize, photoSize); + q.translate(-creditsIconSize, -creditsIconSize); + creditsIconCallback(q); + } + p.drawImage(0, 0, image); + }, widget->lifetime()); + return widget; +} + void SmallBalanceBox( not_null box, std::shared_ptr show, diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.h b/Telegram/SourceFiles/settings/settings_credits_graphics.h index bfc266e3e..fb19e2bff 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.h +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.h @@ -126,6 +126,11 @@ void ShowRefundInfoBox( int totalCount, int photoSize); +[[nodiscard]] object_ptr SubscriptionUserpic( + not_null parent, + not_null peer, + int photoSize); + struct SmallBalanceBot { UserId botId = 0; }; From ed9dcef66f3024985c0cf5bc5a31b4a0309cf179 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 18 Oct 2024 02:19:33 +0300 Subject: [PATCH 005/306] Fixed display of selection marks for messages with huge code blocks. --- .../history/view/history_view_message.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index c57dc2848..b24546abf 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -1615,14 +1615,16 @@ void Message::draw(Painter &p, const PaintContext &context) const { const auto o = ScopedPainterOpacity(p, progress); const auto &st = st::msgSelectionCheck; const auto right = delegate()->elementIsChatWide() - ? (st::msgMaxWidth - + st::msgPhotoSkip - + st::msgSelectionOffset - + st::msgPadding.left() - + st.size) + ? std::min( + (_bubbleWidthLimit + + st::msgPhotoSkip + + st::msgSelectionOffset + + st::msgPadding.left() + + st.size), + width()) : width(); const auto pos = QPoint( - (right + (width() - (st::msgSelectionOffset * progress - st.size) / 2 - st::msgPadding.right() / 2 - st.size), From 975ae17ef9a50c469cfc40f2168979782fb6aeee Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 18 Oct 2024 02:57:26 +0300 Subject: [PATCH 006/306] Moved selection marks to bottom of message bubbles. --- Telegram/SourceFiles/history/view/history_view_message.cpp | 2 +- Telegram/SourceFiles/ui/chat/chat.style | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index b24546abf..51be68d40 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -1628,7 +1628,7 @@ void Message::draw(Painter &p, const PaintContext &context) const { - (st::msgSelectionOffset * progress - st.size) / 2 - st::msgPadding.right() / 2 - st.size), - g.y() + (g.height() - st.size) / 2); + rect::bottom(g) - st.size - st::msgSelectionBottomSkip); { p.setPen(QPen(st.border, st.width)); p.setBrush(context.st->msgServiceBg()); diff --git a/Telegram/SourceFiles/ui/chat/chat.style b/Telegram/SourceFiles/ui/chat/chat.style index cb30fdf47..2f9af4f2b 100644 --- a/Telegram/SourceFiles/ui/chat/chat.style +++ b/Telegram/SourceFiles/ui/chat/chat.style @@ -27,6 +27,7 @@ msgMargin: margins(16px, 6px, 56px, 2px); msgMarginTopAttached: 0px; msgShadow: 2px; msgSelectionOffset: 30px; +msgSelectionBottomSkip: 5px; historyReplyTop: 2px; historyReplyBottom: 2px; From 9e76e6406403c21ca29cff2501a9ec7cd64c09dc Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 18 Oct 2024 03:13:44 +0300 Subject: [PATCH 007/306] Improved parts alignments of round video messages. --- Telegram/SourceFiles/history/view/media/history_view_gif.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index f3de7fe3d..6a3aebfcb 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -801,7 +801,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const { p, context, fullRight, - fullBottom, + fullBottom - st::msgDateImgDelta, 2 * paintx + paintw, (unwrapped ? InfoDisplayType::Background From 1a1e777b873d7ba30c5e06d848af0050b003e152 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 18 Oct 2024 04:10:24 +0300 Subject: [PATCH 008/306] Fixed display of generic media with small width. --- .../history/view/media/history_view_media_generic.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_generic.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_generic.cpp index 18625b684..077a8ebd9 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_generic.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_generic.cpp @@ -110,7 +110,13 @@ QSize MediaGeneric::countOptimalSize() { } QSize MediaGeneric::countCurrentSize(int newWidth) { - return { maxWidth(), minHeight() }; + if (newWidth > maxWidth()) { + newWidth = maxWidth(); + } + for (auto &entry : _entries) { + entry.object->resizeGetHeight(newWidth); + } + return { newWidth, minHeight() }; } void MediaGeneric::draw(Painter &p, const PaintContext &context) const { From a8a1b08127f8f023ad2864cc6d527ca1ceccddbe Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 18 Oct 2024 05:40:10 +0300 Subject: [PATCH 009/306] Added ministars to buttons in section of peer gifts. --- .../info/peer_gifts/info_peer_gifts_common.cpp | 14 +++++++++++++- .../info/peer_gifts/info_peer_gifts_common.h | 2 ++ .../SourceFiles/ui/effects/premium_stars.cpp | 16 +++++++++++----- Telegram/SourceFiles/ui/effects/premium_stars.h | 1 + 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp index dd12b6646..d35759154 100644 --- a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp +++ b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp @@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/text/text_utilities.h" #include "ui/dynamic_image.h" #include "ui/dynamic_thumbnails.h" +#include "ui/effects/premium_graphics.h" #include "ui/painter.h" #include "window/window_session_controller.h" #include "styles/style_credits.h" @@ -39,7 +40,9 @@ GiftButton::GiftButton( QWidget *parent, not_null delegate) : AbstractButton(parent) -, _delegate(delegate) { +, _delegate(delegate) +, _stars(this, true, Ui::Premium::MiniStars::Type::SlowStars) { + _stars.setColorOverride(Ui::Premium::CreditsIconGradientStops()); } GiftButton::~GiftButton() { @@ -159,6 +162,8 @@ void GiftButton::setGeometry(QRect inner, QMargins extend) { void GiftButton::resizeEvent(QResizeEvent *e) { if (!_button.isEmpty()) { _button.moveLeft((width() - _button.width()) / 2); + const auto padding = _button.height() / 2; + _stars.setCenter(_button - QMargins(padding, 0, padding, 0)); } } @@ -307,6 +312,13 @@ void GiftButton::paintEvent(QPaintEvent *e) { if (!premium) { p.setOpacity(1.); } + { + auto clipPath = QPainterPath(); + clipPath.addRoundedRect(geometry, radius, radius); + p.setClipPath(clipPath); + _stars.paint(p); + p.setClipping(false); + } if (!_text.isEmpty()) { p.setPen(st::windowFg); diff --git a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h index 6fd2b7413..47f591e05 100644 --- a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h +++ b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "ui/abstract_button.h" +#include "ui/effects/premium_stars_colored.h" #include "ui/text/text.h" class StickerPremiumMark; @@ -101,6 +102,7 @@ private: Ui::Text::String _text; Ui::Text::String _price; std::shared_ptr _userpic; + Ui::Premium::ColoredMiniStars _stars; bool _subscribed = false; QRect _button; diff --git a/Telegram/SourceFiles/ui/effects/premium_stars.cpp b/Telegram/SourceFiles/ui/effects/premium_stars.cpp index c63f700d7..23d8ad355 100644 --- a/Telegram/SourceFiles/ui/effects/premium_stars.cpp +++ b/Telegram/SourceFiles/ui/effects/premium_stars.cpp @@ -21,19 +21,25 @@ MiniStars::MiniStars( Fn updateCallback, bool opaque, Type type) -: _availableAngles({ +: _availableAngles((type != Type::SlowStars) +? std::vector{ Interval{ -10, 40 }, Interval{ 180 + 10 - 40, 40 }, Interval{ 180 + 15, 50 }, Interval{ -15 - 50, 50 }, -}) -, _lifeLength({ 150 / 5, 200 / 5 }) -, _deathTime({ 1500, 2000 }) +} +: std::vector{ Interval{ -90, 180 }, Interval{ 90, 180 } }) +, _lifeLength((type != Type::SlowStars) + ? Interval{ 150 / 5, 200 / 5 } + : Interval{ 150 * 2, 200 * 2 }) +, _deathTime((type != Type::SlowStars) + ? Interval{ 1500, 2000 } + : Interval{ 1500 * 2, 2000 * 2 }) , _size({ 5, 10 }) , _alpha({ opaque ? 100 : 40, opaque ? 100 : 60 }) , _sinFactor({ 10, 190 }) , _spritesCount({ 0, ((type == Type::MonoStars) ? 1 : 2) }) -, _appearProgressTill(0.2) +, _appearProgressTill((type != Type::SlowStars) ? 0.2 : 0.01) , _disappearProgressAfter(0.8) , _distanceProgressStart(0.5) , _sprite(u":/gui/icons/settings/starmini.svg"_q) diff --git a/Telegram/SourceFiles/ui/effects/premium_stars.h b/Telegram/SourceFiles/ui/effects/premium_stars.h index d224d8186..0adbd21fe 100644 --- a/Telegram/SourceFiles/ui/effects/premium_stars.h +++ b/Telegram/SourceFiles/ui/effects/premium_stars.h @@ -19,6 +19,7 @@ public: enum class Type { MonoStars, BiStars, + SlowStars, }; MiniStars( From 7f20cf59d1963931ccb1c0fd1ad4574d906f4427 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 18 Oct 2024 06:33:55 +0300 Subject: [PATCH 010/306] Added ministars to button in service messages for gifts. --- .../view/media/history_view_premium_gift.cpp | 4 +++ .../view/media/history_view_premium_gift.h | 1 + .../view/media/history_view_service_box.cpp | 34 +++++++++++++++++-- .../view/media/history_view_service_box.h | 8 +++++ .../ui/effects/premium_stars_colored.cpp | 6 ++++ .../ui/effects/premium_stars_colored.h | 1 + 6 files changed, 52 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp b/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp index e12ab3d3f..12e9f1ffc 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp @@ -151,6 +151,10 @@ rpl::producer PremiumGift::button() { : tr::lng_prize_open(); } +bool PremiumGift::buttonMinistars() { + return true; +} + ClickHandlerPtr PremiumGift::createViewLink() { if (starGift() && outgoingGift()) { return nullptr; diff --git a/Telegram/SourceFiles/history/view/media/history_view_premium_gift.h b/Telegram/SourceFiles/history/view/media/history_view_premium_gift.h index 00883240d..db976370e 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_premium_gift.h +++ b/Telegram/SourceFiles/history/view/media/history_view_premium_gift.h @@ -29,6 +29,7 @@ public: QString title() override; TextWithEntities subtitle() override; rpl::producer button() override; + bool buttonMinistars() override; QString cornerTagText() override; int buttonSkip() override; void draw( diff --git a/Telegram/SourceFiles/history/view/media/history_view_service_box.cpp b/Telegram/SourceFiles/history/view/media/history_view_service_box.cpp index 0252e3281..cda0204c6 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_service_box.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_service_box.cpp @@ -16,9 +16,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "ui/chat/chat_style.h" #include "ui/effects/animation_value.h" +#include "ui/effects/premium_stars_colored.h" #include "ui/effects/ripple_animation.h" #include "ui/text/text_utilities.h" #include "ui/painter.h" +#include "ui/rect.h" #include "ui/power_saving.h" #include "styles/style_chat.h" #include "styles/style_premium.h" @@ -98,6 +100,12 @@ ServiceBox::ServiceBox( } }, _lifetime); } + if (_content->buttonMinistars()) { + _button.stars = std::make_unique( + [=](const QRect &) { repaint(); }, + Ui::Premium::MiniStars::Type::SlowStars); + _button.lastFg = std::make_unique(); + } } ServiceBox::~ServiceBox() = default; @@ -117,7 +125,21 @@ void ServiceBox::draw(Painter &p, const PaintContext &context) const { const auto radius = st::msgServiceGiftBoxRadius; p.setPen(Qt::NoPen); p.setBrush(context.st->msgServiceBg()); - p.drawRoundedRect(QRect(QPoint(), _innerSize), radius, radius); + p.drawRoundedRect(Rect(_innerSize), radius, radius); + + if (_button.stars) { + const auto &c = context.st->msgServiceFg()->c; + if ((*_button.lastFg) != c) { + _button.lastFg->setRgb(c.red(), c.green(), c.blue()); + const auto padding = _button.size.height() / 2; + _button.stars->setColorOverride(QGradientStops{ + { 0., anim::with_alpha(c, .3) }, + { 1., c }, + }); + _button.stars->setCenter( + Rect(_button.size) - QMargins(padding, 0, padding, 0)); + } + } const auto content = contentRect(); auto top = content.top() + content.height(); @@ -340,7 +362,15 @@ bool ServiceBox::Button::empty() const { void ServiceBox::Button::drawBg(QPainter &p) const { const auto radius = size.height() / 2.; - p.drawRoundedRect(0, 0, size.width(), size.height(), radius, radius); + const auto r = Rect(size); + p.drawRoundedRect(r, radius, radius); + if (stars) { + auto clipPath = QPainterPath(); + clipPath.addRoundedRect(r, radius, radius); + p.setClipPath(clipPath); + stars->paint(p); + p.setClipping(false); + } } } // namespace HistoryView diff --git a/Telegram/SourceFiles/history/view/media/history_view_service_box.h b/Telegram/SourceFiles/history/view/media/history_view_service_box.h index 2a52e7336..733176c7d 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_service_box.h +++ b/Telegram/SourceFiles/history/view/media/history_view_service_box.h @@ -11,6 +11,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Ui { class RippleAnimation; +namespace Premium { +class ColoredMiniStars; +} // namespace Premium } // namespace Ui namespace HistoryView { @@ -28,6 +31,9 @@ public: return top(); } [[nodiscard]] virtual rpl::producer button() = 0; + [[nodiscard]] virtual bool buttonMinistars() { + return false; + } [[nodiscard]] virtual QString cornerTagText() { return {}; } @@ -106,6 +112,8 @@ private: ClickHandlerPtr link; std::unique_ptr ripple; + std::unique_ptr stars; + std::unique_ptr lastFg; mutable QPoint lastPoint; } _button; diff --git a/Telegram/SourceFiles/ui/effects/premium_stars_colored.cpp b/Telegram/SourceFiles/ui/effects/premium_stars_colored.cpp index 5e20cfd22..c90dc97ab 100644 --- a/Telegram/SourceFiles/ui/effects/premium_stars_colored.cpp +++ b/Telegram/SourceFiles/ui/effects/premium_stars_colored.cpp @@ -27,6 +27,12 @@ ColoredMiniStars::ColoredMiniStars( type) { } +ColoredMiniStars::ColoredMiniStars( + Fn update, + MiniStars::Type type) +: _ministars(update, true, type) { +} + void ColoredMiniStars::setSize(const QSize &size) { _frame = QImage( size * style::DevicePixelRatio(), diff --git a/Telegram/SourceFiles/ui/effects/premium_stars_colored.h b/Telegram/SourceFiles/ui/effects/premium_stars_colored.h index d0ae77b00..2b56d93aa 100644 --- a/Telegram/SourceFiles/ui/effects/premium_stars_colored.h +++ b/Telegram/SourceFiles/ui/effects/premium_stars_colored.h @@ -21,6 +21,7 @@ public: not_null parent, bool optimizeUpdate, MiniStars::Type type = MiniStars::Type::MonoStars); + ColoredMiniStars(Fn update, MiniStars::Type type); void setSize(const QSize &size); void setPosition(QPoint position); From a32ff465797d8b3e39e9011eb135a4240d2ca979 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 18 Oct 2024 07:27:49 +0300 Subject: [PATCH 011/306] Added special hotkeys to change IV zoom more gradually. --- Telegram/Resources/langs/lang.strings | 2 + Telegram/SourceFiles/iv/iv_controller.cpp | 53 ++++++++++++++++++++--- Telegram/lib_ui | 2 +- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 60c7a6413..600f37e1d 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -5562,6 +5562,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_iv_window_title" = "Instant View"; "lng_iv_wrong_layout" = "Wrong layout?"; "lng_iv_not_supported" = "This link appears to be invalid."; +"lng_iv_zoom_tooltip_ctrl" = "Hold Ctrl to zoom by 5%.\nHold Alt to zoom by 1%."; +"lng_iv_zoom_tooltip_cmd" = "Hold Cmd to zoom by 5%.\nHold Alt to zoom by 1%."; "lng_limit_download_title" = "Download speed limited"; "lng_limit_download_subscribe" = "Subscribe to {link} to increase download speed {increase}."; diff --git a/Telegram/SourceFiles/iv/iv_controller.cpp b/Telegram/SourceFiles/iv/iv_controller.cpp index 486778ef7..c17fd8368 100644 --- a/Telegram/SourceFiles/iv/iv_controller.cpp +++ b/Telegram/SourceFiles/iv/iv_controller.cpp @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "iv/iv_controller.h" #include "base/platform/base_platform_info.h" +#include "base/qt/qt_key_modifiers.h" #include "base/invoke_queued.h" #include "base/qt_signal_producer.h" #include "base/qthelp_url.h" @@ -21,9 +22,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/menu/menu_action.h" #include "ui/widgets/rp_window.h" #include "ui/widgets/popup_menu.h" +#include "ui/widgets/tooltip.h" #include "ui/wrap/fade_wrap.h" #include "ui/basic_click_handlers.h" #include "ui/painter.h" +#include "ui/rect.h" #include "ui/webview_helpers.h" #include "ui/ui_utility.h" #include "webview/webview_data_stream_memory.h" @@ -52,9 +55,13 @@ namespace Iv { namespace { constexpr auto kZoomStep = int(10); +constexpr auto kZoomSmallStep = int(5); +constexpr auto kZoomTinyStep = int(1); constexpr auto kDefaultZoom = int(100); -class ItemZoom final : public Ui::Menu::Action { +class ItemZoom final + : public Ui::Menu::Action + , public Ui::AbstractTooltipShower { public: ItemZoom( not_null parent, @@ -109,10 +116,21 @@ public: }; + const auto processTooltip = [=, this](not_null w) { + w->events() | rpl::start_with_next([=](not_null e) { + if (e->type() == QEvent::Enter) { + Ui::Tooltip::Show(1000, this); + } else if (e->type() == QEvent::Leave) { + Ui::Tooltip::Hide(); + } + }, w->lifetime()); + }; + const auto reset = Ui::CreateChild( this, rpl::single(QString()), st::ivResetZoom); + processTooltip(reset); const auto resetLabel = Ui::CreateChild( reset, tr::lng_background_reset_default(), @@ -128,8 +146,16 @@ public: '+', 0, _st.itemFg); - plus->setClickedCallback([this] { - _delegate->ivSetZoom(_delegate->ivZoom() + kZoomStep); + processTooltip(plus); + const auto step = [] { + return base::IsAltPressed() + ? kZoomTinyStep + : base::IsCtrlPressed() + ? kZoomSmallStep + : kZoomStep; + }; + plus->setClickedCallback([this, step] { + _delegate->ivSetZoom(_delegate->ivZoom() + step()); }); plus->show(); const auto minus = Ui::CreateChild( @@ -137,8 +163,9 @@ public: QChar(0x2013), -1, _st.itemFg); - minus->setClickedCallback([this] { - _delegate->ivSetZoom(_delegate->ivZoom() - kZoomStep); + processTooltip(minus); + minus->setClickedCallback([this, step] { + _delegate->ivSetZoom(_delegate->ivZoom() - step()); }); minus->show(); @@ -182,6 +209,22 @@ public: }); } + QString tooltipText() const override { +#ifdef Q_OS_MAC + return tr::lng_iv_zoom_tooltip_cmd(tr::now); +#else + return tr::lng_iv_zoom_tooltip_ctrl(tr::now); +#endif + } + + QPoint tooltipPos() const override { + return QCursor::pos(); + } + + bool tooltipWindowActive() const override { + return true; + } + private: const not_null _delegate; const style::Menu &_st; diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 887f54143..9ac125c50 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 887f5414302a1e8fd84cd880ef8454aa21b681da +Subproject commit 9ac125c505ef105c62c50dd102d19f20f09210c1 From 7092fe2242fb1661abb3f947ec69695b92ea8c24 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 20 Oct 2024 03:38:47 +0300 Subject: [PATCH 012/306] Added default ripple animation style with windowBgOver color. --- Telegram/SourceFiles/boxes/boxes.style | 24 ++++------------ Telegram/SourceFiles/calls/calls.style | 8 ++---- .../chat_helpers/chat_helpers.style | 28 +++++-------------- Telegram/SourceFiles/dialogs/dialogs.style | 4 +-- Telegram/SourceFiles/info/info.style | 16 +++-------- Telegram/SourceFiles/intro/intro.style | 4 +-- Telegram/SourceFiles/iv/iv.style | 8 ++---- Telegram/SourceFiles/passport/passport.style | 4 +-- Telegram/SourceFiles/ui/chat/chat.style | 8 ++---- Telegram/SourceFiles/window/window.style | 4 +-- Telegram/lib_ui | 2 +- 11 files changed, 28 insertions(+), 82 deletions(-) diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index 22e7da4a6..845098628 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -154,9 +154,7 @@ contactsSortButton: IconButton(defaultIconButton) { iconPosition: point(10px, -1px); rippleAreaPosition: point(1px, 6px); rippleAreaSize: 42px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } contactsSortOnlineIcon: icon{{ "contacts_online", boxTitleCloseFg }}; contactsSortOnlineIconOver: icon{{ "contacts_online", boxTitleCloseFgOver }}; @@ -416,9 +414,7 @@ calendarPrevious: IconButton { rippleAreaPosition: point(2px, 2px); rippleAreaSize: 44px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } calendarPreviousDisabled: icon {{ "calendar_down-flip_vertical", menuIconFg }}; calendarNext: IconButton(calendarPrevious) { @@ -616,9 +612,7 @@ proxyTryIPv6Padding: margins(22px, 8px, 22px, 5px); proxyRowPadding: margins(22px, 8px, 8px, 8px); proxyRowIconSkip: 32px; proxyRowSkip: 2px; -proxyRowRipple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; -} +proxyRowRipple: defaultRippleAnimationBgOver; proxyRowTitleFg: windowFg; proxyRowTitlePalette: TextPalette(defaultTextPalette) { linkFg: windowSubTextFg; @@ -683,9 +677,7 @@ themesMenuToggle: IconButton(defaultIconButton) { rippleAreaPosition: point(4px, 4px); rippleAreaSize: 36px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } themesMenuPosition: point(-2px, 25px); @@ -738,9 +730,7 @@ createPollOptionRemove: CrossButton { duration: 150; loadingPeriod: 1000; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } createPollOptionRemovePosition: point(11px, 9px); createPollOptionEmojiPositionSkip: 4px; @@ -951,9 +941,7 @@ sponsoredUrlButton: RoundButton(defaultActiveButton) { textTop: 7px; style: defaultTextStyle; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } requestPeerRestriction: FlatLabel(defaultFlatLabel) { diff --git a/Telegram/SourceFiles/calls/calls.style b/Telegram/SourceFiles/calls/calls.style index 76b2e41dc..7e22913e3 100644 --- a/Telegram/SourceFiles/calls/calls.style +++ b/Telegram/SourceFiles/calls/calls.style @@ -409,9 +409,7 @@ callRatingStar: IconButton { icon: icon {{ "calls/call_rating", windowSubTextFg }}; iconPosition: point(-1px, -1px); - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; rippleAreaPosition: point(0px, 0px); rippleAreaSize: 36px; } @@ -1410,9 +1408,7 @@ groupCallRtmpShowButton: IconButton(defaultIconButton) { rippleAreaPosition: point(0px, 0px); rippleAreaSize: 32px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } groupCallSettingsRtmpShowButton: IconButton(groupCallRtmpShowButton) { ripple: groupCallRipple; diff --git a/Telegram/SourceFiles/chat_helpers/chat_helpers.style b/Telegram/SourceFiles/chat_helpers/chat_helpers.style index d965b7f8a..0c680dd1e 100644 --- a/Telegram/SourceFiles/chat_helpers/chat_helpers.style +++ b/Telegram/SourceFiles/chat_helpers/chat_helpers.style @@ -331,9 +331,7 @@ stickersRemove: IconButton(defaultIconButton) { rippleAreaSize: 40px; rippleAreaPosition: point(0px, 0px); - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } stickersUndoRemove: RoundButton(defaultLightButton) { width: -16px; @@ -494,9 +492,7 @@ hashtagClose: IconButton { rippleAreaPosition: point(5px, 5px); rippleAreaSize: 20px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } stickerPanWidthMin: 64px; @@ -898,9 +894,7 @@ historyBusinessBotSettings: IconButton(defaultIconButton) { iconPosition: point(-1px, -1px); rippleAreaSize: 40px; rippleAreaPosition: point(4px, 9px); - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; height: 58px; width: 48px; } @@ -927,9 +921,7 @@ historyReplyCancel: IconButton { rippleAreaPosition: point(4px, 4px); rippleAreaSize: 40px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } historyPinnedShowAll: IconButton(historyReplyCancel) { icon: icon {{ "pinned_show_all", historyReplyCancelFg }}; @@ -1058,9 +1050,7 @@ historyAttach: IconButton(defaultIconButton) { rippleAreaPosition: point(2px, 3px); rippleAreaSize: 40px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } historyMessagesTTL: IconButtonWithText { @@ -1287,9 +1277,7 @@ defaultComposeFilesMenu: IconButton(defaultIconButton) { rippleAreaPosition: point(1px, 6px); rippleAreaSize: 42px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } defaultComposeFilesField: InputField(defaultInputField) { textMargins: margins(1px, 26px, 31px, 4px); @@ -1349,9 +1337,7 @@ moreChatsBarClose: IconButton(defaultIconButton) { rippleAreaPosition: point(0px, 4px); rippleAreaSize: 40px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } reportReasonTopSkip: 8px; diff --git a/Telegram/SourceFiles/dialogs/dialogs.style b/Telegram/SourceFiles/dialogs/dialogs.style index 6451e79b4..d039869b7 100644 --- a/Telegram/SourceFiles/dialogs/dialogs.style +++ b/Telegram/SourceFiles/dialogs/dialogs.style @@ -222,9 +222,7 @@ dialogsMenuToggle: IconButton { rippleAreaPosition: point(0px, 0px); rippleAreaSize: 40px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } dialogsMenuToggleUnread: icon { { "dialogs/dialogs_menu_unread", dialogsMenuIconFg }, diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style index 0c66b41a7..84dca5dec 100644 --- a/Telegram/SourceFiles/info/info.style +++ b/Telegram/SourceFiles/info/info.style @@ -129,9 +129,7 @@ infoTopBarBack: IconButton(defaultIconButton) { rippleAreaPosition: point(6px, 6px); rippleAreaSize: 42px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } infoTopBarTitle: FlatLabel(defaultFlatLabel) { textFg: windowBoldFg; @@ -623,9 +621,7 @@ infoMembersCancelSearch: CrossButton { duration: 150; loadingPeriod: 1000; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } infoMembersSearchTop: 15px; @@ -841,9 +837,7 @@ topBarSearch: IconButton { rippleAreaPosition: point(0px, 7px); rippleAreaSize: 40px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } topBarCloseChoose: IconButton(topBarSearch) { width: 56px; @@ -1146,9 +1140,7 @@ infoHoursDayLabel: infoHoursState; infoHoursOuter: RoundButton(defaultActiveButton) { textBg: transparent; textBgOver: transparent; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } infoHoursOuterMargin: margins(8px, 4px, 8px, 4px); infoHoursDaySkip: 6px; diff --git a/Telegram/SourceFiles/intro/intro.style b/Telegram/SourceFiles/intro/intro.style index a6b8a7a4c..ddf09c24b 100644 --- a/Telegram/SourceFiles/intro/intro.style +++ b/Telegram/SourceFiles/intro/intro.style @@ -165,9 +165,7 @@ introBackButton: IconButton(defaultIconButton) { rippleAreaPosition: point(8px, 8px); rippleAreaSize: 40px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } introQrTop: -18px; diff --git a/Telegram/SourceFiles/iv/iv.style b/Telegram/SourceFiles/iv/iv.style index cea363566..a3129f5d2 100644 --- a/Telegram/SourceFiles/iv/iv.style +++ b/Telegram/SourceFiles/iv/iv.style @@ -17,9 +17,7 @@ ivMenuToggle: IconButton(defaultIconButton) { rippleAreaPosition: point(6px, 6px); rippleAreaSize: 36px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } ivMenuPosition: point(-2px, 40px); ivBackIcon: icon {{ "box_button_back", menuIconColor }}; @@ -36,9 +34,7 @@ ivPlusMinusZoom: IconButton(ivMenuToggle) { rippleAreaPosition: point(0px, 0px); rippleAreaSize: ivZoomButtonsSize; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } ivResetZoomStyle: TextStyle(defaultTextStyle) { font: font(12px); diff --git a/Telegram/SourceFiles/passport/passport.style b/Telegram/SourceFiles/passport/passport.style index f3a498575..df494e425 100644 --- a/Telegram/SourceFiles/passport/passport.style +++ b/Telegram/SourceFiles/passport/passport.style @@ -108,9 +108,7 @@ passportContactErrorMargin: margins(0px, 0px, 0px, 14px); passportRowPadding: margins(22px, 8px, 25px, 8px); passportRowIconSkip: 10px; passportRowSkip: 2px; -passportRowRipple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; -} +passportRowRipple: defaultRippleAnimationBgOver; passportRowReadyIcon: icon {{ "passport_ready", windowActiveTextFg }}; passportRowEmptyIcon: icon {{ "passport_empty", menuIconFgOver }}; passportRowTitleFg: windowFg; diff --git a/Telegram/SourceFiles/ui/chat/chat.style b/Telegram/SourceFiles/ui/chat/chat.style index 2f9af4f2b..7633eed08 100644 --- a/Telegram/SourceFiles/ui/chat/chat.style +++ b/Telegram/SourceFiles/ui/chat/chat.style @@ -551,9 +551,7 @@ historyAdminLogCancelSearch: CrossButton { duration: 150; loadingPeriod: 1000; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } historyAdminLogSearchTop: 11px; historyAdminLogSearchSlideDuration: 150; @@ -977,9 +975,7 @@ backgroundSwitchToDark: IconButton(defaultIconButton) { rippleAreaPosition: point(4px, 4px); rippleAreaSize: 40px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } backgroundSwitchToLight: IconButton(backgroundSwitchToDark) { icon: icon {{ "menu/header_mode_day", boxTitleCloseFg }}; diff --git a/Telegram/SourceFiles/window/window.style b/Telegram/SourceFiles/window/window.style index 37654c990..32e233a0d 100644 --- a/Telegram/SourceFiles/window/window.style +++ b/Telegram/SourceFiles/window/window.style @@ -43,9 +43,7 @@ notifyClose: IconButton { rippleAreaPosition: point(5px, 5px); rippleAreaSize: 20px; - ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgOver; - } + ripple: defaultRippleAnimationBgOver; } notifyItemTop: 12px; notifyTextLeft: 12px; diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 9ac125c50..0198796f9 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 9ac125c505ef105c62c50dd102d19f20f09210c1 +Subproject commit 0198796f9011aeb8b1449e42a3cae02222df12fc From e6af33367e35211c2a85670a5238e0024ebbca5f Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 17 Oct 2024 12:03:01 +0400 Subject: [PATCH 013/306] Accept bot username in chatbot setup. --- Telegram/SourceFiles/settings/business/settings_chatbots.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Telegram/SourceFiles/settings/business/settings_chatbots.cpp b/Telegram/SourceFiles/settings/business/settings_chatbots.cpp index 3c75cf9ba..cd439e139 100644 --- a/Telegram/SourceFiles/settings/business/settings_chatbots.cpp +++ b/Telegram/SourceFiles/settings/business/settings_chatbots.cpp @@ -226,6 +226,9 @@ Main::Session &PreviewController::session() const { [[nodiscard]] QString ExtractUsername(QString text) { text = text.trimmed(); + if (text.startsWith(QChar('@'))) { + return text.mid(1); + } static const auto expression = QRegularExpression( "^(https://)?([a-zA-Z0-9\\.]+/)?([a-zA-Z0-9_\\.]+)"); const auto match = expression.match(text); From 285c96fd2e0fef5af575660a68891ca150714b8d Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 17 Oct 2024 12:58:05 +0400 Subject: [PATCH 014/306] Add "Respect the Focus settings" on Windows. --- Telegram/Resources/langs/lang.strings | 3 ++- Telegram/SourceFiles/core/core_settings.cpp | 19 +++++++++++++++-- Telegram/SourceFiles/core/core_settings.h | 4 ++++ .../win/notifications_manager_win.cpp | 4 +++- .../settings/settings_notifications.cpp | 21 +++++++++++++++++++ 5 files changed, 47 insertions(+), 4 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 600f37e1d..66a51005b 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -499,8 +499,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_settings_notify_global" = "Global settings"; "lng_settings_notify_title" = "Notifications for chats"; "lng_settings_desktop_notify" = "Desktop notifications"; -"lng_settings_native_title" = "Native notifications"; +"lng_settings_native_title" = "System integration"; "lng_settings_use_windows" = "Use Windows notifications"; +"lng_settings_skip_in_focus" = "Respect system Focus mode"; "lng_settings_use_native_notifications" = "Use native notifications"; "lng_settings_notifications_position" = "Location on the screen"; "lng_settings_notifications_count" = "Notifications count"; diff --git a/Telegram/SourceFiles/core/core_settings.cpp b/Telegram/SourceFiles/core/core_settings.cpp index 71d9ae0e8..af6819f8f 100644 --- a/Telegram/SourceFiles/core/core_settings.cpp +++ b/Telegram/SourceFiles/core/core_settings.cpp @@ -222,7 +222,7 @@ QByteArray Settings::serialize() const { + Serialize::stringSize(_customFontFamily) + sizeof(qint32) * 3 + Serialize::bytearraySize(_tonsiteStorageToken) - + sizeof(qint32) * 2; + + sizeof(qint32) * 3; auto result = QByteArray(); result.reserve(size); @@ -378,7 +378,8 @@ QByteArray Settings::serialize() const { << qint32(!_weatherInCelsius ? 0 : *_weatherInCelsius ? 1 : 2) << _tonsiteStorageToken << qint32(_includeMutedCounterFolders ? 1 : 0) - << qint32(_ivZoom.current()); + << qint32(_ivZoom.current()) + << qint32(_skipToastsInFocus ? 1 : 0); } Ensures(result.size() == size); @@ -503,6 +504,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) { qint32 weatherInCelsius = !_weatherInCelsius ? 0 : *_weatherInCelsius ? 1 : 2; QByteArray tonsiteStorageToken = _tonsiteStorageToken; qint32 ivZoom = _ivZoom.current(); + qint32 skipToastsInFocus = _skipToastsInFocus ? 1 : 0; stream >> themesAccentColors; if (!stream.atEnd()) { @@ -815,6 +817,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) { if (!stream.atEnd()) { stream >> ivZoom; } + if (!stream.atEnd()) { + stream >> skipToastsInFocus; + } if (stream.status() != QDataStream::Ok) { LOG(("App Error: " "Bad data for Core::Settings::constructFromSerialized()")); @@ -1027,6 +1032,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) { : (weatherInCelsius == 1); _tonsiteStorageToken = tonsiteStorageToken; _ivZoom = ivZoom; + _skipToastsInFocus = (skipToastsInFocus == 1); } QString Settings::getSoundPath(const QString &key) const { @@ -1353,6 +1359,7 @@ void Settings::resetOnLastLogout() { _flashBounceNotify = true; _notifyView = NotifyView::ShowPreview; //_nativeNotifications = std::nullopt; + //_skipToastsInFocus = false; //_notificationsCount = 3; //_notificationsCorner = ScreenCorner::BottomRight; _includeMutedCounter = true; @@ -1472,6 +1479,14 @@ void Settings::setNativeNotifications(bool value) { : std::make_optional(value); } +bool Settings::skipToastsInFocus() const { + return _skipToastsInFocus; +} + +void Settings::setSkipToastsInFocus(bool value) { + _skipToastsInFocus = value; +} + void Settings::setTranslateButtonEnabled(bool value) { _translateButtonEnabled = value; } diff --git a/Telegram/SourceFiles/core/core_settings.h b/Telegram/SourceFiles/core/core_settings.h index 54199d8e5..821f9ec21 100644 --- a/Telegram/SourceFiles/core/core_settings.h +++ b/Telegram/SourceFiles/core/core_settings.h @@ -220,6 +220,9 @@ public: [[nodiscard]] bool nativeNotifications() const; void setNativeNotifications(bool value); + [[nodiscard]] bool skipToastsInFocus() const; + void setSkipToastsInFocus(bool value); + [[nodiscard]] int notificationsCount() const { return _notificationsCount; } @@ -958,6 +961,7 @@ private: bool _flashBounceNotify = true; NotifyView _notifyView = NotifyView::ShowPreview; std::optional _nativeNotifications; + bool _skipToastsInFocus = false; int _notificationsCount = 3; ScreenCorner _notificationsCorner = ScreenCorner::BottomRight; bool _includeMutedCounter = true; diff --git a/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp b/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp index 99cd1b907..618e81823 100644 --- a/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp +++ b/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp @@ -367,6 +367,7 @@ bool SkipSoundForCustom() { return (UserNotificationState == QUNS_NOT_PRESENT) || (UserNotificationState == QUNS_PRESENTATION_MODE) + || (FocusAssistBlocks && Core::App().settings().skipToastsInFocus()) || Core::App().screenIsLocked(); } @@ -387,7 +388,8 @@ bool SkipToastForCustom() { QuerySystemNotificationSettings(); return (UserNotificationState == QUNS_PRESENTATION_MODE) - || (UserNotificationState == QUNS_RUNNING_D3D_FULL_SCREEN); + || (UserNotificationState == QUNS_RUNNING_D3D_FULL_SCREEN) + || (FocusAssistBlocks && Core::App().settings().skipToastsInFocus()); } void MaybeFlashBounceForCustom(Fn flashBounce) { diff --git a/Telegram/SourceFiles/settings/settings_notifications.cpp b/Telegram/SourceFiles/settings/settings_notifications.cpp index cf3c759af..00a8bdb9e 100644 --- a/Telegram/SourceFiles/settings/settings_notifications.cpp +++ b/Telegram/SourceFiles/settings/settings_notifications.cpp @@ -864,6 +864,27 @@ NotifyViewCheckboxes SetupNotifyViewOptions( void SetupAdvancedNotifications( not_null controller, not_null container) { + if (Platform::IsWindows()) { + const auto skipInFocus = container->add(object_ptr