Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Read images from gvfs-mtp mounted folder was slow. #92

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ Build-Depends:
libopencv-dev,
libmediainfo-dev,
libffmpegthumbnailer-dev,
libtiff-dev
libtiff-dev,
# Enable use dfm io to copy MTP mount file, Use `|`(or) relationship to
# compatible different environments, qttools5-private-dev will not be used.
# WARNING: control file changes may cause qttools5-private-dev to be installed
# instead of libdfm-io-dev.
libdfm-io-dev | qttools5-private-dev
Standards-Version: 3.9.8
Homepage: http://www.deepin.org

Expand All @@ -57,6 +62,6 @@ Conflicts:
libimage-viewer-dev
Replaces:
libimage-viewer-dev
Recommends: libqt5libqgtk2, kimageformat-plugins ,deepin-ocr
Recommends: libqt5libqgtk2, kimageformat-plugins, deepin-ocr
Description: Image Viewer library development headers.
Deepin Image Viewer library development headers.
13 changes: 11 additions & 2 deletions libimageviewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ pkg_check_modules(3rd_lib REQUIRED
libmediainfo
)

# 查找 dfm-io
pkg_check_modules(dfm-io_lib dfm-io)
if(${dfm-io_lib_FOUND})
message("Found dfm-io, enable MTP file copy optimization.")
add_definitions(-DUSE_DFM_IO)
else()
message("Not found dfm-io, use base api copy MTP file.")
endif()

#需要打开的头文件
FILE (GLOB allHeaders "*.h" "*/*.h" "*/*/*.h")
#需要打开的代码文件
Expand Down Expand Up @@ -98,8 +107,8 @@ set(${TARGET_NAME} ${CMAKE_INSTALL_LIBDIR})
set_target_properties(${TARGET_NAME} PROPERTIES VERSION 0.1.0 SOVERSION 0.1)


target_include_directories(${CMD_NAME} PUBLIC ${3rd_lib_INCLUDE_DIRS} ${TIFF_INCLUDE_DIRS})
target_link_libraries(imageviewer ${3rd_lib_LIBRARIES} freeimage ${TIFF_LIBRARIES} dl)
target_include_directories(${CMD_NAME} PUBLIC ${3rd_lib_INCLUDE_DIRS} ${TIFF_INCLUDE_DIRS} ${dfm-io_lib_INCLUDE_DIRS})
target_link_libraries(imageviewer ${3rd_lib_LIBRARIES} freeimage ${TIFF_LIBRARIES} ${dfm-io_lib_LIBRARIES} dl)

include(GNUInstallDirs)
configure_file(libimageviewer.pc.in ${PROJECT_BINARY_DIR}/libimageviewer.pc @ONLY)
Expand Down
19 changes: 14 additions & 5 deletions libimageviewer/imageviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include "imageengine.h"
#include "viewpanel/viewpanel.h"
#include "service/commonservice.h"
#include "service/mtpfileproxy.h"
#include "unionimage/imageutils.h"
#include "unionimage/baseutils.h"
//#include "widgets/toptoolbar.h"

#define PLUGINTRANSPATH "/usr/share/libimageviewer/translations"
class ImageViewerPrivate
Expand Down Expand Up @@ -115,18 +115,24 @@ bool ImageViewer::startdragImageWithUID(const QStringList &paths, const QString
return d->m_panel->startdragImage(paths, firstPath);
}

void ImageViewer::startImgView(QString currentPath, QStringList paths)
void ImageViewer::startImgView(const QString &currentPath, const QStringList &paths)
{
Q_D(ImageViewer);

QStringList realPaths = paths;
QString realPath = currentPath;
MtpFileProxy::instance()->checkAndCreateProxyFile(realPaths, realPath);

//展示当前图片
d->m_panel->loadImage(currentPath, paths);
d->m_panel->loadImage(realPath, realPaths);

//启动线程制作缩略图
if (LibCommonService::instance()->getImgViewerType() == imageViewerSpace::ImgViewerTypeLocal ||
LibCommonService::instance()->getImgViewerType() == imageViewerSpace::ImgViewerTypeNull) {
//首先生成当前图片的缓存
ImageEngine::instance()->makeImgThumbnail(LibCommonService::instance()->getImgSavePath(), QStringList(currentPath), 1);
ImageEngine::instance()->makeImgThumbnail(LibCommonService::instance()->getImgSavePath(), QStringList(realPath), 1);
//看图制作全部缩略图
ImageEngine::instance()->makeImgThumbnail(LibCommonService::instance()->getImgSavePath(), paths, paths.size());
ImageEngine::instance()->makeImgThumbnail(LibCommonService::instance()->getImgSavePath(), realPaths, realPaths.size());
}
}

Expand All @@ -139,11 +145,14 @@ void ImageViewer::switchFullScreen()
void ImageViewer::startSlideShow(const QStringList &paths, const QString &firstPath)
{
Q_D(ImageViewer);

ViewInfo info;
info.fullScreen = window()->isFullScreen();
info.lastPanel = this;
info.path = firstPath;
info.paths = paths;
MtpFileProxy::instance()->checkAndCreateProxyFile(info.paths, info.path);

info.viewMainWindowID = 0;
d->m_panel->startSlideShow(info);
}
Expand Down
2 changes: 1 addition & 1 deletion libimageviewer/imageviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class IMAGEVIEWERSHARED_EXPORT ImageViewer : public DWidget
bool startdragImageWithUID(const QStringList &paths, const QString &firstPath = "", bool isCustom = false, const QString &album = "", int UID = -1);

//启动图片展示入口
void startImgView(QString currentPath, QStringList paths = QStringList());
void startImgView(const QString &currentPath, const QStringList &paths = QStringList());

//设置topbar的显示和隐藏
void setTopBarVisible(bool visible);
Expand Down
Loading
Loading