mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 22:25:12 +00:00
Reimplement file open confirmations.
This commit is contained in:
@@ -478,6 +478,31 @@ void DocumentData::setattributes(
|
||||
_additional = nullptr;
|
||||
}
|
||||
|
||||
if (!_filename.isEmpty()) {
|
||||
using Type = Core::NameType;
|
||||
if (type == VideoDocument
|
||||
|| type == AnimatedDocument
|
||||
|| type == RoundVideoDocument
|
||||
|| isAnimation()) {
|
||||
if (_nameType != Type::Video) {
|
||||
type = FileDocument;
|
||||
_additional = nullptr;
|
||||
}
|
||||
}
|
||||
if (type == SongDocument || type == VoiceDocument || isAudioFile()) {
|
||||
if (_nameType != Type::Audio) {
|
||||
type = FileDocument;
|
||||
_additional = nullptr;
|
||||
}
|
||||
}
|
||||
if (!Core::NameTypeAllowsThumbnail(_nameType)) {
|
||||
_inlineThumbnailBytes = {};
|
||||
_flags &= ~Flag::InlineThumbnailIsPath;
|
||||
_thumbnail.clear();
|
||||
_videoThumbnail.clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (isAudioFile()
|
||||
|| isAnimation()
|
||||
|| isVoiceMessage()
|
||||
@@ -530,6 +555,10 @@ void DocumentData::updateThumbnails(
|
||||
const ImageWithLocation &thumbnail,
|
||||
const ImageWithLocation &videoThumbnail,
|
||||
bool isPremiumSticker) {
|
||||
if (!_filename.isEmpty()
|
||||
&& !Core::NameTypeAllowsThumbnail(Core::DetectNameType(_filename))) {
|
||||
return;
|
||||
}
|
||||
if (!inlineThumbnail.bytes.isEmpty()
|
||||
&& _inlineThumbnailBytes.isEmpty()) {
|
||||
_inlineThumbnailBytes = inlineThumbnail.bytes;
|
||||
@@ -919,6 +948,7 @@ void DocumentData::setFileName(const QString &remoteFileName) {
|
||||
for (const auto &ch : controls) {
|
||||
_filename = std::move(_filename).replace(ch, "_");
|
||||
}
|
||||
_nameType = Core::DetectNameType(_filename);
|
||||
}
|
||||
|
||||
void DocumentData::setLoadedInMediaCacheLocation() {
|
||||
@@ -1460,6 +1490,10 @@ QString DocumentData::filename() const {
|
||||
return _filename;
|
||||
}
|
||||
|
||||
Core::NameType DocumentData::nameType() const {
|
||||
return _nameType;
|
||||
}
|
||||
|
||||
QString DocumentData::mimeString() const {
|
||||
return _mimeString;
|
||||
}
|
||||
@@ -1527,7 +1561,10 @@ bool DocumentData::isVideoMessage() const {
|
||||
bool DocumentData::isAnimation() const {
|
||||
return (type == AnimatedDocument)
|
||||
|| isVideoMessage()
|
||||
|| (hasMimeType(u"image/gif"_q)
|
||||
|| ((_filename.isEmpty()
|
||||
|| _nameType == Core::NameType::Image
|
||||
|| _nameType == Core::NameType::Video)
|
||||
&& hasMimeType(u"image/gif"_q)
|
||||
&& !(_flags & Flag::StreamingPlaybackFailed));
|
||||
}
|
||||
|
||||
@@ -1537,9 +1574,11 @@ bool DocumentData::isGifv() const {
|
||||
}
|
||||
|
||||
bool DocumentData::isTheme() const {
|
||||
return hasMimeType(u"application/x-tgtheme-tdesktop"_q)
|
||||
|| _filename.endsWith(u".tdesktop-theme"_q, Qt::CaseInsensitive)
|
||||
|| _filename.endsWith(u".tdesktop-palette"_q, Qt::CaseInsensitive);
|
||||
return _filename.endsWith(u".tdesktop-theme"_q, Qt::CaseInsensitive)
|
||||
|| _filename.endsWith(u".tdesktop-palette"_q, Qt::CaseInsensitive)
|
||||
|| (hasMimeType(u"application/x-tgtheme-tdesktop"_q)
|
||||
&& (_filename.isEmpty()
|
||||
|| _nameType == Core::NameType::ThemeFile));
|
||||
}
|
||||
|
||||
bool DocumentData::isSong() const {
|
||||
@@ -1562,6 +1601,10 @@ bool DocumentData::isAudioFile() const {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else if (!_filename.isEmpty()
|
||||
&& _nameType != Core::NameType::Audio
|
||||
&& _nameType != Core::NameType::Video) {
|
||||
return false;
|
||||
}
|
||||
const auto left = _mimeString.mid(prefix.size());
|
||||
const auto types = { u"x-wav"_q, u"wav"_q, u"mp4"_q };
|
||||
|
Reference in New Issue
Block a user