mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +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 <QtCore/QMimeDatabase>
|
||||
#include <QtGui/QImageReader>
|
||||
|
||||
namespace Ui {
|
||||
|
||||
const QStringList &ImageExtensions() {
|
||||
static const auto result = QStringList{
|
||||
u".bmp"_q,
|
||||
u".jpg"_q,
|
||||
u".jpeg"_q,
|
||||
u".png"_q,
|
||||
u".gif"_q,
|
||||
};
|
||||
return result;
|
||||
static const auto result = [] {
|
||||
const auto formats = QImageReader::supportedImageFormats();
|
||||
return formats | ranges::views::transform([](const auto &format) {
|
||||
return '.' + format.toLower();
|
||||
}) | ranges::views::filter([](const auto &format) {
|
||||
const auto mimes = QMimeDatabase().mimeTypesForFileName(format);
|
||||
return mimes.isEmpty()
|
||||
|| !mimes.front().name().startsWith(u"image/"_q);
|
||||
}) | ranges::to<QStringList>;
|
||||
}();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue