mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 23:24:01 +02:00
Show pinned icon in stories.
This commit is contained in:
parent
468d8b04d6
commit
9036e9e8e3
9 changed files with 52 additions and 2 deletions
BIN
Telegram/Resources/icons/dialogs/dialogs_pinned_shadow.png
Normal file
BIN
Telegram/Resources/icons/dialogs/dialogs_pinned_shadow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 754 B |
BIN
Telegram/Resources/icons/dialogs/dialogs_pinned_shadow@2x.png
Normal file
BIN
Telegram/Resources/icons/dialogs/dialogs_pinned_shadow@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
Telegram/Resources/icons/dialogs/dialogs_pinned_shadow@3x.png
Normal file
BIN
Telegram/Resources/icons/dialogs/dialogs_pinned_shadow@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
|
@ -390,7 +390,12 @@ TextWithEntities Story::inReplyText() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Story::setPinnedToTop(bool pinned) {
|
void Story::setPinnedToTop(bool pinned) {
|
||||||
_pinnedToTop = pinned;
|
if (_pinnedToTop != pinned) {
|
||||||
|
_pinnedToTop = pinned;
|
||||||
|
if (const auto item = _peer->owner().stories().lookupItem(this)) {
|
||||||
|
item->setIsPinned(pinned);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Story::pinnedToTop() const {
|
bool Story::pinnedToTop() const {
|
||||||
|
|
|
@ -1360,6 +1360,10 @@ void HistoryItem::setIsPinned(bool pinned) {
|
||||||
const auto changed = (isPinned() != pinned);
|
const auto changed = (isPinned() != pinned);
|
||||||
if (pinned) {
|
if (pinned) {
|
||||||
_flags |= MessageFlag::Pinned;
|
_flags |= MessageFlag::Pinned;
|
||||||
|
if (_flags & MessageFlag::StoryItem) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto &storage = _history->session().storage();
|
auto &storage = _history->session().storage();
|
||||||
storage.add(Storage::SharedMediaAddExisting(
|
storage.add(Storage::SharedMediaAddExisting(
|
||||||
_history->peer->id,
|
_history->peer->id,
|
||||||
|
@ -1379,6 +1383,10 @@ void HistoryItem::setIsPinned(bool pinned) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_flags &= ~MessageFlag::Pinned;
|
_flags &= ~MessageFlag::Pinned;
|
||||||
|
if (_flags & MessageFlag::StoryItem) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_history->session().storage().remove(Storage::SharedMediaRemoveOne(
|
_history->session().storage().remove(Storage::SharedMediaRemoveOne(
|
||||||
_history->peer->id,
|
_history->peer->id,
|
||||||
Storage::SharedMediaType::Pinned,
|
Storage::SharedMediaType::Pinned,
|
||||||
|
@ -1687,6 +1695,11 @@ void HistoryItem::setStoryFields(not_null<Data::Story*> story) {
|
||||||
/*ttlSeconds = */0);
|
/*ttlSeconds = */0);
|
||||||
}
|
}
|
||||||
setText(story->caption());
|
setText(story->caption());
|
||||||
|
if (story->pinnedToTop()) {
|
||||||
|
_flags |= MessageFlag::Pinned;
|
||||||
|
} else {
|
||||||
|
_flags &= ~MessageFlag::Pinned;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryItem::applyEdition(const MTPDmessageService &message) {
|
void HistoryItem::applyEdition(const MTPDmessageService &message) {
|
||||||
|
|
|
@ -343,7 +343,10 @@ std::unique_ptr<BaseLayout> Provider::createLayout(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
using namespace Overview::Layout;
|
using namespace Overview::Layout;
|
||||||
const auto options = MediaOptions{ .story = true };
|
const auto options = MediaOptions{
|
||||||
|
.pinned = item->isPinned(),
|
||||||
|
.story = true,
|
||||||
|
};
|
||||||
if (const auto photo = getPhoto()) {
|
if (const auto photo = getPhoto()) {
|
||||||
return std::make_unique<Photo>(delegate, item, photo, options);
|
return std::make_unique<Photo>(delegate, item, photo, options);
|
||||||
} else if (const auto file = getFile()) {
|
} else if (const auto file = getFile()) {
|
||||||
|
|
|
@ -140,3 +140,12 @@ overviewVideoPlaySelected: icon {{ "overview_video_play", historyFileThumbIconFg
|
||||||
overviewVideoDownload: icon {{ "overview_video_download", historyFileThumbIconFg }};
|
overviewVideoDownload: icon {{ "overview_video_download", historyFileThumbIconFg }};
|
||||||
overviewVideoDownloadSelected: icon {{ "overview_video_download", historyFileThumbIconFgSelected }};
|
overviewVideoDownloadSelected: icon {{ "overview_video_download", historyFileThumbIconFgSelected }};
|
||||||
overviewVideoRadialSize: 36px;
|
overviewVideoRadialSize: 36px;
|
||||||
|
|
||||||
|
storyPinnedIcon: icon{
|
||||||
|
{ "dialogs/dialogs_pinned_shadow", windowShadowFg },
|
||||||
|
{ "dialogs/dialogs_pinned", historyFileThumbIconFg }
|
||||||
|
};
|
||||||
|
storyPinnedIconSelected: icon{
|
||||||
|
{ "dialogs/dialogs_pinned_shadow", windowShadowFg },
|
||||||
|
{ "dialogs/dialogs_pinned", historyFileThumbIconFgSelected }
|
||||||
|
};
|
||||||
|
|
|
@ -339,6 +339,7 @@ Photo::Photo(
|
||||||
, _spoiler(options.spoiler ? std::make_unique<Ui::SpoilerAnimation>([=] {
|
, _spoiler(options.spoiler ? std::make_unique<Ui::SpoilerAnimation>([=] {
|
||||||
delegate->repaintItem(this);
|
delegate->repaintItem(this);
|
||||||
}) : nullptr)
|
}) : nullptr)
|
||||||
|
, _pinned(options.pinned)
|
||||||
, _story(options.story) {
|
, _story(options.story) {
|
||||||
if (_data->inlineThumbnailBytes().isEmpty()
|
if (_data->inlineThumbnailBytes().isEmpty()
|
||||||
&& (_data->hasExact(Data::PhotoSize::Small)
|
&& (_data->hasExact(Data::PhotoSize::Small)
|
||||||
|
@ -407,6 +408,14 @@ void Photo::paint(Painter &p, const QRect &clip, TextSelection selection, const
|
||||||
if (selected) {
|
if (selected) {
|
||||||
p.fillRect(0, 0, _width, _height, st::overviewPhotoSelectOverlay);
|
p.fillRect(0, 0, _width, _height, st::overviewPhotoSelectOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_pinned) {
|
||||||
|
const auto &icon = selected
|
||||||
|
? st::storyPinnedIconSelected
|
||||||
|
: st::storyPinnedIcon;
|
||||||
|
icon.paint(p, _width - icon.width(), 0, _width);
|
||||||
|
}
|
||||||
|
|
||||||
const auto checkDelta = st::overviewCheckSkip + st::overviewCheck.size;
|
const auto checkDelta = st::overviewCheckSkip + st::overviewCheck.size;
|
||||||
const auto checkLeft = _width - checkDelta;
|
const auto checkLeft = _width - checkDelta;
|
||||||
const auto checkTop = _height - checkDelta;
|
const auto checkTop = _height - checkDelta;
|
||||||
|
@ -475,6 +484,7 @@ Video::Video(
|
||||||
, _spoiler(options.spoiler ? std::make_unique<Ui::SpoilerAnimation>([=] {
|
, _spoiler(options.spoiler ? std::make_unique<Ui::SpoilerAnimation>([=] {
|
||||||
delegate->repaintItem(this);
|
delegate->repaintItem(this);
|
||||||
}) : nullptr)
|
}) : nullptr)
|
||||||
|
, _pinned(options.pinned)
|
||||||
, _story(options.story) {
|
, _story(options.story) {
|
||||||
setDocumentLinks(_data);
|
setDocumentLinks(_data);
|
||||||
_data->loadThumbnail(parent->fullId());
|
_data->loadThumbnail(parent->fullId());
|
||||||
|
@ -547,6 +557,13 @@ void Video::paint(Painter &p, const QRect &clip, TextSelection selection, const
|
||||||
p.fillRect(QRect(0, 0, _width, _height), st::overviewPhotoSelectOverlay);
|
p.fillRect(QRect(0, 0, _width, _height), st::overviewPhotoSelectOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_pinned) {
|
||||||
|
const auto &icon = selected
|
||||||
|
? st::storyPinnedIconSelected
|
||||||
|
: st::storyPinnedIcon;
|
||||||
|
icon.paint(p, _width - icon.width(), 0, _width);
|
||||||
|
}
|
||||||
|
|
||||||
if (!selected && !context->selecting && radialOpacity < 1.) {
|
if (!selected && !context->selecting && radialOpacity < 1.) {
|
||||||
if (clip.intersects(QRect(0, _height - st::normalFont->height, _width, st::normalFont->height))) {
|
if (clip.intersects(QRect(0, _height - st::normalFont->height, _width, st::normalFont->height))) {
|
||||||
const auto download = !loaded && !_dataMedia->canBePlayed(parent());
|
const auto download = !loaded && !_dataMedia->canBePlayed(parent());
|
||||||
|
|
|
@ -185,6 +185,7 @@ struct Info : public RuntimeComponent<Info, LayoutItemBase> {
|
||||||
|
|
||||||
struct MediaOptions {
|
struct MediaOptions {
|
||||||
bool spoiler = false;
|
bool spoiler = false;
|
||||||
|
bool pinned = false;
|
||||||
bool story = false;
|
bool story = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -218,6 +219,7 @@ private:
|
||||||
|
|
||||||
QPixmap _pix;
|
QPixmap _pix;
|
||||||
bool _goodLoaded = false;
|
bool _goodLoaded = false;
|
||||||
|
bool _pinned = false;
|
||||||
bool _story = false;
|
bool _story = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -318,6 +320,7 @@ private:
|
||||||
|
|
||||||
QPixmap _pix;
|
QPixmap _pix;
|
||||||
bool _pixBlurred = true;
|
bool _pixBlurred = true;
|
||||||
|
bool _pinned = false;
|
||||||
bool _story = false;
|
bool _story = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue