init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
151
Telegram/SourceFiles/overview/overview.style
Normal file
151
Telegram/SourceFiles/overview/overview.style
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
using "ui/basic.style";
|
||||
using "ui/chat/chat.style";
|
||||
using "ui/widgets/widgets.style";
|
||||
using "boxes/boxes.style";
|
||||
|
||||
OverviewFileLayout {
|
||||
maxWidth: pixels;
|
||||
songPadding: margins;
|
||||
songThumbSize: pixels;
|
||||
songNameTop: pixels;
|
||||
songStatusTop: pixels;
|
||||
songIconBg: color;
|
||||
songOverBg: color;
|
||||
songPause: icon;
|
||||
songPauseSelected: icon;
|
||||
songPlay: icon;
|
||||
songPlaySelected: icon;
|
||||
songCancel: icon;
|
||||
songCancelSelected: icon;
|
||||
songDownload: icon;
|
||||
songDownloadSelected: icon;
|
||||
|
||||
voicePause: icon;
|
||||
voicePauseSelected: icon;
|
||||
voicePlay: icon;
|
||||
voicePlaySelected: icon;
|
||||
voiceCancel: icon;
|
||||
voiceCancelSelected: icon;
|
||||
voiceDownload: icon;
|
||||
voiceDownloadSelected: icon;
|
||||
|
||||
filePadding: margins;
|
||||
fileThumbSize: pixels;
|
||||
fileNameTop: pixels;
|
||||
fileStatusTop: pixels;
|
||||
fileDateTop: pixels;
|
||||
}
|
||||
|
||||
overviewCheckPressedSize: 0.8;
|
||||
overviewCheck: RoundCheckbox(defaultRoundCheckbox) {
|
||||
bgInactive: overviewCheckBg;
|
||||
bgActive: overviewCheckBgActive;
|
||||
border: overviewCheckBorder;
|
||||
size: 29px;
|
||||
sizeSmall: 0.3;
|
||||
check: icon {{ "overview_photo_check", overviewCheckFgActive, point(4px, 8px) }};
|
||||
}
|
||||
overviewSmallCheck: RoundCheckbox(defaultPeerListCheck) {
|
||||
border: overviewCheckBorder;
|
||||
}
|
||||
overviewCheckSkip: 5px;
|
||||
|
||||
overviewPhotoBg: windowBgOver;
|
||||
overviewPhotoMinSize: 90px;
|
||||
overviewVideoBg: imageBg;
|
||||
|
||||
overviewFileThumbBg: imageBg;
|
||||
overviewFileExtPadding: 5px;
|
||||
overviewFileExtTop: 24px;
|
||||
overviewFileExtFg: windowFgActive;
|
||||
overviewFileExtFont: font(18px semibold);
|
||||
|
||||
overviewVoicePause: icon {{ "player/playlist_pause", historyFileInIconFg }};
|
||||
overviewVoicePauseSelected: icon {{ "player/playlist_pause", historyFileInIconFgSelected }};
|
||||
overviewVoicePlay: icon {{ "player/playlist_play", historyFileInIconFg }};
|
||||
overviewVoicePlaySelected: icon {{ "player/playlist_play", historyFileInIconFgSelected }};
|
||||
overviewVoiceCancel: icon {{ "player/playlist_cancel", historyFileInIconFg }};
|
||||
overviewVoiceCancelSelected: icon {{ "player/playlist_cancel", historyFileInIconFgSelected }};
|
||||
overviewVoiceDownload: icon {{ "player/playlist_download", historyFileInIconFg }};
|
||||
overviewVoiceDownloadSelected: icon {{ "player/playlist_download", historyFileInIconFgSelected }};
|
||||
|
||||
overviewSongPause: icon {{ "player/playlist_pause", historyFileThumbIconFg }};
|
||||
overviewSongPauseSelected: icon {{ "player/playlist_pause", historyFileThumbIconFgSelected }};
|
||||
overviewSongPlay: icon {{ "player/playlist_play", historyFileThumbIconFg }};
|
||||
overviewSongPlaySelected: icon {{ "player/playlist_play", historyFileThumbIconFgSelected }};
|
||||
overviewSongCancel: icon {{ "player/playlist_cancel", historyFileThumbIconFg }};
|
||||
overviewSongCancelSelected: icon {{ "player/playlist_cancel", historyFileThumbIconFgSelected }};
|
||||
overviewSongDownload: icon {{ "player/playlist_download", historyFileThumbIconFg }};
|
||||
overviewSongDownloadSelected: icon {{ "player/playlist_download", historyFileThumbIconFgSelected }};
|
||||
overviewSmallCancel: icon {{ "history_audio_cancel", historyFileInIconFg }};
|
||||
overviewSmallCancelSelected: icon {{ "history_audio_cancel", historyFileInIconFgSelected }};
|
||||
overviewSmallDownload: icon {{ "history_audio_download", historyFileInIconFg }};
|
||||
overviewSmallDownloadSelected: icon {{ "history_audio_download", historyFileInIconFgSelected }};
|
||||
overviewFileLayout: OverviewFileLayout {
|
||||
maxWidth: 520px;
|
||||
songPadding: margins(17px, 7px, 10px, 6px);
|
||||
songThumbSize: 36px;
|
||||
songNameTop: 7px;
|
||||
songStatusTop: 25px;
|
||||
songIconBg: msgFileInBg;
|
||||
songOverBg: msgFileInBgOver;
|
||||
songPause: overviewSongPause;
|
||||
songPauseSelected: overviewSongPauseSelected;
|
||||
songPlay: overviewSongPlay;
|
||||
songPlaySelected: overviewSongPlaySelected;
|
||||
songCancel: overviewSongCancel;
|
||||
songCancelSelected: overviewSongCancelSelected;
|
||||
songDownload: overviewSongDownload;
|
||||
songDownloadSelected: overviewSongDownloadSelected;
|
||||
|
||||
voicePause: overviewVoicePause;
|
||||
voicePauseSelected: overviewVoicePauseSelected;
|
||||
voicePlay: overviewVoicePlay;
|
||||
voicePlaySelected: overviewVoicePlaySelected;
|
||||
voiceCancel: overviewVoiceCancel;
|
||||
voiceCancelSelected: overviewVoiceCancelSelected;
|
||||
voiceDownload: overviewVoiceDownload;
|
||||
voiceDownloadSelected: overviewVoiceDownloadSelected;
|
||||
|
||||
filePadding: margins(0px, 3px, 16px, 3px);
|
||||
fileThumbSize: 70px;
|
||||
fileNameTop: 7px;
|
||||
fileStatusTop: 24px;
|
||||
fileDateTop: 49px;
|
||||
}
|
||||
|
||||
linksMaxWidth: 520px;
|
||||
linksLetterFg: windowFgActive;
|
||||
linksLetterFont: font(24px);
|
||||
linksMargin: margins(0px, 7px, 0px, 5px);
|
||||
linksTextFg: windowFg;
|
||||
linksTextTop: 6px;
|
||||
linksBorder: 1px;
|
||||
linksBorderFg: shadowFg;
|
||||
linksPhotoSize: 46px;
|
||||
linksPhotoPadding: 12px;
|
||||
|
||||
overviewVideoStatusMargin: 3px;
|
||||
overviewVideoStatusPadding: point(6px, 0px);
|
||||
overviewVideoStatusRadius: 4px;
|
||||
overviewVideoPlay: icon {{ "overview_video_play", historyFileThumbIconFg }};
|
||||
overviewVideoPlaySelected: icon {{ "overview_video_play", historyFileThumbIconFgSelected }};
|
||||
overviewVideoDownload: icon {{ "overview_video_download", historyFileThumbIconFg }};
|
||||
overviewVideoDownloadSelected: icon {{ "overview_video_download", historyFileThumbIconFgSelected }};
|
||||
overviewVideoRadialSize: 36px;
|
||||
|
||||
storyPinnedIcon: icon{
|
||||
{ "dialogs/dialogs_pinned_shadow", windowShadowFg },
|
||||
{ "dialogs/dialogs_pinned", historyFileThumbIconFg }
|
||||
};
|
||||
storyPinnedIconSelected: icon{
|
||||
{ "dialogs/dialogs_pinned_shadow", windowShadowFg },
|
||||
{ "dialogs/dialogs_pinned", historyFileThumbIconFgSelected }
|
||||
};
|
||||
60
Telegram/SourceFiles/overview/overview_checkbox.cpp
Normal file
60
Telegram/SourceFiles/overview/overview_checkbox.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "overview/overview_checkbox.h"
|
||||
|
||||
#include "styles/style_overview.h"
|
||||
#include "styles/style_widgets.h"
|
||||
|
||||
namespace Overview::Layout {
|
||||
|
||||
void Checkbox::paint(
|
||||
QPainter &p,
|
||||
QPoint position,
|
||||
int outerWidth,
|
||||
bool selected,
|
||||
bool selecting) {
|
||||
_check.setDisplayInactive(selecting);
|
||||
_check.setChecked(selected);
|
||||
const auto pression = _pression.value((_active && _pressed) ? 1. : 0.);
|
||||
const auto scale = 1. - (1. - st::overviewCheckPressedSize) * pression;
|
||||
_check.paint(p, position.x(), position.y(), outerWidth, scale);
|
||||
}
|
||||
|
||||
void Checkbox::setActive(bool active) {
|
||||
_active = active;
|
||||
if (_pressed) {
|
||||
startAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
void Checkbox::setPressed(bool pressed) {
|
||||
_pressed = pressed;
|
||||
if (_active) {
|
||||
startAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
void Checkbox::setChecked(bool checked, anim::type animated) {
|
||||
_check.setChecked(checked, animated);
|
||||
}
|
||||
|
||||
void Checkbox::startAnimation() {
|
||||
const auto showPressed = (_pressed && _active);
|
||||
_pression.start(
|
||||
_updateCallback,
|
||||
showPressed ? 0. : 1.,
|
||||
showPressed ? 1. : 0.,
|
||||
st::overviewCheck.duration);
|
||||
}
|
||||
|
||||
void Checkbox::finishAnimating() {
|
||||
_pression.stop();
|
||||
_check.finishAnimating();
|
||||
}
|
||||
|
||||
} // namespace Overview::Layout
|
||||
54
Telegram/SourceFiles/overview/overview_checkbox.h
Normal file
54
Telegram/SourceFiles/overview/overview_checkbox.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "ui/effects/round_checkbox.h"
|
||||
|
||||
namespace style {
|
||||
struct RoundCheckbox;
|
||||
} // namespace style
|
||||
|
||||
namespace Overview::Layout {
|
||||
|
||||
class Checkbox {
|
||||
public:
|
||||
template <typename UpdateCallback>
|
||||
Checkbox(UpdateCallback callback, const style::RoundCheckbox &st)
|
||||
: _updateCallback(callback)
|
||||
, _check(st, _updateCallback) {
|
||||
}
|
||||
|
||||
void paint(
|
||||
QPainter &p,
|
||||
QPoint position,
|
||||
int outerWidth,
|
||||
bool selected,
|
||||
bool selecting);
|
||||
|
||||
void setActive(bool active);
|
||||
void setPressed(bool pressed);
|
||||
void setChecked(bool checked, anim::type animated = anim::type::normal);
|
||||
void finishAnimating();
|
||||
|
||||
void invalidateCache() {
|
||||
_check.invalidateCache();
|
||||
}
|
||||
|
||||
private:
|
||||
void startAnimation();
|
||||
|
||||
Fn<void()> _updateCallback;
|
||||
Ui::RoundCheckbox _check;
|
||||
|
||||
Ui::Animations::Simple _pression;
|
||||
bool _active = false;
|
||||
bool _pressed = false;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Overview::Layout
|
||||
2448
Telegram/SourceFiles/overview/overview_layout.cpp
Normal file
2448
Telegram/SourceFiles/overview/overview_layout.cpp
Normal file
File diff suppressed because it is too large
Load Diff
514
Telegram/SourceFiles/overview/overview_layout.h
Normal file
514
Telegram/SourceFiles/overview/overview_layout.h
Normal file
@@ -0,0 +1,514 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "layout/layout_item_base.h"
|
||||
#include "layout/layout_document_generic_preview.h"
|
||||
#include "media/clip/media_clip_reader.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/effects/radial_animation.h"
|
||||
|
||||
class Image;
|
||||
|
||||
namespace style {
|
||||
struct RoundCheckbox;
|
||||
struct OverviewFileLayout;
|
||||
} // namespace style
|
||||
|
||||
namespace Data {
|
||||
class Media;
|
||||
class PhotoMedia;
|
||||
class DocumentMedia;
|
||||
} // namespace Data
|
||||
|
||||
namespace Ui {
|
||||
class SpoilerAnimation;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Overview::Layout {
|
||||
|
||||
class Checkbox;
|
||||
class ItemBase;
|
||||
class Delegate;
|
||||
|
||||
class PaintContext : public PaintContextBase {
|
||||
public:
|
||||
PaintContext(crl::time ms, bool selecting, bool paused)
|
||||
: PaintContextBase(ms, selecting)
|
||||
, paused(paused) {
|
||||
}
|
||||
bool skipBorder = false;
|
||||
bool paused = false;
|
||||
|
||||
};
|
||||
|
||||
class ItemBase : public LayoutItemBase, public base::has_weak_ptr {
|
||||
public:
|
||||
ItemBase(not_null<Delegate*> delegate, not_null<HistoryItem*> parent);
|
||||
~ItemBase();
|
||||
|
||||
virtual void paint(
|
||||
Painter &p,
|
||||
const QRect &clip,
|
||||
TextSelection selection,
|
||||
const PaintContext *context) = 0;
|
||||
|
||||
[[nodiscard]] QDateTime dateTime() const;
|
||||
|
||||
[[nodiscard]] not_null<HistoryItem*> getItem() const {
|
||||
return _parent;
|
||||
}
|
||||
|
||||
void clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) override;
|
||||
void clickHandlerPressedChanged(const ClickHandlerPtr &action, bool pressed) override;
|
||||
|
||||
void invalidateCache();
|
||||
|
||||
virtual void itemDataChanged() {
|
||||
}
|
||||
virtual void clearHeavyPart() {
|
||||
}
|
||||
|
||||
virtual void maybeClearSensitiveSpoiler() {
|
||||
}
|
||||
|
||||
protected:
|
||||
[[nodiscard]] not_null<HistoryItem*> parent() const {
|
||||
return _parent;
|
||||
}
|
||||
[[nodiscard]] not_null<Delegate*> delegate() const {
|
||||
return _delegate;
|
||||
}
|
||||
void paintCheckbox(
|
||||
Painter &p,
|
||||
QPoint position,
|
||||
bool selected,
|
||||
const PaintContext *context);
|
||||
[[nodiscard]] virtual const style::RoundCheckbox &checkboxStyle() const;
|
||||
|
||||
private:
|
||||
void ensureCheckboxCreated();
|
||||
|
||||
const not_null<Delegate*> _delegate;
|
||||
const not_null<HistoryItem*> _parent;
|
||||
const QDateTime _dateTime;
|
||||
std::unique_ptr<Checkbox> _check;
|
||||
|
||||
};
|
||||
|
||||
class RadialProgressItem : public ItemBase {
|
||||
public:
|
||||
RadialProgressItem(
|
||||
not_null<Delegate*> delegate,
|
||||
not_null<HistoryItem*> parent)
|
||||
: ItemBase(delegate, parent) {
|
||||
}
|
||||
RadialProgressItem(const RadialProgressItem &other) = delete;
|
||||
|
||||
void clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) override;
|
||||
|
||||
virtual void clearSpoiler() {
|
||||
}
|
||||
|
||||
~RadialProgressItem();
|
||||
|
||||
protected:
|
||||
ClickHandlerPtr _openl, _savel, _cancell;
|
||||
void setLinks(
|
||||
ClickHandlerPtr &&openl,
|
||||
ClickHandlerPtr &&savel,
|
||||
ClickHandlerPtr &&cancell);
|
||||
void setDocumentLinks(
|
||||
not_null<DocumentData*> document,
|
||||
bool forceOpen = false);
|
||||
|
||||
void radialAnimationCallback(crl::time now) const;
|
||||
|
||||
void ensureRadial();
|
||||
void checkRadialFinished() const;
|
||||
|
||||
bool isRadialAnimation() const {
|
||||
if (_radial) {
|
||||
if (_radial->animating()) {
|
||||
return true;
|
||||
}
|
||||
checkRadialFinished();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual float64 dataProgress() const = 0;
|
||||
virtual bool dataFinished() const = 0;
|
||||
virtual bool dataLoaded() const = 0;
|
||||
virtual bool iconAnimated() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
mutable std::unique_ptr<Ui::RadialAnimation> _radial;
|
||||
Ui::Animations::Simple _a_iconOver;
|
||||
|
||||
};
|
||||
|
||||
class StatusText {
|
||||
public:
|
||||
// duration = -1 - no duration, duration = -2 - "GIF" duration
|
||||
void update(
|
||||
int64 newSize,
|
||||
int64 fullSize,
|
||||
TimeId duration,
|
||||
TimeId realDuration);
|
||||
void setSize(int64 newSize);
|
||||
|
||||
[[nodiscard]] int64 size() const {
|
||||
return _size;
|
||||
}
|
||||
[[nodiscard]] QString text() const {
|
||||
return _text;
|
||||
}
|
||||
|
||||
private:
|
||||
// >= 0 will contain download / upload string, _size = loaded bytes
|
||||
// < 0 will contain played string, _size = -(seconds + 1) played
|
||||
// 0xFFFFFFF0LL will contain status for not yet downloaded file
|
||||
// 0xFFFFFFF1LL will contain status for already downloaded file
|
||||
// 0xFFFFFFF2LL will contain status for failed to download / upload file
|
||||
int64 _size = 0;
|
||||
QString _text;
|
||||
|
||||
};
|
||||
|
||||
struct Info : RuntimeComponent<Info, LayoutItemBase> {
|
||||
int top = 0;
|
||||
};
|
||||
|
||||
struct MediaOptions {
|
||||
bool spoiler = false;
|
||||
bool story = false;
|
||||
bool storyPinned = false;
|
||||
bool storyShowPinned = false;
|
||||
bool storyHidden = false;
|
||||
bool storyShowHidden = false;
|
||||
};
|
||||
|
||||
class Photo final : public ItemBase {
|
||||
public:
|
||||
Photo(
|
||||
not_null<Delegate*> delegate,
|
||||
not_null<HistoryItem*> parent,
|
||||
not_null<PhotoData*> photo,
|
||||
MediaOptions options);
|
||||
~Photo();
|
||||
|
||||
void initDimensions() override;
|
||||
int32 resizeGetHeight(int32 width) override;
|
||||
void paint(Painter &p, const QRect &clip, TextSelection selection, const PaintContext *context) override;
|
||||
TextState getState(
|
||||
QPoint point,
|
||||
StateRequest request) const override;
|
||||
|
||||
void itemDataChanged() override;
|
||||
void clearHeavyPart() override;
|
||||
|
||||
void maybeClearSensitiveSpoiler() override;
|
||||
|
||||
private:
|
||||
void ensureDataMediaCreated() const;
|
||||
void setPixFrom(not_null<Image*> image);
|
||||
[[nodiscard]] ClickHandlerPtr makeOpenPhotoHandler();
|
||||
void clearSpoiler();
|
||||
|
||||
const not_null<PhotoData*> _data;
|
||||
mutable std::shared_ptr<Data::PhotoMedia> _dataMedia;
|
||||
std::unique_ptr<Ui::SpoilerAnimation> _spoiler;
|
||||
|
||||
QImage _pix;
|
||||
QImage _hiddenBgCache;
|
||||
bool _goodLoaded : 1 = false;
|
||||
bool _sensitiveSpoiler : 1 = false;
|
||||
bool _story : 1 = false;
|
||||
bool _storyPinned : 1 = false;
|
||||
bool _storyShowPinned : 1 = false;
|
||||
bool _storyHidden : 1 = false;
|
||||
bool _storyShowHidden : 1 = false;
|
||||
|
||||
ClickHandlerPtr _link;
|
||||
|
||||
};
|
||||
|
||||
class Gif final : public RadialProgressItem {
|
||||
public:
|
||||
Gif(
|
||||
not_null<Delegate*> delegate,
|
||||
not_null<HistoryItem*> parent,
|
||||
not_null<DocumentData*> gif);
|
||||
~Gif();
|
||||
|
||||
void initDimensions() override;
|
||||
int32 resizeGetHeight(int32 width) override;
|
||||
void paint(
|
||||
Painter &p,
|
||||
const QRect &clip,
|
||||
TextSelection selection,
|
||||
const PaintContext *context) override;
|
||||
TextState getState(
|
||||
QPoint point,
|
||||
StateRequest request) const override;
|
||||
|
||||
void clearHeavyPart() override;
|
||||
void setPosition(int32 position) override;
|
||||
|
||||
void clearSpoiler() override;
|
||||
void maybeClearSensitiveSpoiler() override;
|
||||
|
||||
protected:
|
||||
float64 dataProgress() const override;
|
||||
bool dataFinished() const override;
|
||||
bool dataLoaded() const override;
|
||||
bool iconAnimated() const override;
|
||||
|
||||
private:
|
||||
QSize countFrameSize() const;
|
||||
int contentWidth() const;
|
||||
int contentHeight() const;
|
||||
|
||||
void validateThumbnail(
|
||||
Image *image,
|
||||
QSize size,
|
||||
QSize frame,
|
||||
bool good);
|
||||
void prepareThumbnail(QSize size, QSize frame);
|
||||
|
||||
void update();
|
||||
|
||||
void ensureDataMediaCreated() const;
|
||||
void updateStatusText();
|
||||
|
||||
void clipCallback(Media::Clip::Notification notification);
|
||||
|
||||
Media::Clip::ReaderPointer _gif;
|
||||
|
||||
const not_null<DocumentData*> _data;
|
||||
mutable std::shared_ptr<Data::DocumentMedia> _dataMedia;
|
||||
StatusText _status;
|
||||
std::unique_ptr<Ui::SpoilerAnimation> _spoiler;
|
||||
|
||||
QImage _thumb;
|
||||
bool _thumbGood = false;
|
||||
bool _sensitiveSpoiler = false;
|
||||
|
||||
};
|
||||
|
||||
class Video final : public RadialProgressItem {
|
||||
public:
|
||||
Video(
|
||||
not_null<Delegate*> delegate,
|
||||
not_null<HistoryItem*> parent,
|
||||
not_null<DocumentData*> video,
|
||||
MediaOptions options);
|
||||
~Video();
|
||||
|
||||
void initDimensions() override;
|
||||
int32 resizeGetHeight(int32 width) override;
|
||||
void paint(Painter &p, const QRect &clip, TextSelection selection, const PaintContext *context) override;
|
||||
TextState getState(
|
||||
QPoint point,
|
||||
StateRequest request) const override;
|
||||
|
||||
void itemDataChanged() override;
|
||||
void clearHeavyPart() override;
|
||||
void clearSpoiler() override;
|
||||
|
||||
void maybeClearSensitiveSpoiler() override;
|
||||
|
||||
protected:
|
||||
float64 dataProgress() const override;
|
||||
bool dataFinished() const override;
|
||||
bool dataLoaded() const override;
|
||||
bool iconAnimated() const override;
|
||||
|
||||
private:
|
||||
void ensureDataMediaCreated() const;
|
||||
void updateStatusText();
|
||||
|
||||
const not_null<DocumentData*> _data;
|
||||
PhotoData *_videoCover = nullptr;
|
||||
mutable std::shared_ptr<Data::DocumentMedia> _dataMedia;
|
||||
mutable std::shared_ptr<Data::PhotoMedia> _videoCoverMedia;
|
||||
StatusText _status;
|
||||
|
||||
QString _duration;
|
||||
std::unique_ptr<Ui::SpoilerAnimation> _spoiler;
|
||||
|
||||
QImage _pix;
|
||||
QImage _hiddenBgCache;
|
||||
bool _pixBlurred : 1 = true;
|
||||
bool _sensitiveSpoiler : 1 = false;
|
||||
bool _story : 1 = false;
|
||||
bool _storyPinned : 1 = false;
|
||||
bool _storyShowPinned : 1 = false;
|
||||
bool _storyHidden : 1 = false;
|
||||
bool _storyShowHidden : 1 = false;
|
||||
|
||||
};
|
||||
|
||||
class Voice final : public RadialProgressItem {
|
||||
public:
|
||||
Voice(
|
||||
not_null<Delegate*> delegate,
|
||||
not_null<HistoryItem*> parent,
|
||||
not_null<DocumentData*> voice,
|
||||
const style::OverviewFileLayout &st);
|
||||
|
||||
void initDimensions() override;
|
||||
void paint(Painter &p, const QRect &clip, TextSelection selection, const PaintContext *context) override;
|
||||
TextState getState(
|
||||
QPoint point,
|
||||
StateRequest request) const override;
|
||||
|
||||
void clearHeavyPart() override;
|
||||
|
||||
protected:
|
||||
float64 dataProgress() const override;
|
||||
bool dataFinished() const override;
|
||||
bool dataLoaded() const override;
|
||||
bool iconAnimated() const override;
|
||||
const style::RoundCheckbox &checkboxStyle() const override;
|
||||
|
||||
private:
|
||||
void ensureDataMediaCreated() const;
|
||||
|
||||
const not_null<DocumentData*> _data;
|
||||
mutable std::shared_ptr<Data::DocumentMedia> _dataMedia;
|
||||
StatusText _status;
|
||||
ClickHandlerPtr _namel;
|
||||
|
||||
const style::OverviewFileLayout &_st;
|
||||
|
||||
Ui::Text::String _name;
|
||||
Ui::Text::String _details;
|
||||
Ui::Text::String _caption;
|
||||
int _nameVersion = 0;
|
||||
|
||||
void updateName();
|
||||
bool updateStatusText();
|
||||
|
||||
};
|
||||
|
||||
struct DocumentFields {
|
||||
not_null<DocumentData*> document;
|
||||
TimeId dateOverride = 0;
|
||||
bool forceFileLayout = false;
|
||||
};
|
||||
|
||||
class Document final : public RadialProgressItem {
|
||||
public:
|
||||
Document(
|
||||
not_null<Delegate*> delegate,
|
||||
not_null<HistoryItem*> parent,
|
||||
DocumentFields fields,
|
||||
const style::OverviewFileLayout &st);
|
||||
|
||||
void initDimensions() override;
|
||||
void paint(Painter &p, const QRect &clip, TextSelection selection, const PaintContext *context) override;
|
||||
TextState getState(
|
||||
QPoint point,
|
||||
StateRequest request) const override;
|
||||
|
||||
void clearHeavyPart() override;
|
||||
|
||||
protected:
|
||||
float64 dataProgress() const override;
|
||||
bool dataFinished() const override;
|
||||
bool dataLoaded() const override;
|
||||
bool iconAnimated() const override;
|
||||
const style::RoundCheckbox &checkboxStyle() const override;
|
||||
|
||||
private:
|
||||
[[nodiscard]] bool downloadInCorner() const;
|
||||
void drawCornerDownload(QPainter &p, bool selected, const PaintContext *context) const;
|
||||
[[nodiscard]] TextState cornerDownloadTextState(
|
||||
QPoint point,
|
||||
StateRequest request) const;
|
||||
|
||||
[[nodiscard]] bool songLayout() const;
|
||||
void ensureDataMediaCreated() const;
|
||||
|
||||
not_null<DocumentData*> _data;
|
||||
mutable std::shared_ptr<Data::DocumentMedia> _dataMedia;
|
||||
StatusText _status;
|
||||
ClickHandlerPtr _msgl, _namel;
|
||||
|
||||
const style::OverviewFileLayout &_st;
|
||||
const ::Layout::DocumentGenericPreview _generic;
|
||||
|
||||
bool _thumbLoaded = false;
|
||||
bool _forceFileLayout = false;
|
||||
QPixmap _thumb;
|
||||
|
||||
Ui::Text::String _name;
|
||||
QString _date, _ext;
|
||||
int _datew = 0;
|
||||
int _extw = 0;
|
||||
int _thumbw = 0;
|
||||
|
||||
bool withThumb() const;
|
||||
bool updateStatusText();
|
||||
|
||||
};
|
||||
|
||||
class Link final : public ItemBase {
|
||||
public:
|
||||
Link(
|
||||
not_null<Delegate*> delegate,
|
||||
not_null<HistoryItem*> parent,
|
||||
Data::Media *media);
|
||||
|
||||
void initDimensions() override;
|
||||
int32 resizeGetHeight(int32 width) override;
|
||||
void paint(Painter &p, const QRect &clip, TextSelection selection, const PaintContext *context) override;
|
||||
TextState getState(
|
||||
QPoint point,
|
||||
StateRequest request) const override;
|
||||
|
||||
void clearHeavyPart() override;
|
||||
|
||||
protected:
|
||||
const style::RoundCheckbox &checkboxStyle() const override;
|
||||
|
||||
private:
|
||||
void ensurePhotoMediaCreated();
|
||||
void ensureDocumentMediaCreated();
|
||||
void validateThumbnail();
|
||||
|
||||
ClickHandlerPtr _photol;
|
||||
|
||||
QString _title, _letter;
|
||||
int _titlew = 0;
|
||||
WebPageData *_page = nullptr;
|
||||
std::shared_ptr<Data::PhotoMedia> _photoMedia;
|
||||
std::shared_ptr<Data::DocumentMedia> _documentMedia;
|
||||
int _pixw = 0;
|
||||
int _pixh = 0;
|
||||
Ui::Text::String _text;
|
||||
QPixmap _thumbnail;
|
||||
bool _thumbnailBlurred = true;
|
||||
|
||||
struct LinkEntry {
|
||||
LinkEntry() = default;
|
||||
LinkEntry(const QString &url, const QString &text);
|
||||
|
||||
QString text;
|
||||
int width = 0;
|
||||
std::shared_ptr<TextClickHandler> lnk;
|
||||
};
|
||||
QVector<LinkEntry> _links;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Overview::Layout
|
||||
33
Telegram/SourceFiles/overview/overview_layout_delegate.h
Normal file
33
Telegram/SourceFiles/overview/overview_layout_delegate.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
class StickerPremiumMark;
|
||||
|
||||
namespace Overview::Layout {
|
||||
|
||||
class ItemBase;
|
||||
|
||||
class Delegate {
|
||||
public:
|
||||
virtual void registerHeavyItem(not_null<const ItemBase*> item) = 0;
|
||||
virtual void unregisterHeavyItem(not_null<const ItemBase*> item) = 0;
|
||||
virtual void repaintItem(not_null<const ItemBase*> item) = 0;
|
||||
virtual bool itemVisible(not_null<const ItemBase*> item) = 0;
|
||||
|
||||
[[nodiscard]] virtual not_null<StickerPremiumMark*> hiddenMark() = 0;
|
||||
|
||||
virtual void openPhoto(not_null<PhotoData*> photo, FullMsgId id) = 0;
|
||||
virtual void openDocument(
|
||||
not_null<DocumentData*> document,
|
||||
FullMsgId id,
|
||||
bool showInMediaView = false) = 0;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Overview::Layout
|
||||
Reference in New Issue
Block a user