mirror of https://github.com/procxx/kepka.git
parent
e88c575d4a
commit
bfe7bf2c11
|
@ -1581,18 +1581,21 @@ void SendFilesBox::captionResized() {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SendFilesBox::canAddUrls(const QList<QUrl> &urls) const {
|
||||||
|
return !urls.isEmpty() && ranges::find_if(
|
||||||
|
urls,
|
||||||
|
[](const QUrl &url) { return !url.isLocalFile(); }
|
||||||
|
) == urls.end();
|
||||||
|
}
|
||||||
|
|
||||||
bool SendFilesBox::canAddFiles(not_null<const QMimeData*> data) const {
|
bool SendFilesBox::canAddFiles(not_null<const QMimeData*> data) const {
|
||||||
auto files = 0;
|
const auto urls = data->hasUrls() ? data->urls() : QList<QUrl>();
|
||||||
if (data->hasUrls()) {
|
auto filesCount = canAddUrls(urls) ? urls.size() : 0;
|
||||||
for (const auto &url : data->urls()) {
|
if (!filesCount && data->hasImage()) {
|
||||||
if (url.isLocalFile()) {
|
++filesCount;
|
||||||
++files;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (data->hasImage()) {
|
|
||||||
++files;
|
|
||||||
}
|
}
|
||||||
if (_list.files.size() + files > Storage::MaxAlbumItems()) {
|
|
||||||
|
if (_list.files.size() + filesCount > Storage::MaxAlbumItems()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (_list.files.size() > 1 && !_albumPreview) {
|
} else if (_list.files.size() > 1 && !_albumPreview) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1605,10 +1608,14 @@ bool SendFilesBox::canAddFiles(not_null<const QMimeData*> data) const {
|
||||||
|
|
||||||
bool SendFilesBox::addFiles(not_null<const QMimeData*> data) {
|
bool SendFilesBox::addFiles(not_null<const QMimeData*> data) {
|
||||||
auto list = [&] {
|
auto list = [&] {
|
||||||
if (data->hasUrls()) {
|
const auto urls = data->hasUrls() ? data->urls() : QList<QUrl>();
|
||||||
return Storage::PrepareMediaList(
|
auto result = canAddUrls(urls)
|
||||||
data->urls(),
|
? Storage::PrepareMediaList(urls, st::sendMediaPreviewSize)
|
||||||
st::sendMediaPreviewSize);
|
: Storage::PreparedList(
|
||||||
|
Storage::PreparedList::Error::EmptyFile,
|
||||||
|
QString());
|
||||||
|
if (result.error == Storage::PreparedList::Error::None) {
|
||||||
|
return result;
|
||||||
} else if (data->hasImage()) {
|
} else if (data->hasImage()) {
|
||||||
auto image = qvariant_cast<QImage>(data->imageData());
|
auto image = qvariant_cast<QImage>(data->imageData());
|
||||||
if (!image.isNull()) {
|
if (!image.isNull()) {
|
||||||
|
@ -1618,9 +1625,7 @@ bool SendFilesBox::addFiles(not_null<const QMimeData*> data) {
|
||||||
st::sendMediaPreviewSize);
|
st::sendMediaPreviewSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Storage::PreparedList(
|
return result;
|
||||||
Storage::PreparedList::Error::EmptyFile,
|
|
||||||
QString());
|
|
||||||
}();
|
}();
|
||||||
if (_list.files.size() + list.files.size() > Storage::MaxAlbumItems()) {
|
if (_list.files.size() + list.files.size() > Storage::MaxAlbumItems()) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -84,6 +84,7 @@ private:
|
||||||
void updateControlsGeometry();
|
void updateControlsGeometry();
|
||||||
|
|
||||||
bool canAddFiles(not_null<const QMimeData*> data) const;
|
bool canAddFiles(not_null<const QMimeData*> data) const;
|
||||||
|
bool canAddUrls(const QList<QUrl> &urls) const;
|
||||||
bool addFiles(not_null<const QMimeData*> data);
|
bool addFiles(not_null<const QMimeData*> data);
|
||||||
|
|
||||||
QString _titleText;
|
QString _titleText;
|
||||||
|
|
Loading…
Reference in New Issue