2016-04-12 21:31:28 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-04-12 21:31:28 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2021-07-26 05:45:07 +00:00
|
|
|
#include "layout/layout_item_base.h"
|
2021-07-26 05:38:10 +00:00
|
|
|
#include "layout/layout_document_generic_preview.h"
|
2021-07-22 16:15:30 +00:00
|
|
|
#include "media/clip/media_clip_reader.h"
|
2016-04-12 21:31:28 +00:00
|
|
|
#include "core/click_handler_types.h"
|
2019-04-02 09:13:30 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2016-09-28 10:15:03 +00:00
|
|
|
#include "ui/effects/radial_animation.h"
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2020-05-29 14:08:18 +00:00
|
|
|
class Image;
|
|
|
|
|
2017-11-23 14:58:00 +00:00
|
|
|
namespace style {
|
|
|
|
struct RoundCheckbox;
|
2023-09-05 08:01:47 +00:00
|
|
|
struct OverviewFileLayout;
|
2017-11-23 14:58:00 +00:00
|
|
|
} // namespace style
|
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
namespace Data {
|
|
|
|
class Media;
|
2020-05-25 14:16:04 +00:00
|
|
|
class PhotoMedia;
|
2020-03-27 11:40:50 +00:00
|
|
|
class DocumentMedia;
|
2018-01-14 16:02:25 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
2022-12-27 09:10:38 +00:00
|
|
|
namespace Ui {
|
|
|
|
class SpoilerAnimation;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
namespace Overview {
|
|
|
|
namespace Layout {
|
|
|
|
|
2017-11-23 14:58:00 +00:00
|
|
|
class Checkbox;
|
2020-05-21 12:27:04 +00:00
|
|
|
class ItemBase;
|
|
|
|
class Delegate;
|
2017-11-23 14:58:00 +00:00
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
class PaintContext : public PaintContextBase {
|
|
|
|
public:
|
2022-12-27 09:10:38 +00:00
|
|
|
PaintContext(crl::time ms, bool selecting, bool paused)
|
|
|
|
: PaintContextBase(ms, selecting)
|
|
|
|
, paused(paused) {
|
2016-04-12 21:31:28 +00:00
|
|
|
}
|
2022-02-26 11:51:54 +00:00
|
|
|
bool skipBorder = false;
|
2022-12-27 09:10:38 +00:00
|
|
|
bool paused = false;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-06-14 06:51:14 +00:00
|
|
|
class ItemBase : public LayoutItemBase, public base::has_weak_ptr {
|
2016-04-12 21:31:28 +00:00
|
|
|
public:
|
2020-05-21 12:27:04 +00:00
|
|
|
ItemBase(not_null<Delegate*> delegate, not_null<HistoryItem*> parent);
|
|
|
|
~ItemBase();
|
2017-10-05 15:35:52 +00:00
|
|
|
|
2020-05-21 12:49:47 +00:00
|
|
|
virtual void paint(
|
|
|
|
Painter &p,
|
|
|
|
const QRect &clip,
|
|
|
|
TextSelection selection,
|
|
|
|
const PaintContext *context) = 0;
|
|
|
|
|
2022-02-24 15:04:24 +00:00
|
|
|
[[nodiscard]] QDateTime dateTime() const;
|
2018-02-03 19:52:35 +00:00
|
|
|
|
2022-02-24 15:04:24 +00:00
|
|
|
[[nodiscard]] not_null<HistoryItem*> getItem() const {
|
2016-04-12 21:31:28 +00:00
|
|
|
return _parent;
|
|
|
|
}
|
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
void clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) override;
|
|
|
|
void clickHandlerPressedChanged(const ClickHandlerPtr &action, bool pressed) override;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2020-05-21 12:49:47 +00:00
|
|
|
void invalidateCache();
|
2017-11-23 14:58:00 +00:00
|
|
|
|
2020-05-21 12:27:04 +00:00
|
|
|
virtual void clearHeavyPart() {
|
|
|
|
}
|
2017-11-23 14:58:00 +00:00
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
protected:
|
2020-05-21 12:27:04 +00:00
|
|
|
[[nodiscard]] not_null<HistoryItem*> parent() const {
|
2017-11-23 14:58:00 +00:00
|
|
|
return _parent;
|
|
|
|
}
|
2020-05-21 12:27:04 +00:00
|
|
|
[[nodiscard]] not_null<Delegate*> delegate() const {
|
|
|
|
return _delegate;
|
|
|
|
}
|
2017-11-23 14:58:00 +00:00
|
|
|
void paintCheckbox(
|
|
|
|
Painter &p,
|
|
|
|
QPoint position,
|
|
|
|
bool selected,
|
|
|
|
const PaintContext *context);
|
2022-02-24 15:04:24 +00:00
|
|
|
[[nodiscard]] virtual const style::RoundCheckbox &checkboxStyle() const;
|
2017-11-23 14:58:00 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void ensureCheckboxCreated();
|
|
|
|
|
2020-05-21 12:27:04 +00:00
|
|
|
const not_null<Delegate*> _delegate;
|
2018-02-03 19:52:35 +00:00
|
|
|
const not_null<HistoryItem*> _parent;
|
|
|
|
const QDateTime _dateTime;
|
2017-11-23 14:58:00 +00:00
|
|
|
std::unique_ptr<Checkbox> _check;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class RadialProgressItem : public ItemBase {
|
|
|
|
public:
|
2020-05-21 12:27:04 +00:00
|
|
|
RadialProgressItem(
|
|
|
|
not_null<Delegate*> delegate,
|
|
|
|
not_null<HistoryItem*> parent)
|
|
|
|
: ItemBase(delegate, parent) {
|
2016-04-12 21:31:28 +00:00
|
|
|
}
|
|
|
|
RadialProgressItem(const RadialProgressItem &other) = delete;
|
|
|
|
|
2016-12-09 18:56:01 +00:00
|
|
|
void clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) override;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2022-12-27 09:10:38 +00:00
|
|
|
virtual void clearSpoiler() {
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
~RadialProgressItem();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ClickHandlerPtr _openl, _savel, _cancell;
|
2017-10-05 15:35:52 +00:00
|
|
|
void setLinks(
|
|
|
|
ClickHandlerPtr &&openl,
|
|
|
|
ClickHandlerPtr &&savel,
|
|
|
|
ClickHandlerPtr &&cancell);
|
2021-07-22 16:12:30 +00:00
|
|
|
void setDocumentLinks(
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
bool forceOpen = false);
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2019-04-04 15:24:13 +00:00
|
|
|
void radialAnimationCallback(crl::time now) const;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2016-11-21 16:24:23 +00:00
|
|
|
void ensureRadial();
|
2019-04-01 17:44:54 +00:00
|
|
|
void checkRadialFinished() const;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2019-04-04 15:24:13 +00:00
|
|
|
bool isRadialAnimation() const {
|
|
|
|
if (_radial) {
|
|
|
|
if (_radial->animating()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
checkRadialFinished();
|
|
|
|
}
|
|
|
|
return false;
|
2016-04-12 21:31:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual float64 dataProgress() const = 0;
|
|
|
|
virtual bool dataFinished() const = 0;
|
|
|
|
virtual bool dataLoaded() const = 0;
|
|
|
|
virtual bool iconAnimated() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-04-01 17:44:54 +00:00
|
|
|
mutable std::unique_ptr<Ui::RadialAnimation> _radial;
|
2019-04-02 09:13:30 +00:00
|
|
|
Ui::Animations::Simple _a_iconOver;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-11-21 16:24:23 +00:00
|
|
|
class StatusText {
|
2016-04-12 21:31:28 +00:00
|
|
|
public:
|
2016-11-21 16:24:23 +00:00
|
|
|
// duration = -1 - no duration, duration = -2 - "GIF" duration
|
2022-05-10 14:22:28 +00:00
|
|
|
void update(
|
|
|
|
int64 newSize,
|
|
|
|
int64 fullSize,
|
|
|
|
TimeId duration,
|
|
|
|
TimeId realDuration);
|
|
|
|
void setSize(int64 newSize);
|
|
|
|
|
|
|
|
[[nodiscard]] int64 size() const {
|
2016-11-21 16:24:23 +00:00
|
|
|
return _size;
|
|
|
|
}
|
2022-05-10 14:22:28 +00:00
|
|
|
[[nodiscard]] QString text() const {
|
2016-11-21 16:24:23 +00:00
|
|
|
return _text;
|
2016-04-12 21:31:28 +00:00
|
|
|
}
|
|
|
|
|
2016-11-21 16:24:23 +00:00
|
|
|
private:
|
|
|
|
// >= 0 will contain download / upload string, _size = loaded bytes
|
|
|
|
// < 0 will contain played string, _size = -(seconds + 1) played
|
2022-05-10 14:22:28 +00:00
|
|
|
// 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;
|
2016-11-21 16:24:23 +00:00
|
|
|
QString _text;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
struct Info : public RuntimeComponent<Info, LayoutItemBase> {
|
2016-04-12 21:31:28 +00:00
|
|
|
int top = 0;
|
|
|
|
};
|
|
|
|
|
2023-06-19 17:00:34 +00:00
|
|
|
struct MediaOptions {
|
|
|
|
bool spoiler = false;
|
|
|
|
bool story = false;
|
|
|
|
};
|
|
|
|
|
2020-05-21 12:27:04 +00:00
|
|
|
class Photo final : public ItemBase {
|
2016-04-12 21:31:28 +00:00
|
|
|
public:
|
2017-10-05 15:35:52 +00:00
|
|
|
Photo(
|
2020-05-21 12:27:04 +00:00
|
|
|
not_null<Delegate*> delegate,
|
2017-10-05 15:35:52 +00:00
|
|
|
not_null<HistoryItem*> parent,
|
2022-12-27 09:10:38 +00:00
|
|
|
not_null<PhotoData*> photo,
|
2023-06-19 17:00:34 +00:00
|
|
|
MediaOptions options);
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
int32 resizeGetHeight(int32 width) override;
|
2016-11-21 16:24:23 +00:00
|
|
|
void paint(Painter &p, const QRect &clip, TextSelection selection, const PaintContext *context) override;
|
2018-01-27 13:59:24 +00:00
|
|
|
TextState getState(
|
2017-10-13 19:07:04 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const override;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2020-05-25 14:16:04 +00:00
|
|
|
void clearHeavyPart() override;
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
private:
|
2020-05-25 14:16:04 +00:00
|
|
|
void ensureDataMediaCreated() const;
|
2019-01-25 14:37:28 +00:00
|
|
|
void setPixFrom(not_null<Image*> image);
|
2022-12-27 09:10:38 +00:00
|
|
|
void clearSpoiler();
|
2019-01-25 14:37:28 +00:00
|
|
|
|
2020-05-25 14:16:04 +00:00
|
|
|
const not_null<PhotoData*> _data;
|
|
|
|
mutable std::shared_ptr<Data::PhotoMedia> _dataMedia;
|
2016-04-12 21:31:28 +00:00
|
|
|
ClickHandlerPtr _link;
|
2022-12-27 09:10:38 +00:00
|
|
|
std::unique_ptr<Ui::SpoilerAnimation> _spoiler;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2016-11-21 16:24:23 +00:00
|
|
|
QPixmap _pix;
|
|
|
|
bool _goodLoaded = false;
|
2023-06-19 17:00:34 +00:00
|
|
|
bool _story = false;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-07-22 16:15:30 +00:00
|
|
|
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;
|
2021-07-25 22:37:06 +00:00
|
|
|
void setPosition(int32 position) override;
|
2021-07-22 16:15:30 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2022-08-04 10:35:08 +00:00
|
|
|
QImage _thumb;
|
2021-07-22 16:15:30 +00:00
|
|
|
bool _thumbGood = false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-03-27 11:40:50 +00:00
|
|
|
class Video final : public RadialProgressItem {
|
2016-04-12 21:31:28 +00:00
|
|
|
public:
|
2017-10-05 15:35:52 +00:00
|
|
|
Video(
|
2020-05-21 12:27:04 +00:00
|
|
|
not_null<Delegate*> delegate,
|
2017-10-05 15:35:52 +00:00
|
|
|
not_null<HistoryItem*> parent,
|
2022-12-27 09:10:38 +00:00
|
|
|
not_null<DocumentData*> video,
|
2023-06-19 17:00:34 +00:00
|
|
|
MediaOptions options);
|
2020-03-27 11:40:50 +00:00
|
|
|
~Video();
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
int32 resizeGetHeight(int32 width) override;
|
2016-11-21 16:24:23 +00:00
|
|
|
void paint(Painter &p, const QRect &clip, TextSelection selection, const PaintContext *context) override;
|
2018-01-27 13:59:24 +00:00
|
|
|
TextState getState(
|
2017-10-13 19:07:04 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const override;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2020-05-21 13:13:29 +00:00
|
|
|
void clearHeavyPart() override;
|
2022-12-27 09:10:38 +00:00
|
|
|
void clearSpoiler() override;
|
2020-05-21 13:13:29 +00:00
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
protected:
|
2017-09-26 11:49:16 +00:00
|
|
|
float64 dataProgress() const override;
|
|
|
|
bool dataFinished() const override;
|
|
|
|
bool dataLoaded() const override;
|
|
|
|
bool iconAnimated() const override;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
private:
|
2020-03-27 11:40:50 +00:00
|
|
|
void ensureDataMediaCreated() const;
|
|
|
|
void updateStatusText();
|
|
|
|
|
2020-05-25 14:16:04 +00:00
|
|
|
const not_null<DocumentData*> _data;
|
2020-03-27 11:40:50 +00:00
|
|
|
mutable std::shared_ptr<Data::DocumentMedia> _dataMedia;
|
2016-11-21 16:24:23 +00:00
|
|
|
StatusText _status;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
QString _duration;
|
2022-12-27 09:10:38 +00:00
|
|
|
std::unique_ptr<Ui::SpoilerAnimation> _spoiler;
|
|
|
|
|
2016-11-21 16:24:23 +00:00
|
|
|
QPixmap _pix;
|
2019-04-08 10:35:25 +00:00
|
|
|
bool _pixBlurred = true;
|
2023-06-19 17:00:34 +00:00
|
|
|
bool _story = false;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-04-08 15:09:29 +00:00
|
|
|
class Voice final : public RadialProgressItem {
|
2016-04-12 21:31:28 +00:00
|
|
|
public:
|
2017-10-05 15:35:52 +00:00
|
|
|
Voice(
|
2020-05-21 12:27:04 +00:00
|
|
|
not_null<Delegate*> delegate,
|
2017-10-05 15:35:52 +00:00
|
|
|
not_null<HistoryItem*> parent,
|
|
|
|
not_null<DocumentData*> voice,
|
|
|
|
const style::OverviewFileLayout &st);
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
void initDimensions() override;
|
2016-11-21 16:24:23 +00:00
|
|
|
void paint(Painter &p, const QRect &clip, TextSelection selection, const PaintContext *context) override;
|
2018-01-27 13:59:24 +00:00
|
|
|
TextState getState(
|
2017-10-13 19:07:04 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const override;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2020-05-21 13:13:29 +00:00
|
|
|
void clearHeavyPart() override;
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
protected:
|
2017-09-26 11:49:16 +00:00
|
|
|
float64 dataProgress() const override;
|
|
|
|
bool dataFinished() const override;
|
|
|
|
bool dataLoaded() const override;
|
|
|
|
bool iconAnimated() const override;
|
2017-11-23 14:58:00 +00:00
|
|
|
const style::RoundCheckbox &checkboxStyle() const override;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
private:
|
2020-04-08 15:09:29 +00:00
|
|
|
void ensureDataMediaCreated() const;
|
2018-11-05 08:22:05 +00:00
|
|
|
|
2023-06-05 12:50:43 +00:00
|
|
|
const not_null<DocumentData*> _data;
|
2020-04-08 15:09:29 +00:00
|
|
|
mutable std::shared_ptr<Data::DocumentMedia> _dataMedia;
|
2016-11-21 16:24:23 +00:00
|
|
|
StatusText _status;
|
2016-04-12 21:31:28 +00:00
|
|
|
ClickHandlerPtr _namel;
|
|
|
|
|
2016-12-08 14:08:54 +00:00
|
|
|
const style::OverviewFileLayout &_st;
|
|
|
|
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _name, _details;
|
2022-05-10 14:22:28 +00:00
|
|
|
int _nameVersion = 0;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2016-11-21 16:24:23 +00:00
|
|
|
void updateName();
|
|
|
|
bool updateStatusText();
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2022-02-26 16:48:12 +00:00
|
|
|
struct DocumentFields {
|
|
|
|
not_null<DocumentData*> document;
|
|
|
|
TimeId dateOverride = 0;
|
2022-02-27 11:27:19 +00:00
|
|
|
bool forceFileLayout = false;
|
2022-02-26 16:48:12 +00:00
|
|
|
};
|
2023-09-05 08:01:47 +00:00
|
|
|
|
2020-04-08 15:09:29 +00:00
|
|
|
class Document final : public RadialProgressItem {
|
2016-04-12 21:31:28 +00:00
|
|
|
public:
|
2017-10-05 15:35:52 +00:00
|
|
|
Document(
|
2020-05-21 12:27:04 +00:00
|
|
|
not_null<Delegate*> delegate,
|
2017-10-05 15:35:52 +00:00
|
|
|
not_null<HistoryItem*> parent,
|
2022-02-26 16:48:12 +00:00
|
|
|
DocumentFields fields,
|
2017-10-05 15:35:52 +00:00
|
|
|
const style::OverviewFileLayout &st);
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
void initDimensions() override;
|
2016-11-21 16:24:23 +00:00
|
|
|
void paint(Painter &p, const QRect &clip, TextSelection selection, const PaintContext *context) override;
|
2018-01-27 13:59:24 +00:00
|
|
|
TextState getState(
|
2017-10-13 19:07:04 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const override;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2020-05-21 13:13:29 +00:00
|
|
|
void clearHeavyPart() override;
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
protected:
|
2017-09-26 11:49:16 +00:00
|
|
|
float64 dataProgress() const override;
|
|
|
|
bool dataFinished() const override;
|
|
|
|
bool dataLoaded() const override;
|
|
|
|
bool iconAnimated() const override;
|
2017-11-23 14:58:00 +00:00
|
|
|
const style::RoundCheckbox &checkboxStyle() const override;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
private:
|
2019-03-15 12:09:05 +00:00
|
|
|
[[nodiscard]] bool downloadInCorner() const;
|
2022-09-16 20:23:27 +00:00
|
|
|
void drawCornerDownload(QPainter &p, bool selected, const PaintContext *context) const;
|
2019-03-15 12:09:05 +00:00
|
|
|
[[nodiscard]] TextState cornerDownloadTextState(
|
|
|
|
QPoint point,
|
|
|
|
StateRequest request) const;
|
|
|
|
|
2022-02-27 11:27:19 +00:00
|
|
|
[[nodiscard]] bool songLayout() const;
|
2020-04-08 15:09:29 +00:00
|
|
|
void ensureDataMediaCreated() const;
|
|
|
|
|
2017-10-05 15:35:52 +00:00
|
|
|
not_null<DocumentData*> _data;
|
2020-04-08 15:09:29 +00:00
|
|
|
mutable std::shared_ptr<Data::DocumentMedia> _dataMedia;
|
2016-11-21 16:24:23 +00:00
|
|
|
StatusText _status;
|
2016-04-12 21:31:28 +00:00
|
|
|
ClickHandlerPtr _msgl, _namel;
|
|
|
|
|
2016-10-13 15:04:40 +00:00
|
|
|
const style::OverviewFileLayout &_st;
|
2021-07-26 05:38:10 +00:00
|
|
|
const ::Layout::DocumentGenericPreview _generic;
|
2016-10-13 15:04:40 +00:00
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
bool _thumbLoaded = false;
|
2022-02-27 11:27:19 +00:00
|
|
|
bool _forceFileLayout = false;
|
2016-11-21 16:24:23 +00:00
|
|
|
QPixmap _thumb;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _name;
|
2016-10-13 15:04:40 +00:00
|
|
|
QString _date, _ext;
|
2022-05-10 14:22:28 +00:00
|
|
|
int _datew = 0;
|
|
|
|
int _extw = 0;
|
|
|
|
int _thumbw = 0;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
bool withThumb() const;
|
2016-11-21 16:24:23 +00:00
|
|
|
bool updateStatusText();
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-04-08 15:09:29 +00:00
|
|
|
class Link final : public ItemBase {
|
2016-04-12 21:31:28 +00:00
|
|
|
public:
|
2017-10-05 15:35:52 +00:00
|
|
|
Link(
|
2020-05-21 12:27:04 +00:00
|
|
|
not_null<Delegate*> delegate,
|
2017-10-05 15:35:52 +00:00
|
|
|
not_null<HistoryItem*> parent,
|
2018-01-14 16:02:25 +00:00
|
|
|
Data::Media *media);
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
void initDimensions() override;
|
|
|
|
int32 resizeGetHeight(int32 width) override;
|
2016-11-21 16:24:23 +00:00
|
|
|
void paint(Painter &p, const QRect &clip, TextSelection selection, const PaintContext *context) override;
|
2018-01-27 13:59:24 +00:00
|
|
|
TextState getState(
|
2017-10-13 19:07:04 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const override;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
2020-05-21 13:13:29 +00:00
|
|
|
void clearHeavyPart() override;
|
|
|
|
|
2017-11-23 14:58:00 +00:00
|
|
|
protected:
|
|
|
|
const style::RoundCheckbox &checkboxStyle() const override;
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
private:
|
2020-05-25 14:16:04 +00:00
|
|
|
void ensurePhotoMediaCreated();
|
2020-04-15 14:06:34 +00:00
|
|
|
void ensureDocumentMediaCreated();
|
2020-05-21 10:59:55 +00:00
|
|
|
void validateThumbnail();
|
2020-04-15 14:06:34 +00:00
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
ClickHandlerPtr _photol;
|
|
|
|
|
|
|
|
QString _title, _letter;
|
|
|
|
int _titlew = 0;
|
|
|
|
WebPageData *_page = nullptr;
|
2020-05-25 14:16:04 +00:00
|
|
|
std::shared_ptr<Data::PhotoMedia> _photoMedia;
|
2020-04-15 14:06:34 +00:00
|
|
|
std::shared_ptr<Data::DocumentMedia> _documentMedia;
|
2016-04-12 21:31:28 +00:00
|
|
|
int _pixw = 0;
|
|
|
|
int _pixh = 0;
|
2022-09-30 07:25:02 +00:00
|
|
|
Ui::Text::String _text;
|
2020-05-21 10:59:55 +00:00
|
|
|
QPixmap _thumbnail;
|
2020-12-30 12:12:39 +00:00
|
|
|
bool _thumbnailBlurred = true;
|
2016-04-12 21:31:28 +00:00
|
|
|
|
|
|
|
struct LinkEntry {
|
2022-07-27 11:24:34 +00:00
|
|
|
LinkEntry() = default;
|
2016-04-12 21:31:28 +00:00
|
|
|
LinkEntry(const QString &url, const QString &text);
|
2022-07-27 11:24:34 +00:00
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
QString text;
|
2022-07-27 11:24:34 +00:00
|
|
|
int width = 0;
|
2017-12-18 10:38:14 +00:00
|
|
|
std::shared_ptr<TextClickHandler> lnk;
|
2016-04-12 21:31:28 +00:00
|
|
|
};
|
|
|
|
QVector<LinkEntry> _links;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Layout
|
|
|
|
} // namespace Overview
|