2020-10-13 12:07:53 +00:00
|
|
|
/*
|
|
|
|
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
|
|
|
|
|
2020-10-16 07:52:55 +00:00
|
|
|
#include <QtCore/QSemaphore>
|
2020-10-15 14:27:16 +00:00
|
|
|
#include <deque>
|
|
|
|
|
2020-10-13 12:07:53 +00:00
|
|
|
namespace Ui {
|
|
|
|
|
|
|
|
struct PreparedFileInformation {
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PreparedFile {
|
2020-10-16 07:52:55 +00:00
|
|
|
// File-s can be grouped if 'groupFiles'.
|
|
|
|
// File-s + Photo-s can be grouped if 'groupFiles && !sendImagesAsPhotos'.
|
|
|
|
// Photo-s can be grouped if '(groupFiles && !sendImagesAsPhotos)
|
|
|
|
// || (groupMediaInAlbums && sendImagesAsPhotos)'.
|
|
|
|
// Photo-s + Video-s can be grouped if 'groupMediaInAlbums
|
|
|
|
// && sendImagesAsPhotos'.
|
|
|
|
// Video-s can be grouped if 'groupMediaInAlbums'.
|
2020-10-13 12:07:53 +00:00
|
|
|
enum class AlbumType {
|
2020-10-16 07:52:55 +00:00
|
|
|
File,
|
2020-10-13 12:07:53 +00:00
|
|
|
Photo,
|
|
|
|
Video,
|
|
|
|
};
|
|
|
|
|
|
|
|
PreparedFile(const QString &path);
|
|
|
|
PreparedFile(PreparedFile &&other);
|
|
|
|
PreparedFile &operator=(PreparedFile &&other);
|
|
|
|
~PreparedFile();
|
|
|
|
|
|
|
|
QString path;
|
|
|
|
QByteArray content;
|
|
|
|
QString mime;
|
2020-10-16 07:52:55 +00:00
|
|
|
int size = 0;
|
2020-10-13 12:07:53 +00:00
|
|
|
std::unique_ptr<Ui::PreparedFileInformation> information;
|
|
|
|
QImage preview;
|
|
|
|
QSize shownDimensions;
|
2020-10-16 07:52:55 +00:00
|
|
|
AlbumType type = AlbumType::File;
|
2020-10-13 12:07:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PreparedList {
|
|
|
|
enum class Error {
|
|
|
|
None,
|
|
|
|
NonLocalUrl,
|
|
|
|
Directory,
|
|
|
|
EmptyFile,
|
|
|
|
TooLargeFile,
|
|
|
|
};
|
|
|
|
|
|
|
|
PreparedList() = default;
|
|
|
|
PreparedList(Error error, QString errorData)
|
|
|
|
: error(error)
|
|
|
|
, errorData(errorData) {
|
|
|
|
}
|
|
|
|
[[nodiscard]] static PreparedList Reordered(
|
|
|
|
PreparedList &&list,
|
|
|
|
std::vector<int> order);
|
|
|
|
void mergeToEnd(PreparedList &&other, bool cutToAlbumSize = false);
|
|
|
|
|
2020-10-16 07:52:55 +00:00
|
|
|
[[nodiscard]] bool canAddCaption(bool groupMediaInAlbums) const;
|
|
|
|
[[nodiscard]] bool canBeSentInSlowmode() const;
|
2020-10-13 12:07:53 +00:00
|
|
|
|
|
|
|
Error error = Error::None;
|
|
|
|
QString errorData;
|
|
|
|
std::vector<PreparedFile> files;
|
2020-10-15 14:27:16 +00:00
|
|
|
std::deque<PreparedFile> filesToProcess;
|
|
|
|
std::optional<bool> overrideSendImagesAsPhotos;
|
2020-10-13 12:07:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
[[nodiscard]] int MaxAlbumItems();
|
2020-10-13 17:15:52 +00:00
|
|
|
[[nodiscard]] bool ValidateThumbDimensions(int width, int height);
|
2020-10-13 12:07:53 +00:00
|
|
|
|
|
|
|
} // namespace Ui
|