mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Move PreparedFile/PreparedList to td_ui.
This commit is contained in:
@@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "base/variant.h"
|
||||
#include "api/api_common.h"
|
||||
#include "ui/chat/attach/attach_prepare.h"
|
||||
|
||||
constexpr auto kFileSizeLimit = 2000 * 1024 * 1024; // Load files up to 1500mb
|
||||
|
||||
@@ -239,44 +240,22 @@ struct FileLoadResult {
|
||||
|
||||
};
|
||||
|
||||
struct FileMediaInformation {
|
||||
struct Image {
|
||||
QImage data;
|
||||
bool animated = false;
|
||||
};
|
||||
struct Song {
|
||||
int duration = -1;
|
||||
QString title;
|
||||
QString performer;
|
||||
QImage cover;
|
||||
};
|
||||
struct Video {
|
||||
bool isGifv = false;
|
||||
bool supportsStreaming = false;
|
||||
int duration = -1;
|
||||
QImage thumbnail;
|
||||
};
|
||||
|
||||
QString filemime;
|
||||
std::variant<v::null_t, Image, Song, Video> media;
|
||||
};
|
||||
|
||||
class FileLoadTask final : public Task {
|
||||
public:
|
||||
static std::unique_ptr<FileMediaInformation> ReadMediaInformation(
|
||||
static std::unique_ptr<Ui::PreparedFileInformation> ReadMediaInformation(
|
||||
const QString &filepath,
|
||||
const QByteArray &content,
|
||||
const QString &filemime);
|
||||
static bool FillImageInformation(
|
||||
QImage &&image,
|
||||
bool animated,
|
||||
std::unique_ptr<FileMediaInformation> &result);
|
||||
std::unique_ptr<Ui::PreparedFileInformation> &result);
|
||||
|
||||
FileLoadTask(
|
||||
not_null<Main::Session*> session,
|
||||
const QString &filepath,
|
||||
const QByteArray &content,
|
||||
std::unique_ptr<FileMediaInformation> information,
|
||||
std::unique_ptr<Ui::PreparedFileInformation> information,
|
||||
SendMediaType type,
|
||||
const FileLoadTo &to,
|
||||
const TextWithTags &caption,
|
||||
@@ -289,6 +268,7 @@ public:
|
||||
const VoiceWaveform &waveform,
|
||||
const FileLoadTo &to,
|
||||
const TextWithTags &caption);
|
||||
~FileLoadTask();
|
||||
|
||||
uint64 fileid() const {
|
||||
return _id;
|
||||
@@ -303,22 +283,20 @@ private:
|
||||
static bool CheckForSong(
|
||||
const QString &filepath,
|
||||
const QByteArray &content,
|
||||
std::unique_ptr<FileMediaInformation> &result);
|
||||
std::unique_ptr<Ui::PreparedFileInformation> &result);
|
||||
static bool CheckForVideo(
|
||||
const QString &filepath,
|
||||
const QByteArray &content,
|
||||
std::unique_ptr<FileMediaInformation> &result);
|
||||
std::unique_ptr<Ui::PreparedFileInformation> &result);
|
||||
static bool CheckForImage(
|
||||
const QString &filepath,
|
||||
const QByteArray &content,
|
||||
std::unique_ptr<FileMediaInformation> &result);
|
||||
std::unique_ptr<Ui::PreparedFileInformation> &result);
|
||||
|
||||
template <typename Mimes, typename Extensions>
|
||||
static bool CheckMimeOrExtensions(const QString &filepath, const QString &filemime, Mimes &mimes, Extensions &extensions);
|
||||
|
||||
std::unique_ptr<FileMediaInformation> readMediaInformation(const QString &filemime) const {
|
||||
return ReadMediaInformation(_filepath, _content, filemime);
|
||||
}
|
||||
std::unique_ptr<Ui::PreparedFileInformation> readMediaInformation(const QString &filemime) const;
|
||||
void removeFromAlbum();
|
||||
|
||||
uint64 _id = 0;
|
||||
@@ -328,7 +306,7 @@ private:
|
||||
const std::shared_ptr<SendingAlbum> _album;
|
||||
QString _filepath;
|
||||
QByteArray _content;
|
||||
std::unique_ptr<FileMediaInformation> _information;
|
||||
std::unique_ptr<Ui::PreparedFileInformation> _information;
|
||||
int32 _duration = 0;
|
||||
VoiceWaveform _waveform;
|
||||
SendMediaType _type;
|
||||
|
Reference in New Issue
Block a user