Skip to content

Commit

Permalink
Allow building with Qt 6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
berolinux authored and whoozle committed Jan 7, 2025
1 parent cf7036c commit 477db54
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
27 changes: 25 additions & 2 deletions qt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
if(DESIRED_QT_VERSION)
if(DESIRED_QT_VERSION MATCHES 4)
find_package(Qt4 QUIET)
else()
elseif(DESIRED_QT_VERSION MATCHES 5)
find_package(Qt5Widgets QUIET)
find_package(Qt5Network QUIET)
find_package(Qt5LinguistTools QUIET)
else()
find_package(Qt6Widgets QUIET)
find_package(Qt6Network QUIET)
find_package(Qt6LinguistTools QUIET)
endif()
else()
find_package(Qt6Widgets QUIET)
find_package(Qt6Network QUIET)
find_package(Qt6LinguistTools QUIET)
find_package(Qt5Widgets QUIET)
find_package(Qt5Network QUIET)
find_package(Qt5LinguistTools QUIET)
Expand Down Expand Up @@ -53,7 +60,23 @@ set(TS_FILES
translations/android-file-transfer-linux_zh-CN.ts
)

if (Qt5Widgets_FOUND)
if (Qt6Widgets_FOUND)
message(STATUS "Using Qt6")
qt6_wrap_cpp(HEADERS_MOC ${HEADERS})
qt6_wrap_ui(FORMS_HEADERS ${FORMS})

qt6_add_translation(QM_FILES ${TS_FILES})
set(QM_FILES_XML "")
foreach(_QM ${QM_FILES})
get_filename_component(_QM ${_QM} NAME)
set(QM_FILES_XML "${QM_FILES_XML}<file>${_QM}</file>")
endforeach()
configure_file(translations/translations.qrc.in translations.qrc)

qt6_add_resources(RESOURCES android-file-transfer.qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
include_directories(${Qt6Widgets_INCLUDE_DIRS} ${Qt6Network_INCLUDE_DIRS})
set(EXTRA_QT_LINK ${Qt6Widgets_LIBRARIES} ${Qt6Network_LIBRARIES})
elseif (Qt5Widgets_FOUND)
message(STATUS "Using Qt5")
qt5_wrap_cpp(HEADERS_MOC ${HEADERS})
qt5_wrap_ui(FORMS_HEADERS ${FORMS})
Expand Down
1 change: 1 addition & 0 deletions qt/commandqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QObject>
#include <QQueue>
#include <QMap>
#include <QDebug>
#include <mtp/ptp/ObjectId.h>
#include <mtp/ptp/ObjectFormat.h>
#include <mtp/metadata/Library.h>
Expand Down

0 comments on commit 477db54

Please sign in to comment.