mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Get supported image extensions from QImageReader
This commit is contained in:
parent
9fba9048af
commit
36de2e98d4
1 changed files with 13 additions and 8 deletions
|
@ -7,17 +7,22 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "ui/chat/attach/attach_extensions.h"
|
#include "ui/chat/attach/attach_extensions.h"
|
||||||
|
|
||||||
|
#include <QtCore/QMimeDatabase>
|
||||||
|
#include <QtGui/QImageReader>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
const QStringList &ImageExtensions() {
|
const QStringList &ImageExtensions() {
|
||||||
static const auto result = QStringList{
|
static const auto result = [] {
|
||||||
u".bmp"_q,
|
const auto formats = QImageReader::supportedImageFormats();
|
||||||
u".jpg"_q,
|
return formats | ranges::views::transform([](const auto &format) {
|
||||||
u".jpeg"_q,
|
return '.' + format.toLower();
|
||||||
u".png"_q,
|
}) | ranges::views::filter([](const auto &format) {
|
||||||
u".gif"_q,
|
const auto mimes = QMimeDatabase().mimeTypesForFileName(format);
|
||||||
};
|
return mimes.isEmpty()
|
||||||
return result;
|
|| !mimes.front().name().startsWith(u"image/"_q);
|
||||||
|
}) | ranges::to<QStringList>;
|
||||||
|
}();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue