Skip to content

Commit

Permalink
fix: 修复看图ftp共享目录图片打开显示空白
Browse files Browse the repository at this point in the history
修复看图ftp共享目录图片打开显示空白

Bug: https://pms.uniontech.com/bug-view-275425.html
Log: 修复看图ftp共享目录图片打开显示空白
  • Loading branch information
myk1343 committed Oct 26, 2024
1 parent 4372724 commit fbf4154
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions libimageviewer/viewpanel/scen/imagegraphicsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

#include <DGuiApplicationHelper>
#include <DApplicationHelper>
#include <QNetworkAccessManager>
#include <QNetworkReply>

#ifndef QT_NO_OPENGL
//#include <QGLWidget>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit fbf4154

Please sign in to comment.