From fb7ac874f05c546048121b0291646637b6732b52 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 24 Dec 2018 13:25:02 +0400 Subject: [PATCH] Show poll question in pinned bar. --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/data/data_media_types.cpp | 2 +- Telegram/SourceFiles/history/history_widget.cpp | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 99c06f7dbe..f15b225a1b 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -156,6 +156,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_deleted" = "Deleted Account"; "lng_deleted_message" = "Deleted message"; "lng_pinned_message" = "Pinned message"; +"lng_pinned_poll" = "Pinned poll"; "lng_pinned_unpin_sure" = "Would you like to unpin this message?"; "lng_pinned_pin_sure" = "Would you like to pin this message?"; "lng_pinned_pin" = "Pin"; diff --git a/Telegram/SourceFiles/data/data_media_types.cpp b/Telegram/SourceFiles/data/data_media_types.cpp index 961ffd4481..e29fe3bfce 100644 --- a/Telegram/SourceFiles/data/data_media_types.cpp +++ b/Telegram/SourceFiles/data/data_media_types.cpp @@ -1217,7 +1217,7 @@ PollData *MediaPoll::poll() const { } QString MediaPoll::notificationText() const { - return lang(lng_in_dlg_poll); + return _poll->question; } QString MediaPoll::pinnedTextSubstring() const { diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index d73a1a0af1..bd6d5d20d8 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -6496,8 +6496,9 @@ void HistoryWidget::drawPinnedBar(Painter &p) { int32 left = st::msgReplyBarSkip + st::msgReplyBarSkip; if (_pinnedBar->msg) { - if (_pinnedBar->msg->media() && _pinnedBar->msg->media()->hasReplyPreview()) { - if (const auto image = _pinnedBar->msg->media()->replyPreview()) { + const auto media = _pinnedBar->msg->media(); + if (media && media->hasReplyPreview()) { + if (const auto image = media->replyPreview()) { QRect to(left, top, st::msgReplyBarSize.height(), st::msgReplyBarSize.height()); p.drawPixmap(to.x(), to.y(), image->pixSingle(_pinnedBar->msg->fullId(), image->width() / cIntRetinaFactor(), image->height() / cIntRetinaFactor(), to.width(), to.height(), ImageRoundRadius::Small)); } @@ -6505,7 +6506,7 @@ void HistoryWidget::drawPinnedBar(Painter &p) { } p.setPen(st::historyReplyNameFg); p.setFont(st::msgServiceNameFont); - p.drawText(left, top + st::msgServiceNameFont->ascent, lang(lng_pinned_message)); + p.drawText(left, top + st::msgServiceNameFont->ascent, lang((media && media->poll()) ? lng_pinned_poll : lng_pinned_message)); p.setPen(st::historyComposeAreaFg); p.setTextPalette(st::historyComposeAreaPalette);