From 8ecb49f1328e2bc6cc7fc571e943b43562df6365 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 2 Jan 2024 08:45:58 +0400 Subject: [PATCH 01/15] Multiple by the magic multiplier only on Wayland --- Telegram/lib_ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/lib_ui b/Telegram/lib_ui index e9901b171..99e36f9ac 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit e9901b17192f35c8205751f889ef14e5859b946b +Subproject commit 99e36f9ac64048a6b7fcb0e6ee2e8eaca48935e1 From 1b11731d6b1248178427c8d2176202057ac8f5d7 Mon Sep 17 00:00:00 2001 From: kukuruzka <60149954+kukuruzka165@users.noreply.github.com> Date: Tue, 28 Nov 2023 18:35:13 +0200 Subject: [PATCH 02/15] Fix crash on some videos --- Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp index 378d9b4d1..95cefeffc 100644 --- a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp +++ b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp @@ -522,7 +522,7 @@ AVRational ValidateAspectRatio(AVRational aspect) { QSize CorrectByAspect(QSize size, AVRational aspect) { Expects(IsValidAspectRatio(aspect)); - return QSize(size.width() * aspect.num / aspect.den, size.height()); + return QSize(size.width() * av_q2d(aspect), size.height()); } bool RotationSwapWidthHeight(int rotation) { From fbd6b5b640482e098257f739efa4c35c8a8b629c Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Jan 2024 12:01:03 +0400 Subject: [PATCH 03/15] Fix possible build issue on Windows. --- Telegram/lib_webview | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/lib_webview b/Telegram/lib_webview index 1bb91474c..63e4ba48f 160000 --- a/Telegram/lib_webview +++ b/Telegram/lib_webview @@ -1 +1 @@ -Subproject commit 1bb91474c2337396673dd8a7c68e65ea317b6db5 +Subproject commit 63e4ba48fd8540fa3c2949d123160a2ce3411d70 From 175914f02b2c6aab0d8c287c91684df087683508 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Jan 2024 12:12:16 +0400 Subject: [PATCH 04/15] Show "My Notes", "Author Hidden" in title. --- .../history/view/history_view_top_bar_widget.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index 67a3b6c57..774081836 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -75,6 +75,19 @@ inline bool HasGroupCallMenu(const not_null &peer) { || (peer->isChat() && peer->asChat()->amCreator())); } +QString TopBarNameText( + not_null peer, + Dialogs::EntryState::Section section) { + if (section == Dialogs::EntryState::Section::SavedSublist) { + if (peer->isSelf()) { + return tr::lng_my_notes(tr::now); + } else if (peer->isSavedHiddenAuthor()) { + return tr::lng_hidden_author_messages(tr::now); + } + } + return peer->topBarNameText(); +} + } // namespace struct TopBarWidget::EmojiInteractionSeenAnimation { @@ -554,7 +567,7 @@ void TopBarWidget::paintTopBar(Painter &p) { _titleNameVersion = namePeer->nameVersion(); _title.setText( st::msgNameStyle, - namePeer->topBarNameText(), + TopBarNameText(namePeer, _activeChat.section), Ui::NameTextOptions()); } const auto badgeWidth = _titleBadge.drawGetWidth( From c51a8816ebce3b18734945192fcbbafb430a5f6f Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Jan 2024 12:59:22 +0400 Subject: [PATCH 05/15] Show selected sublist as active in list. --- Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp | 10 +++++++++- Telegram/SourceFiles/dialogs/dialogs_inner_widget.h | 1 + .../history/view/history_view_sublist_section.cpp | 2 +- Telegram/SourceFiles/mainwidget.cpp | 4 ++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index c1a630b78..afbf0ca77 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -624,7 +624,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) { bool selected, bool mayBeActive) { const auto key = row->key(); - const auto active = mayBeActive && (activeEntry.key == key); + const auto active = mayBeActive && isRowActive(row, activeEntry); const auto forum = key.history() && key.history()->isForum(); if (forum && !_topicJumpCache) { _topicJumpCache = std::make_unique(); @@ -977,6 +977,14 @@ void InnerWidget::paintCollapsedRow( }); } +bool InnerWidget::isRowActive( + not_null row, + const RowDescriptor &entry) const { + const auto key = row->key(); + return (entry.key == key) + || (entry.key.sublist() && key.peer() && key.peer()->isSelf()); +} + bool InnerWidget::isSearchResultActive( not_null result, const RowDescriptor &entry) const { diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h index 55d257bb5..7915bd912 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h @@ -231,6 +231,7 @@ private: void switchToFilter(FilterId filterId); bool chooseHashtag(); ChosenRow computeChosenRow() const; + bool isRowActive(not_null row, const RowDescriptor &entry) const; bool isSearchResultActive( not_null result, const RowDescriptor &entry) const; diff --git a/Telegram/SourceFiles/history/view/history_view_sublist_section.cpp b/Telegram/SourceFiles/history/view/history_view_sublist_section.cpp index 5664029bb..7481b5eb5 100644 --- a/Telegram/SourceFiles/history/view/history_view_sublist_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_sublist_section.cpp @@ -259,7 +259,7 @@ not_null SublistWidget::sublist() const { Dialogs::RowDescriptor SublistWidget::activeChat() const { return { - _history, + _sublist, FullMsgId(_history->peer->id, ShowAtUnreadMsgId) }; } diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 202ac2589..511954377 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -2446,6 +2446,10 @@ auto MainWidget::thirdSectionForCurrentMainSection( return std::make_shared( peer, Info::Memento::DefaultSection(peer)); + } else if (const auto sublist = key.sublist()) { + return std::make_shared( + session().user(), + Info::Memento::DefaultSection(session().user())); } Unexpected("Key in MainWidget::thirdSectionForCurrentMainSection()."); } From e2e55312b8cbb60a2b62d623378318b70b9a40af Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Jan 2024 12:59:41 +0400 Subject: [PATCH 06/15] Fix viewer hide workaround for software renderer. --- .../media/view/media_view_overlay_raster.cpp | 11 +++++++++++ .../media/view/media_view_overlay_raster.h | 1 + 2 files changed, 12 insertions(+) diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_raster.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_raster.cpp index 4ca702d39..2867a363c 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_raster.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_raster.cpp @@ -20,10 +20,21 @@ OverlayWidget::RendererSW::RendererSW(not_null owner) , _transparentBrush(style::TransparentPlaceholder()) { } +bool OverlayWidget::RendererSW::handleHideWorkaround() { + // This is needed on Windows or Linux, + // because on reopen it blinks with the last shown content. + return _owner->_hideWorkaround != nullptr; +} + void OverlayWidget::RendererSW::paintFallback( Painter &&p, const QRegion &clip, Ui::GL::Backend backend) { + if (handleHideWorkaround()) { + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(clip.boundingRect(), Qt::transparent); + return; + } _p = &p; _clip = &clip; _clipOuter = clip.boundingRect(); diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_raster.h b/Telegram/SourceFiles/media/view/media_view_overlay_raster.h index 6399f2219..8057e4d91 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_raster.h +++ b/Telegram/SourceFiles/media/view/media_view_overlay_raster.h @@ -59,6 +59,7 @@ private: QRect rect, float64 opacity = 1.) override; + bool handleHideWorkaround(); void validateOverControlImage(); [[nodiscard]] static QRect TransformRect(QRectF geometry, int rotation); From 7638f4cc3d4017a15d134034205f5a7b5a7efbf8 Mon Sep 17 00:00:00 2001 From: Eric Kotato Date: Tue, 2 Jan 2024 12:14:49 +0300 Subject: [PATCH 07/15] Fix warning C4805 --- Telegram/SourceFiles/boxes/gift_premium_box.cpp | 2 +- Telegram/SourceFiles/core/core_settings.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.cpp b/Telegram/SourceFiles/boxes/gift_premium_box.cpp index b01d980d9..809705cd5 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_premium_box.cpp @@ -1037,7 +1037,7 @@ void GiftCodeBox( state->data = session->api().premium().giftCodeValue(slug); state->used = state->data.value( ) | rpl::map([=](const Api::GiftCode &data) { - return data.used; + return data.used != 0; }); box->setWidth(st::boxWideWidth); diff --git a/Telegram/SourceFiles/core/core_settings.cpp b/Telegram/SourceFiles/core/core_settings.cpp index 5d780570d..ac4119d95 100644 --- a/Telegram/SourceFiles/core/core_settings.cpp +++ b/Telegram/SourceFiles/core/core_settings.cpp @@ -1258,7 +1258,7 @@ void Settings::resetOnLastLogout() { _tabbedReplacedWithInfo = false; // per-window _systemDarkModeEnabled = false; _hiddenGroupCallTooltips = 0; - _storiesClickTooltipHidden = 0; + _storiesClickTooltipHidden = false; _recentEmojiPreload.clear(); _recentEmoji.clear(); From 676e85983dc79a9e42f125e6de0f76164f85422e Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Jan 2024 13:02:34 +0400 Subject: [PATCH 08/15] Don't cut bio value, show what server returned. --- Telegram/SourceFiles/info/profile/info_profile_values.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/info/profile/info_profile_values.cpp b/Telegram/SourceFiles/info/profile/info_profile_values.cpp index 6c7b4ac2b..e66a9839b 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_values.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_values.cpp @@ -203,12 +203,7 @@ TextWithEntities AboutWithEntities( const auto stripExternal = peer->isChat() || peer->isMegagroup() || (user && !isBot && !isPremium); - const auto limit = Data::PremiumLimits(&peer->session()) - .aboutLengthDefault(); - const auto used = (!user || isPremium || value.size() <= limit) - ? value - : value.mid(0, limit) + "..."; - auto result = TextWithEntities{ used }; + auto result = TextWithEntities{ value }; TextUtilities::ParseEntities(result, flags); if (stripExternal) { StripExternalLinks(result); From 0b5f05c7d4e1b2d2b65f8f0dddb1bda07308091a Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Jan 2024 13:29:31 +0400 Subject: [PATCH 09/15] Skip service accounts in gift premiums box. --- Telegram/SourceFiles/boxes/gift_premium_box.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.cpp b/Telegram/SourceFiles/boxes/gift_premium_box.cpp index 809705cd5..61be013b3 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_premium_box.cpp @@ -903,9 +903,13 @@ void GiftPremiumValidator::showChoosePeerBox(const QString &ref) { protected: std::unique_ptr createRow( not_null user) override { - return !user->isSelf() - ? ContactsBoxController::createRow(user) - : nullptr; + if (user->isSelf() + || user->isBot() + || user->isServiceUser() + || user->isInaccessible()) { + return nullptr; + } + return ContactsBoxController::createRow(user); } void rowClicked(not_null row) override { From ca9caa36da393f874782bbfe2b15d3c41d90e10d Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Jan 2024 13:52:45 +0400 Subject: [PATCH 10/15] Inside message use original senders colors. --- Telegram/SourceFiles/history/history_item.cpp | 16 ++++++++++++++++ Telegram/SourceFiles/history/history_item.h | 5 +++++ .../history/view/history_view_element.cpp | 4 ++++ .../history/view/history_view_element.h | 1 + .../history/view/history_view_message.cpp | 2 +- .../history/view/history_view_reply.cpp | 2 +- .../history/view/media/history_view_document.cpp | 2 +- .../view/media/history_view_extended_preview.cpp | 2 +- .../history/view/media/history_view_game.cpp | 2 +- .../history/view/media/history_view_gif.cpp | 2 +- .../view/media/history_view_media_grouped.cpp | 2 +- .../history/view/media/history_view_photo.cpp | 2 +- .../history/view/media/history_view_web_page.cpp | 4 ++-- 13 files changed, 36 insertions(+), 10 deletions(-) diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index e758858cf..dcdd8b3d0 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -1235,6 +1235,22 @@ uint8 HistoryItem::colorIndex() const { Unexpected("No displayFrom and no displayHiddenSenderInfo."); } +PeerData *HistoryItem::contentColorsFrom() const { + if (const auto forwarded = Get()) { + return forwarded->originalSender; + } + return displayFrom(); +} + +uint8 HistoryItem::contentColorIndex() const { + if (const auto forwarded = Get()) { + return forwarded->originalSender + ? forwarded->originalSender->colorIndex() + : forwarded->originalHiddenSenderInfo->colorIndex; + } + return colorIndex(); +} + std::unique_ptr HistoryItem::createView( not_null delegate, HistoryView::Element *replacing) { diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index de206baac..412b9e057 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -516,6 +516,11 @@ public: [[nodiscard]] PeerData *displayFrom() const; [[nodiscard]] uint8 colorIndex() const; + // In forwards we show name in sender's color, but the message + // content uses the color of the original sender. + [[nodiscard]] PeerData *contentColorsFrom() const; + [[nodiscard]] uint8 contentColorIndex() const; + [[nodiscard]] std::unique_ptr createView( not_null delegate, HistoryView::Element *replacing = nullptr); diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index 872c10fd8..a573eace0 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -490,6 +490,10 @@ uint8 Element::colorIndex() const { return data()->colorIndex(); } +uint8 Element::contentColorIndex() const { + return data()->contentColorIndex(); +} + QDateTime Element::dateTime() const { return _dateTime; } diff --git a/Telegram/SourceFiles/history/view/history_view_element.h b/Telegram/SourceFiles/history/view/history_view_element.h index 3fbaa598f..3b524915f 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.h +++ b/Telegram/SourceFiles/history/view/history_view_element.h @@ -317,6 +317,7 @@ public: void refreshDataId(); [[nodiscard]] uint8 colorIndex() const; + [[nodiscard]] uint8 contentColorIndex() const; [[nodiscard]] QDateTime dateTime() const; [[nodiscard]] int y() const; diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 82acfc530..4edffbe37 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -1670,7 +1670,7 @@ void Message::paintText( .availableWidth = trect.width(), .palette = &stm->textPalette, .pre = stm->preCache.get(), - .blockquote = context.quoteCache(colorIndex()), + .blockquote = context.quoteCache(contentColorIndex()), .colors = context.st->highlightColors(), .spoiler = Ui::Text::DefaultSpoilerCache(), .now = context.now, diff --git a/Telegram/SourceFiles/history/view/history_view_reply.cpp b/Telegram/SourceFiles/history/view/history_view_reply.cpp index b2d89f2fd..678b34b8f 100644 --- a/Telegram/SourceFiles/history/view/history_view_reply.cpp +++ b/Telegram/SourceFiles/history/view/history_view_reply.cpp @@ -201,7 +201,7 @@ void Reply::update( } } _colorPeer = message - ? message->displayFrom() + ? message->contentColorsFrom() : story ? story->peer().get() : _externalSender diff --git a/Telegram/SourceFiles/history/view/media/history_view_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_document.cpp index 226285f72..e3e2808cd 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_document.cpp @@ -888,7 +888,7 @@ void Document::draw( .availableWidth = captionw, .palette = &stm->textPalette, .pre = stm->preCache.get(), - .blockquote = context.quoteCache(parent()->colorIndex()), + .blockquote = context.quoteCache(parent()->contentColorIndex()), .colors = context.st->highlightColors(), .spoiler = Ui::Text::DefaultSpoilerCache(), .now = context.now, diff --git a/Telegram/SourceFiles/history/view/media/history_view_extended_preview.cpp b/Telegram/SourceFiles/history/view/media/history_view_extended_preview.cpp index b229b5eb9..d127fc4fc 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_extended_preview.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_extended_preview.cpp @@ -237,7 +237,7 @@ void ExtendedPreview::draw(Painter &p, const PaintContext &context) const { .availableWidth = captionw, .palette = &stm->textPalette, .pre = stm->preCache.get(), - .blockquote = context.quoteCache(parent()->colorIndex()), + .blockquote = context.quoteCache(parent()->contentColorIndex()), .colors = context.st->highlightColors(), .spoiler = Ui::Text::DefaultSpoilerCache(), .now = context.now, diff --git a/Telegram/SourceFiles/history/view/media/history_view_game.cpp b/Telegram/SourceFiles/history/view/media/history_view_game.cpp index 57dd72167..2eda3513c 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_game.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_game.cpp @@ -219,7 +219,7 @@ void Game::draw(Painter &p, const PaintContext &context) const { auto tshift = inner.top(); auto paintw = inner.width(); - const auto colorIndex = parent()->colorIndex(); + const auto colorIndex = parent()->contentColorIndex(); const auto selected = context.selected(); const auto cache = context.outbg ? stm->replyCache[st->colorPatternIndex(colorIndex)].get() diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index 21d35d0a6..87a0e00bf 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -724,7 +724,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const { .availableWidth = captionw, .palette = &stm->textPalette, .pre = stm->preCache.get(), - .blockquote = context.quoteCache(parent()->colorIndex()), + .blockquote = context.quoteCache(parent()->contentColorIndex()), .colors = context.st->highlightColors(), .spoiler = Ui::Text::DefaultSpoilerCache(), .now = context.now, diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp index 379afd782..038192cf1 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp @@ -405,7 +405,7 @@ void GroupedMedia::draw(Painter &p, const PaintContext &context) const { .availableWidth = captionw, .palette = &stm->textPalette, .pre = stm->preCache.get(), - .blockquote = context.quoteCache(parent()->colorIndex()), + .blockquote = context.quoteCache(parent()->contentColorIndex()), .colors = context.st->highlightColors(), .spoiler = Ui::Text::DefaultSpoilerCache(), .now = context.now, diff --git a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp index b87c0c6a3..fa633ab37 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp @@ -433,7 +433,7 @@ void Photo::draw(Painter &p, const PaintContext &context) const { .availableWidth = captionw, .palette = &stm->textPalette, .pre = stm->preCache.get(), - .blockquote = context.quoteCache(parent()->colorIndex()), + .blockquote = context.quoteCache(parent()->contentColorIndex()), .colors = context.st->highlightColors(), .spoiler = Ui::Text::DefaultSpoilerCache(), .now = context.now, diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index 7e75ddb91..43b3d8370 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -584,11 +584,11 @@ void WebPage::draw(Painter &p, const PaintContext &context) const { const auto selected = context.selected(); const auto view = parent(); - const auto colorIndex = view->colorIndex(); + const auto from = view->data()->contentColorsFrom(); + const auto colorIndex = from ? from->colorIndex() : view->colorIndex(); const auto cache = context.outbg ? stm->replyCache[st->colorPatternIndex(colorIndex)].get() : st->coloredReplyCache(selected, colorIndex).get(); - const auto from = view->data()->displayFrom(); const auto backgroundEmojiId = from ? from->backgroundEmojiId() : DocumentId(); From 5c29cc59c8049b20094494d26b36471eec47807d Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Jan 2024 14:11:09 +0400 Subject: [PATCH 11/15] Show forward original sender in reply bar. --- .../history/view/history_view_reply.cpp | 26 +++++++++++++++++-- .../history/view/history_view_reply.h | 2 ++ Telegram/SourceFiles/ui/chat/chat.style | 2 ++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_reply.cpp b/Telegram/SourceFiles/history/view/history_view_reply.cpp index 678b34b8f..1c78094d6 100644 --- a/Telegram/SourceFiles/history/view/history_view_reply.cpp +++ b/Telegram/SourceFiles/history/view/history_view_reply.cpp @@ -408,7 +408,10 @@ void Reply::updateName( std::optional resolvedSender) const { auto viaBotUsername = QString(); const auto message = data->resolvedMessage.get(); - if (message && !message->Has()) { + const auto forwarded = message + ? message->Get() + : nullptr; + if (message && !forwarded) { if (const auto bot = message->viaBot()) { viaBotUsername = bot->username(); } @@ -424,7 +427,14 @@ void Reply::updateName( && externalPeer && (externalPeer != sender) && (externalPeer->isChat() || externalPeer->isMegagroup()); - const auto shorten = !viaBotUsername.isEmpty() || groupNameAdded; + const auto originalNameAdded = !displayAsExternal + && forwarded + && !message->isDiscussionPost() + && (!message->showForwardsFromSender(forwarded) + || forwarded->forwardOfForward()); + const auto shorten = !viaBotUsername.isEmpty() + || groupNameAdded + || originalNameAdded; const auto name = sender ? senderName(sender, shorten) : senderName(view, data, shorten); @@ -443,6 +453,11 @@ void Reply::updateName( if (groupNameAdded) { nameFull.append(' ').append(PeerEmoji(history, externalPeer)); nameFull.append(externalPeer->name()); + } else if (originalNameAdded) { + nameFull.append(' ').append(ForwardEmoji(&history->owner())); + nameFull.append(forwarded->originalSender + ? forwarded->originalSender->name() + : forwarded->originalHiddenSenderInfo->name); } if (!viaBotUsername.isEmpty()) { nameFull.append(u" @"_q).append(viaBotUsername); @@ -838,6 +853,13 @@ TextWithEntities Reply::PeerEmoji( icon.second)); } +TextWithEntities Reply::ForwardEmoji(not_null owner) { + return Ui::Text::SingleCustomEmoji( + owner->customEmojiManager().registerInternalEmoji( + st::historyReplyForward, + st::historyReplyForwardPadding)); +} + TextWithEntities Reply::ComposePreviewName( not_null history, not_null to, diff --git a/Telegram/SourceFiles/history/view/history_view_reply.h b/Telegram/SourceFiles/history/view/history_view_reply.h index 9a70356ea..416f4c009 100644 --- a/Telegram/SourceFiles/history/view/history_view_reply.h +++ b/Telegram/SourceFiles/history/view/history_view_reply.h @@ -105,6 +105,8 @@ public: [[nodiscard]] static TextWithEntities PeerEmoji( not_null owner, PeerData *peer); + [[nodiscard]] static TextWithEntities ForwardEmoji( + not_null owner); [[nodiscard]] static TextWithEntities ComposePreviewName( not_null history, not_null to, diff --git a/Telegram/SourceFiles/ui/chat/chat.style b/Telegram/SourceFiles/ui/chat/chat.style index b025a57b8..7507e0e6b 100644 --- a/Telegram/SourceFiles/ui/chat/chat.style +++ b/Telegram/SourceFiles/ui/chat/chat.style @@ -38,6 +38,8 @@ historyReplyGroup: icon {{ "chat/reply_type_group", windowFg }}; historyReplyGroupPadding: margins(0px, 4px, 4px, 0px); historyReplyChannel: icon {{ "chat/reply_type_channel", windowFg }}; historyReplyChannelPadding: margins(0px, 5px, 4px, 0px); +historyReplyForward: icon {{ "mini_forward", windowFg }}; +historyReplyForwardPadding: margins(0px, 2px, 2px, 0px); msgReplyPadding: margins(6px, 6px, 11px, 6px); msgReplyBarPos: point(1px, 0px); From bdf67645bb0daac3dabb09a50a7ec88f814bc7b1 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 2 Jan 2024 13:40:21 +0300 Subject: [PATCH 12/15] Improved phrase of terms in gifts box from settings. --- Telegram/Resources/langs/lang.strings | 2 ++ Telegram/SourceFiles/boxes/gift_premium_box.cpp | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 26ef1de59..9d0707518 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2087,6 +2087,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_premium_gifts_about_paid_below#one" = "They now have access to additional features."; "lng_premium_gifts_about_paid_below#other" = "They now have access to additional features."; "lng_premium_gifts_summary_subtitle" = "What's Included"; +"lng_premium_gifts_terms" = "By gifting Telegram Premium, you agree to the Telegram {link} and {policy}."; +"lng_premium_gifts_terms_policy" = "Privacy Policy"; "lng_boost_channel_button" = "Boost Channel"; "lng_boost_again_button" = "Boost Again"; diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.cpp b/Telegram/SourceFiles/boxes/gift_premium_box.cpp index 61be013b3..f7b2e2d43 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_premium_box.cpp @@ -603,7 +603,20 @@ void GiftsBox( box, object_ptr( box, - session->api().premium().statusTextValue(), // TODO. + tr::lng_premium_gifts_terms( + lt_link, + tr::lng_payments_terms_link( + ) | rpl::map([](const QString &t) { + using namespace Ui::Text; + return Link(t, u"https://telegram.org/tos"_q); + }), + lt_policy, + tr::lng_premium_gifts_terms_policy( + ) | rpl::map([](const QString &t) { + using namespace Ui::Text; + return Link(t, u"https://telegram.org/privacy"_q); + }), + Ui::Text::RichLangValue), st::premiumGiftTerms), st::defaultBoxDividerLabelPadding), {}); From 382dab4ecbfb14d7664050d70dbd8d10b49e5790 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Jan 2024 14:48:51 +0400 Subject: [PATCH 13/15] Don't push sublists to stack endlessly. --- .../view/history_view_sublist_section.cpp | 4 +++ .../view/history_view_sublist_section.h | 2 ++ .../info/saved/info_saved_sublists_widget.cpp | 5 +++- Telegram/SourceFiles/mainwidget.cpp | 25 +++++++++++++++---- Telegram/SourceFiles/mainwidget.h | 4 ++- Telegram/SourceFiles/window/section_widget.h | 3 +++ .../window/window_session_controller.h | 1 + 7 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_sublist_section.cpp b/Telegram/SourceFiles/history/view/history_view_sublist_section.cpp index 7481b5eb5..a1c9578f8 100644 --- a/Telegram/SourceFiles/history/view/history_view_sublist_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_sublist_section.cpp @@ -293,6 +293,10 @@ bool SublistWidget::showInternal( return false; } +bool SublistWidget::sameTypeAs(not_null memento) { + return dynamic_cast(memento.get()) != nullptr; +} + void SublistWidget::setInternalState( const QRect &geometry, not_null memento) { diff --git a/Telegram/SourceFiles/history/view/history_view_sublist_section.h b/Telegram/SourceFiles/history/view/history_view_sublist_section.h index 008f521c5..819ce363c 100644 --- a/Telegram/SourceFiles/history/view/history_view_sublist_section.h +++ b/Telegram/SourceFiles/history/view/history_view_sublist_section.h @@ -58,6 +58,8 @@ public: bool showInternal( not_null memento, const Window::SectionShow ¶ms) override; + bool sameTypeAs(not_null memento) override; + std::shared_ptr createMemento() override; bool showMessage( PeerId peerId, diff --git a/Telegram/SourceFiles/info/saved/info_saved_sublists_widget.cpp b/Telegram/SourceFiles/info/saved/info_saved_sublists_widget.cpp index db3990963..41c9eafa6 100644 --- a/Telegram/SourceFiles/info/saved/info_saved_sublists_widget.cpp +++ b/Telegram/SourceFiles/info/saved/info_saved_sublists_widget.cpp @@ -60,9 +60,12 @@ SublistsWidget::SublistsWidget( _list->chosenRow() | rpl::start_with_next([=](Dialogs::ChosenRow row) { if (const auto sublist = row.key.sublist()) { + using namespace Window; + auto params = SectionShow(SectionShow::Way::Forward); + params.dropSameFromStack = true; controller->showSection( std::make_shared(sublist), - Window::SectionShow::Way::Forward); + params); } }, _list->lifetime()); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 511954377..a62d53826 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -1379,7 +1379,7 @@ void MainWidget::showHistory( if (!back && (way != Way::ClearStack)) { // This may modify the current section, for example remove its contents. - saveSectionInStack(); + saveSectionInStack(params); } if (_history->peer() @@ -1501,13 +1501,23 @@ Ui::ChatTheme *MainWidget::customChatTheme() const { return _history->customChatTheme(); } -void MainWidget::saveSectionInStack() { +bool MainWidget::saveSectionInStack( + const SectionShow ¶ms, + Window::SectionWidget *newMainSection) { if (_mainSection) { if (auto memento = _mainSection->createMemento()) { + if (params.dropSameFromStack + && newMainSection + && newMainSection->sameTypeAs(memento.get())) { + // When choosing saved sublist we want to save the original + // "Saved Messages" in the stack, but don't save every + // sublist in a new stack entry when clicking them through. + return false; + } _stack.push_back(std::make_unique( std::move(memento))); } else { - return; + return false; } } else if (const auto history = _history->history()) { _stack.push_back(std::make_unique( @@ -1515,7 +1525,7 @@ void MainWidget::saveSectionInStack() { _history->msgId(), _history->replyReturns())); } else { - return; + return false; } const auto raw = _stack.back().get(); raw->setThirdSectionWeak(_thirdSection.data()); @@ -1528,6 +1538,7 @@ void MainWidget::saveSectionInStack() { } } }, raw->lifetime()); + return true; } void MainWidget::showSection( @@ -1730,7 +1741,11 @@ void MainWidget::showNewSection( if (saveInStack) { // This may modify the current section, for example remove its contents. - saveSectionInStack(); + if (!saveSectionInStack(params, newMainSection)) { + saveInStack = false; + animatedShow = false; + animationParams = Window::SectionSlideParams(); + } } auto &settingSection = newThirdSection ? _thirdSection diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index de94e66da..d407f8496 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -286,7 +286,9 @@ private: Window::SectionSlideParams prepareHistoryAnimation(PeerId historyPeerId); Window::SectionSlideParams prepareDialogsAnimation(); - void saveSectionInStack(); + bool saveSectionInStack( + const SectionShow ¶ms, + Window::SectionWidget *newMainSection = nullptr); int getMainSectionTop() const; int getThirdSectionTop() const; diff --git a/Telegram/SourceFiles/window/section_widget.h b/Telegram/SourceFiles/window/section_widget.h index 52b94f702..10cf3f1e9 100644 --- a/Telegram/SourceFiles/window/section_widget.h +++ b/Telegram/SourceFiles/window/section_widget.h @@ -138,6 +138,9 @@ public: virtual bool showInternal( not_null memento, const SectionShow ¶ms) = 0; + virtual bool sameTypeAs(not_null memento) { + return false; + } virtual bool showMessage( PeerId peerId, diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index ac23dfae4..03a60fcac 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -162,6 +162,7 @@ struct SectionShow { bool childColumn = false; bool forbidLayer = false; bool reapplyLocalDraft = false; + bool dropSameFromStack = false; Origin origin; }; From c8dd94601b1984df86e3a47b11f4d75498408cea Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Jan 2024 15:03:23 +0400 Subject: [PATCH 14/15] Don't add original name in forward of reply. --- Telegram/SourceFiles/history/view/history_view_reply.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_reply.cpp b/Telegram/SourceFiles/history/view/history_view_reply.cpp index 1c78094d6..527654d9a 100644 --- a/Telegram/SourceFiles/history/view/history_view_reply.cpp +++ b/Telegram/SourceFiles/history/view/history_view_reply.cpp @@ -430,8 +430,9 @@ void Reply::updateName( const auto originalNameAdded = !displayAsExternal && forwarded && !message->isDiscussionPost() - && (!message->showForwardsFromSender(forwarded) - || forwarded->forwardOfForward()); + && (forwarded->forwardOfForward() + || (!message->showForwardsFromSender(forwarded) + && !view->data()->Has())); const auto shorten = !viaBotUsername.isEmpty() || groupNameAdded || originalNameAdded; From 4274f9d3f3bb27e2ddc684133bc59cc4d20145c4 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Jan 2024 15:04:48 +0400 Subject: [PATCH 15/15] Version 4.14.2. - Show original senders name in reply to forward information. - Use original senders color / emoji pattern in forwards. - Highlight active saved messages chat in list. - Fix chats list scrolling on X11 (Linux). --- Telegram/Resources/uwp/AppX/AppxManifest.xml | 2 +- Telegram/Resources/winrc/Telegram.rc | 8 ++++---- Telegram/Resources/winrc/Updater.rc | 8 ++++---- Telegram/SourceFiles/core/version.h | 4 ++-- Telegram/build/version | 8 ++++---- changelog.txt | 7 +++++++ 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index 14a581ce3..6dee69ef6 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -10,7 +10,7 @@ + Version="4.14.2.0" /> Telegram Desktop Telegram Messenger LLP diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index 48f6b926c..e162c8d1e 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -44,8 +44,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,14,1,0 - PRODUCTVERSION 4,14,1,0 + FILEVERSION 4,14,2,0 + PRODUCTVERSION 4,14,2,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -62,10 +62,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop" - VALUE "FileVersion", "4.14.1.0" + VALUE "FileVersion", "4.14.2.0" VALUE "LegalCopyright", "Copyright (C) 2014-2024" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "4.14.1.0" + VALUE "ProductVersion", "4.14.2.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index 81ca80299..9e5612b20 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -35,8 +35,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,14,1,0 - PRODUCTVERSION 4,14,1,0 + FILEVERSION 4,14,2,0 + PRODUCTVERSION 4,14,2,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -53,10 +53,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop Updater" - VALUE "FileVersion", "4.14.1.0" + VALUE "FileVersion", "4.14.2.0" VALUE "LegalCopyright", "Copyright (C) 2014-2024" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "4.14.1.0" + VALUE "ProductVersion", "4.14.2.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index b493f4ee6..868f37cae 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -22,7 +22,7 @@ constexpr auto AppId = "{53F49750-6209-4FBF-9CA8-7A333C87D1ED}"_cs; constexpr auto AppNameOld = "Telegram Win (Unofficial)"_cs; constexpr auto AppName = "Telegram Desktop"_cs; constexpr auto AppFile = "Telegram"_cs; -constexpr auto AppVersion = 4014001; -constexpr auto AppVersionStr = "4.14.1"; +constexpr auto AppVersion = 4014002; +constexpr auto AppVersionStr = "4.14.2"; constexpr auto AppBetaVersion = false; constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION; diff --git a/Telegram/build/version b/Telegram/build/version index fa61513ba..b024a1911 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,7 +1,7 @@ -AppVersion 4014001 +AppVersion 4014002 AppVersionStrMajor 4.14 -AppVersionStrSmall 4.14.1 -AppVersionStr 4.14.1 +AppVersionStrSmall 4.14.2 +AppVersionStr 4.14.2 BetaChannel 0 AlphaVersion 0 -AppVersionOriginal 4.14.1 +AppVersionOriginal 4.14.2 diff --git a/changelog.txt b/changelog.txt index d3ae5b8fa..a69fb9144 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,10 @@ +4.14.2 (02.01.24) + +- Show original senders name in reply to forward information. +- Use original senders color / emoji pattern in forwards. +- Highlight active saved messages chat in list. +- Fix chats list scrolling on X11 (Linux). + 4.14.1 (01.01.24) - Fix crash in "Author Hidden" chat in "Saved Messages".