From fbf415407fb7b048c6f2ac9fff42323a36dc922f Mon Sep 17 00:00:00 2001 From: ut001910 Date: Sat, 26 Oct 2024 16:25:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=9C=8B=E5=9B=BEftp?= =?UTF-8?q?=E5=85=B1=E4=BA=AB=E7=9B=AE=E5=BD=95=E5=9B=BE=E7=89=87=E6=89=93?= =?UTF-8?q?=E5=BC=80=E6=98=BE=E7=A4=BA=E7=A9=BA=E7=99=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复看图ftp共享目录图片打开显示空白 Bug: https://pms.uniontech.com/bug-view-275425.html Log: 修复看图ftp共享目录图片打开显示空白 --- .../viewpanel/scen/imagegraphicsview.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libimageviewer/viewpanel/scen/imagegraphicsview.cpp b/libimageviewer/viewpanel/scen/imagegraphicsview.cpp index 5a2fd6ac..bb40cd6a 100644 --- a/libimageviewer/viewpanel/scen/imagegraphicsview.cpp +++ b/libimageviewer/viewpanel/scen/imagegraphicsview.cpp @@ -42,6 +42,8 @@ #include #include +#include +#include #ifndef QT_NO_OPENGL //#include @@ -78,6 +80,25 @@ QVariantList cachePixmap(const QString &path) if (QFileInfo(path).exists() && p.isNull()) { //判定为损坏图片 // p = utils::image::getDamagePixmap(DApplicationHelper::instance()->themeType() == DApplicationHelper::LightType); + if(path.contains("ftp:host=")) {//前面失败后再处理ftp图片 + QFileInfo info(path); + if(info.size() <= 1024*1024*1024) {//小于1Mftp文件做下载本地处理 + QNetworkAccessManager manager; + QEventLoop loop; + + QObject::connect(&manager, &QNetworkAccessManager::finished, [&](QNetworkReply *reply){ + QByteArray imageData = reply->readAll(); + tImg.loadFromData(imageData); + p = QPixmap::fromImage(tImg); + loop.quit(); + }); + int nIdex = path.indexOf("ftp:host="); + QString urlAddr = path.mid(nIdex).replace("ftp:host=", "ftp://"); + QNetworkRequest request(urlAddr); + manager.get(request); + loop.exec(); + } + } qDebug() << errMsg; } QVariantList vl;