Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Support for Qt6 #29

Merged
merged 2 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ endif()
get_filename_component(QT_QMAKE_PATH ${QT_QMAKE_EXECUTABLE} PATH)

set(QT_ROOT ${QT_QMAKE_PATH}/)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QT_QMAKE_PATH}/../lib/cmake/Qt5)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QT_QMAKE_PATH}/../lib/cmake/Qt${QT_VERSION_MAJOR})

find_package(Qt5 COMPONENTS Core Gui REQUIRED)

find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

Expand All @@ -36,7 +38,10 @@ file(GLOB LIBQPSD_HEADERS "*.h")
SET(CMAKE_DEBUG_POSTFIX "d")

add_library(${PROJECT_NAME} MODULE ${LIBQPSD_SOURCES} ${LIBQPSD_HEADERS})
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui)
target_link_libraries(${PROJECT_NAME}
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
)

set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}/libs)
set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}/libs)
Expand Down
2 changes: 1 addition & 1 deletion qpsdplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ QImageIOPlugin::Capabilities QPsdPlugin::capabilities(
return Capabilities(CanRead);//TODO: add CanWrite support

if (!(format.isEmpty() && device->isOpen()))
return 0;
return { };
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @aa-bamboo for your pull request.

I haven't done Qt in a long time. Will this change still be backward-compatible with Qt5?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It works in Qt5.15 which I have tested too.
It depends on CPP standard, not on Qt version.
Unified initializers were added in CPP11 standard.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks 🥇


Capabilities cap;
if (device->isReadable() && QPsdHandler::canRead(device))
Expand Down