mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show repost-from-name in story header.
This commit is contained in:
parent
6057bb2b37
commit
d6d76c8477
9 changed files with 85 additions and 2 deletions
BIN
Telegram/Resources/icons/mediaview/mini_repost.png
Normal file
BIN
Telegram/Resources/icons/mediaview/mini_repost.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 481 B |
BIN
Telegram/Resources/icons/mediaview/mini_repost@2x.png
Normal file
BIN
Telegram/Resources/icons/mediaview/mini_repost@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 780 B |
BIN
Telegram/Resources/icons/mediaview/mini_repost@3x.png
Normal file
BIN
Telegram/Resources/icons/mediaview/mini_repost@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -879,6 +879,8 @@ void Controller::show(
|
||||||
const auto document = story->document();
|
const auto document = story->document();
|
||||||
_header->show({
|
_header->show({
|
||||||
.peer = peer,
|
.peer = peer,
|
||||||
|
.repostPeer = story->repostSourcePeer(),
|
||||||
|
.repostFrom = _repostView ? _repostView->fromName() : nullptr,
|
||||||
.date = story->date(),
|
.date = story->date(),
|
||||||
.fullIndex = _sliderCount ? _index : 0,
|
.fullIndex = _sliderCount ? _index : 0,
|
||||||
.fullCount = _sliderCount ? shownCount() : 0,
|
.fullCount = _sliderCount ? shownCount() : 0,
|
||||||
|
|
|
@ -9,7 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "chat_helpers/compose/compose_show.h"
|
#include "chat_helpers/compose/compose_show.h"
|
||||||
|
#include "core/ui_integration.h"
|
||||||
|
#include "data/stickers/data_custom_emoji.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
|
#include "data/data_session.h"
|
||||||
#include "media/stories/media_stories_controller.h"
|
#include "media/stories/media_stories_controller.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/controls/userpic_button.h"
|
#include "ui/controls/userpic_button.h"
|
||||||
|
@ -252,9 +255,24 @@ struct MadePrivacyBadge {
|
||||||
result.text.append(
|
result.text.append(
|
||||||
QString::fromUtf8(" \xE2\x80\xA2 ") + tr::lng_edited(tr::now));
|
QString::fromUtf8(" \xE2\x80\xA2 ") + tr::lng_edited(tr::now));
|
||||||
}
|
}
|
||||||
|
if (!data.repostFrom.isEmpty()) {
|
||||||
|
result.text = QString::fromUtf8("\xC2\xA0\xE2\x80\xA2 ")
|
||||||
|
+ result.text;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] TextWithEntities RepostNameValue(
|
||||||
|
not_null<Data::Session*> owner,
|
||||||
|
QString name) {
|
||||||
|
const auto result = Ui::Text::SingleCustomEmoji(
|
||||||
|
owner->customEmojiManager().registerInternalEmoji(
|
||||||
|
st::storiesRepostIcon,
|
||||||
|
st::storiesRepostIconPadding)
|
||||||
|
).append(name);
|
||||||
|
return Ui::Text::Link(result);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Header::Header(not_null<Controller*> controller)
|
Header::Header(not_null<Controller*> controller)
|
||||||
|
@ -275,7 +293,9 @@ void Header::show(HeaderData data) {
|
||||||
const auto namex = st::storiesHeaderNamePosition.x();
|
const auto namex = st::storiesHeaderNamePosition.x();
|
||||||
const auto namer = namex + _name->width();
|
const auto namer = namex + _name->width();
|
||||||
const auto datex = st::storiesHeaderDatePosition.x();
|
const auto datex = st::storiesHeaderDatePosition.x();
|
||||||
const auto dater = datex + _date->width();
|
const auto dater = datex
|
||||||
|
+ (_repost ? _repost->width() : 0)
|
||||||
|
+ _date->width();
|
||||||
const auto r = std::max(namer, dater);
|
const auto r = std::max(namer, dater);
|
||||||
_info->setGeometry({ 0, 0, r, _widget->height() });
|
_info->setGeometry({ 0, 0, r, _widget->height() });
|
||||||
}
|
}
|
||||||
|
@ -285,6 +305,7 @@ void Header::show(HeaderData data) {
|
||||||
if (peerChanged) {
|
if (peerChanged) {
|
||||||
_volume = nullptr;
|
_volume = nullptr;
|
||||||
_date = nullptr;
|
_date = nullptr;
|
||||||
|
_repost = nullptr;
|
||||||
_name = nullptr;
|
_name = nullptr;
|
||||||
_counter = nullptr;
|
_counter = nullptr;
|
||||||
_userpic = nullptr;
|
_userpic = nullptr;
|
||||||
|
@ -350,6 +371,32 @@ void Header::show(HeaderData data) {
|
||||||
_date->widthValue(
|
_date->widthValue(
|
||||||
) | rpl::start_with_next(updateInfoGeometry, _date->lifetime());
|
) | rpl::start_with_next(updateInfoGeometry, _date->lifetime());
|
||||||
|
|
||||||
|
if (data.repostFrom.isEmpty()) {
|
||||||
|
_repost = nullptr;
|
||||||
|
} else {
|
||||||
|
_repost = std::make_unique<Ui::FlatLabel>(
|
||||||
|
_widget.get(),
|
||||||
|
st::storiesHeaderDate);
|
||||||
|
const auto repostName = RepostNameValue(
|
||||||
|
&data.peer->owner(),
|
||||||
|
data.repostFrom);
|
||||||
|
_repost->setMarkedText(
|
||||||
|
data.repostPeer ? Ui::Text::Link(repostName) : repostName,
|
||||||
|
Core::MarkedTextContext{
|
||||||
|
.session = &data.peer->session(),
|
||||||
|
.customEmojiRepaint = [=] { _repost->update(); },
|
||||||
|
});
|
||||||
|
if (const auto peer = data.repostPeer) {
|
||||||
|
_repost->setClickHandlerFilter([=](const auto &...) {
|
||||||
|
_controller->uiShow()->show(PrepareShortInfoBox(peer));
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
_repost->show();
|
||||||
|
_repost->widthValue(
|
||||||
|
) | rpl::start_with_next(updateInfoGeometry, _repost->lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
auto counter = ComposeCounter(data);
|
auto counter = ComposeCounter(data);
|
||||||
if (!counter.isEmpty()) {
|
if (!counter.isEmpty()) {
|
||||||
_counter = std::make_unique<Ui::FlatLabel>(
|
_counter = std::make_unique<Ui::FlatLabel>(
|
||||||
|
@ -433,13 +480,30 @@ void Header::show(HeaderData data) {
|
||||||
_counter->move(counterLeft, _name->y());
|
_counter->move(counterLeft, _name->y());
|
||||||
}
|
}
|
||||||
const auto dateLeft = st::storiesHeaderDatePosition.x();
|
const auto dateLeft = st::storiesHeaderDatePosition.x();
|
||||||
const auto dateAvailable = right - dateLeft;
|
const auto dateTop = st::storiesHeaderDatePosition.y();
|
||||||
|
const auto dateSkip = _repost ? st::storiesHeaderRepostWidthMin : 0;
|
||||||
|
const auto dateAvailable = right - dateLeft - dateSkip;
|
||||||
if (dateAvailable <= 0) {
|
if (dateAvailable <= 0) {
|
||||||
_date->hide();
|
_date->hide();
|
||||||
} else {
|
} else {
|
||||||
_date->show();
|
_date->show();
|
||||||
_date->resizeToNaturalWidth(dateAvailable);
|
_date->resizeToNaturalWidth(dateAvailable);
|
||||||
}
|
}
|
||||||
|
if (_repost) {
|
||||||
|
const auto repostAvailable = dateAvailable
|
||||||
|
+ dateSkip
|
||||||
|
- _date->width();
|
||||||
|
if (repostAvailable <= 0) {
|
||||||
|
_repost->hide();
|
||||||
|
} else {
|
||||||
|
_repost->show();
|
||||||
|
_repost->resizeToNaturalWidth(repostAvailable);
|
||||||
|
}
|
||||||
|
_repost->move(dateLeft, dateTop);
|
||||||
|
_date->move(dateLeft + _repost->width(), dateTop);
|
||||||
|
} else {
|
||||||
|
_date->move(dateLeft, dateTop);
|
||||||
|
}
|
||||||
}, _date->lifetime());
|
}, _date->lifetime());
|
||||||
|
|
||||||
if (timestamp.changes > 0) {
|
if (timestamp.changes > 0) {
|
||||||
|
|
|
@ -32,6 +32,8 @@ enum class PauseState;
|
||||||
|
|
||||||
struct HeaderData {
|
struct HeaderData {
|
||||||
not_null<PeerData*> peer;
|
not_null<PeerData*> peer;
|
||||||
|
PeerData *repostPeer = nullptr;
|
||||||
|
QString repostFrom;
|
||||||
TimeId date = 0;
|
TimeId date = 0;
|
||||||
int fullIndex = 0;
|
int fullIndex = 0;
|
||||||
int fullCount = 0;
|
int fullCount = 0;
|
||||||
|
@ -84,6 +86,7 @@ private:
|
||||||
std::unique_ptr<Ui::UserpicButton> _userpic;
|
std::unique_ptr<Ui::UserpicButton> _userpic;
|
||||||
std::unique_ptr<Ui::FlatLabel> _name;
|
std::unique_ptr<Ui::FlatLabel> _name;
|
||||||
std::unique_ptr<Ui::FlatLabel> _counter;
|
std::unique_ptr<Ui::FlatLabel> _counter;
|
||||||
|
std::unique_ptr<Ui::FlatLabel> _repost;
|
||||||
std::unique_ptr<Ui::FlatLabel> _date;
|
std::unique_ptr<Ui::FlatLabel> _date;
|
||||||
rpl::event_stream<> _dateUpdated;
|
rpl::event_stream<> _dateUpdated;
|
||||||
std::unique_ptr<Ui::RpWidget> _playPause;
|
std::unique_ptr<Ui::RpWidget> _playPause;
|
||||||
|
|
|
@ -184,6 +184,11 @@ RepostClickHandler RepostView::lookupHandler(QPoint position) {
|
||||||
return { _link, this };
|
return { _link, this };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString RepostView::fromName() const {
|
||||||
|
const auto sender = _story->repostSourcePeer();
|
||||||
|
return sender ? sender->name() : _story->repostSourceName();
|
||||||
|
}
|
||||||
|
|
||||||
void RepostView::recountDimensions() {
|
void RepostView::recountDimensions() {
|
||||||
const auto sender = _story->repostSourcePeer();
|
const auto sender = _story->repostSourcePeer();
|
||||||
const auto name = sender ? sender->name() : _story->repostSourceName();
|
const auto name = sender ? sender->name() : _story->repostSourceName();
|
||||||
|
|
|
@ -38,6 +38,8 @@ public:
|
||||||
void draw(Painter &p, int x, int y, int availableWidth);
|
void draw(Painter &p, int x, int y, int availableWidth);
|
||||||
[[nodiscard]] RepostClickHandler lookupHandler(QPoint position);
|
[[nodiscard]] RepostClickHandler lookupHandler(QPoint position);
|
||||||
|
|
||||||
|
[[nodiscard]] QString fromName() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void recountDimensions();
|
void recountDimensions();
|
||||||
|
|
||||||
|
|
|
@ -433,10 +433,14 @@ storiesHeaderName: FlatLabel(defaultFlatLabel) {
|
||||||
storiesHeaderNamePosition: point(50px, 0px);
|
storiesHeaderNamePosition: point(50px, 0px);
|
||||||
storiesHeaderDate: FlatLabel(defaultFlatLabel) {
|
storiesHeaderDate: FlatLabel(defaultFlatLabel) {
|
||||||
textFg: mediaviewControlFg;
|
textFg: mediaviewControlFg;
|
||||||
|
palette: TextPalette(defaultTextPalette) {
|
||||||
|
linkFg: mediaviewControlFg;
|
||||||
|
}
|
||||||
minWidth: 10px;
|
minWidth: 10px;
|
||||||
maxHeight: 20px;
|
maxHeight: 20px;
|
||||||
}
|
}
|
||||||
storiesHeaderDatePosition: point(50px, 17px);
|
storiesHeaderDatePosition: point(50px, 17px);
|
||||||
|
storiesHeaderRepostWidthMin: 40px;
|
||||||
storiesShadowTop: icon{{ "mediaview/shadow_bottom-flip_vertical", windowShadowFg }};
|
storiesShadowTop: icon{{ "mediaview/shadow_bottom-flip_vertical", windowShadowFg }};
|
||||||
storiesShadowBottom: mediaviewShadowBottom;
|
storiesShadowBottom: mediaviewShadowBottom;
|
||||||
storiesControlsMinWidth: 280px;
|
storiesControlsMinWidth: 280px;
|
||||||
|
@ -1009,9 +1013,12 @@ storiesLikeCountStyle: TextStyle(defaultTextStyle) {
|
||||||
font: font(32px semibold);
|
font: font(32px semibold);
|
||||||
}
|
}
|
||||||
storiesChangelogFooterWidthMin: 240px;
|
storiesChangelogFooterWidthMin: 240px;
|
||||||
|
|
||||||
storiesRepostSimpleStyle: QuoteStyle(defaultQuoteStyle) {
|
storiesRepostSimpleStyle: QuoteStyle(defaultQuoteStyle) {
|
||||||
padding: margins(8px, 2px, 8px, 2px);
|
padding: margins(8px, 2px, 8px, 2px);
|
||||||
verticalSkip: 4px;
|
verticalSkip: 4px;
|
||||||
outline: 0px;
|
outline: 0px;
|
||||||
radius: 10px;
|
radius: 10px;
|
||||||
}
|
}
|
||||||
|
storiesRepostIcon: icon {{ "mediaview/mini_repost", windowFg }};
|
||||||
|
storiesRepostIconPadding: margins(0px, 4px, 4px, 0px);
|
||||||
|
|
Loading…
Add table
Reference in a new issue