MCPcopy Create free account
hub / github.com/YACReader/yacreader / imagePathFromMimeData

Method imagePathFromMimeData

common/yacreader_global_gui.cpp:97–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97QString 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}

Callers

nothing calls this directly

Calls 4

isEmptyMethod · 0.80
toLowerMethod · 0.80
QStringClass · 0.50
clearMethod · 0.45

Tested by

no test coverage detected