2017-09-26 11:49:16 +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.
|
2017-09-26 11:49:16 +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
|
2017-09-26 11:49:16 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2019-04-30 12:53:44 +00:00
|
|
|
#include "base/flags.h"
|
2019-09-13 06:06:02 +00:00
|
|
|
#include "base/binary_guard.h"
|
2017-09-26 11:49:16 +00:00
|
|
|
#include "data/data_types.h"
|
2019-01-25 14:37:28 +00:00
|
|
|
#include "ui/image/image.h"
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
class mtpFileLoader;
|
|
|
|
|
2018-10-25 09:24:45 +00:00
|
|
|
namespace Images {
|
|
|
|
class Source;
|
|
|
|
} // namespace Images
|
|
|
|
|
2018-08-27 11:35:58 +00:00
|
|
|
namespace Storage {
|
|
|
|
namespace Cache {
|
|
|
|
struct Key;
|
|
|
|
} // namespace Cache
|
|
|
|
} // namespace Storage
|
|
|
|
|
2019-02-13 18:10:18 +00:00
|
|
|
namespace Media {
|
|
|
|
namespace Streaming {
|
|
|
|
class Loader;
|
|
|
|
} // namespace Streaming
|
|
|
|
} // namespace Media
|
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
namespace Data {
|
|
|
|
class Session;
|
|
|
|
} // namespace Data
|
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
2018-01-27 09:21:57 +00:00
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
inline uint64 mediaMix32To64(int32 a, int32 b) {
|
|
|
|
return (uint64(*reinterpret_cast<uint32*>(&a)) << 32)
|
|
|
|
| uint64(*reinterpret_cast<uint32*>(&b));
|
|
|
|
}
|
|
|
|
|
2018-07-13 21:25:47 +00:00
|
|
|
// version field removed from document.
|
|
|
|
inline MediaKey mediaKey(LocationType type, int32 dc, const uint64 &id) {
|
|
|
|
return MediaKey(mediaMix32To64(type, dc), id);
|
2017-09-26 11:49:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct DocumentAdditionalData {
|
|
|
|
virtual ~DocumentAdditionalData() = default;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct StickerData : public DocumentAdditionalData {
|
2018-07-13 21:25:47 +00:00
|
|
|
Data::FileOrigin setOrigin() const;
|
|
|
|
|
2018-11-09 15:16:47 +00:00
|
|
|
std::unique_ptr<Image> image;
|
2019-05-27 12:57:26 +00:00
|
|
|
bool animated = false;
|
2017-09-26 11:49:16 +00:00
|
|
|
QString alt;
|
|
|
|
MTPInputStickerSet set = MTP_inputStickerSetEmpty();
|
|
|
|
StorageImageLocation loc; // doc thumb location
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SongData : public DocumentAdditionalData {
|
|
|
|
int32 duration = 0;
|
|
|
|
QString title, performer;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VoiceData : public DocumentAdditionalData {
|
|
|
|
~VoiceData();
|
|
|
|
|
|
|
|
int duration = 0;
|
|
|
|
VoiceWaveform waveform;
|
|
|
|
char wavemax = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool fileIsImage(const QString &name, const QString &mime);
|
|
|
|
|
|
|
|
namespace Serialize {
|
|
|
|
class Document;
|
|
|
|
} // namespace Serialize;
|
|
|
|
|
|
|
|
class DocumentData {
|
|
|
|
public:
|
2019-01-25 14:37:28 +00:00
|
|
|
DocumentData(not_null<Data::Session*> owner, DocumentId id);
|
2018-01-27 09:21:57 +00:00
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] Data::Session &owner() const;
|
2019-07-24 11:45:24 +00:00
|
|
|
[[nodiscard]] Main::Session &session() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
void setattributes(
|
|
|
|
const QVector<MTPDocumentAttribute> &attributes);
|
|
|
|
|
2018-07-13 21:25:47 +00:00
|
|
|
void automaticLoad(
|
|
|
|
Data::FileOrigin origin,
|
2018-11-30 12:49:30 +00:00
|
|
|
const HistoryItem *item);
|
2017-09-26 11:49:16 +00:00
|
|
|
void automaticLoadSettingsChanged();
|
|
|
|
|
2019-03-13 09:35:47 +00:00
|
|
|
enum class FilePathResolve {
|
|
|
|
Cached,
|
|
|
|
Checked,
|
|
|
|
SaveFromData,
|
|
|
|
SaveFromDataSilent,
|
2017-09-26 11:49:16 +00:00
|
|
|
};
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool loaded(
|
2019-03-13 09:35:47 +00:00
|
|
|
FilePathResolve resolve = FilePathResolve::Cached) const;
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool loading() const;
|
|
|
|
[[nodiscard]] QString loadingFilePath() const;
|
|
|
|
[[nodiscard]] bool displayLoading() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
void save(
|
2018-07-13 21:25:47 +00:00
|
|
|
Data::FileOrigin origin,
|
2017-09-26 11:49:16 +00:00
|
|
|
const QString &toFile,
|
|
|
|
LoadFromCloudSetting fromCloud = LoadFromCloudOrLocal,
|
|
|
|
bool autoLoading = false);
|
|
|
|
void cancel();
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool cancelled() const;
|
|
|
|
[[nodiscard]] float64 progress() const;
|
2019-04-10 11:26:15 +00:00
|
|
|
[[nodiscard]] int loadOffset() const;
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool uploading() const;
|
2019-05-31 16:45:03 +00:00
|
|
|
[[nodiscard]] bool loadedInMediaCache() const;
|
|
|
|
void setLoadedInMediaCache(bool loaded);
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2017-12-25 14:17:00 +00:00
|
|
|
void setWaitingForAlbum();
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool waitingForAlbum() const;
|
2017-12-25 14:17:00 +00:00
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] QByteArray data() const;
|
|
|
|
[[nodiscard]] const FileLocation &location(bool check = false) const;
|
2017-09-26 11:49:16 +00:00
|
|
|
void setLocation(const FileLocation &loc);
|
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] QString filepath(
|
2019-03-13 09:35:47 +00:00
|
|
|
FilePathResolve resolve = FilePathResolve::Cached) const;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-01-16 12:25:29 +00:00
|
|
|
[[nodiscard]] bool saveToCache() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2018-10-23 12:57:43 +00:00
|
|
|
void unload();
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] Image *getReplyPreview(Data::FileOrigin origin);
|
|
|
|
|
|
|
|
[[nodiscard]] StickerData *sticker() const;
|
|
|
|
void checkStickerLarge();
|
|
|
|
void checkStickerSmall();
|
|
|
|
[[nodiscard]] Image *getStickerSmall();
|
|
|
|
[[nodiscard]] Image *getStickerLarge();
|
|
|
|
[[nodiscard]] Data::FileOrigin stickerSetOrigin() const;
|
|
|
|
[[nodiscard]] Data::FileOrigin stickerOrGifOrigin() const;
|
|
|
|
[[nodiscard]] bool isStickerSetInstalled() const;
|
|
|
|
[[nodiscard]] SongData *song();
|
|
|
|
[[nodiscard]] const SongData *song() const;
|
|
|
|
[[nodiscard]] VoiceData *voice();
|
|
|
|
[[nodiscard]] const VoiceData *voice() const;
|
|
|
|
|
|
|
|
[[nodiscard]] bool isVoiceMessage() const;
|
|
|
|
[[nodiscard]] bool isVideoMessage() const;
|
|
|
|
[[nodiscard]] bool isSong() const;
|
|
|
|
[[nodiscard]] bool isAudioFile() const;
|
|
|
|
[[nodiscard]] bool isVideoFile() const;
|
|
|
|
[[nodiscard]] bool isAnimation() const;
|
|
|
|
[[nodiscard]] bool isGifv() const;
|
|
|
|
[[nodiscard]] bool isTheme() const;
|
|
|
|
[[nodiscard]] bool isSharedMediaMusic() const;
|
2019-03-06 08:21:42 +00:00
|
|
|
[[nodiscard]] TimeId getDuration() const;
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool isImage() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
void recountIsImage();
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool supportsStreaming() const;
|
2019-03-05 13:56:27 +00:00
|
|
|
void setNotSupportsStreaming();
|
2017-09-26 11:49:16 +00:00
|
|
|
void setData(const QByteArray &data) {
|
|
|
|
_data = data;
|
|
|
|
}
|
2019-09-06 11:33:51 +00:00
|
|
|
void setDataAndCache(const QByteArray &data);
|
2019-01-16 12:25:29 +00:00
|
|
|
bool checkWallPaperProperties();
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool isWallPaper() const;
|
2019-01-29 16:26:19 +00:00
|
|
|
[[nodiscard]] bool isPatternWallPaper() const;
|
2019-01-25 14:37:28 +00:00
|
|
|
|
|
|
|
[[nodiscard]] bool hasThumbnail() const;
|
|
|
|
void loadThumbnail(Data::FileOrigin origin);
|
|
|
|
[[nodiscard]] Image *thumbnailInline() const;
|
|
|
|
[[nodiscard]] Image *thumbnail() const;
|
|
|
|
void updateThumbnails(
|
|
|
|
ImagePtr thumbnailInline,
|
|
|
|
ImagePtr thumbnail);
|
|
|
|
|
|
|
|
[[nodiscard]] Image *goodThumbnail() const;
|
|
|
|
[[nodiscard]] Storage::Cache::Key goodThumbnailCacheKey() const;
|
2019-03-01 11:16:55 +00:00
|
|
|
void setGoodThumbnailOnUpload(QImage &&image, QByteArray &&bytes);
|
2018-10-25 08:12:56 +00:00
|
|
|
void refreshGoodThumbnail();
|
2018-10-25 09:24:45 +00:00
|
|
|
void replaceGoodThumbnail(std::unique_ptr<Images::Source> &&source);
|
2018-10-25 08:12:56 +00:00
|
|
|
|
2019-06-26 10:01:04 +00:00
|
|
|
[[nodiscard]] auto bigFileBaseCacheKey() const
|
|
|
|
-> std::optional<Storage::Cache::Key>;
|
|
|
|
|
2018-07-13 16:49:46 +00:00
|
|
|
void setRemoteLocation(
|
|
|
|
int32 dc,
|
|
|
|
uint64 access,
|
|
|
|
const QByteArray &fileReference);
|
2017-09-26 11:49:16 +00:00
|
|
|
void setContentUrl(const QString &url);
|
2018-03-04 20:04:13 +00:00
|
|
|
void setWebLocation(const WebFileLocation &location);
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool hasRemoteLocation() const;
|
|
|
|
[[nodiscard]] bool hasWebLocation() const;
|
|
|
|
[[nodiscard]] bool isNull() const;
|
|
|
|
[[nodiscard]] MTPInputDocument mtpInput() const;
|
|
|
|
[[nodiscard]] QByteArray fileReference() const;
|
2018-07-16 17:31:07 +00:00
|
|
|
void refreshFileReference(const QByteArray &value);
|
2018-09-26 18:08:11 +00:00
|
|
|
void refreshStickerThumbFileReference();
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
// When we have some client-side generated document
|
|
|
|
// (for example for displaying an external inline bot result)
|
|
|
|
// and it has downloaded data, we can collect that data from it
|
|
|
|
// to (this) received from the server "same" document.
|
2019-01-25 14:37:28 +00:00
|
|
|
void collectLocalData(not_null<DocumentData*> local);
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] QString filename() const;
|
|
|
|
[[nodiscard]] QString mimeString() const;
|
|
|
|
[[nodiscard]] bool hasMimeType(QLatin1String mime) const;
|
2018-01-27 09:21:57 +00:00
|
|
|
void setMimeString(const QString &mime);
|
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] MediaKey mediaKey() const;
|
|
|
|
[[nodiscard]] Storage::Cache::Key cacheKey() const;
|
|
|
|
[[nodiscard]] uint8 cacheTag() const;
|
2018-01-27 09:21:57 +00:00
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] static QString ComposeNameString(
|
2018-01-27 09:21:57 +00:00
|
|
|
const QString &filename,
|
|
|
|
const QString &songTitle,
|
|
|
|
const QString &songPerformer);
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] QString composeNameString() const;
|
2017-11-05 11:00:48 +00:00
|
|
|
|
2019-02-27 11:36:19 +00:00
|
|
|
[[nodiscard]] bool canBePlayed() const;
|
|
|
|
[[nodiscard]] bool canBeStreamed() const;
|
2019-04-12 09:25:00 +00:00
|
|
|
[[nodiscard]] auto createStreamingLoader(
|
|
|
|
Data::FileOrigin origin,
|
|
|
|
bool forceRemoteLoader) const
|
|
|
|
-> std::unique_ptr<Media::Streaming::Loader>;
|
2019-02-13 18:10:18 +00:00
|
|
|
|
2019-03-04 11:28:52 +00:00
|
|
|
void setInappPlaybackFailed();
|
|
|
|
[[nodiscard]] bool inappPlaybackFailed() const;
|
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
~DocumentData();
|
|
|
|
|
|
|
|
DocumentId id = 0;
|
|
|
|
DocumentType type = FileDocument;
|
|
|
|
QSize dimensions;
|
|
|
|
int32 date = 0;
|
|
|
|
int32 size = 0;
|
|
|
|
|
|
|
|
FileStatus status = FileReady;
|
2017-12-25 14:17:00 +00:00
|
|
|
|
|
|
|
std::unique_ptr<Data::UploadState> uploadingData;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
private:
|
2019-04-30 12:53:44 +00:00
|
|
|
enum class Flag : uchar {
|
|
|
|
StreamingMaybeYes = 0x01,
|
|
|
|
StreamingMaybeNo = 0x02,
|
|
|
|
StreamingPlaybackFailed = 0x04,
|
|
|
|
ImageType = 0x08,
|
|
|
|
DownloadCancelled = 0x10,
|
|
|
|
LoadedInMediaCache = 0x20,
|
2019-03-05 13:56:27 +00:00
|
|
|
};
|
2019-04-30 12:53:44 +00:00
|
|
|
using Flags = base::flags<Flag>;
|
|
|
|
friend constexpr bool is_flag_type(Flag) { return true; };
|
|
|
|
|
|
|
|
static constexpr Flags kStreamingSupportedMask = Flags()
|
|
|
|
| Flag::StreamingMaybeYes
|
|
|
|
| Flag::StreamingMaybeNo;
|
|
|
|
static constexpr Flags kStreamingSupportedUnknown = Flags()
|
|
|
|
| Flag::StreamingMaybeYes
|
|
|
|
| Flag::StreamingMaybeNo;
|
|
|
|
static constexpr Flags kStreamingSupportedMaybeYes = Flags()
|
|
|
|
| Flag::StreamingMaybeYes;
|
|
|
|
static constexpr Flags kStreamingSupportedMaybeNo = Flags()
|
|
|
|
| Flag::StreamingMaybeNo;
|
|
|
|
static constexpr Flags kStreamingSupportedNo = Flags();
|
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
friend class Serialize::Document;
|
|
|
|
|
2018-01-27 09:21:57 +00:00
|
|
|
LocationType locationType() const;
|
2019-05-10 08:38:23 +00:00
|
|
|
void validateLottieSticker();
|
2018-10-25 08:47:06 +00:00
|
|
|
void validateGoodThumbnail();
|
2019-03-05 13:56:27 +00:00
|
|
|
void setMaybeSupportsStreaming(bool supports);
|
2019-05-31 16:45:03 +00:00
|
|
|
void setLoadedInMediaCacheLocation();
|
2018-01-27 09:21:57 +00:00
|
|
|
|
2019-04-30 12:53:44 +00:00
|
|
|
void destroyLoader() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-04-12 08:00:06 +00:00
|
|
|
[[nodiscard]] bool useStreamingLoader() const;
|
2019-01-25 14:37:28 +00:00
|
|
|
[[nodiscard]] bool thumbnailEnoughForSticker() const;
|
|
|
|
|
2018-07-13 21:25:47 +00:00
|
|
|
// Two types of location: from MTProto by dc+access or from web by url
|
2017-09-26 11:49:16 +00:00
|
|
|
int32 _dc = 0;
|
|
|
|
uint64 _access = 0;
|
2018-07-13 16:49:46 +00:00
|
|
|
QByteArray _fileReference;
|
2017-09-26 11:49:16 +00:00
|
|
|
QString _url;
|
2017-11-05 11:00:48 +00:00
|
|
|
QString _filename;
|
|
|
|
QString _mimeString;
|
2018-03-04 20:04:13 +00:00
|
|
|
WebFileLocation _urlLocation;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
ImagePtr _thumbnailInline;
|
|
|
|
ImagePtr _thumbnail;
|
2018-10-25 08:12:56 +00:00
|
|
|
std::unique_ptr<Image> _goodThumbnail;
|
2019-01-25 14:37:28 +00:00
|
|
|
Data::ReplyPreview _replyPreview;
|
2018-10-25 08:12:56 +00:00
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
not_null<Data::Session*> _owner;
|
2018-01-27 09:21:57 +00:00
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
FileLocation _location;
|
|
|
|
QByteArray _data;
|
|
|
|
std::unique_ptr<DocumentAdditionalData> _additional;
|
|
|
|
int32 _duration = -1;
|
2019-04-30 12:53:44 +00:00
|
|
|
mutable Flags _flags = kStreamingSupportedUnknown;
|
|
|
|
mutable std::unique_ptr<FileLoader> _loader;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
VoiceWaveform documentWaveformDecode(const QByteArray &encoded5bit);
|
|
|
|
QByteArray documentWaveformEncode5bit(const VoiceWaveform &waveform);
|
|
|
|
|
2017-12-18 13:13:41 +00:00
|
|
|
class DocumentClickHandler : public FileClickHandler {
|
2017-09-26 11:49:16 +00:00
|
|
|
public:
|
2017-12-15 16:25:47 +00:00
|
|
|
DocumentClickHandler(
|
|
|
|
not_null<DocumentData*> document,
|
2020-05-04 13:38:49 +00:00
|
|
|
FullMsgId context = FullMsgId());
|
|
|
|
|
|
|
|
[[nodiscard]] bool valid() const {
|
|
|
|
return !_session.empty();
|
2017-09-26 11:49:16 +00:00
|
|
|
}
|
2020-05-04 13:38:49 +00:00
|
|
|
|
|
|
|
[[nodiscard]] not_null<DocumentData*> document() const {
|
2017-09-26 11:49:16 +00:00
|
|
|
return _document;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2020-05-04 13:38:49 +00:00
|
|
|
const base::weak_ptr<Main::Session> _session;
|
|
|
|
const not_null<DocumentData*> _document;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class DocumentSaveClickHandler : public DocumentClickHandler {
|
|
|
|
public:
|
2019-03-11 14:35:11 +00:00
|
|
|
enum class Mode {
|
|
|
|
ToCacheOrFile,
|
|
|
|
ToFile,
|
|
|
|
ToNewFile,
|
|
|
|
};
|
2017-09-26 11:49:16 +00:00
|
|
|
using DocumentClickHandler::DocumentClickHandler;
|
2018-07-13 21:25:47 +00:00
|
|
|
static void Save(
|
|
|
|
Data::FileOrigin origin,
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<DocumentData*> document,
|
2019-03-11 14:35:11 +00:00
|
|
|
Mode mode = Mode::ToCacheOrFile);
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class DocumentOpenClickHandler : public DocumentClickHandler {
|
|
|
|
public:
|
|
|
|
using DocumentClickHandler::DocumentClickHandler;
|
2018-07-13 21:25:47 +00:00
|
|
|
static void Open(
|
|
|
|
Data::FileOrigin origin,
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<DocumentData*> document,
|
2019-03-11 14:35:11 +00:00
|
|
|
HistoryItem *context);
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class DocumentCancelClickHandler : public DocumentClickHandler {
|
|
|
|
public:
|
|
|
|
using DocumentClickHandler::DocumentClickHandler;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-03-13 09:35:47 +00:00
|
|
|
class DocumentOpenWithClickHandler : public DocumentClickHandler {
|
|
|
|
public:
|
|
|
|
using DocumentClickHandler::DocumentClickHandler;
|
|
|
|
static void Open(
|
|
|
|
Data::FileOrigin origin,
|
|
|
|
not_null<DocumentData*> document);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
class VoiceSeekClickHandler : public DocumentOpenClickHandler {
|
|
|
|
public:
|
|
|
|
using DocumentOpenClickHandler::DocumentOpenClickHandler;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override {
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-01-29 16:26:19 +00:00
|
|
|
class DocumentWrappedClickHandler : public DocumentClickHandler {
|
|
|
|
public:
|
|
|
|
DocumentWrappedClickHandler(
|
|
|
|
ClickHandlerPtr wrapped,
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
FullMsgId context = FullMsgId())
|
|
|
|
: DocumentClickHandler(document, context)
|
|
|
|
, _wrapped(wrapped) {
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override {
|
|
|
|
_wrapped->onClick({ Qt::LeftButton });
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ClickHandlerPtr _wrapped;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-03-06 16:04:47 +00:00
|
|
|
QString FileNameForSave(
|
2017-09-26 11:49:16 +00:00
|
|
|
const QString &title,
|
|
|
|
const QString &filter,
|
|
|
|
const QString &prefix,
|
|
|
|
QString name,
|
|
|
|
bool savingAs,
|
|
|
|
const QDir &dir = QDir());
|
2018-12-05 08:07:17 +00:00
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
QString FileExtension(const QString &filepath);
|
|
|
|
bool IsValidMediaFile(const QString &filepath);
|
|
|
|
bool IsExecutableName(const QString &filepath);
|
2019-01-17 08:18:23 +00:00
|
|
|
base::binary_guard ReadImageAsync(
|
|
|
|
not_null<DocumentData*> document,
|
2019-02-04 15:53:00 +00:00
|
|
|
FnMut<QImage(QImage)> postprocess,
|
2019-01-17 08:18:23 +00:00
|
|
|
FnMut<void(QImage&&)> done);
|
2018-12-05 08:07:17 +00:00
|
|
|
|
|
|
|
} // namespace Data
|