mirror of
https://github.com/YACReader/yacreader
synced 2025-05-25 18:00:46 -04:00
Format
This commit is contained in:
parent
bed3503aae
commit
4adad5f966
@ -115,36 +115,33 @@ QString YACReader::imageFileLoader(QWidget *parent)
|
|||||||
QString YACReader::imagePathFromMimeData(const QMimeData *mimeData)
|
QString YACReader::imagePathFromMimeData(const QMimeData *mimeData)
|
||||||
{
|
{
|
||||||
QString filePath;
|
QString filePath;
|
||||||
|
|
||||||
// Check for URLs (drag from browser or file explorer)
|
|
||||||
if (mimeData->hasUrls()) {
|
if (mimeData->hasUrls()) {
|
||||||
QList<QUrl> urlList = mimeData->urls();
|
QList<QUrl> urlList = mimeData->urls();
|
||||||
|
|
||||||
// We only handle the first URL for simplicity
|
|
||||||
if (!urlList.isEmpty()) {
|
if (!urlList.isEmpty()) {
|
||||||
QUrl url = urlList.first();
|
QUrl url = urlList.first();
|
||||||
if (url.isLocalFile()) {
|
if (url.isLocalFile()) {
|
||||||
filePath = url.toLocalFile();
|
filePath = url.toLocalFile();
|
||||||
|
|
||||||
// Verify it's an image file using the extension
|
|
||||||
QFileInfo fileInfo(filePath);
|
QFileInfo fileInfo(filePath);
|
||||||
QString extension = fileInfo.suffix().toLower();
|
QString extension = fileInfo.suffix().toLower();
|
||||||
QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
|
QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
|
||||||
bool isSupported = false;
|
bool isSupported = false;
|
||||||
|
|
||||||
for (const QByteArray &format : supportedFormats) {
|
for (const QByteArray &format : supportedFormats) {
|
||||||
if (extension == QString(format).toLower()) {
|
if (extension == QString(format).toLower()) {
|
||||||
isSupported = true;
|
isSupported = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSupported) {
|
if (!isSupported) {
|
||||||
filePath.clear(); // Not a supported image format
|
filePath.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user