| 95 | } |
| 96 | |
| 97 | QString YACReader::imagePathFromMimeData(const QMimeData *mimeData) |
| 98 | { |
| 99 | QString filePath; |
| 100 | |
| 101 | if (mimeData->hasUrls()) { |
| 102 | QList<QUrl> urlList = mimeData->urls(); |
| 103 | |
| 104 | if (!urlList.isEmpty()) { |
| 105 | QUrl url = urlList.first(); |
| 106 | if (url.isLocalFile()) { |
| 107 | filePath = url.toLocalFile(); |
| 108 | |
| 109 | QFileInfo fileInfo(filePath); |
| 110 | QString extension = fileInfo.suffix().toLower(); |
| 111 | QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats(); |
| 112 | bool isSupported = false; |
| 113 | |
| 114 | for (const QByteArray &format : supportedFormats) { |
| 115 | if (extension == QString(format).toLower()) { |
| 116 | isSupported = true; |
| 117 | break; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | if (!isSupported) { |
| 122 | filePath.clear(); |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | return filePath; |
| 129 | } |