From a1365a4574909f73f367acd034a60ffedc61c7f2 Mon Sep 17 00:00:00 2001 From: renbin Date: Fri, 15 Nov 2024 09:38:53 +0800 Subject: [PATCH] feat: support qt6.8 Support Qt6.8 - Update debian/control remove obsolete depends; - Compile both Qt5 and Qt6 based packages; - Updated CMake configuration to include Qt6 support; - Updated method calls for Qt6 compatibility; - Removed obsolete files related to Qt5; - Update README.md. Log: Support Qt6.8 --- .reuse/dep5 | 2 +- CMakeLists.txt | 31 ++- README.md | 60 ++--- README.zh_CN.md | 58 ++--- debian/control | 65 ++++-- debian/copyright | 2 +- debian/image-editor6.1 | 35 +++ debian/libimageeditor.install | 2 +- debian/libimageeditor.manpages | 1 + debian/libimageeditor6-dev.install | 5 + debian/libimageeditor6.install | 6 + debian/libimageeditor6.manpages | 1 + debian/manpages | 1 - debian/rules | 4 +- libimageviewer/CMakeLists.txt | 163 +------------- libimageviewer/image-viewer_global.h | 1 + libimageviewer/imageviewer.cpp | 4 + libimageviewer/libimageviewer-qt5.cmake | 5 + libimageviewer/libimageviewer-qt6.cmake | 5 + libimageviewer/libimageviewer.cmake | 187 +++++++++++++++ libimageviewer/libimageviewer.pc.in | 11 +- libimageviewer/movieservice.cpp | 21 +- libimageviewer/quickprint/quickprint.cpp | 4 + libimageviewer/service/aimodelservice.cpp | 2 +- libimageviewer/service/aimodelservice.h | 2 +- libimageviewer/service/mtpfileproxy.cpp | 11 +- libimageviewer/slideshow/imageanimation.cpp | 84 +++++-- libimageviewer/slideshow/slideshowpanel.cpp | 41 +++- libimageviewer/unionimage/baseutils.cpp | 9 +- libimageviewer/unionimage/imageutils.cpp | 4 +- libimageviewer/unionimage/unionimage.cpp | 6 +- .../contents/aienhancefloatwidget.cpp | 10 +- .../viewpanel/contents/bottomtoolbar.cpp | 43 ++-- .../viewpanel/contents/bottomtoolbar.h | 2 - .../viewpanel/contents/imageinfowidget.cpp | 15 +- .../viewpanel/contents/imgviewdelegate.cpp | 12 +- .../viewpanel/contents/imgviewlistview.h | 1 - .../viewpanel/contents/imgviewwidget.cpp | 2 - .../viewpanel/contents/imgviewwidget.h | 2 - libimageviewer/viewpanel/lockwidget.cpp | 4 +- libimageviewer/viewpanel/lockwidget.h | 1 - libimageviewer/viewpanel/navigationwidget.cpp | 6 +- .../viewpanel/scen/imagegraphicsview.cpp | 212 ++++-------------- .../viewpanel/scen/imagegraphicsview.h | 2 - libimageviewer/viewpanel/thumbnailwidget.cpp | 10 +- libimageviewer/viewpanel/viewpanel.cpp | 3 +- libimageviewer/widgets/extensionpanel.cpp | 2 +- libimageviewer/widgets/imagebutton.cpp | 69 +++--- libimageviewer/widgets/imagebutton.h | 37 ++- libimageviewer/widgets/printhelper.cpp | 2 +- libimageviewer/widgets/renamedialog.cpp | 12 +- libimageviewer/widgets/themewidget.h | 24 +- libimageviewer/widgets/toast.cpp | 133 ----------- libimageviewer/widgets/toast.h | 72 ------ libimageviewer/widgets/toptoolbar.cpp | 4 +- libimageviewer/widgets/toptoolbar.h | 1 - libimagevisualresult/CMakeLists.txt | 93 +------- .../libimagevisualresult-qt5.cmake | 5 + .../libimagevisualresult-qt6.cmake | 5 + .../libimagevisualresult.cmake | 73 ++++++ .../libimagevisualresult.pc.in | 8 +- tests/CMakeLists.txt | 46 ++-- 62 files changed, 812 insertions(+), 932 deletions(-) create mode 100644 debian/image-editor6.1 create mode 100644 debian/libimageeditor.manpages create mode 100644 debian/libimageeditor6-dev.install create mode 100644 debian/libimageeditor6.install create mode 100644 debian/libimageeditor6.manpages delete mode 100644 debian/manpages create mode 100644 libimageviewer/libimageviewer-qt5.cmake create mode 100644 libimageviewer/libimageviewer-qt6.cmake create mode 100644 libimageviewer/libimageviewer.cmake delete mode 100755 libimageviewer/widgets/toast.cpp delete mode 100755 libimageviewer/widgets/toast.h create mode 100644 libimagevisualresult/libimagevisualresult-qt5.cmake create mode 100644 libimagevisualresult/libimagevisualresult-qt6.cmake create mode 100644 libimagevisualresult/libimagevisualresult.cmake diff --git a/.reuse/dep5 b/.reuse/dep5 index 872c8c71..a7bb277d 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -29,7 +29,7 @@ Copyright: UnionTech Software Technology Co., Ltd. License: CC0-1.0 # Project file -Files: *.pro *.prf *.pri *.qrc *CMakeLists.txt .tx/* +Files: *.pro *.prf *.pri *.qrc *CMakeLists.txt .tx/* *.cmake Copyright: UnionTech Software Technology Co., Ltd. License: CC0-1.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index d6acf4a8..7f9a6ce8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,29 +2,36 @@ cmake_minimum_required(VERSION 3.0.0) project(imageeditor) -set(CMAKE_C_FLAGS "-fPIC") -set(CMAKE_CXX_FLAGS "-fPIC") - execute_process(COMMAND uname -m OUTPUT_VARIABLE MACH ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) +set(CMAKE_C_FLAGS "-fPIC") +set(CMAKE_CXX_FLAGS "-fPIC") set(CMAKE_EXPORT_COMPILE_COMMANDS on) - -find_package(PkgConfig REQUIRED) - # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) +# check Qt version, support Qt5 default +find_package(Qt6 QUIET) +if (Qt6_FOUND) + set(SUPPORT_QT6 TRUE) + set(QT_VERSION_MAJOR 6) + set(DTK_VERSION_MAJOR 6) + # libimageeditor major version + set(IMGE_VERSION_MAJOR 6) +else() + set(QT_VERSION_MAJOR 5) +endif() + +find_package(PkgConfig REQUIRED) + include_directories(${PROJECT_BINARY_DIR}) include_directories(${PROJECT_SOURCE_DIR}) -message(STATUS ${CMAKE_CXX_FLAGS}) +add_subdirectory(libimageviewer) +add_subdirectory(libimagevisualresult) option(DOTEST "option for test" OFF) if(DOTEST OR CMAKE_BUILD_TYPE STREQUAL "Debug") - add_subdirectory(tests) + # add_subdirectory(tests) endif() - -add_subdirectory(libimageviewer) -add_subdirectory(libimagevisualresult) - diff --git a/README.md b/README.md index 5eaa2a27..87ce79a8 100644 --- a/README.md +++ b/README.md @@ -8,40 +8,44 @@ Image editor is a public library for deepin-image-viewer and deepin-album devel _The **master** branch is current development branch, build dependencies may changes without update README.md, refer to `./debian/control` for a working build depends list_ -* Qt (>=5.11) -* debhelper (>= 11), -* cmake, -* qtbase5-dev, +* debhelper (>= 11), +* cmake, * pkg-config, -* libexif-dev, +* qtbase5-dev, +* qtbase5-private-dev, +* qttools5-dev, +* qttools5-dev-tools, +* qtmultimedia5-dev, * libqt5svg5-dev, * libqt5x11extras5-dev, -* libsqlite3-dev, -* qttools5-dev-tools, -* qttools5-dev, -* libxcb-util0-dev, +* qt6-base-dev, +* qt6-base-private-dev, +* qt6-tools-dev, +* qt6-tools-dev-tools, +* qt6-multimedia-dev, +* libqt6svg6-dev, +* libqt6opengl6-dev, +* libexif-dev, +* libsqlite3-dev, +* libxcb-util0-dev, * libstartup-notification0-dev, -* libraw-dev, -* libqt5opengl5-dev, -* qtbase5-private-dev, -* qtmultimedia5-dev, -* x11proto-xext-dev, -* libmtdev-dev, +* libraw-dev, +* x11proto-xext-dev, +* libmtdev-dev, * libegl1-mesa-dev, -* libudev-dev, -* libfontconfig1-dev, -* libfreetype6-dev, -* libglib2.0-dev, -* libxrender-dev, +* libudev-dev, +* libfontconfig1-dev, +* libfreetype6-dev, +* libxrender-dev, * libdtkwidget-dev, -* libdtkwidget5-bin, * libdtkcore5-bin, -* libgio-qt-dev, -* libudisks2-qt5-dev, -* libopencv-dev, +* libdtk6widget-dev, +* libdtk6core-bin, * libmediainfo-dev, -* libgstreamer1.0-dev, -* libtiff-dev +* libffmpegthumbnailer-dev, +* libtiff-dev, +* libdfm6-io-dev | hello, +* libdfm-io-dev | hello ## Installation @@ -58,13 +62,13 @@ $ sudo apt-get build-dep image-editor ``` or ``` shell -$ sudo apt install cmake qtbase5-dev pkg-config libexif-dev libqt5svg5-dev libqt5x11extras5-dev libsqlite3-dev qttools5-dev-tools qttools5-dev libxcb-util0-dev libstartup-notification0-dev libraw-dev libqt5opengl5-dev qtbase5-private-dev qtmultimedia5-dev x11proto-xext-dev libmtdev-dev libegl1-mesa-dev libudev-dev libfontconfig1-dev libfreetype6-dev libglib2.0-dev libxrender-dev libdtkwidget-dev libdtkwidget5-bin libdtkcore5-bin libgio-qt-dev libudisks2-qt5-dev libmediainfo-dev libopencv-dev libgstreamer1.0-dev +$ sudo apt install cmake pkg-config qtbase5-dev qtbase5-private-dev qttools5-dev qttools5-dev-tools qtmultimedia5-dev libqt5svg5-dev libqt5x11extras5-dev qt6-base-dev qt6-base-private-dev qt6-tools-dev qt6-tools-dev-tools qt6-multimedia-dev libqt6svg6-dev libqt6opengl6-dev libexif-dev libsqlite3-dev libxcb-util0-dev libstartup-notification0-dev libraw-dev x11proto-xext-dev libmtdev-dev libegl1-mesa-dev libudev-dev libfontconfig1-dev libfreetype6-dev libxrender-dev libdtkwidget-dev libdtkcore5-bin libdtk6widget-dev libdtk6core-bin libmediainfo-dev libffmpegthumbnailer-dev libtiff-dev libdfm6-io-dev libdfm-io-dev ``` 2. Build: ``` -$ cd draw +$ cd image-editor $ mkdir Build $ cd Build $ cmake ../ diff --git a/README.zh_CN.md b/README.zh_CN.md index b465b070..d2367e70 100644 --- a/README.zh_CN.md +++ b/README.zh_CN.md @@ -8,40 +8,44 @@ Image editor 是深度开发的用于 deepin-image-viewer 和 deepin-album 的 _**master**分支是当前开发分支,编译依赖可能在未更新README.md文件的情况下变更,请参考./debian/control文件获取有效的编译依赖列表_ -* Qt (>=5.11) -* debhelper (>= 11), -* cmake, -* qtbase5-dev, +* debhelper (>= 11), +* cmake, * pkg-config, -* libexif-dev, +* qtbase5-dev, +* qtbase5-private-dev, +* qttools5-dev, +* qttools5-dev-tools, +* qtmultimedia5-dev, * libqt5svg5-dev, * libqt5x11extras5-dev, -* libsqlite3-dev, -* qttools5-dev-tools, -* qttools5-dev, -* libxcb-util0-dev, +* qt6-base-dev, +* qt6-base-private-dev, +* qt6-tools-dev, +* qt6-tools-dev-tools, +* qt6-multimedia-dev, +* libqt6svg6-dev, +* libqt6opengl6-dev, +* libexif-dev, +* libsqlite3-dev, +* libxcb-util0-dev, * libstartup-notification0-dev, -* libraw-dev, -* libqt5opengl5-dev, -* qtbase5-private-dev, -* qtmultimedia5-dev, -* x11proto-xext-dev, -* libmtdev-dev, +* libraw-dev, +* x11proto-xext-dev, +* libmtdev-dev, * libegl1-mesa-dev, -* libudev-dev, -* libfontconfig1-dev, -* libfreetype6-dev, -* libglib2.0-dev, -* libxrender-dev, +* libudev-dev, +* libfontconfig1-dev, +* libfreetype6-dev, +* libxrender-dev, * libdtkwidget-dev, -* libdtkwidget5-bin, * libdtkcore5-bin, -* libgio-qt-dev, -* libudisks2-qt5-dev, -* libopencv-dev, +* libdtk6widget-dev, +* libdtk6core-bin, * libmediainfo-dev, -* libgstreamer1.0-dev, -* libtiff-dev +* libffmpegthumbnailer-dev, +* libtiff-dev, +* libdfm6-io-dev | hello, +* libdfm-io-dev | hello ## 安装 @@ -58,7 +62,7 @@ $ sudo apt-get build-dep image-editor ``` 或者手动安装 ``` shell -$ sudo apt install cmake qtbase5-dev pkg-config libexif-dev libqt5svg5-dev libqt5x11extras5-dev libsqlite3-dev qttools5-dev-tools qttools5-dev libxcb-util0-dev libstartup-notification0-dev libraw-dev libqt5opengl5-dev qtbase5-private-dev qtmultimedia5-dev x11proto-xext-dev libmtdev-dev libegl1-mesa-dev libudev-dev libfontconfig1-dev libfreetype6-dev libglib2.0-dev libxrender-dev libdtkwidget-dev libdtkwidget5-bin libdtkcore5-bin libgio-qt-dev libudisks2-qt5-dev libmediainfo-dev libopencv-dev libgstreamer1.0-dev +$ sudo apt install cmake pkg-config qtbase5-dev qtbase5-private-dev qttools5-dev qttools5-dev-tools qtmultimedia5-dev libqt5svg5-dev libqt5x11extras5-dev qt6-base-dev qt6-base-private-dev qt6-tools-dev qt6-tools-dev-tools qt6-multimedia-dev libqt6svg6-dev libqt6opengl6-dev libexif-dev libsqlite3-dev libxcb-util0-dev libstartup-notification0-dev libraw-dev x11proto-xext-dev libmtdev-dev libegl1-mesa-dev libudev-dev libfontconfig1-dev libfreetype6-dev libxrender-dev libdtkwidget-dev libdtkcore5-bin libdtk6widget-dev libdtk6core-bin libmediainfo-dev libffmpegthumbnailer-dev libtiff-dev libdfm6-io-dev libdfm-io-dev ``` 2. 构建: diff --git a/debian/control b/debian/control index 70dad7e6..24227806 100644 --- a/debian/control +++ b/debian/control @@ -5,20 +5,28 @@ Maintainer: Deepin Packages Builder Build-Depends: debhelper (>= 11), cmake, - qtbase5-dev, pkg-config, +# Qt5 + qtbase5-dev, + qtbase5-private-dev, + qttools5-dev, + qttools5-dev-tools, + qtmultimedia5-dev, + libqt5svg5-dev, + libqt5x11extras5-dev, +# Qt6 + qt6-base-dev, + qt6-base-private-dev, + qt6-tools-dev, + qt6-tools-dev-tools, + qt6-multimedia-dev, + libqt6svg6-dev, + libqt6opengl6-dev, libexif-dev, - libqt5svg5-dev, - libqt5x11extras5-dev, libsqlite3-dev, - qttools5-dev-tools, - qttools5-dev, libxcb-util0-dev, libstartup-notification0-dev, libraw-dev, - libqt5opengl5-dev, - qtbase5-private-dev, - qtmultimedia5-dev, x11proto-xext-dev, libmtdev-dev, libegl1-mesa-dev, @@ -26,24 +34,47 @@ Build-Depends: libfontconfig1-dev, libfreetype6-dev, libxrender-dev, - libdtkwidget-dev, - libdtkwidget5-bin, +# DTK + libdtkwidget-dev, libdtkcore5-bin, - libgio-qt-dev, - libudisks2-qt5-dev, -# Disable opencv, not used now. -# libopencv-dev, + libdtk6widget-dev, + libdtk6core-bin, libmediainfo-dev, libffmpegthumbnailer-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 +# compatible different environments, hello will not be used. +# WARNING: control file changes may cause hello to be installed # instead of libdfm-io-dev. - libdfm-io-dev | qttools5-private-dev + libdfm6-io-dev | hello, + libdfm-io-dev | hello Standards-Version: 3.9.8 Homepage: http://www.deepin.org +# Support Qt5 +Package: libimageeditor6 +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Conflicts: + libimage-viewer +Replaces: + libimage-viewer +Recommends: libqt6libqgtk2, kimageformat6-plugins, deepin-ocr, ffmpegthumbnailer, ffmpeg +Description: Image Viewer library. + Deepin Image Viewer library. + +Package: libimageeditor6-dev +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, libimageeditor(=${binary:Version}) +Conflicts: + libimage-viewer-dev +Replaces: + libimage-viewer-dev +Recommends: libqt6libgtk2, kimageformat6-plugins, deepin-ocr +Description: Image Viewer library development headers. + Deepin Image Viewer library development headers. + +# Support Qt5 Package: libimageeditor Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} diff --git a/debian/copyright b/debian/copyright index a84ffcc1..5b83d71d 100644 --- a/debian/copyright +++ b/debian/copyright @@ -28,7 +28,7 @@ Copyright: UnionTech Software Technology Co., Ltd. License: CC0-1.0 # Project file -Files: *.pro *.prf *.pri *.qrc *CMakeLists.txt .tx/* +Files: *.pro *.prf *.pri *.qrc *CMakeLists.txt .tx/* *.cmake Copyright: UnionTech Software Technology Co., Ltd. License: CC0-1.0 diff --git a/debian/image-editor6.1 b/debian/image-editor6.1 new file mode 100644 index 00000000..ae6fb170 --- /dev/null +++ b/debian/image-editor6.1 @@ -0,0 +1,35 @@ +.\" This file is processed to generate manpages in the +.\" build diretory. +.TH image-editor6 1 "2020-11-17" "Deepin" + +.SH NAME +imageeditor6 \- the picture manager from UOS, based on Qt6. + +.SH SYNOPSIS +.B image-editor6 +[\fIPATH\fR] + +.SH DESCRIPTION +Deepin Image Viewer is a fashion photo manager for viewing and organizing pictures. + +.PP +This program does not accept any command line options. + +If the \fIPATH\fR is specified, open that picture with Image Viewer. +If the \fIPATH\fR is omitted, open Image Viewer and show all pictures in it. +If Image Viewer has been launched, open the picture with Image Viewer. +Otherwise, launch Image Viewer and open the picture with it. + +.SH SEE ALSO +https://www.deepin.org/en/original/image-editor/ + +.SH AUTHOR +.PP +.B imageeditor +is written by Deepin Technology Co., Ltd. +.PP +This manual page was written by +.MT liuminghang@\:uniontech.com +Liu Ming Hang +.ME +for the Debian Project (but may be used by others). diff --git a/debian/libimageeditor.install b/debian/libimageeditor.install index a8068f16..10f4a39d 100644 --- a/debian/libimageeditor.install +++ b/debian/libimageeditor.install @@ -3,4 +3,4 @@ usr/lib/*/libimageviewer.so usr/share/libimageviewer/translations/*.qm usr/lib/*/libimagevisualresult.so.* usr/share/libimagevisualresult/filter_cube/*.CUBE -usr/share/libimagevisualresult/filter_cube/*.dat +usr/share/libimagevisualresult/filter_cube/*.dat \ No newline at end of file diff --git a/debian/libimageeditor.manpages b/debian/libimageeditor.manpages new file mode 100644 index 00000000..9cabcd4a --- /dev/null +++ b/debian/libimageeditor.manpages @@ -0,0 +1 @@ +debian/image-editor.1 \ No newline at end of file diff --git a/debian/libimageeditor6-dev.install b/debian/libimageeditor6-dev.install new file mode 100644 index 00000000..761cad49 --- /dev/null +++ b/debian/libimageeditor6-dev.install @@ -0,0 +1,5 @@ +usr/include/libimageviewer6/*.h +usr/lib/*/pkgconfig/libimageviewer6.pc +usr/include/libimagevisualresult6/*.h +usr/lib/*/libimagevisualresult6.so +usr/lib/*/pkgconfig/libimagevisualresult6.pc diff --git a/debian/libimageeditor6.install b/debian/libimageeditor6.install new file mode 100644 index 00000000..112568f3 --- /dev/null +++ b/debian/libimageeditor6.install @@ -0,0 +1,6 @@ +usr/lib/*/libimageviewer6.so.* +usr/lib/*/libimageviewer6.so +usr/share/libimageviewer6/translations/*.qm +usr/lib/*/libimagevisualresult6.so.* +usr/share/libimagevisualresult6/filter_cube/*.CUBE +usr/share/libimagevisualresult6/filter_cube/*.dat \ No newline at end of file diff --git a/debian/libimageeditor6.manpages b/debian/libimageeditor6.manpages new file mode 100644 index 00000000..08820ad2 --- /dev/null +++ b/debian/libimageeditor6.manpages @@ -0,0 +1 @@ +debian/image-editor6.1 \ No newline at end of file diff --git a/debian/manpages b/debian/manpages deleted file mode 100644 index bd0aa65c..00000000 --- a/debian/manpages +++ /dev/null @@ -1 +0,0 @@ -debian/image-editor.1 diff --git a/debian/rules b/debian/rules index 1ec08a6d..ecc4370c 100755 --- a/debian/rules +++ b/debian/rules @@ -1,6 +1,6 @@ #!/usr/bin/make -f include /usr/share/dpkg/default.mk -export QT_SELECT=5 +export QT_SELECT=6 DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) %: @@ -12,3 +12,5 @@ override_dh_auto_configure: -DCMAKE_INSTALL_PREFIX=/usr \ -DAPP_VERSION=$(DEB_VERSION_UPSTREAM) -DVERSION=$(DEB_VERSION_UPSTREAM) LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) +override_dh_auto_build: + dh_auto_build -- -j$(nproc) \ No newline at end of file diff --git a/libimageviewer/CMakeLists.txt b/libimageviewer/CMakeLists.txt index aee43c77..d2db4533 100644 --- a/libimageviewer/CMakeLists.txt +++ b/libimageviewer/CMakeLists.txt @@ -1,162 +1,5 @@ -#定义需要的cmake版本 -cmake_minimum_required(VERSION 3.10) - -# 设置工程名字 -project(libimageviewer VERSION 0.1.0) - -# 检查dtkwidget版本 -execute_process(COMMAND dpkg -s libdtkwidget-dev - COMMAND grep Version - TIMEOUT 5 - OUTPUT_VARIABLE DWIDGET_VERSION_STR) -string(REPLACE "Version: " "" DWIDGET_VERSION_STR ${DWIDGET_VERSION_STR}) -message(STATUS "BUILD DTKWidget VERSION ${DWIDGET_VERSION_STR}") - -if (${DWIDGET_VERSION_STR} VERSION_LESS "5.6.9-1") - message(STATUS "Use specific dtk watermakr, Version < 5.6.9-1") - add_definitions(-DUSE_SPECIFIC_DTK_WATERMARK) -else() - message(STATUS "Use master dtk watermakr, Version >= 5.6.9-1") -endif() - -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -set(CMAKE_C_FLAGS "-fPIC") -set(CMAKE_CXX_FLAGS "-fPIC") - -#Qt需要的包 -set(QtModule Core Gui Widgets Svg DBus Concurrent PrintSupport LinguistTools) - -set(TARGET_NAME imageviewer) -set(CMD_NAME imageviewer) - -#先查找到这些qt相关的模块以供链接使用 -find_package(Qt5 REQUIRED ${QtModule}) - -#设置输出目录 -#set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/../deepin-album/lib) - -#包含目录 -include_directories(${CMAKE_INCLUDE_CURRENT_DIR}) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -add_definitions( -DLITE_DIV ) -add_definitions( -DCMAKE_BUILD ) - -#库目录 -aux_source_directory(imageviewer allSources) - - -find_package(PkgConfig REQUIRED) -find_package(TIFF) -pkg_check_modules(3rd_lib REQUIRED - dtkwidget - dtkcore - dtkgui - gobject-2.0 - 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") -#需要打开的代码文件 -FILE (GLOB allSources - "*.cpp" "*.c" - "*/*.cpp" "*/*.c" - "*/*/*.cpp" "*/*/*.c" - ) -file(GLOB_RECURSE RESOURCES "*.qrc") - -#------------------添加第三方库begins--------------------------# -file(GLOB tiffToolsSources ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/tiff-tools/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/tiff-tools/*.h) -#使用第三方库需要用到的一个包 - -set(INC_DIR /usr/include/) -set(LINK_DIR /usr/lib/) - -include_directories(${INC_DIR}) -link_directories(${LINK_DIR}) - -set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1) - -file(GLOB TS LIST_DIRECTORIES false translations/libimageviewer*.ts) - -set_source_files_properties(${TS} PROPERTIES OUTPUT_LOCATION ${PROJECT_SOURCE_DIR}/translations) - -qt5_create_translation(QM ${allSources} ${GLOB}) - -if (NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug")) - qt5_create_translation(QM ${allSources} ${TS}) -endif () - -# 设置不删除生成的文件夹内容文件 -set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1) - -#编译为库 -add_library(imageviewer SHARED ${allHeaders} ${allSources} ${RESOURCES} ${QM} ${tiffToolsSources}) -#使用库 -qt5_use_modules(imageviewer ${QtModule}) - - -#将库安装到指定位置 -set(PREFIX /usr) -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} ${dfm-io_lib_INCLUDE_DIRS}) -target_link_libraries(imageviewer ${3rd_lib_LIBRARIES} ${TIFF_LIBRARIES} ${dfm-io_lib_LIBRARIES} dl) - -include(GNUInstallDirs) -configure_file(libimageviewer.pc.in ${PROJECT_BINARY_DIR}/libimageviewer.pc @ONLY) - -install(TARGETS ${CMD_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -# 公共库头文件 -install(FILES - imageengine.h - imageviewer.h - image-viewer_global.h - movieservice.h - quickprint.h - DESTINATION include/libimageviewer) - -# pkg-config 配置文件 -install(FILES ${PROJECT_BINARY_DIR}/libimageviewer.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -# translations 翻译文件 -install(DIRECTORY ${PROJECT_SOURCE_DIR}/translations - DESTINATION ${PREFIX}/share/libimageviewer - FILES_MATCHING PATTERN "*.qm") - -# 加速编译优化参数 -if (NOT(CMAKE_BUILD_TYPE STREQUAL "Debug")) - if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "mips64") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wl,-O1 -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi -z noexecstack") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wl,-O1 -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi -z noexecstack") - SET(CMAKE_EXE_LINKER_FLAGS "-pie") - else() - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wl,-O1 -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wl,-O1 -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections") - SET(CMAKE_EXE_LINKER_FLAGS "-pie") - endif() +if(SUPPORT_QT6) + include(libimageviewer-qt6.cmake) endif() -if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "sw_64") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mieee") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mieee") - add_definitions( -DISSW_64 ) -endif() +include(libimageviewer-qt5.cmake) diff --git a/libimageviewer/image-viewer_global.h b/libimageviewer/image-viewer_global.h index df514215..4ef1c42f 100644 --- a/libimageviewer/image-viewer_global.h +++ b/libimageviewer/image-viewer_global.h @@ -9,6 +9,7 @@ #include #include #include +#include #if defined(IMAGEVIEWER_LIBRARY) # define IMAGEVIEWERSHARED_EXPORT Q_DECL_EXPORT diff --git a/libimageviewer/imageviewer.cpp b/libimageviewer/imageviewer.cpp index 9840a6f2..69cb202c 100644 --- a/libimageviewer/imageviewer.cpp +++ b/libimageviewer/imageviewer.cpp @@ -74,7 +74,11 @@ ImageViewerPrivate::ImageViewerPrivate(imageViewerSpace::ImgViewerType imgViewer } } +#if QT_VERSION_CHECK(6, 0, 0) < QT_VERSION + QStringList parseLocalNameList = QLocale::system().name().split("_", Qt::SkipEmptyParts); +#else QStringList parseLocalNameList = QLocale::system().name().split("_", QString::SkipEmptyParts); +#endif if (parseLocalNameList.length() > 0) { QString translateFilename = QString("/libimageviewer_%2.qm").arg(parseLocalNameList.at(0)); diff --git a/libimageviewer/libimageviewer-qt5.cmake b/libimageviewer/libimageviewer-qt5.cmake new file mode 100644 index 00000000..fe8de58f --- /dev/null +++ b/libimageviewer/libimageviewer-qt5.cmake @@ -0,0 +1,5 @@ +set(QT_VERSION_MAJOR 5) +unset(DTK_VERSION_MAJOR) +unset(IMGE_VERSION_MAJOR) + +include(libimageviewer.cmake) diff --git a/libimageviewer/libimageviewer-qt6.cmake b/libimageviewer/libimageviewer-qt6.cmake new file mode 100644 index 00000000..f7593d8b --- /dev/null +++ b/libimageviewer/libimageviewer-qt6.cmake @@ -0,0 +1,5 @@ +set(QT_VERSION_MAJOR 6) +set(DTK_VERSION_MAJOR 6) +set(IMGE_VERSION_MAJOR 6) + +include(libimageviewer.cmake) diff --git a/libimageviewer/libimageviewer.cmake b/libimageviewer/libimageviewer.cmake new file mode 100644 index 00000000..ac3df0c8 --- /dev/null +++ b/libimageviewer/libimageviewer.cmake @@ -0,0 +1,187 @@ +# 定义需要的cmake版本 +cmake_minimum_required(VERSION 3.10) + +# 设置工程名字 +project(libimageviewer${IMGE_VERSION_MAJOR} VERSION 0.1.0) +set(TARGET_NAME imageviewer${IMGE_VERSION_MAJOR}) +message("\n\n>>> Project: ${PROJECT_NAME}") + +# Check the dtkwidget version to open watermark +execute_process(COMMAND dpkg -s libdtkwidget-dev + COMMAND grep Version + TIMEOUT 5 + OUTPUT_VARIABLE DWIDGET_VERSION_STR) +string(REPLACE "Version: " "" DWIDGET_VERSION_STR ${DWIDGET_VERSION_STR}) +message(STATUS "BUILD DTKWidget VERSION ${DWIDGET_VERSION_STR}") + +if(${DWIDGET_VERSION_STR} VERSION_LESS "5.6.9-1") + message(STATUS "Use specific dtk watermakr, Version < 5.6.9-1") + add_definitions(-DUSE_SPECIFIC_DTK_WATERMARK) +else() + message(STATUS "Use master dtk watermakr, Version >= 5.6.9-1") +endif() + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +set(CMAKE_C_FLAGS "-fPIC") +set(CMAKE_CXX_FLAGS "-fPIC") + +# 先查找到这些qt相关的模块以供链接使用 +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets Svg DBus Concurrent PrintSupport LinguistTools) + +if(${QT_VERSION_MAJOR} EQUAL 6) + find_package(Qt6 REQUIRED COMPONENTS SvgWidgets) +endif() + +# 包含目录 +include_directories(${CMAKE_INCLUDE_CURRENT_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +add_definitions(-DLITE_DIV) +add_definitions(-DCMAKE_BUILD) + +# 库目录 +aux_source_directory(imageviewer allSources) + +find_package(PkgConfig REQUIRED) +find_package(TIFF) +pkg_check_modules(3rd_lib REQUIRED + dtk${DTK_VERSION_MAJOR}widget + dtk${DTK_VERSION_MAJOR}core + dtk${DTK_VERSION_MAJOR}gui + gobject-2.0 + libmediainfo +) + +# find dfm-io +if(${QT_VERSION_MAJOR} EQUAL 6) + pkg_check_modules(dfm-io_lib dfm6-io) +else() + pkg_check_modules(dfm-io_lib dfm-io) +endif() + +if(${dfm-io_lib_FOUND}) + message("--- Found ${dfm-io_lib_LIBRARIES}, 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") + +# 需要打开的代码文件 +FILE(GLOB_RECURSE allSources "*.cpp" "*.c") +file(GLOB_RECURSE RESOURCES "*.qrc") + +# ------------------添加第三方库begins--------------------------# +file(GLOB tiffToolsSources ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/tiff-tools/*.c + ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/tiff-tools/*.h) + +# 使用第三方库需要用到的一个包 +set(INC_DIR /usr/include/) +set(LINK_DIR /usr/lib/) + +include_directories(${INC_DIR}) +link_directories(${LINK_DIR}) + +set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1) + +# transaltions: in qt5, translations need to be generated before the target is set, +# while Qt6 does the opposite +if(${QT_VERSION_MAJOR} EQUAL 5) + file(GLOB TS LIST_DIRECTORIES false translations/libimageviewer*.ts) + set_source_files_properties(${TS} PROPERTIES OUTPUT_LOCATION ${PROJECT_SOURCE_DIR}/translations) + + qt5_create_translation(QM ${allSources} ${GLOB}) + + if(NOT(${CMAKE_BUILD_TYPE} MATCHES "Debug")) + qt5_create_translation(QM ${allSources} ${TS}) + endif() +endif() + +# 设置不删除生成的文件夹内容文件 +set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1) + +# 编译为库 +add_library(${TARGET_NAME} SHARED ${allHeaders} ${allSources} ${RESOURCES} ${QM} ${tiffToolsSources}) + +# 将库安装到指定位置 +set_target_properties(${TARGET_NAME} PROPERTIES VERSION 0.1.0 SOVERSION 0.1) + +target_include_directories(${TARGET_NAME} PUBLIC ${3rd_lib_INCLUDE_DIRS} ${TIFF_INCLUDE_DIRS} ${dfm-io_lib_INCLUDE_DIRS}) +target_link_libraries(${TARGET_NAME} + Qt${QT_VERSION_MAJOR}::Core + Qt${QT_VERSION_MAJOR}::Gui + Qt${QT_VERSION_MAJOR}::Widgets + Qt${QT_VERSION_MAJOR}::Svg + Qt${QT_VERSION_MAJOR}::DBus + Qt${QT_VERSION_MAJOR}::Concurrent + Qt${QT_VERSION_MAJOR}::PrintSupport + ${3rd_lib_LIBRARIES} + ${TIFF_LIBRARIES} + ${dfm-io_lib_LIBRARIES} + dl) + +if(${QT_VERSION_MAJOR} EQUAL 6) + target_link_libraries(${TARGET_NAME} Qt6::SvgWidgets) +endif() + +# get standard install paths +include(GNUInstallDirs) +configure_file(libimageviewer.pc.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY) +install(FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + +# lib and headers +install(TARGETS ${TARGET_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(FILES + imageengine.h + imageviewer.h + image-viewer_global.h + movieservice.h + quickprint.h + DESTINATION include/${PROJECT_NAME}) + +# translations, set load path for translations +if(${QT_VERSION_MAJOR} EQUAL 6) + file(COPY ${PROJECT_SOURCE_DIR}/translations/ + DESTINATION ${PROJECT_SOURCE_DIR}/translations${IMGE_VERSION_MAJOR} + FILES_MATCHING PATTERN "*.ts") + + file(GLOB TS6 LIST_DIRECTORIES false translations${IMGE_VERSION_MAJOR}/libimageviewer*.ts) + set_source_files_properties(${TS6} PROPERTIES OUTPUT_LOCATION ${PROJECT_SOURCE_DIR}/translations${IMGE_VERSION_MAJOR}) + + qt6_add_translations(${TARGET_NAME} + TS_FILES ${TS6} + SOURCES ${allSources} + ) +endif() + +# copy .qm translation file to same path "usr/shar/${PROJECT_NAME}/translations" +install(DIRECTORY ${PROJECT_SOURCE_DIR}/translations${IMGE_VERSION_MAJOR}/ + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/translations + FILES_MATCHING PATTERN "*.qm") +target_compile_definitions(${TARGET_NAME} PRIVATE -DPLUGIN_QM_TRANS_PATH=${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/translations) + +# Accelerated compilation of optimized parameters +if(NOT(CMAKE_BUILD_TYPE STREQUAL "Debug")) + if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "mips64") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wl,-O1 -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi -z noexecstack") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wl,-O1 -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi -z noexecstack") + SET(CMAKE_EXE_LINKER_FLAGS "-pie") + else() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wl,-O1 -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wl,-O1 -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections") + SET(CMAKE_EXE_LINKER_FLAGS "-pie") + endif() +endif() + +if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "sw_64") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mieee") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mieee") + add_definitions(-DISSW_64) +endif() diff --git a/libimageviewer/libimageviewer.pc.in b/libimageviewer/libimageviewer.pc.in index ddd3a98d..7708ccce 100644 --- a/libimageviewer/libimageviewer.pc.in +++ b/libimageviewer/libimageviewer.pc.in @@ -1,12 +1,11 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix}/bin -libimageviewer=${prefix}/@CMAKE_INSTALL_LIBDIR@ -includedir=${prefix}/include/libimageviewer +@PROJECT_NAME@=${prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/include/@PROJECT_NAME@ -Name: image-viewer +Name: image-viewer@IMGE_VERSION_MAJOR@ Description: deepin image viewer plugins Version: @PROJECT_VERSION@ -Libs: -L${libimageviewer} -limageviewer +Libs: -L${@PROJECT_NAME@} -l@TARGET_NAME@ Cflags: -I${includedir} -Requires: Qt5Core Qt5Gui Qt5Widgets Qt5Svg Qt5DBus Qt5Concurrent Qt5PrintSupport dtkcore dtkwidget - +Requires: Qt@QT_VERSION_MAJOR@Core Qt@QT_VERSION_MAJOR@Gui Qt@QT_VERSION_MAJOR@Widgets Qt@QT_VERSION_MAJOR@Svg Qt@QT_VERSION_MAJOR@DBus Qt@QT_VERSION_MAJOR@Concurrent Qt@QT_VERSION_MAJOR@PrintSupport dtk@DTK_VERSION_MAJOR@core dtk@DTK_VERSION_MAJOR@widget diff --git a/libimageviewer/movieservice.cpp b/libimageviewer/movieservice.cpp index 50f6186f..2201ba79 100644 --- a/libimageviewer/movieservice.cpp +++ b/libimageviewer/movieservice.cpp @@ -324,9 +324,10 @@ MovieInfo MovieService::getMovieInfo_ffmpeg(const QFileInfo &fi) mi.vCodecID = videoStreamInfo[0].split(" ")[0]; //分辨率,长宽比 - QRegExp resolutionExp(resolutionPattern); - if (resolutionExp.indexIn(videoInfoString) > 0) { - mi.resolution = resolutionExp.cap(0); + QRegularExpression resolutionExp(resolutionPattern); + QRegularExpressionMatch match = resolutionExp.match(videoInfoString); + if (match.hasMatch()) { + mi.resolution = match.captured(0); auto videoSize = mi.resolution.split("x"); int size_w = videoSize[0].toInt(); @@ -338,18 +339,20 @@ MovieInfo MovieService::getMovieInfo_ffmpeg(const QFileInfo &fi) } //码率 - QRegExp codeRateExp(codeRatePattern); - if (codeRateExp.indexIn(videoInfoString) > 0) { - auto codeRate = codeRateExp.cap(0); + QRegularExpression codeRateExp(codeRatePattern); + match = codeRateExp.match(videoInfoString); + if (match.hasMatch()) { + auto codeRate = match.captured(0); mi.vCodeRate = codeRate.split(" ")[0].toInt(); } else { mi.vCodeRate = 0; } //帧率 - QRegExp fpsExp(fpsPattern); - if (fpsExp.indexIn(videoInfoString) > 0) { - auto fps = fpsExp.cap(0); + QRegularExpression fpsExp(fpsPattern); + match = fpsExp.match(videoInfoString); + if (match.hasMatch()) { + auto fps = match.captured(0); mi.fps = fps.split(" ")[0].toInt(); } else { mi.fps = 0; diff --git a/libimageviewer/quickprint/quickprint.cpp b/libimageviewer/quickprint/quickprint.cpp index 63c3a959..9b582d8e 100644 --- a/libimageviewer/quickprint/quickprint.cpp +++ b/libimageviewer/quickprint/quickprint.cpp @@ -141,7 +141,11 @@ void QuickPrintPrivate::asyncPrint(DPrinter *printer, const QVector &pageRa QPainter painter(printer); painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::SmoothPixmapTransform); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QRect rect = printer->pageRect(QPrinter::DevicePixel).toRect(); +#else QRect rect = printer->pageRect(); +#endif qreal ratio = 0.0; for (int page : pageRange) { diff --git a/libimageviewer/service/aimodelservice.cpp b/libimageviewer/service/aimodelservice.cpp index 8761891f..e44ebbcc 100644 --- a/libimageviewer/service/aimodelservice.cpp +++ b/libimageviewer/service/aimodelservice.cpp @@ -445,7 +445,7 @@ void AIModelService::cancelProcess(const QString &output) if (dptr->enhanceCache.contains(output)) { EnhancePtr ptr = dptr->enhanceCache.value(output); if (!ptr.isNull() && Loading == ptr->state.loadAcquire()) { - ptr->state.store(Cancel); + ptr->state.storeRelease(Cancel); Q_EMIT enhanceEnd(ptr->source, ptr->output, Cancel); } diff --git a/libimageviewer/service/aimodelservice.h b/libimageviewer/service/aimodelservice.h index 907b53a1..ec928341 100644 --- a/libimageviewer/service/aimodelservice.h +++ b/libimageviewer/service/aimodelservice.h @@ -45,7 +45,7 @@ class AIModelService : public QObject void saveEnhanceFile(const QString &filePath); void saveEnhanceFileAs(const QString &filePath, QWidget *target = nullptr); - bool detectErrorAndNotify(QWidget *targetWidget, Error error, const QString &output = QString::null); + bool detectErrorAndNotify(QWidget *targetWidget, Error error, const QString &output = {}); // 图片切换/中断增强处理等操作时,清理之前的图像增强状态 Q_SIGNAL void clearPreviousEnhance(); diff --git a/libimageviewer/service/mtpfileproxy.cpp b/libimageviewer/service/mtpfileproxy.cpp index a5587c5b..65274aa0 100644 --- a/libimageviewer/service/mtpfileproxy.cpp +++ b/libimageviewer/service/mtpfileproxy.cpp @@ -5,13 +5,18 @@ #include "mtpfileproxy.h" #include "imageengine.h" +#include #include #include #include #ifdef USE_DFM_IO -#include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +# include +#else +# include +#endif USING_IO_NAMESPACE #endif @@ -30,7 +35,7 @@ static void fileOperateCallbackFunc(bool ret, void *data) } } -MtpFileProxy::MtpFileProxy() +MtpFileProxy::MtpFileProxy() { #ifdef USE_DFM_IO qInfo() << qPrintable("Use dfm-io copy MTP file."); @@ -85,7 +90,7 @@ bool MtpFileProxy::checkFileDeviceIsMtp(const QString &filePath) if (storage.device().startsWith("gvfs") || storage.device().startsWith("cifs")) { // /run/user/1000/gvfs/mtp: /run/user/1000/gvfs/gphoto2: QString absoluteFilePath = QFileInfo(filePath).absoluteFilePath(); - if (absoluteFilePath.contains(QRegExp("fs/(mtp|gphoto2):"))) { + if (absoluteFilePath.contains(QRegularExpression("fs/(mtp|gphoto2):"))) { // 判断是否为图片文件 if (ImageEngine::instance()->isImage(filePath)) { return true; diff --git a/libimageviewer/slideshow/imageanimation.cpp b/libimageviewer/slideshow/imageanimation.cpp index af488051..1f95eaa1 100644 --- a/libimageviewer/slideshow/imageanimation.cpp +++ b/libimageviewer/slideshow/imageanimation.cpp @@ -14,10 +14,12 @@ #include #include #include -#include #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#include +#endif #include @@ -518,8 +520,8 @@ void LibImageAnimationPrivate::setPathList(const QString &first, const QStringLi void LibImageAnimationPrivate::startAnimation() { - qsrand(static_cast(QTime(0, 0, 0).secsTo(QTime::currentTime()))); - m_animationType = static_cast(qrand() % (3)); + std::srand(static_cast(QTime(0, 0, 0).secsTo(QTime::currentTime()))); + m_animationType = static_cast(std::rand() % (3)); if (!m_continuousanimationTimer) { m_continuousanimationTimer = new QTimer(this); m_factor = 0.0f; @@ -592,8 +594,8 @@ void LibImageAnimationPrivate::onStaticTimer() qDebug() << "ImageAnimationPrivate::onStaticTimer m_SliderModel = " << LibImageAnimation::AutoPlayModel; if (m_PlayOrStatue == LibImageAnimation::PlayStatue && m_SliderModel == LibImageAnimation::AutoPlayModel) { - qsrand(static_cast(QTime(0, 0, 0).secsTo(QTime::currentTime()))); - m_animationType = static_cast(qrand() % (3)); + std::srand(static_cast(QTime(0, 0, 0).secsTo(QTime::currentTime()))); + m_animationType = static_cast(std::rand() % (3)); setImage1(m_imageName2); setImage2(queue->jumpTonext()); startAnimation(); @@ -608,18 +610,34 @@ void LibImageAnimationPrivate::setImage1(const QString &imageName1_bar) LibUnionImage_NameSpace::loadStaticImageFromFile(imageName1_bar, tImg, errMsg); QPixmap p1 = QPixmap::fromImage(tImg); int beginX = 0, beginY = 0; + + QRect screenGeometry; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (auto screen = QGuiApplication::primaryScreen()) { + screenGeometry = screen->geometry(); + } + +#else + // 双屏下或者多屏下 int number = QApplication::desktop()->screenNumber(q_ptr); if (number < 0) { number = 0; } + + if (auto screen = QGuiApplication::screens().at(number)) { + screenGeometry = screen->geometry(); + } + +#endif + // 多屏显示问题,定位当前屏幕 if (p1.width() >= p1.height()) { - m_pixmap1 = QPixmap(QGuiApplication::screens().at(number)->geometry().size()); + m_pixmap1 = QPixmap(screenGeometry.size()); QPainter pa1(&m_pixmap1); m_pixmap1.fill(QColor("#252525")); - p1 = p1.scaledToWidth(QGuiApplication::screens().at(number)->geometry().size().width()); - if (p1.height() > QGuiApplication::screens().at(number)->geometry().size().height()) { - p1 = p1.scaledToHeight(QGuiApplication::screens().at(number)->geometry().size().height()); + p1 = p1.scaledToWidth(screenGeometry.width()); + if (p1.height() > screenGeometry.height()) { + p1 = p1.scaledToHeight(screenGeometry.height()); } // 多屏显示去除x偏移 centrePoint = q_ptr->getCurScreenGeometry().center(); @@ -630,12 +648,12 @@ void LibImageAnimationPrivate::setImage1(const QString &imageName1_bar) pa1.drawPixmap(beginX, beginY, p1); pa1.end(); } else { - m_pixmap1 = QPixmap(QGuiApplication::screens().at(number)->geometry().size()); + m_pixmap1 = QPixmap(screenGeometry.size()); QPainter pa1(&m_pixmap1); m_pixmap1.fill(QColor("#252525")); - p1 = p1.scaledToHeight(QGuiApplication::screens().at(number)->geometry().size().height() + 8); - if (p1.width() > QGuiApplication::screens().at(number)->geometry().size().width()) { - p1 = p1.scaledToWidth(QGuiApplication::screens().at(number)->geometry().size().width()); + p1 = p1.scaledToHeight(screenGeometry.height() + 8); + if (p1.width() > screenGeometry.width()) { + p1 = p1.scaledToWidth(screenGeometry.width()); } // 多屏显示去除x偏移 centrePoint = q_ptr->getCurScreenGeometry().center(); @@ -656,18 +674,33 @@ void LibImageAnimationPrivate::setImage2(const QString &imageName2_bar) QString errMsg; LibUnionImage_NameSpace::loadStaticImageFromFile(imageName2_bar, tImg, errMsg); QPixmap p2 = QPixmap::fromImage(tImg); + + QRect screenGeometry; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (auto screen = QGuiApplication::primaryScreen()) { + screenGeometry = screen->geometry(); + } + +#else // 双屏下或者多屏下 int number = QApplication::desktop()->screenNumber(q_ptr); if (number < 0) { number = 0; } + + if (auto screen = QGuiApplication::screens().at(number)) { + screenGeometry = screen->geometry(); + } + +#endif + if (p2.width() >= p2.height()) { - m_pixmap2 = QPixmap(QGuiApplication::screens().at(number)->geometry().size()); + m_pixmap2 = QPixmap(screenGeometry.size()); QPainter pa2(&m_pixmap2); m_pixmap2.fill(QColor("#252525")); - p2 = p2.scaledToWidth(QGuiApplication::screens().at(number)->geometry().size().width()); - if (p2.height() > QGuiApplication::screens().at(number)->geometry().size().height()) { - p2 = p2.scaledToHeight(QGuiApplication::screens().at(number)->geometry().size().height()); + p2 = p2.scaledToWidth(screenGeometry.width()); + if (p2.height() > screenGeometry.height()) { + p2 = p2.scaledToHeight(screenGeometry.height()); } // 多屏显示下,要去除x偏移 centrePoint = q_ptr->getCurScreenGeometry().center(); @@ -678,12 +711,12 @@ void LibImageAnimationPrivate::setImage2(const QString &imageName2_bar) pa2.drawPixmap(beginX, beginY, p2); pa2.end(); } else { - m_pixmap2 = QPixmap(QGuiApplication::screens().at(number)->geometry().size()); + m_pixmap2 = QPixmap(screenGeometry.size()); QPainter pa2(&m_pixmap2); m_pixmap2.fill(QColor("#252525")); - p2 = p2.scaledToHeight(QGuiApplication::screens().at(number)->geometry().size().height() + 8); - if (p2.width() > QGuiApplication::screens().at(number)->geometry().size().width()) { - p2 = p2.scaledToWidth(QGuiApplication::screens().at(number)->geometry().size().width()); + p2 = p2.scaledToHeight(screenGeometry.height() + 8); + if (p2.width() > screenGeometry.width()) { + p2 = p2.scaledToWidth(screenGeometry.width()); } // 多屏显示下,要去除x偏移 centrePoint = q_ptr->getCurScreenGeometry().center(); @@ -704,7 +737,7 @@ LibImageAnimation::LibImageAnimation(QWidget *parent) : setAttribute(Qt::WA_TransparentForMouseEvents, true); setAttribute(Qt::WA_StyledBackground, true); QPalette pal(palette()); - pal.setColor(QPalette::Background, Qt::black); + pal.setColor(QPalette::Window, Qt::black); setAutoFillBackground(true); setPalette(pal); } @@ -779,11 +812,18 @@ const QString LibImageAnimation::currentPath() const QRect LibImageAnimation::getCurScreenGeometry() { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QRect tempRect; + if (auto screen = QApplication::primaryScreen()) { + tempRect = screen->geometry(); + } +#else int number = QApplication::desktop()->screenNumber(this); if (number < 0) { number = 0; } QRect tempRect = QGuiApplication::screens().at(number)->geometry(); +#endif tempRect.setRect(0, 0, tempRect.width(), tempRect.height()); return tempRect; } diff --git a/libimageviewer/slideshow/slideshowpanel.cpp b/libimageviewer/slideshow/slideshowpanel.cpp index 34323f1f..1d373381 100644 --- a/libimageviewer/slideshow/slideshowpanel.cpp +++ b/libimageviewer/slideshow/slideshowpanel.cpp @@ -13,7 +13,9 @@ #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include +#endif #include #include @@ -157,7 +159,7 @@ LibSlideShowPanel::LibSlideShowPanel(QWidget *parent) : QWidget(parent) initConnections(); setMouseTracking(true); QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(m_animation); this->setLayout(layout); qDebug() << QGuiApplication::primaryScreen()->geometry().width(); @@ -295,12 +297,27 @@ void LibSlideShowPanel::startSlideShow(const ViewInfo &vinfo) //todo屏蔽了全局信号 // emit dApp->signalM->updatePauseButton(); } + + QRect screenGeometry; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (auto screen = QGuiApplication::primaryScreen()) { + screenGeometry = screen->geometry(); + } + +#else int number = QApplication::desktop()->screenNumber(this); if (number < 0) { number = 0; } - int nParentWidth = QGuiApplication::screens().at(number)->geometry().width(); - int nParentHeight = QGuiApplication::screens().at(number)->geometry().height(); + + if (auto screen = QGuiApplication::screens().at(number)) { + screenGeometry = screen->geometry(); + } + +#endif + + int nParentWidth = screenGeometry.width(); + int nParentHeight = screenGeometry.height(); slideshowbottombar->move((nParentWidth - slideshowbottombar->width()) / 2, nParentHeight); m_animation->startSlideShow(m_vinfo.path, m_vinfo.paths); auto actionlist = m_menu->actions(); @@ -395,12 +412,28 @@ void LibSlideShowPanel::mouseMoveEvent(QMouseEvent *event) if (window()->isFullScreen()) { QPoint pos = mapFromGlobal(QCursor::pos()); + + // 处理程序界面的初始高度和全屏下幻灯片界面不一致导致底部工具栏位置错误 + QRect screenGeometry; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (auto screen = QGuiApplication::primaryScreen()) { + screenGeometry = screen->geometry(); + } + +#else int number = QApplication::desktop()->screenNumber(this); if (number < 0) { number = 0; } - if (QGuiApplication::screens().at(number)->geometry().size().height() != height()) + + if (auto screen = QGuiApplication::screens().at(number)) { + screenGeometry = screen->geometry(); + } + +#endif + + if (screenGeometry.height() != height()) return; if (height() - 20 < pos.y() && height() >= pos.y() && height() >= slideshowbottombar->y()) { QPropertyAnimation *animation = new QPropertyAnimation(slideshowbottombar, "pos"); diff --git a/libimageviewer/unionimage/baseutils.cpp b/libimageviewer/unionimage/baseutils.cpp index f4a14b12..afa58abc 100755 --- a/libimageviewer/unionimage/baseutils.cpp +++ b/libimageviewer/unionimage/baseutils.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -384,12 +385,12 @@ bool trashFile(const QString &file) QString SpliteText(const QString &text, const QFont &font, int nLabelSize, bool bReturn) { QFontMetrics fm(font); - int nTextSize = fm.width(text); + int nTextSize = fm.horizontalAdvance(text); if (nTextSize > nLabelSize) { int nPos = 0; long nOffset = 0; for (int i = 0; i < text.size(); i++) { - nOffset += fm.width(text.at(i)); + nOffset += fm.horizontalAdvance(text.at(i)); if (nOffset >= nLabelSize) { nPos = i; break; @@ -514,7 +515,11 @@ bool loadLibTransaltor() } } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QStringList parseLocalNameList = QLocale::system().name().split("_", Qt::SkipEmptyParts); +#else QStringList parseLocalNameList = QLocale::system().name().split("_", QString::SkipEmptyParts); +#endif if (parseLocalNameList.length() > 0) { QString translateFilename = QString("/libimageviewer_%2.qm").arg(parseLocalNameList.at(0)); diff --git a/libimageviewer/unionimage/imageutils.cpp b/libimageviewer/unionimage/imageutils.cpp index 9443a5dd..e949ff62 100755 --- a/libimageviewer/unionimage/imageutils.cpp +++ b/libimageviewer/unionimage/imageutils.cpp @@ -501,7 +501,7 @@ QMap thumbnailAttribute(const QUrl &url) set.insert("Thumb::Mimetype", QMimeDatabase().mimeTypeForFile(path).name()); set.insert("Thumb::Size", QString::number(info.size())); set.insert("Thumb::URI", url.toString()); - set.insert("Thumb::MTime", QString::number(info.lastModified().toTime_t())); + set.insert("Thumb::MTime", QString::number(info.lastModified().toSecsSinceEpoch())); set.insert("Software", "Deepin Image Viewer"); QImageReader reader(path); @@ -738,7 +738,7 @@ bool isVaultFile(const QString &path) { bool bVaultFile = false; QString rootPath = makeVaultLocalPath("", ""); - if (rootPath.back() == "/") { + if (rootPath.back() == QChar('/')) { rootPath.chop(1); } diff --git a/libimageviewer/unionimage/unionimage.cpp b/libimageviewer/unionimage/unionimage.cpp index 455b0d8a..0588d989 100644 --- a/libimageviewer/unionimage/unionimage.cpp +++ b/libimageviewer/unionimage/unionimage.cpp @@ -502,7 +502,7 @@ UNIONIMAGESHARED_EXPORT bool rotateImageFIle(int angel, const QString &path, QSt QPainter rotatePainter; rotatePainter.begin(&generator); rotatePainter.resetTransform(); - rotatePainter.setRenderHint(QPainter::HighQualityAntialiasing, true); + rotatePainter.setRenderHint(QPainter::Antialiasing, true); int realangel = angel / 90; if (realangel > 0) { for (int i = 0; i < qAbs(realangel); i++) { @@ -526,7 +526,7 @@ UNIONIMAGESHARED_EXPORT bool rotateImageFIle(int angel, const QString &path, QSt QImage image_copy(path); image_copy = adjustImageToRealPosition(image_copy, orientation); if (!image_copy.isNull()) { - QMatrix rotatematrix; + QTransform rotatematrix; rotatematrix.rotate(angel); image_copy = image_copy.transformed(rotatematrix, Qt::SmoothTransformation); @@ -561,7 +561,7 @@ UNIONIMAGESHARED_EXPORT bool rotateImageFIleWithImage(int angel, QImage &img, co QPainter rotatePainter; rotatePainter.begin(&generator); rotatePainter.resetTransform(); - rotatePainter.setRenderHint(QPainter::HighQualityAntialiasing, true); + rotatePainter.setRenderHint(QPainter::Antialiasing, true); int realangel = angel / 90; if (realangel > 0) { for (int i = 0; i < qAbs(realangel); i++) { diff --git a/libimageviewer/viewpanel/contents/aienhancefloatwidget.cpp b/libimageviewer/viewpanel/contents/aienhancefloatwidget.cpp index 80761138..f091a4d9 100644 --- a/libimageviewer/viewpanel/contents/aienhancefloatwidget.cpp +++ b/libimageviewer/viewpanel/contents/aienhancefloatwidget.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include const int FLOAT_WDITH = 72; @@ -112,8 +112,8 @@ void AIEnhanceFloatWidget::onThemeChanged() // 取消阴影 pa.setColor(DPalette::Shadow, btnframecolor); - DApplicationHelper::instance()->setPalette(resetBtn, pa); - DApplicationHelper::instance()->setPalette(saveAsBtn, pa); + DPaletteHelper::instance()->setPalette(resetBtn, pa); + DPaletteHelper::instance()->setPalette(saveAsBtn, pa); } else { QColor maskColor("#202020"); maskColor.setAlphaF(0.50); @@ -130,7 +130,7 @@ void AIEnhanceFloatWidget::onThemeChanged() // 取消阴影 pa.setColor(DPalette::Shadow, btnframecolor); - DApplicationHelper::instance()->setPalette(resetBtn, pa); - DApplicationHelper::instance()->setPalette(saveAsBtn, pa); + DPaletteHelper::instance()->setPalette(resetBtn, pa); + DPaletteHelper::instance()->setPalette(saveAsBtn, pa); } } diff --git a/libimageviewer/viewpanel/contents/bottomtoolbar.cpp b/libimageviewer/viewpanel/contents/bottomtoolbar.cpp index a4f10350..6f4a944c 100644 --- a/libimageviewer/viewpanel/contents/bottomtoolbar.cpp +++ b/libimageviewer/viewpanel/contents/bottomtoolbar.cpp @@ -13,9 +13,8 @@ #include #include -#include #include -#include +#include #include #include @@ -419,20 +418,20 @@ void LibBottomToolbar::slotThemeChanged(int type) pa.setColor(DPalette::FrameBorder, btnframecolor); // 取消阴影 pa.setColor(DPalette::Shadow, btnframecolor); - DApplicationHelper::instance()->setPalette(m_backButton, pa); - DApplicationHelper::instance()->setPalette(m_preButton, pa); - DApplicationHelper::instance()->setPalette(m_nextButton, pa); - DApplicationHelper::instance()->setPalette(m_adaptImageBtn, pa); - DApplicationHelper::instance()->setPalette(m_adaptScreenBtn, pa); - DApplicationHelper::instance()->setPalette(m_clBT, pa); + DPaletteHelper::instance()->setPalette(m_backButton, pa); + DPaletteHelper::instance()->setPalette(m_preButton, pa); + DPaletteHelper::instance()->setPalette(m_nextButton, pa); + DPaletteHelper::instance()->setPalette(m_adaptImageBtn, pa); + DPaletteHelper::instance()->setPalette(m_adaptScreenBtn, pa); + DPaletteHelper::instance()->setPalette(m_clBT, pa); if (m_ocrIsExists) { - DApplicationHelper::instance()->setPalette(m_ocrBtn, pa); + DPaletteHelper::instance()->setPalette(m_ocrBtn, pa); } - DApplicationHelper::instance()->setPalette(m_rotateLBtn, pa); - DApplicationHelper::instance()->setPalette(m_rotateRBtn, pa); - DApplicationHelper::instance()->setPalette(m_trashBtn, pa); + DPaletteHelper::instance()->setPalette(m_rotateLBtn, pa); + DPaletteHelper::instance()->setPalette(m_rotateRBtn, pa); + DPaletteHelper::instance()->setPalette(m_trashBtn, pa); } else { QColor maskColor("#202020"); maskColor.setAlphaF(0.50); @@ -447,20 +446,20 @@ void LibBottomToolbar::slotThemeChanged(int type) pa.setColor(DPalette::FrameBorder, btnframecolor); // 取消阴影 pa.setColor(DPalette::Shadow, btnframecolor); - DApplicationHelper::instance()->setPalette(m_backButton, pa); - DApplicationHelper::instance()->setPalette(m_preButton, pa); - DApplicationHelper::instance()->setPalette(m_nextButton, pa); - DApplicationHelper::instance()->setPalette(m_adaptImageBtn, pa); - DApplicationHelper::instance()->setPalette(m_adaptScreenBtn, pa); - DApplicationHelper::instance()->setPalette(m_clBT, pa); + DPaletteHelper::instance()->setPalette(m_backButton, pa); + DPaletteHelper::instance()->setPalette(m_preButton, pa); + DPaletteHelper::instance()->setPalette(m_nextButton, pa); + DPaletteHelper::instance()->setPalette(m_adaptImageBtn, pa); + DPaletteHelper::instance()->setPalette(m_adaptScreenBtn, pa); + DPaletteHelper::instance()->setPalette(m_clBT, pa); if (m_ocrIsExists) { - DApplicationHelper::instance()->setPalette(m_ocrBtn, pa); + DPaletteHelper::instance()->setPalette(m_ocrBtn, pa); } - DApplicationHelper::instance()->setPalette(m_rotateLBtn, pa); - DApplicationHelper::instance()->setPalette(m_rotateRBtn, pa); - DApplicationHelper::instance()->setPalette(m_trashBtn, pa); + DPaletteHelper::instance()->setPalette(m_rotateLBtn, pa); + DPaletteHelper::instance()->setPalette(m_rotateRBtn, pa); + DPaletteHelper::instance()->setPalette(m_trashBtn, pa); } } diff --git a/libimageviewer/viewpanel/contents/bottomtoolbar.h b/libimageviewer/viewpanel/contents/bottomtoolbar.h index 753e90e0..90d6a1af 100644 --- a/libimageviewer/viewpanel/contents/bottomtoolbar.h +++ b/libimageviewer/viewpanel/contents/bottomtoolbar.h @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -32,7 +31,6 @@ DWIDGET_USE_NAMESPACE class ElidedLabel; class QAbstractItemModel; -//class DImageButton; class ImageButton; class LibImgViewListView; class ImageItem; diff --git a/libimageviewer/viewpanel/contents/imageinfowidget.cpp b/libimageviewer/viewpanel/contents/imageinfowidget.cpp index 4c95cf72..0e69040f 100644 --- a/libimageviewer/viewpanel/contents/imageinfowidget.cpp +++ b/libimageviewer/viewpanel/contents/imageinfowidget.cpp @@ -10,7 +10,7 @@ #include "service/commonservice.h" #include "service/mtpfileproxy.h" -#include +#include #include #include #include @@ -113,7 +113,7 @@ class DFMDArrowLineExpand : public DArrowLineDrawer QRectF bgRect; bgRect.setSize(size()); const QPalette pal = QGuiApplication::palette(); // this->palette(); - QColor bgColor = pal.color(QPalette::Background); + QColor bgColor = pal.color(QPalette::Window); QPainterPath path; path.addRoundedRect(bgRect, 8, 8); @@ -168,7 +168,6 @@ LibImageInfoWidget::LibImageInfoWidget(const QString &darkStyle, const QString & m_mainLayout = new QVBoxLayout(this); m_mainLayout->setContentsMargins(0, 0, 0, 0); - m_mainLayout->setMargin(0); m_mainLayout->setSpacing(10); m_mainLayout->addWidget(m_exif_base); @@ -374,7 +373,7 @@ void LibImageInfoWidget::updateBaseInfo(const QMap &infos, boo //部分图片采用meta data的形式无法正确读取大小,此处改成使用已缓存的图片大小数据 if (i->key == "Dimension") { - value = QString().sprintf("%dx%d", info.imgOriginalWidth, info.imgOriginalHeight); + value = QString("%1x%2").arg(info.imgOriginalWidth).arg(info.imgOriginalHeight); } /*lmh0825真实格式,没有真格式采用后缀名*/ @@ -390,7 +389,7 @@ void LibImageInfoWidget::updateBaseInfo(const QMap &infos, boo SimpleFormField *field = new SimpleFormField; field->setAlignment(Qt::AlignLeft | Qt::AlignTop); DFontSizeManager::instance()->bind(field, DFontSizeManager::T8); - DPalette pa1 = DApplicationHelper::instance()->palette(field); + DPalette pa1 = DPaletteHelper::instance()->palette(field); pa1.setBrush(DPalette::WindowText, pa1.color(DPalette::TextTitle)); field->setPalette(pa1); @@ -415,7 +414,7 @@ void LibImageInfoWidget::updateBaseInfo(const QMap &infos, boo } title->setAlignment(Qt::AlignLeft | Qt::AlignTop); DFontSizeManager::instance()->bind(title, DFontSizeManager::T8); - DPalette pa2 = DApplicationHelper::instance()->palette(title); + DPalette pa2 = DPaletteHelper::instance()->palette(title); pa2.setBrush(DPalette::WindowText, pa2.color(DPalette::TextTitle)); title->setPalette(pa2); if (CNflag) { @@ -447,7 +446,7 @@ void LibImageInfoWidget::updateDetailsInfo(const QMap &infos, SimpleFormField *field = new SimpleFormField; field->setAlignment(Qt::AlignLeft | Qt::AlignTop); DFontSizeManager::instance()->bind(field, DFontSizeManager::T8); - DPalette pa1 = DApplicationHelper::instance()->palette(field); + DPalette pa1 = DPaletteHelper::instance()->palette(field); pa1.setBrush(DPalette::WindowText, pa1.color(DPalette::TextTitle)); field->setPalette(pa1); field->setText(SpliteText(value, field->font(), m_maxFieldWidth)); @@ -461,7 +460,7 @@ void LibImageInfoWidget::updateDetailsInfo(const QMap &infos, } title->setAlignment(Qt::AlignLeft | Qt::AlignTop); DFontSizeManager::instance()->bind(title, DFontSizeManager::T8); - DPalette pa2 = DApplicationHelper::instance()->palette(title); + DPalette pa2 = DPaletteHelper::instance()->palette(title); pa2.setBrush(DPalette::WindowText, pa2.color(DPalette::TextTitle)); title->setPalette(pa2); if (CNflag) { diff --git a/libimageviewer/viewpanel/contents/imgviewdelegate.cpp b/libimageviewer/viewpanel/contents/imgviewdelegate.cpp index daa4be70..f84c96bc 100644 --- a/libimageviewer/viewpanel/contents/imgviewdelegate.cpp +++ b/libimageviewer/viewpanel/contents/imgviewdelegate.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include "imgviewlistview.h" @@ -80,18 +81,13 @@ void LibImgViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op painter->restore(); return; } + _pixmap = data.image; -// _pixmap = ImageDataService::instance()->getThumnailImageByPath(data.path); if (_pixmap.isNull()) { -// _pixmap = data.damagedPixmap; _pixmap = m_damageImage; } -// bool selected = data.isSelected; -// if (/*(option.state & QStyle::State_MouseOver) &&*/ -// (option.state & QStyle::State_Selected) != 0) { -// selected = true; -// } - painter->setRenderHints(QPainter::HighQualityAntialiasing | + + painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::Antialiasing); QRect backgroundRect = option.rect; diff --git a/libimageviewer/viewpanel/contents/imgviewlistview.h b/libimageviewer/viewpanel/contents/imgviewlistview.h index 680fd1a0..58003104 100644 --- a/libimageviewer/viewpanel/contents/imgviewlistview.h +++ b/libimageviewer/viewpanel/contents/imgviewlistview.h @@ -23,7 +23,6 @@ #include #include #include -#include #include "image-viewer_global.h" diff --git a/libimageviewer/viewpanel/contents/imgviewwidget.cpp b/libimageviewer/viewpanel/contents/imgviewwidget.cpp index 7eed8a6a..1e00b522 100644 --- a/libimageviewer/viewpanel/contents/imgviewwidget.cpp +++ b/libimageviewer/viewpanel/contents/imgviewwidget.cpp @@ -20,9 +20,7 @@ #include #include -#include #include -#include #include #include "service/commonservice.h" diff --git a/libimageviewer/viewpanel/contents/imgviewwidget.h b/libimageviewer/viewpanel/contents/imgviewwidget.h index 356634b5..6acba81e 100644 --- a/libimageviewer/viewpanel/contents/imgviewwidget.h +++ b/libimageviewer/viewpanel/contents/imgviewwidget.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -30,7 +29,6 @@ DWIDGET_USE_NAMESPACE class ElidedLabel; class QAbstractItemModel; -//class DImageButton; class ImageButton; class MyImageListWidget; class ImageItem; diff --git a/libimageviewer/viewpanel/lockwidget.cpp b/libimageviewer/viewpanel/lockwidget.cpp index 8a3a691b..400c7544 100644 --- a/libimageviewer/viewpanel/lockwidget.cpp +++ b/libimageviewer/viewpanel/lockwidget.cpp @@ -190,9 +190,9 @@ LockWidget::~LockWidget() void LockWidget::wheelEvent(QWheelEvent *event) { if ((event->modifiers() == Qt::ControlModifier)) { - if (event->delta() > 0) { + if (event->angleDelta().y() > 0) { emit previousRequested(); - } else if (event->delta() < 0) { + } else if (event->angleDelta().y() < 0) { emit nextRequested(); } qDebug() << "control++"; diff --git a/libimageviewer/viewpanel/lockwidget.h b/libimageviewer/viewpanel/lockwidget.h index d55779b0..5a13fd56 100644 --- a/libimageviewer/viewpanel/lockwidget.h +++ b/libimageviewer/viewpanel/lockwidget.h @@ -46,7 +46,6 @@ private slots: void pinchTriggered(QPinchGesture *gesture); private: void onThemeChanged(DGuiApplicationHelper::ColorType theme); -// DLabel *m_thumbnailLabel{nullptr}; QPixmap m_logo; QString m_picString; bool m_theme; diff --git a/libimageviewer/viewpanel/navigationwidget.cpp b/libimageviewer/viewpanel/navigationwidget.cpp index ae6d92bc..54688e01 100644 --- a/libimageviewer/viewpanel/navigationwidget.cpp +++ b/libimageviewer/viewpanel/navigationwidget.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -40,7 +41,6 @@ NavigationWidget::NavigationWidget(QWidget *parent) { hide(); resize(150, 112); -// onThemeChanged(dApp->viewerTheme->getCurrentTheme()); ImageButton *closeBtn_light = new ImageButton(ICON_CLOSE_NORMAL_LIGHT, ICON_CLOSE_HOVER_LIGHT, ICON_CLOSE_PRESS_LIGHT, " ", this); closeBtn_light->setTooltipVisible(true); @@ -48,7 +48,7 @@ NavigationWidget::NavigationWidget(QWidget *parent) closeBtn_light->move(QPoint(this->x() + this->width() - 27 - 10, rect().topRight().y() + 4 - 3)); DPalette palette1 ; - palette1.setColor(DPalette::Background, QColor(0, 0, 0, 1)); + palette1.setColor(DPalette::Window, QColor(0, 0, 0, 1)); closeBtn_light->setPalette(palette1); closeBtn_light->hide(); connect(closeBtn_light, &ImageButton::clicked, [this]() { @@ -61,7 +61,7 @@ NavigationWidget::NavigationWidget(QWidget *parent) closeBtn_dark->move(QPoint(this->x() + this->width() - 27 - 10, rect().topRight().y() + 4 - 3)); DPalette palette2 ; - palette2.setColor(DPalette::Background, QColor(0, 0, 0, 1)); + palette2.setColor(DPalette::Window, QColor(0, 0, 0, 1)); closeBtn_dark->setPalette(palette2); closeBtn_dark->hide(); connect(closeBtn_dark, &ImageButton::clicked, [this]() { diff --git a/libimageviewer/viewpanel/scen/imagegraphicsview.cpp b/libimageviewer/viewpanel/scen/imagegraphicsview.cpp index bb40cd6a..bf11b787 100644 --- a/libimageviewer/viewpanel/scen/imagegraphicsview.cpp +++ b/libimageviewer/viewpanel/scen/imagegraphicsview.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include #include @@ -23,9 +22,15 @@ #include #include #include -#include #include #include +#include +#include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#include +#endif + +#include #include #include "graphicsitem.h" @@ -40,14 +45,8 @@ #include "service/aimodelservice.h" #include "service/permissionconfig.h" -#include -#include -#include -#include -#ifndef QT_NO_OPENGL -//#include -#endif + #include #include "service/commonservice.h" @@ -79,7 +78,6 @@ QVariantList cachePixmap(const QString &path) QPixmap p = QPixmap::fromImage(tImg); 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文件做下载本地处理 @@ -172,40 +170,40 @@ LibImageGraphicsView::LibImageGraphicsView(QWidget *parent) }, Qt::QueuedConnection); //让默认的快捷键失效,默认会滑动窗口 - connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up), this), &QShortcut::activated, this, &LibImageGraphicsView::slotsUp); - connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Down), this), &QShortcut::activated, this, &LibImageGraphicsView::slotsDown); - new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Left), this); - new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Right), this); - - new QShortcut(QKeySequence(Qt::ALT + Qt::Key_Left), this); - new QShortcut(QKeySequence(Qt::ALT + Qt::Key_Right), this); - new QShortcut(QKeySequence(Qt::ALT + Qt::Key_Up), this); - new QShortcut(QKeySequence(Qt::ALT + Qt::Key_Down), this); - - new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Left), this); - new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Right), this); - new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Up), this); - new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Down), this); - - new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Left), this); - new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Right), this); - new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Up), this); - new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Down), this); - - new QShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + Qt::Key_Left), this); - new QShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + Qt::Key_Right), this); - new QShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + Qt::Key_Up), this); - new QShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + Qt::Key_Down), this); - - new QShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Left), this); - new QShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Right), this); - new QShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Up), this); - new QShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Down), this); - - new QShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_Left), this); - new QShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_Right), this); - new QShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_Up), this); - new QShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_Down), this); + connect(new QShortcut(QKeySequence(Qt::CTRL, Qt::Key_Up), this), &QShortcut::activated, this, &LibImageGraphicsView::slotsUp); + connect(new QShortcut(QKeySequence(Qt::CTRL, Qt::Key_Down), this), &QShortcut::activated, this, &LibImageGraphicsView::slotsDown); + new QShortcut(QKeySequence(Qt::CTRL, Qt::Key_Left), this); + new QShortcut(QKeySequence(Qt::CTRL, Qt::Key_Right), this); + + new QShortcut(QKeySequence(Qt::ALT, Qt::Key_Left), this); + new QShortcut(QKeySequence(Qt::ALT, Qt::Key_Right), this); + new QShortcut(QKeySequence(Qt::ALT, Qt::Key_Up), this); + new QShortcut(QKeySequence(Qt::ALT, Qt::Key_Down), this); + + new QShortcut(QKeySequence(Qt::SHIFT, Qt::Key_Left), this); + new QShortcut(QKeySequence(Qt::SHIFT, Qt::Key_Right), this); + new QShortcut(QKeySequence(Qt::SHIFT, Qt::Key_Up), this); + new QShortcut(QKeySequence(Qt::SHIFT, Qt::Key_Down), this); + + new QShortcut(QKeySequence(Qt::CTRL, Qt::SHIFT, Qt::Key_Left), this); + new QShortcut(QKeySequence(Qt::CTRL, Qt::SHIFT, Qt::Key_Right), this); + new QShortcut(QKeySequence(Qt::CTRL, Qt::SHIFT, Qt::Key_Up), this); + new QShortcut(QKeySequence(Qt::CTRL, Qt::SHIFT, Qt::Key_Down), this); + + new QShortcut(QKeySequence(Qt::ALT, Qt::SHIFT, Qt::Key_Left), this); + new QShortcut(QKeySequence(Qt::ALT, Qt::SHIFT, Qt::Key_Right), this); + new QShortcut(QKeySequence(Qt::ALT, Qt::SHIFT, Qt::Key_Up), this); + new QShortcut(QKeySequence(Qt::ALT, Qt::SHIFT, Qt::Key_Down), this); + + new QShortcut(QKeySequence(Qt::CTRL, Qt::ALT, Qt::Key_Left), this); + new QShortcut(QKeySequence(Qt::CTRL, Qt::ALT, Qt::Key_Right), this); + new QShortcut(QKeySequence(Qt::CTRL, Qt::ALT, Qt::Key_Up), this); + new QShortcut(QKeySequence(Qt::CTRL, Qt::ALT, Qt::Key_Down), this); + + new QShortcut(QKeySequence(Qt::CTRL, Qt::ALT, Qt::SHIFT, Qt::Key_Left), this); + new QShortcut(QKeySequence(Qt::CTRL, Qt::ALT, Qt::SHIFT, Qt::Key_Right), this); + new QShortcut(QKeySequence(Qt::CTRL, Qt::ALT, Qt::SHIFT, Qt::Key_Up), this); + new QShortcut(QKeySequence(Qt::CTRL, Qt::ALT, Qt::SHIFT, Qt::Key_Down), this); } int LibImageGraphicsView::getcurrentImgCount() @@ -1557,7 +1555,7 @@ void LibImageGraphicsView::addLoadSpinner(bool enhanceImage) m_spinnerCtx = new QWidget(this); m_spinnerCtx->setFixedSize(SPINNER_SIZE); QVBoxLayout *hLayout = new QVBoxLayout; - hLayout->setMargin(0); + hLayout->setContentsMargins(0, 0, 0, 0); hLayout->setSpacing(0); hLayout->addWidget(m_spinner, 0, Qt::AlignCenter); @@ -1613,9 +1611,9 @@ void LibImageGraphicsView::wheelEvent(QWheelEvent *event) } if ((event->modifiers() == Qt::ControlModifier)) { - if (event->delta() > 0) { + if (event->angleDelta().y() > 0) { emit previousRequested(); - } else if (event->delta() < 0) { + } else if (event->angleDelta().y() < 0) { emit nextRequested(); } @@ -1625,127 +1623,11 @@ void LibImageGraphicsView::wheelEvent(QWheelEvent *event) event->accept(); } else { - qreal factor = qPow(1.2, event->delta() / 240.0); + qreal factor = qPow(1.2, event->angleDelta().y() / 240.0); qDebug() << factor; - scaleAtPoint(event->pos(), factor); + scaleAtPoint(event->position().toPoint(), factor); event->accept(); } } -// qDebug() << "---" << __FUNCTION__ << "---" << this->sceneRect(); } - -//CFileWatcher::CFileWatcher(QObject *parent): QThread(parent) -//{ -// _handleId = inotify_init(); -//} - -//CFileWatcher::~CFileWatcher() -//{ -// clear(); -//} - -//bool CFileWatcher::isVaild() -//{ -// return (_handleId != -1); -//} - -//void CFileWatcher::addWather(const QString &path) -//{ -// QMutexLocker loker(&_mutex); -// if (!isVaild()) -// return; -// QFileInfo info(path); -// if (!info.exists() || !info.isFile()) { -// return; -// } -// if (watchedFiles.find(path) != watchedFiles.end()) { -// return; -// } -// std::string sfile = path.toStdString(); -// int fileId = inotify_add_watch(_handleId, sfile.c_str(), IN_MODIFY | IN_DELETE_SELF | IN_MOVE_SELF); -// watchedFiles.insert(path, fileId); -// watchedFilesId.insert(fileId, path); -// if (!_running) { -// _running = true; -// start(); -// } -//} - -//void CFileWatcher::removePath(const QString &path) -//{ -// QMutexLocker loker(&_mutex); -// if (!isVaild()) -// return; -// auto itf = watchedFiles.find(path); -// if (itf != watchedFiles.end()) { -// inotify_rm_watch(_handleId, itf.value()); -// watchedFilesId.remove(itf.value()); -// watchedFiles.erase(itf); -// } -//} - -//void CFileWatcher::clear() -//{ -// QMutexLocker loker(&_mutex); -// for (auto it : watchedFiles) { -// inotify_rm_watch(_handleId, it); -// } -// watchedFilesId.clear(); -// watchedFiles.clear(); -//} - -//void CFileWatcher::run() -//{ -// doRun(); -//} - -//void CFileWatcher::doRun() -//{ -// if (!isVaild()) -// return; - -// char name[1024]; -// auto freadsome = [ = ](void *dest, size_t remain, FILE * file) { -// char *offset = reinterpret_cast(dest); -// while (remain) { -// if (file == nullptr) -// return -1; -// size_t n = fread(offset, 1, remain, file); -// if (n == 0) { -// return -1; -// } - -// remain -= n; -// offset += n; -// } -// return 0; -// }; - -// FILE *watcher_file = fdopen(_handleId, "r"); - -// while (true) { -// inotify_event event; -// if (-1 == freadsome(&event, sizeof(event), watcher_file)) { -// qWarning() << "------------- freadsome error !!!!!---------- "; -// break; -// } -// if (event.len) { -// freadsome(name, event.len, watcher_file); -// } else { -// QMutexLocker loker(&_mutex); -// auto itf = watchedFilesId.find(event.wd); -// if (itf != watchedFilesId.end()) { -// //qDebug() << "file = " << itf.value() << " event.wd = " << event.wd << "event.mask = " << event.mask; - -// if (event.mask & IN_MODIFY) { -// emit fileChanged(itf.value(), EFileModified); -// } else if (event.mask & IN_MOVE_SELF) { -// emit fileChanged(itf.value(), EFileMoved); -// } else if (event.mask & IN_DELETE_SELF) { -// emit fileChanged(itf.value(), EFileMoved); -// } -// } -// } -// } -//} diff --git a/libimageviewer/viewpanel/scen/imagegraphicsview.h b/libimageviewer/viewpanel/scen/imagegraphicsview.h index 4ca89003..4cb8983a 100644 --- a/libimageviewer/viewpanel/scen/imagegraphicsview.h +++ b/libimageviewer/viewpanel/scen/imagegraphicsview.h @@ -139,8 +139,6 @@ class LibImageGraphicsView : public QGraphicsView void sigClicked(); public slots: -// void setHighQualityAntialiasing(bool highQualityAntialiasing); - //保存旋转图片 void slotSavePic(); diff --git a/libimageviewer/viewpanel/thumbnailwidget.cpp b/libimageviewer/viewpanel/thumbnailwidget.cpp index 7df3e966..af060f68 100644 --- a/libimageviewer/viewpanel/thumbnailwidget.cpp +++ b/libimageviewer/viewpanel/thumbnailwidget.cpp @@ -193,7 +193,7 @@ void ThumbnailWidget::paintEvent(QPaintEvent *event) Q_UNUSED(event); if (m_defaultImage.isNull() && !m_isDefaultThumbnail) { QPainter painter(this); - painter.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform); + painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); QIcon m_icon(m_defaultImage); m_icon.paint(&painter, QRect(1, 1, 1, 1)); return; @@ -214,9 +214,7 @@ void ThumbnailWidget::paintEvent(QPaintEvent *event) QRect imgRect = QRect(imgStartPoint.x(), imgStartPoint.y(), 128, 128); QPainter painter(this); - painter.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform); - // painter.drawPixmap(imgRect, m_defaultImage); - // QIcon m_icon(m_picString); + painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); QIcon m_icon(m_defaultImage); m_icon.paint(&painter, imgRect); } @@ -295,9 +293,9 @@ ThumbnailWidget::~ThumbnailWidget() {} void ThumbnailWidget::wheelEvent(QWheelEvent *event) { if ((event->modifiers() == Qt::ControlModifier)) { - if (event->delta() > 0) { + if (event->angleDelta().y() > 0) { emit previousRequested(); - } else if (event->delta() < 0) { + } else if (event->angleDelta().y() < 0) { emit nextRequested(); } qDebug() << "control++"; diff --git a/libimageviewer/viewpanel/viewpanel.cpp b/libimageviewer/viewpanel/viewpanel.cpp index 1572c8d0..94f4291e 100644 --- a/libimageviewer/viewpanel/viewpanel.cpp +++ b/libimageviewer/viewpanel/viewpanel.cpp @@ -12,11 +12,12 @@ #include #include #include -#include + #include #include #include #include + #include "contents/bottomtoolbar.h" #include "navigationwidget.h" #include "lockwidget.h" diff --git a/libimageviewer/widgets/extensionpanel.cpp b/libimageviewer/widgets/extensionpanel.cpp index 1bb194eb..98117ddd 100755 --- a/libimageviewer/widgets/extensionpanel.cpp +++ b/libimageviewer/widgets/extensionpanel.cpp @@ -163,7 +163,7 @@ void ExtensionPanel::init() m_scrollArea = new QScrollArea; m_scrollArea->setMinimumHeight(40); QPalette palette = m_scrollArea->viewport()->palette(); - palette.setBrush(QPalette::Background, Qt::NoBrush); + palette.setBrush(QPalette::Window, Qt::NoBrush); m_scrollArea->viewport()->setPalette(palette); m_scrollArea->setFrameShape(QFrame::Shape::NoFrame); diff --git a/libimageviewer/widgets/imagebutton.cpp b/libimageviewer/widgets/imagebutton.cpp index d42fa421..d5ab944d 100755 --- a/libimageviewer/widgets/imagebutton.cpp +++ b/libimageviewer/widgets/imagebutton.cpp @@ -3,48 +3,56 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "imagebutton.h" -//#include "application.h" + #include -#include -#include +#include +#include #include #include #include #include #include +#include + +#include +#include DWIDGET_USE_NAMESPACE typedef DFrame QFrToDFrame; +typedef DLabel QLbtoDLabel; + +// comaptible alias +#if DTK_VERSION >= DTK_VERSION_CHECK(6, 0, 0, 0) +using DImageButton = DToolButton; +#endif ImageButton::ImageButton(QWidget *parent) - : DImageButton(parent), m_tooltipVisiable(false) +#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0) + : DImageButton(parent) +#else + : DToolButton(parent) +#endif + , m_tooltipVisiable(false) { -// onThemeChanged(dApp->viewerTheme->getCurrentTheme()); -// connect(dApp->viewerTheme, &ViewerThemeManager::viewerThemeChanged, this, -// &ImageButton::onThemeChanged); } -ImageButton::ImageButton(const QString &normalPic, const QString &hoverPic, - const QString &pressPic, const QString &disablePic, - QWidget *parent) +ImageButton::ImageButton( + const QString &normalPic, const QString &hoverPic, const QString &pressPic, const QString &disablePic, QWidget *parent) +#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0) : DImageButton(normalPic, hoverPic, pressPic, parent) +#else + : DToolButton(parent) +#endif , m_tooltipVisiable(false) , m_disablePic_(disablePic) { -// onThemeChanged(dApp->viewerTheme->getCurrentTheme()); -// connect(dApp->viewerTheme, &ViewerThemeManager::viewerThemeChanged, this, -// &ImageButton::onThemeChanged); +#if DTK_VERSION >= DTK_VERSION_CHECK(6, 0, 0, 0) + setIcon(QIcon(normalPic)); +#endif } - void ImageButton::setDisabled(bool d) { -// if (d) { -// setNormalPic(m_disablePic_); -// } -// else { -// setNormalPic(this->getNormalPic()); -// } DImageButton::setDisabled(d); } @@ -56,29 +64,26 @@ bool ImageButton::event(QEvent *e) return false; } - } else if (e->type() == QEvent::Leave) { + } else if (e->type() == QEvent::Leave) { emit mouseLeave(); DImageButton::leaveEvent(e); } else if (e->type() == QEvent::MouseButtonPress) { emit mouseLeave(); - } return DImageButton::event(e); } -//void ImageButton::onThemeChanged(ViewerThemeManager::AppTheme theme) -//{ -// Q_UNUSED(theme); -//} - void ImageButton::setTooltipVisible(bool visible) { m_tooltipVisiable = visible; } - +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void ImageButton::enterEvent(QEvent *e) +#else +void ImageButton::enterEvent(QEnterEvent *e) +#endif { if (isEnabled()) { DImageButton::enterEvent(e); @@ -94,7 +99,7 @@ void ImageButton::showTooltip(const QPoint &gPos) } QFrToDFrame *tf = new QFrToDFrame(); -// tf->setStyleSheet(this->styleSheet()); + tf->setWindowFlags(Qt::ToolTip); tf->setAttribute(Qt::WA_TranslucentBackground); QLbtoDLabel *tl = new QLbtoDLabel(tf); @@ -105,7 +110,7 @@ void ImageButton::showTooltip(const QPoint &gPos) layout->addWidget(tl); tf->show(); - QRect dr = qApp->desktop()->geometry(); + QRect dr = qApp->primaryScreen()->geometry(); int y = gPos.y() + tf->height(); if (y > dr.y() + dr.height()) { y = gPos.y() - tf->height() - 10; @@ -114,9 +119,7 @@ void ImageButton::showTooltip(const QPoint &gPos) QTimer::singleShot(5000, tf, SLOT(deleteLater())); - connect(tf, &QFrToDFrame::destroyed, this, [ = ] { - m_tooltipVisiable = false; - }); + connect(tf, &QFrToDFrame::destroyed, this, [=] { m_tooltipVisiable = false; }); connect(this, &ImageButton::mouseLeave, tf, &QFrToDFrame::deleteLater); } diff --git a/libimageviewer/widgets/imagebutton.h b/libimageviewer/widgets/imagebutton.h index 7ec49673..fef837a5 100755 --- a/libimageviewer/widgets/imagebutton.h +++ b/libimageviewer/widgets/imagebutton.h @@ -5,22 +5,33 @@ #ifndef IMAGEBUTTON_H #define IMAGEBUTTON_H -#include +#include -//#include "controller/viewerthememanager.h" +#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0) #include +#else +#include +#endif + #include -using namespace Dtk::Widget; -typedef DLabel QLbtoDLabel; +class QEvent; +class QEnterEvent; +DWIDGET_USE_NAMESPACE +#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0) class ImageButton : public DImageButton +#else +class ImageButton : public DToolButton +#endif { Q_OBJECT public: explicit ImageButton(QWidget *parent = nullptr); - explicit ImageButton(const QString &normalPic, const QString &hoverPic, - const QString &pressPic, const QString &disablePic, + explicit ImageButton(const QString &normalPic, + const QString &hoverPic, + const QString &pressPic, + const QString &disablePic, QWidget *parent = nullptr); void setDisabled(bool d); @@ -28,19 +39,23 @@ class ImageButton : public DImageButton void setTooltipVisible(bool visible); inline const QString getDisablePic() const { return m_disablePic_; } -signals: - void mouseLeave(); + + Q_SIGNAL void mouseLeave(); protected: +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void enterEvent(QEvent *e) Q_DECL_OVERRIDE; +#else + void enterEvent(QEnterEvent *e) Q_DECL_OVERRIDE; +#endif + bool event(QEvent *e) Q_DECL_OVERRIDE; private: void showTooltip(const QPoint &gPos); -// void onThemeChanged(ViewerThemeManager::AppTheme theme); -private: + bool m_tooltipVisiable; QString m_disablePic_; }; -#endif // IMAGEBUTTON_H +#endif // IMAGEBUTTON_H diff --git a/libimageviewer/widgets/printhelper.cpp b/libimageviewer/widgets/printhelper.cpp index 49f92d7a..81dd7cf6 100755 --- a/libimageviewer/widgets/printhelper.cpp +++ b/libimageviewer/widgets/printhelper.cpp @@ -163,7 +163,7 @@ void RequestedSlot::paintRequestSync(DPrinter *_printer) if (!img.isNull()) { painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::SmoothPixmapTransform); - QRect wRect = _printer->pageRect(); + QRect wRect = _printer->pageRect(QPrinter::DevicePixel).toRect(); // 修复bug98129,打印不完全问题,ratio应该是适应宽或者高,不应该直接适应宽 qreal ratio = 0.0; qDebug() << wRect; diff --git a/libimageviewer/widgets/renamedialog.cpp b/libimageviewer/widgets/renamedialog.cpp index 6f1e9c64..3d07b3d7 100644 --- a/libimageviewer/widgets/renamedialog.cpp +++ b/libimageviewer/widgets/renamedialog.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include DWIDGET_USE_NAMESPACE @@ -75,10 +75,10 @@ RenameDialog::RenameDialog(const QString &filename, QWidget *parent) m_lineedt->lineEdit()->setFocus(); int Dirlen = /*m_DirPath.size() +*/ 1 + m_labformat->text().size(); // 正则表达式排除文管不支持的字符 - // 屏蔽特殊字符 QRegExp rx("[^\\\\//:*?\"<>|]*"); - QRegExp rx("^[^\\.\\\\/\':\\*\\?\"<>|%&][^\\\\/\':\\*\\?\"<>|%&]*"); + // 屏蔽特殊字符 QRegularExpression rx("[^\\\\//:*?\"<>|]*"); + QRegularExpression rx("^[^\\.\\\\/\':\\*\\?\"<>|%&][^\\\\/\':\\*\\?\"<>|%&]*"); - QRegExpValidator *pReg = new QRegExpValidator(rx, this); + QRegularExpressionValidator *pReg = new QRegularExpressionValidator(rx, this); m_lineedt->lineEdit()->setValidator(pReg); connect(okbtn, &DSuggestButton::clicked, this, [=] { m_filename = m_lineedt->text() + m_labformat->text(); @@ -97,7 +97,7 @@ RenameDialog::RenameDialog(const QString &filename, QWidget *parent) if (arg.isEmpty()) { return; } - if (arg.at(0) == " ") { + if (arg.at(0) == QChar(' ')) { QString str = arg; str = str.right(str.size() - 1); @@ -110,7 +110,7 @@ RenameDialog::RenameDialog(const QString &filename, QWidget *parent) int num = 0; int i = 0; for (; i < arg.size(); i++) { - if (arg.at(i) >= 0x4e00 && arg.at(i) <= 0x9fa5) { + if (arg.at(i) >= QChar(0x4e00) && arg.at(i) <= QChar(0x9fa5)) { num += 3; if (num >= 256 - Dirlen - 1) break; diff --git a/libimageviewer/widgets/themewidget.h b/libimageviewer/widgets/themewidget.h index 92ab4d8b..0b038d6f 100755 --- a/libimageviewer/widgets/themewidget.h +++ b/libimageviewer/widgets/themewidget.h @@ -11,9 +11,10 @@ #include #include -#include +#include + +DGUI_USE_NAMESPACE -DWIDGET_USE_NAMESPACE class ThemeWidget : public QWidget { Q_OBJECT @@ -24,28 +25,11 @@ class ThemeWidget : public QWidget public slots: void onThemeChanged(DGuiApplicationHelper::ColorType theme); -// bool isDeepMode(); + private: QString m_darkStyle; QString m_lightStyle; bool m_deepMode = false; }; -//TODO: if a widget Multiple Inheritance from ThemeWidget and -// QScrollArea. warning(QWidget is an ambiguous base). -//class ThemeScrollArea : public QScrollArea { -// Q_OBJECT -//public: -// ThemeScrollArea(const QString &darkFile, const QString &lightFile, -// QWidget* parent = 0); -// ~ThemeScrollArea(); - -//public slots: -// void onThemeChanged(ViewerThemeManager::AppTheme theme); -// bool isDeepMode(); -//private: -// QString m_darkStyle; -// QString m_lightStyle; -// bool m_deepMode = false; -//}; #endif // THEMEWIDGET_H diff --git a/libimageviewer/widgets/toast.cpp b/libimageviewer/widgets/toast.cpp deleted file mode 100755 index 4d7aecd5..00000000 --- a/libimageviewer/widgets/toast.cpp +++ /dev/null @@ -1,133 +0,0 @@ -// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#include "toast.h" - - - -#include -#include -#include -#include -#include -#include -#include "imagebutton.h" -#include -#include "dthememanager.h" -#include "dgraphicsgloweffect.h" -#include "dhidpihelper.h" -#include "accessibility/ac-desktop-define.h" -DWIDGET_BEGIN_NAMESPACE - - - -Toast::Toast(QWidget *parent) : - QFrame(parent), DObject(*new ToastPrivate(this)) -{ - D_D(Toast); - setObjectName(TOAST_OBJECT); - DThemeManager::registerWidget(this); - - d->initUI(); -} - -Toast::~Toast() -{ - -} - -QString Toast::text() const -{ - D_DC(Toast); - return d->textLabel->text(); -} - -QIcon Toast::icon() const -{ - D_DC(Toast); - return d->icon; -} - -qreal Toast::opacity() const -{ - D_DC(Toast); - return d->effect->opacity(); -} - -void Toast::setText(QString text) -{ - D_D(Toast); - d->textLabel->setVisible(true); - d->textLabel->setText(text); -} - -void Toast::setIcon(QString iconfile) -{ - D_D(Toast); - d->icon = QIcon(iconfile); - d->iconLabel->setVisible(true); - d->iconLabel->setPixmap(DHiDPIHelper::loadNxPixmap(iconfile)); -} - -void Toast::setIcon(QIcon icon, QSize defaultSize) -{ - D_D(Toast); - d->icon = icon; - d->iconLabel->setVisible(true); - d->iconLabel->setPixmap(d->icon.pixmap(icon.actualSize(defaultSize))); -} - -void Toast::setOpacity(qreal opacity) -{ - D_D(Toast); - d->effect->setOpacity(opacity); - update(); -} - - -ToastPrivate::ToastPrivate(Toast *qq) - : DObjectPrivate(qq) -{ - -} - -void ToastPrivate::initUI() -{ - D_Q(Toast); - q->setWindowFlags(q->windowFlags() | Qt::WindowStaysOnTopHint); - - auto layout = new QHBoxLayout(q); - layout->setContentsMargins(10, 10, 10, 10); - layout->setSpacing(12); - - iconLabel = new QLabel; - iconLabel->setVisible(false); - textLabel = new QLabel; - textLabel->setVisible(false); - //由于qrc路径变更,代码中使用也得变更 - closeBt = new ImageButton(":/common/images/input_clear_normal.svg", - ":/common/images/input_clear_hover.svg", - ":/common/images/input_clear_press.svg", - ":/common/images/input_clear_normal.svg"); - - q->connect(closeBt, &ImageButton::clicked, q, [ = ]() { - q->hide(); - q->setProperty("hide_by_user", true); - }); - - layout->addWidget(iconLabel); - layout->addWidget(textLabel); - layout->addStretch(); - layout->addWidget(closeBt); - - effect = new DGraphicsGlowEffect(q); - effect->setBlurRadius(20.0); - effect->setColor(QColor(0, 0, 0, 255 / 10)); - effect->setOffset(0, 0); - q->setGraphicsEffect(effect); - q->hide(); -} - - -DWIDGET_END_NAMESPACE diff --git a/libimageviewer/widgets/toast.h b/libimageviewer/widgets/toast.h deleted file mode 100755 index 95c38c60..00000000 --- a/libimageviewer/widgets/toast.h +++ /dev/null @@ -1,72 +0,0 @@ -// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#pragma once - -#include -#include -#include - -#include "dtkwidget_global.h" -#include -#include - -#include -#include -#include "imagebutton.h" -#include -#include "dthememanager.h" -#include "dgraphicsgloweffect.h" -#include - -DWIDGET_BEGIN_NAMESPACE - -class ToastPrivate; -class LIBDTKWIDGETSHARED_EXPORT Toast : public QFrame, public DTK_CORE_NAMESPACE::DObject -{ - Q_OBJECT - - Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) -public: - explicit Toast(QWidget *parent = Q_NULLPTR); - ~Toast(); - - QString text() const; - QIcon icon() const; - -public Q_SLOTS: -// void pop(); -// void pack(); - - void setText(QString text); - void setIcon(QString icon); - void setIcon(QIcon icon, QSize defaultSize = QSize(20, 20)); - -private: - qreal opacity() const; - void setOpacity(qreal); - - D_DECLARE_PRIVATE(Toast) -}; -class ToastPrivate: public DTK_CORE_NAMESPACE::DObjectPrivate - -{ -public: - explicit ToastPrivate(Toast *qq); - - QIcon icon; - QLabel *iconLabel = Q_NULLPTR; - QLabel *textLabel = Q_NULLPTR; - - ImageButton *closeBt = Q_NULLPTR; - - QPropertyAnimation *animation = Q_NULLPTR; - DGraphicsGlowEffect *effect = Q_NULLPTR; - - void initUI(); -private: - D_DECLARE_PUBLIC(Toast) -}; - -DWIDGET_END_NAMESPACE diff --git a/libimageviewer/widgets/toptoolbar.cpp b/libimageviewer/widgets/toptoolbar.cpp index 974c5bc6..be43aa85 100644 --- a/libimageviewer/widgets/toptoolbar.cpp +++ b/libimageviewer/widgets/toptoolbar.cpp @@ -23,7 +23,7 @@ #include #include #include -#include + DWIDGET_USE_NAMESPACE namespace { @@ -61,7 +61,7 @@ LibTopToolbar::LibTopToolbar(bool manager, QWidget *parent) { m_manager = manager; QPalette palette; - palette.setColor(QPalette::Background, QColor(0, 0, 0, 0)); // 最后一项为透明度 + palette.setColor(QPalette::Window, QColor(0, 0, 0, 0)); // 最后一项为透明度 setPalette(palette); initMenu(); initWidgets(); diff --git a/libimageviewer/widgets/toptoolbar.h b/libimageviewer/widgets/toptoolbar.h index 711bbdae..cb756878 100644 --- a/libimageviewer/widgets/toptoolbar.h +++ b/libimageviewer/widgets/toptoolbar.h @@ -13,7 +13,6 @@ #include #include #include -#include #include #include diff --git a/libimagevisualresult/CMakeLists.txt b/libimagevisualresult/CMakeLists.txt index 53568c4c..9a8ec641 100644 --- a/libimagevisualresult/CMakeLists.txt +++ b/libimagevisualresult/CMakeLists.txt @@ -1,92 +1,7 @@ -#定义需要的cmake版本 -cmake_minimum_required(VERSION 3.10) - -# 设置工程名称 -project(libimagevisualresult VERSION 0.1.0) - -set(TARGET_NAME imagevisualresult) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_EXPORT_COMPILE_COMMANDS on) - -set(CMAKE_C_FLAGS "-fPIC") -set(CMAKE_CXX_FLAGS "-fPIC") - -find_package(PkgConfig REQUIRED) -# OpenCV 并未使用,暂时屏蔽 -# find_package(OpenCV REQUIRED) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -include_directories(${PROJECT_BINARY_DIR}) -include_directories(${PROJECT_SOURCE_DIR}) - -#文件夹包含 -set(SRCS - src/lut.cpp - src/lut.h - src/utils.cpp - src/utils.h - src/visualresult.cpp - src/visualresult.h - src/main.c) - -file (GLOB_RECURSE OUT_HEADERS ${CMAKE_CURRENT_LIST_DIR}/src/visualresult.h) - -#-------------添加第三方库begins-----------------------# -set(INC_DIR /usr/include/) -set(LINK_DIR /usr/lib/) - -include_directories(${INC_DIR}) -link_directories(${LINK_DIR}) - -add_executable(${PROJECT_NAME} ${SRCS}) - -# 设置不删除生成的文件夹内容文件 -set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1) - -# link_directories(${OpenCV_LIBRARY_DIRS}) -# target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS}) - -# 设置不删除生成的文件夹内容文件 -set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1) - -#编译为库 -add_library(${TARGET_NAME} SHARED ${SRCS} ${allHeaders} ${allSource}) - -#将库安装到指定位置 -set(PREFIX /usr) -set(${TARGET_NAME} ${CMAKE_INSTALL_LIBDIR}) - -set_target_properties(${TARGET_NAME} PROPERTIES VERSION 0.1.0 SOVERSION 0.1) - -include(GNUInstallDirs) -configure_file(libimagevisualresult.pc.in ${PROJECT_BINARY_DIR}/libimagevisualresult.pc @ONLY) - -install(TARGETS ${TARGET_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -install(FILES ${OUT_HEADERS} DESTINATION include/libimagevisualresult) - -install(FILES ${PROJECT_BINARY_DIR}/libimagevisualresult.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +if(SUPPORT_QT6) + include(libimagevisualresult-qt6.cmake) +endif() -# CUBE 颜色表文件 安装到usr/share下, 方便其他应用访问 -install(DIRECTORY ${PROJECT_SOURCE_DIR}/filter_cube - DESTINATION ${PREFIX}/share/libimagevisualresult - FILES_MATCHING PATTERN "*.CUBE") -install(DIRECTORY ${PROJECT_SOURCE_DIR}/filter_cube - DESTINATION ${PREFIX}/share/libimagevisualresult - FILES_MATCHING PATTERN "*.dat") +include(libimagevisualresult-qt5.cmake) -# 加速编译优化参数 -if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "mips64") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wl,-O1 -Wl,--as-needed -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi -z noexecstack") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wl,-O1 -Wl,--as-needed -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi -z noexecstack") - SET(CMAKE_EXE_LINKER_FLAGS "-pie") -else() - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wl,-O1 -Wl,--as-needed -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wl,-O1 -Wl,--as-needed -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections") - SET(CMAKE_EXE_LINKER_FLAGS "-pie") -endif() diff --git a/libimagevisualresult/libimagevisualresult-qt5.cmake b/libimagevisualresult/libimagevisualresult-qt5.cmake new file mode 100644 index 00000000..9bd93526 --- /dev/null +++ b/libimagevisualresult/libimagevisualresult-qt5.cmake @@ -0,0 +1,5 @@ +set(QT_VERSION_MAJOR 5) +unset(DTK_VERSION_MAJOR) +unset(IMGE_VERSION_MAJOR) + +include(libimagevisualresult.cmake) diff --git a/libimagevisualresult/libimagevisualresult-qt6.cmake b/libimagevisualresult/libimagevisualresult-qt6.cmake new file mode 100644 index 00000000..fd5c9de8 --- /dev/null +++ b/libimagevisualresult/libimagevisualresult-qt6.cmake @@ -0,0 +1,5 @@ +set(QT_VERSION_MAJOR 6) +set(DTK_VERSION_MAJOR 6) +set(IMGE_VERSION_MAJOR 6) + +include(libimagevisualresult.cmake) diff --git a/libimagevisualresult/libimagevisualresult.cmake b/libimagevisualresult/libimagevisualresult.cmake new file mode 100644 index 00000000..5283200f --- /dev/null +++ b/libimagevisualresult/libimagevisualresult.cmake @@ -0,0 +1,73 @@ +# 定义需要的cmake版本 +cmake_minimum_required(VERSION 3.10) + +# Set the project name, imagevisualresult6 if Qt6, otherwise imagevisualresult +project(libimagevisualresult${IMGE_VERSION_MAJOR} VERSION 0.1.0) +set(TARGET_NAME imagevisualresult${IMGE_VERSION_MAJOR}) +message("\n\n>>> Project: ${PROJECT_NAME}") + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS on) +set(CMAKE_C_FLAGS "-fPIC") +set(CMAKE_CXX_FLAGS "-fPIC") +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +include_directories(${PROJECT_BINARY_DIR}) +include_directories(${PROJECT_SOURCE_DIR}) + +# 文件夹包含 +set(SRCS + src/lut.cpp + src/lut.h + src/utils.cpp + src/utils.h + src/visualresult.cpp + src/visualresult.h + src/main.c) +file(GLOB_RECURSE OUT_HEADERS ${CMAKE_CURRENT_LIST_DIR}/src/visualresult.h) + +# -------------添加第三方库begins-----------------------# +set(INC_DIR /usr/include/) +set(LINK_DIR /usr/lib/) + +include_directories(${INC_DIR}) +link_directories(${LINK_DIR}) + +add_executable(${PROJECT_NAME} ${SRCS}) + +# 设置不删除生成的文件夹内容文件 +set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1) + +# 编译为库 +add_library(${TARGET_NAME} SHARED ${SRCS} ${allHeaders} ${allSource}) + +# 将库安装到指定位置 +include(GNUInstallDirs) +set_target_properties(${TARGET_NAME} PROPERTIES VERSION 0.1.0 SOVERSION 0.1) + +install(TARGETS ${TARGET_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(FILES ${OUT_HEADERS} DESTINATION include/${PROJECT_NAME}) + +# config libiamgevisualresult${IMGE_VERSION_MAJOR}.pc.in +configure_file(libimagevisualresult.pc.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY) +install(FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + +# CUBE 颜色表文件 安装到usr/share下, 方便其他应用访问 +install(DIRECTORY ${PROJECT_SOURCE_DIR}/filter_cube + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME} + FILES_MATCHING PATTERN "*.CUBE") +install(DIRECTORY ${PROJECT_SOURCE_DIR}/filter_cube + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME} + FILES_MATCHING PATTERN "*.dat") + +# 加速编译优化参数 +if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "mips64") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wl,-O1 -Wl,--as-needed -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi -z noexecstack") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wl,-O1 -Wl,--as-needed -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi -z noexecstack") + SET(CMAKE_EXE_LINKER_FLAGS "-pie") +else() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wl,-O1 -Wl,--as-needed -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wl,-O1 -Wl,--as-needed -Wl,-E -fPIE -ffunction-sections -fdata-sections -Wl,--gc-sections") + SET(CMAKE_EXE_LINKER_FLAGS "-pie") +endif() diff --git a/libimagevisualresult/libimagevisualresult.pc.in b/libimagevisualresult/libimagevisualresult.pc.in index 2f997a9f..588959ba 100644 --- a/libimagevisualresult/libimagevisualresult.pc.in +++ b/libimagevisualresult/libimagevisualresult.pc.in @@ -1,11 +1,11 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix}/bin -libimagevisualresult=${prefix}/@CMAKE_INSTALL_LIBDIR@ -includedir=${prefix}/include/libimagevisualresult +@PROJECT_NAME@=${prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/include/@PROJECT_NAME@ -Name: imagevisualresult +Name: @TARGET_NAME@ Description: deepin image viewer plugins Version: @PROJECT_VERSION@ -Libs: -L${libimageviewer} -limagevisualresult +Libs: -L${libimageviewer@IMGE_VERSION_MAJOR@} -l@TARGET_NAME@ Cflags: -I${includedir} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 61bb4cef..3c731881 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,11 +5,11 @@ project(image-editor-test VERSION 0.1) ADD_COMPILE_OPTIONS(-fno-access-control) #"option"用来定义宏,"ON"表示打开,"OFF"表示关闭 -option (LITE_DIV "Use tutorial provided math implementation" ON) -add_definitions( -DLITE_DIV ) +option(LITE_DIV "Use tutorial provided math implementation" ON) +add_definitions(-DLITE_DIV) -option (USE_TEST "Use TESTS" ON) -add_definitions( -DUSE_TEST ) +option(USE_TEST "Use TESTS" ON) +add_definitions(-DUSE_TEST) ADD_COMPILE_OPTIONS(-fno-access-control) @@ -26,7 +26,7 @@ execute_process(COMMAND uname -m OUTPUT_VARIABLE MACH -if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ") endif() @@ -35,28 +35,28 @@ endif() set(AllTestQRC ./testqrc/testresource.qrc) file(GLOB_RECURSE HEADERSCURRENT "*.h") -file(GLOB_RECURSE SOURCESCURRENT "*.cpp") +file(GLOB_RECURSE SOURCESCURRENT "*.cpp") -file (GLOB_RECURSE SOURCES +file(GLOB_RECURSE SOURCES "../libimageviewer/*.cpp" "../libimageviewer/*.h" "../libimagevisualresult/exposure.cpp" "../libimagevisualresult/exposure.h" - ) +) file(GLOB_RECURSE SOURCESC "../libimageviewer/*.c") #file(GLOB_RECURSE HEADERS "../src/src/module/modulepanel.h") file(GLOB_RECURSE FORMS "../libimageviewer/*.ui") file(GLOB_RECURSE RESOURCES "../*.qrc") # 三方库 tiff-tools tiffcp.c file(GLOB tiffToolsSources ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/tiff-tools/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/tiff-tools/*.h) + ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/tiff-tools/*.h) include_directories(${CMAKE_INCLUDE_CURRENT_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(PROJECT_INCLUDE ${PROJECT_SOURCE_DIR}/../libimageviewer/ ${PROJECT_SOURCE_DIR}/../src/src/utils - ) +) find_package(PkgConfig REQUIRED) find_package(TIFF) @@ -71,18 +71,14 @@ find_package(Qt5Concurrent) find_package(Qt5Svg) find_package(Qt5X11Extras) find_package(Qt5PrintSupport) -find_package(Qt5OpenGL) find_package(Qt5LinguistTools) pkg_check_modules(3rd_lib REQUIRED dtkcore dtkwidget - gio-qt - gio-unix-2.0 - gsettings-qt gstreamer-1.0 libmediainfo - ) +) ## translations @@ -91,17 +87,17 @@ file(GLOB TS LIST_DIRECTORIES false translations/${CMD_NAME}*.ts) set_source_files_properties(${TS} PROPERTIES OUTPUT_LOCATION ${PROJECT_SOURCE_DIR}/translations) -qt5_create_translation(QM ${SOURCES} ${GLOB}) +qt5_create_translation(QM ${SOURCES} ${GLOB}) -if (NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug")) +if(NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug")) qt5_create_translation(QM ${SRCS} ${TS}) -endif () +endif() -add_executable( ${TARGET_NAME} ${SOURCES} ${SOURCESC} +add_executable(${TARGET_NAME} ${SOURCES} ${SOURCESC} ${HEADERS} ${AllTestQRC} ${RESOURCES} ${HEADERSCURRENT} ${SOURCESCURRENT} ${QM} ${tiffToolsSources} - ) +) # 暂未使用OpenCV, 暂时屏蔽 # find_package(OpenCV REQUIRED) @@ -124,19 +120,15 @@ target_link_libraries( Qt5::Concurrent Qt5::X11Extras Qt5::PrintSupport - Qt5::OpenGL Qt5::Test dtkwidget dtkcore X11 Xext exif -# gio-unix-2.0 - gio-qt - udisks2-qt5 pthread gtest - ) +) include_directories(${PROJECT_BINARY_DIR}) @@ -150,7 +142,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # 添加gocv覆盖率文件的输出 #set(CMAKE_CXX_FLAGS "-g -fprofile-arcs -ftest-coverage") # 加速编译优化参数 -if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "mips64") +if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "mips64") set(CMAKE_CXX_FLAGS "-g -fprofile-arcs -ftest-coverage") else() set(CMAKE_CXX_FLAGS "-fsanitize=undefined,address,leak -fno-omit-frame-pointer -g -fprofile-arcs -ftest-coverage -pthread ") @@ -182,7 +174,7 @@ add_custom_command(TARGET test COMMAND genhtml -o ./coverageResult/report ./coverageResult/${PROJECT_NAME}_Coverage_fileter.info COMMAND echo " -- Coverage files have been output to ${CMAKE_BINARY_DIR}/coverageResult/report " WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) +) add_dependencies(test ${PROJECT_NAME})