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

WIP: Qt6 transition #10267

Closed
wants to merge 2 commits into from
Closed
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
44 changes: 19 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2018 KeePassXC Team <[email protected]>
# Copyright (C) 2023 KeePassXC Team <[email protected]>
# Copyright (C) 2010 Felix Geyer <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -205,6 +205,9 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0")
check_pie_supported()
endif()

# Find Qt6 compatibility library
find_package(Qt6 REQUIRED COMPONENTS Core5Compat)

# Find Botan early since the version affects subsequent compiler options
find_package(Botan REQUIRED)
if(BOTAN_VERSION VERSION_GREATER_EQUAL "3.0.0")
Expand Down Expand Up @@ -496,31 +499,22 @@ if(UNIX AND NOT APPLE)
if(WITH_XC_X11)
list(APPEND QT_COMPONENTS X11Extras)
endif()
find_package(Qt5 COMPONENTS ${QT_COMPONENTS} DBus REQUIRED)
find_package(Qt6 COMPONENTS ${QT_COMPONENTS} DBus REQUIRED)
elseif(APPLE)
find_package(Qt5 COMPONENTS ${QT_COMPONENTS} REQUIRED HINTS
/usr/local/opt/qt@5/lib/cmake
/usr/local/Cellar/qt@5/*/lib/cmake
/opt/homebrew/opt/qt@5/lib/cmake
ENV PATH)
find_package(Qt5 COMPONENTS MacExtras HINTS
/usr/local/opt/qt@5/lib/cmake
/usr/local/Cellar/qt@5/*/lib/cmake
/opt/homebrew/opt/qt@5/lib/cmake
find_package(Qt6 COMPONENTS ${QT_COMPONENTS} REQUIRED HINTS
/usr/local/opt/qt/lib/cmake
/usr/local/Cellar/qt/*/lib/cmake
/opt/homebrew/opt/qt/lib/cmake
ENV PATH)
else()
find_package(Qt5 COMPONENTS ${QT_COMPONENTS} REQUIRED)
find_package(Qt6 COMPONENTS ${QT_COMPONENTS} REQUIRED)
endif()

if(Qt5Core_VERSION VERSION_LESS "5.12.0")
message(FATAL_ERROR "Qt version 5.12.0 or higher is required")
if(Qt6Core_VERSION VERSION_LESS "6.6.0")
message(FATAL_ERROR "Qt version 6.6.0 or higher is required")
endif()

get_filename_component(Qt5_PREFIX ${Qt5_DIR}/../../.. REALPATH)
if(APPLE)
# Add includes under Qt5 Prefix in case Qt6 is also installed
include_directories(SYSTEM ${Qt5_PREFIX}/include)
endif()
get_filename_component(Qt6_PREFIX ${Qt6_DIR}/../../.. REALPATH)

# Process moc automatically
set(CMAKE_AUTOMOC ON)
Expand All @@ -531,18 +525,18 @@ set(CMAKE_AUTORCC ON)

if(APPLE)
set(CMAKE_MACOSX_RPATH TRUE)
find_program(MACDEPLOYQT_EXE macdeployqt HINTS ${Qt5_PREFIX}/bin ${Qt5_PREFIX}/tools/qt5/bin ENV PATH)
find_program(MACDEPLOYQT_EXE macdeployqt6 HINTS ${Qt6_PREFIX}/bin ${Qt6_PREFIX}/tools/qt/bin ENV PATH)
if(NOT MACDEPLOYQT_EXE)
message(FATAL_ERROR "macdeployqt is required to build on macOS")
message(FATAL_ERROR "macdeployqt6 is required to build on macOS")
endif()
message(STATUS "Using macdeployqt: ${MACDEPLOYQT_EXE}")
message(STATUS "Using macdeployqt6: ${MACDEPLOYQT_EXE}")
set(MACDEPLOYQT_EXTRA_BINARIES "")
elseif(WIN32)
find_program(WINDEPLOYQT_EXE windeployqt HINTS ${Qt5_PREFIX}/bin ${Qt5_PREFIX}/tools/qt5/bin ENV PATH)
find_program(WINDEPLOYQT_EXE windeployqt6 HINTS ${Qt6_PREFIX}/bin ${Qt6_PREFIX}/tools/qt/bin ENV PATH)
if(NOT WINDEPLOYQT_EXE)
message(FATAL_ERROR "windeployqt is required to build on Windows")
message(FATAL_ERROR "windeployqt6 is required to build on Windows")
endif()
message(STATUS "Using windeployqt: ${WINDEPLOYQT_EXE}")
message(STATUS "Using windeployq6t: ${WINDEPLOYQT_EXE}")
endif()

# Debian sets the build type to None for package builds.
Expand Down
14 changes: 7 additions & 7 deletions release-tool
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,10 @@ checkXcodeSetup() {
fi
}

checkQt5LUpdateExists() {
checkQt6LUpdateExists() {
if cmdExists lupdate && ! $(lupdate -version | grep -q "lupdate version 5\."); then
if ! cmdExists lupdate-qt5; then
exitError "Qt Linguist tool (lupdate-qt5) is not installed! Please install using 'apt install qttools5-dev-tools'"
if ! cmdExists lupdate-qt6; then
exitError "Qt Linguist tool (lupdate-qt6) is not installed! Please install using 'apt install qttools6-dev-tools'"
fi
fi
}
Expand All @@ -379,7 +379,7 @@ performChecks() {
logInfo "Validating toolset and repository..."

checkTransifexCommandExists
checkQt5LUpdateExists
checkQt6LUpdateExists
checkGitRepository
checkReleaseDoesNotExist
checkWorkingTreeClean
Expand Down Expand Up @@ -955,7 +955,7 @@ build() {
export MACOSX_DEPLOYMENT_TARGET

logInfo "Configuring build..."
cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="$(uname -m)" \
cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" ${CMAKE_OPTIONS} "$SRC_DIR"

logInfo "Compiling and packaging sources..."
Expand Down Expand Up @@ -1404,10 +1404,10 @@ i18n() {
exit 1
fi

checkQt5LUpdateExists
checkQt6LUpdateExists

logInfo "Updating source translation file..."
LUPDATE=lupdate-qt5
LUPDATE=lupdate-qt6
if ! command -v $LUPDATE > /dev/null; then
LUPDATE=lupdate
fi
Expand Down
10 changes: 5 additions & 5 deletions share/translations/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2017 KeePassXC Team <[email protected]>
# Copyright (C) 2023 KeePassXC Team <[email protected]>
# Copyright (C) 2014 Felix Geyer <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
Expand All @@ -20,15 +20,15 @@ list(REMOVE_ITEM TRANSLATION_FILES keepassxc_en.ts)
list(REMOVE_ITEM TRANSLATION_FILES ${TRANSLATION_EN_ABS})
message(STATUS "Including translations...\n")

qt5_add_translation(QM_FILES ${TRANSLATION_FILES})
qt6_add_translation(QM_FILES ${TRANSLATION_FILES})

if(WIN32)
file(GLOB QTBASE_TRANSLATIONS ${Qt5_PREFIX}/share/qt5/translations/qtbase_*.qm)
file(GLOB QTBASE_TRANSLATIONS ${Qt6_PREFIX}/share/qt/translations/qtbase_*.qm)
elseif(APPLE OR KEEPASSXC_DIST_APPIMAGE)
file(GLOB QTBASE_TRANSLATIONS
/usr/share/qt/translations/qtbase_*.qm
/usr/share/qt5/translations/qtbase_*.qm
${Qt5_PREFIX}/translations/qtbase_*.qm)
/usr/share/qt6/translations/qtbase_*.qm
${Qt6_PREFIX}/translations/qtbase_*.qm)
endif()
set(QM_FILES ${QM_FILES} ${QTBASE_TRANSLATIONS})

Expand Down
68 changes: 35 additions & 33 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2023 KeePassXC Team <[email protected]>
# Copyright (C) 2025 KeePassXC Team <[email protected]>
# Copyright (C) 2010 Felix Geyer <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -233,26 +233,26 @@ if(UNIX AND NOT APPLE)
endif()
if(WITH_XC_X11)
list(APPEND gui_SOURCES
gui/osutils/nixutils/X11Funcs.cpp)
gui/osutils/nixutils/X11Funcs.cpp)
endif()
qt5_add_dbus_adaptor(gui_SOURCES
qt6_add_dbus_adaptor(gui_SOURCES
gui/org.keepassxc.KeePassXC.MainWindow.xml
gui/MainWindow.h
MainWindow)

set_source_files_properties(
quickunlock/dbus/org.freedesktop.PolicyKit1.Authority.xml
PROPERTIES
INCLUDE "quickunlock/PolkitDbusTypes.h"
)
qt5_add_dbus_interface(core_SOURCES
quickunlock/dbus/org.freedesktop.PolicyKit1.Authority.xml
polkit_dbus
quickunlock/dbus/org.freedesktop.PolicyKit1.Authority.xml
PROPERTIES
INCLUDE "quickunlock/PolkitDbusTypes.h"
)
qt6_add_dbus_interface(core_SOURCES
quickunlock/dbus/org.freedesktop.PolicyKit1.Authority.xml
polkit_dbus
)

find_library(KEYUTILS_LIBRARIES NAMES keyutils)
if(NOT KEYUTILS_LIBRARIES)
message(FATAL_ERROR "Could not find libkeyutils")
message(FATAL_ERROR "Could not find libkeyutils")
endif()
endif()

Expand Down Expand Up @@ -329,19 +329,19 @@ set(autotype_SOURCES
autotype/WindowSelectComboBox.cpp)

add_library(autotype STATIC ${autotype_SOURCES})
target_link_libraries(autotype Qt5::Core Qt5::Widgets)
target_link_libraries(autotype Qt6::Core Qt6::Widgets)

if(WITH_XC_YUBIKEY)
list(APPEND core_SOURCES
keys/drivers/YubiKey.h
keys/drivers/YubiKey.cpp
keys/drivers/YubiKeyInterface.cpp
keys/drivers/YubiKeyInterfaceUSB.cpp
keys/drivers/YubiKeyInterfacePCSC.cpp)
keys/drivers/YubiKey.h
keys/drivers/YubiKey.cpp
keys/drivers/YubiKeyInterface.cpp
keys/drivers/YubiKeyInterfaceUSB.cpp
keys/drivers/YubiKeyInterfacePCSC.cpp)
else()
list(APPEND core_SOURCES
keys/drivers/YubiKey.h
keys/drivers/YubiKeyStub.cpp)
keys/drivers/YubiKey.h
keys/drivers/YubiKeyStub.cpp)
endif()

if(WITH_XC_NETWORKING)
Expand All @@ -360,10 +360,10 @@ configure_file(git-info.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/git-info.h)
# Core Library Definition
add_library(keepassxc_core STATIC ${core_SOURCES})
set_target_properties(keepassxc_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
target_link_libraries(keepassxc_core
target_link_libraries(keepassxc_core
${qrcode_LIB}
Qt5::Core
Qt5::Concurrent
Qt6::Core
Qt6::Concurrent
${BOTAN_LIBRARIES}
${PCSC_LIBRARIES}
${ZXCVBN_LIBRARIES}
Expand All @@ -375,11 +375,13 @@ target_link_libraries(keepassxc_core

# GUI Library Definition
add_library(keepassxc_gui STATIC ${gui_SOURCES})
find_package(Qt6 REQUIRED COMPONENTS SvgWidgets)
set_target_properties(keepassxc_gui PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
target_link_libraries(keepassxc_gui
keepassxc_core
Qt5::Network
Qt5::Widgets
Qt6::Network
Qt6::SvgWidgets
Qt6::Widgets
autotype
${browser_LIB}
${fdosecrets_LIB}
Expand All @@ -388,19 +390,19 @@ target_link_libraries(keepassxc_gui

if(APPLE)
target_link_libraries(keepassxc_gui "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication -framework ScreenCaptureKit")
if(Qt5MacExtras_FOUND)
target_link_libraries(keepassxc_gui Qt5::MacExtras)
if(Qt6MacExtras_FOUND)
target_link_libraries(keepassxc_gui Qt6::MacExtras)
endif()
endif()
if(HAIKU)
target_link_libraries(keepassxc_gui network)
endif()
if(UNIX AND NOT APPLE)
target_link_libraries(keepassxc_core Qt5::DBus ${LIBUSB_LIBRARIES})
target_link_libraries(keepassxc_core Qt6::DBus ${LIBUSB_LIBRARIES})
if(WITH_XC_X11)
target_link_libraries(keepassxc_gui Qt5::X11Extras X11)
target_link_libraries(keepassxc_gui Qt6::X11Extras X11)
endif()
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
include_directories(${Qt6Gui_PRIVATE_INCLUDE_DIRS})
endif()
if(WIN32)
target_link_libraries(keepassxc_gui Wtsapi32.lib Ws2_32.lib)
Expand Down Expand Up @@ -524,7 +526,7 @@ if(WIN32)
COMPONENT Runtime)

# Use windeployqt.exe to setup Qt dependencies
if(Qt5Core_VERSION VERSION_LESS "5.14.1")
if(Qt6Core_VERSION VERSION_LESS "6.6.0")
set(WINDEPLOYQT_MODE "--release")
if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
set(WINDEPLOYQT_MODE "--debug")
Expand All @@ -539,15 +541,15 @@ if(WIN32)
find_file(OPENSSL_DLL
NAMES libssl-3.dll libssl-3-x64.dll
HINTS "${OPENSSL_ROOT_DIR}/bin"
)
)
if (NOT OPENSSL_DLL)
message(FATAL_ERROR "Cannot find libssl dll, ensure openssl is properly installed.")
endif()

find_file(CRYPTO_DLL
NAMES libcrypto-3.dll libcrypto-3-x64.dll
HINTS "${OPENSSL_ROOT_DIR}/bin"
)
)
if (NOT CRYPTO_DLL)
message(FATAL_ERROR "Cannot find libcrypto dll, ensure openssl is properly installed.")
endif()
Expand All @@ -557,7 +559,7 @@ if(WIN32)
endif()

# install CA cert chains
find_file(SSL_CA_BUNDLE ca-bundle.crt PATHS "${Qt5_PREFIX}/ssl/certs")
find_file(SSL_CA_BUNDLE ca-bundle.crt PATHS "${Qt6_PREFIX}/ssl/certs")
if(SSL_CA_BUNDLE)
install(FILES ${SSL_CA_BUNDLE} DESTINATION "ssl/certs")
else()
Expand Down
4 changes: 2 additions & 2 deletions src/autotype/AutoTypeMatch.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 KeePassXC Team <[email protected]>
* Copyright (C) 2023 KeePassXC Team <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -18,10 +18,10 @@
#ifndef KPXC_AUTOTYPEMATCH_H
#define KPXC_AUTOTYPEMATCH_H

#include "core/Entry.h"
#include <QPair>
#include <QPointer>

class Entry;
typedef QPair<QPointer<Entry>, QString> AutoTypeMatch;

#endif // KPXC_AUTOTYPEMATCH_H
8 changes: 4 additions & 4 deletions src/autotype/AutoTypeMatchView.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2023 KeePassXC Team <[email protected]>
* Copyright (C) 2015 David Wu <[email protected]>
* Copyright (C) 2017 KeePassXC Team <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -38,9 +38,9 @@ class CustomSortFilterProxyModel : public QSortFilterProxyModel
auto index1 = sourceModel()->index(sourceRow, 1, sourceParent);
auto index2 = sourceModel()->index(sourceRow, 2, sourceParent);

return sourceModel()->data(index0).toString().contains(filterRegExp())
|| sourceModel()->data(index1).toString().contains(filterRegExp())
|| sourceModel()->data(index2).toString().contains(filterRegExp());
return sourceModel()->data(index0).toString().contains(filterRegularExpression())
|| sourceModel()->data(index1).toString().contains(filterRegularExpression())
|| sourceModel()->data(index2).toString().contains(filterRegularExpression());
}
};

Expand Down
Loading
Loading