From 4adad5f966175f86af64350f7bef420670d40ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 9 May 2025 21:33:14 +0200 Subject: [PATCH] Format --- common/yacreader_global_gui.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/common/yacreader_global_gui.cpp b/common/yacreader_global_gui.cpp index a5c08f2f..7ad76dfa 100644 --- a/common/yacreader_global_gui.cpp +++ b/common/yacreader_global_gui.cpp @@ -115,36 +115,33 @@ QString YACReader::imageFileLoader(QWidget *parent) QString YACReader::imagePathFromMimeData(const QMimeData *mimeData) { QString filePath; - - // Check for URLs (drag from browser or file explorer) + if (mimeData->hasUrls()) { QList urlList = mimeData->urls(); - - // We only handle the first URL for simplicity + if (!urlList.isEmpty()) { QUrl url = urlList.first(); if (url.isLocalFile()) { filePath = url.toLocalFile(); - - // Verify it's an image file using the extension + QFileInfo fileInfo(filePath); QString extension = fileInfo.suffix().toLower(); QList supportedFormats = QImageReader::supportedImageFormats(); bool isSupported = false; - + for (const QByteArray &format : supportedFormats) { if (extension == QString(format).toLower()) { isSupported = true; break; } } - + if (!isSupported) { - filePath.clear(); // Not a supported image format + filePath.clear(); } } } } - + return filePath; }