From d6e8c90e2965c8a2b8eb177b26e031f5abec2f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20V=C3=A1radi?= Date: Sat, 8 Feb 2025 10:00:43 +0100 Subject: [PATCH 1/2] Basic patches applied --- CMakeLists.txt | 59 +++++++++++++++------- NextcloudCPack.cmake | 63 ------------------------ VERSION.cmake | 40 ++++++++++----- shell_integration/dolphin/CMakeLists.txt | 4 +- src/csync/CMakeLists.txt | 1 - src/libsync/vfs/cfapi/CMakeLists.txt | 2 +- src/libsync/vfs/suffix/CMakeLists.txt | 2 +- src/libsync/vfs/xattr/CMakeLists.txt | 2 +- 8 files changed, 76 insertions(+), 97 deletions(-) delete mode 100644 NextcloudCPack.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b7448b2e3625..53abf9d0e8874 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,10 +112,6 @@ include(GNUInstallDirs) include(DefineInstallationPaths) include(GenerateExportHeader) -include(GetGitRevisionDescription) - -get_git_head_revision(GIT_REFSPEC GIT_SHA1) - add_definitions( -DQT_DISABLE_DEPRECATED_BEFORE=0x051200 -DQT_DEPRECATED_WARNINGS @@ -123,19 +119,6 @@ add_definitions( -DQT_MESSAGELOGCONTEXT #enable function name and line number in debug output ) -# if we cannot get it from git, directly try .tag (packages) -# this will work if the tar balls have been properly created -# via git-archive. -if ("${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND") - file(READ ${CMAKE_SOURCE_DIR}/.tag sha1_candidate) - string(REPLACE "\n" "" sha1_candidate ${sha1_candidate}) - if (NOT ${sha1_candidate} STREQUAL "$Format:%H$") - message("${sha1_candidate}") - set (GIT_SHA1 "${sha1_candidate}") - endif() -endif() -message(STATUS "GIT_SHA1 ${GIT_SHA1}") - set(SYSCONFDIR ${SYSCONF_INSTALL_DIR}) set(SHAREDIR ${CMAKE_INSTALL_FULL_DATADIR}) @@ -295,7 +278,47 @@ if (NOT DEFINED APPLICATION_ICON_NAME) set(APPLICATION_ICON_NAME ${APPLICATION_SHORTNAME}) endif() -include(NextcloudCPack.cmake) +# Get rid of NextcloudCPack.cmake, just include it here +# include(NextcloudCPack.cmake) +include( InstallRequiredSystemLibraries ) +set( CPACK_PACKAGE_CONTACT "Dominik Schmidt " ) + +set( CPACK_PACKAGE_VERSION_MAJOR ${MIRALL_VERSION_MAJOR} ) +set( CPACK_PACKAGE_VERSION_MINOR ${MIRALL_VERSION_MINOR} ) +set( CPACK_PACKAGE_VERSION_PATCH ${MIRALL_VERSION_PATCH} ) +set( CPACK_PACKAGE_VERSION_BUILD ${MIRALL_VERSION_BUILD} ) +set( CPACK_PACKAGE_VERSION ${MIRALL_VERSION_FULL}${MIRALL_VERSION_SUFFIX} ) + +if(APPLE) + set( CPACK_GENERATOR "DragNDrop" ) + set( CPACK_SOURCE_GENERATOR "") + set( CPACK_PACKAGE_FILE_NAME ${APPLICATION_SHORTNAME}-${CPACK_PACKAGE_VERSION} ) + set( CPACK_PACKAGE_ICON ${CMAKE_BINARY_DIR}/src/gui/${APPLICATION_ICON_NAME}.icns) + + set( CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/admin/osx/DS_Store.in") + + set( CPACK_DMG_FORMAT "UDBZ" ) + set( CPACK_DMG_VOLUME_NAME "${APPLICATION_SHORTNAME}") +endif() + +if(WIN32) + set( CPACK_PACKAGE_FILE_NAME ${APPLICATION_SHORTNAME}-${CPACK_PACKAGE_VERSION}-setup ) + set( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md" ) # File used as a description of a project /path/to/project/ReadMe.txt + set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "${APPLICATION_NAME} Syncing Client" ) # Description summary of a project + set( CPACK_PACKAGE_INSTALL_DIRECTORY ${APPLICATION_SHORTNAME} ) # Installation directory on the target system -> C:\Program Files\${APPLICATION_SHORTNAME} + set( CPACK_PACKAGE_INSTALL_REGISTRY_KEY ${APPLICATION_SHORTNAME} ) # Registry key used when installing this project CMake 2.5.0 + set( CPACK_PACKAGE_NAME ${APPLICATION_NAME} ) # Package name, defaults to the project name + set( CPACK_PACKAGE_VENDOR "http://${APPLICATION_DOMAIN}" ) # Package vendor name +endif() + +set( CPACK_TOPLEVEL_TAG "unused" ) # Directory for the installed files. - needed to provide anything to avoid an error# CPACK_INSTALL_COMMANDS Extra commands to install components. + +# Set the options file that needs to be included inside CMakeCPackOptions.cmake +configure_file("${CMAKE_SOURCE_DIR}/CPackOptions.cmake.in" + "${CMAKE_BINARY_DIR}/CPackOptions.cmake" @ONLY) +set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_BINARY_DIR}/CPackOptions.cmake") # File included at cpack time, once per generator after setting CPACK_GENERATOR to the actual generator being > +include(CPack) +# end of included file add_definitions(-DUNICODE) add_definitions(-D_UNICODE) diff --git a/NextcloudCPack.cmake b/NextcloudCPack.cmake deleted file mode 100644 index 0682090c06d4c..0000000000000 --- a/NextcloudCPack.cmake +++ /dev/null @@ -1,63 +0,0 @@ -include( InstallRequiredSystemLibraries ) - -set( CPACK_PACKAGE_CONTACT "Dominik Schmidt " ) - -include("${CMAKE_SOURCE_DIR}/NEXTCLOUD.cmake") - -include( VERSION.cmake ) -set( CPACK_PACKAGE_VERSION_MAJOR ${MIRALL_VERSION_MAJOR} ) -set( CPACK_PACKAGE_VERSION_MINOR ${MIRALL_VERSION_MINOR} ) -set( CPACK_PACKAGE_VERSION_PATCH ${MIRALL_VERSION_PATCH} ) -set( CPACK_PACKAGE_VERSION_BUILD ${MIRALL_VERSION_BUILD} ) -set( CPACK_PACKAGE_VERSION ${MIRALL_VERSION_FULL}${MIRALL_VERSION_SUFFIX} ) - -if(APPLE) - set( CPACK_GENERATOR "DragNDrop" ) - set( CPACK_SOURCE_GENERATOR "") - set( CPACK_PACKAGE_FILE_NAME ${APPLICATION_SHORTNAME}-${CPACK_PACKAGE_VERSION} ) - set( CPACK_PACKAGE_ICON ${CMAKE_BINARY_DIR}/src/gui/${APPLICATION_ICON_NAME}.icns) - - set( CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/admin/osx/DS_Store.in") -# set( CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/admin/osx/DMGBackground.png" ) - - set( CPACK_DMG_FORMAT "UDBZ" ) - set( CPACK_DMG_VOLUME_NAME "${APPLICATION_SHORTNAME}") - - # did not work with cmake 2.8.7, so we override MacOSXBundleInfo.plist.in - #set( CPACK_BUNDLE_PLIST ${CMAKE_SOURCE_DIR}/admin/osx/Info.plist ) - - # do we need these? - #set( CPACK_SYSTEM_NAME "OSX" ) - #set( CPACK_PACKAGE_NAME "FOO" ) - #set( CPACK_BUNDLE_NAME "BAR" ) -endif() - - - - -if(WIN32) - set( CPACK_PACKAGE_FILE_NAME ${APPLICATION_SHORTNAME}-${CPACK_PACKAGE_VERSION}-setup ) - # Package file name without extension. Also a directory of installer cmake-2.5.0-Linux-i686 - # CPACK_GENERATOR CPack generator to be used STGZ;TGZ;TZ - # CPACK_INCLUDE_TOPLEVEL_DIRECTORY Controls whether CPack adds a top-level directory, usually of the form ProjectName-Version-OS, to the top of package tree. 0 to disable, 1 to enable - # CPACK_INSTALL_CMAKE_PROJECTS List of four values: Build directory, Project Name, Project Component, Directory in the package /home/andy/vtk/CMake-bin;CMake;ALL;/ - set( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md" ) # File used as a description of a project /path/to/project/ReadMe.txt - set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "${APPLICATION_NAME} Syncing Client" ) # Description summary of a project - # CPACK_PACKAGE_EXECUTABLES List of pairs of executables and labels. Used by the NSIS generator to create Start Menu shortcuts. ccmake;CMake - set( CPACK_PACKAGE_INSTALL_DIRECTORY ${APPLICATION_SHORTNAME} ) # Installation directory on the target system -> C:\Program Files\${APPLICATION_SHORTNAME} - set( CPACK_PACKAGE_INSTALL_REGISTRY_KEY ${APPLICATION_SHORTNAME} ) # Registry key used when installing this project CMake 2.5.0 - set( CPACK_PACKAGE_NAME ${APPLICATION_NAME} ) # Package name, defaults to the project name - set( CPACK_PACKAGE_VENDOR "http://${APPLICATION_DOMAIN}" ) # Package vendor name -endif() - -# set( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt" ) # License file for the project, used by the STGZ, NSIS, and PackageMaker generators. /home/andy/vtk/CMake/Copyright.txt - - -set( CPACK_TOPLEVEL_TAG "unused" ) # Directory for the installed files. - needed to provide anything to avoid an error# CPACK_INSTALL_COMMANDS Extra commands to install components. - - -# Set the options file that needs to be included inside CMakeCPackOptions.cmake -configure_file("${CMAKE_SOURCE_DIR}/CPackOptions.cmake.in" - "${CMAKE_BINARY_DIR}/CPackOptions.cmake" @ONLY) -set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_BINARY_DIR}/CPackOptions.cmake") # File included at cpack time, once per generator after setting CPACK_GENERATOR to the actual generator being used; allows per-generator setting of CPACK_* variables at cpack time. ${PROJECT_BINARY_DIR}/CPackOptions.cmake -include(CPack) diff --git a/VERSION.cmake b/VERSION.cmake index 2acfd5ad417b1..1fffd431acf9c 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -17,22 +17,40 @@ set(NEXTCLOUD_SERVER_VERSION_MOUNT_ROOT_PROPERTY_SUPPORTED_MAJOR 28) set(NEXTCLOUD_SERVER_VERSION_MOUNT_ROOT_PROPERTY_SUPPORTED_MINOR 0) set(NEXTCLOUD_SERVER_VERSION_MOUNT_ROOT_PROPERTY_SUPPORTED_PATCH 3) -if ( NOT DEFINED MIRALL_VERSION_SUFFIX ) - set( MIRALL_VERSION_SUFFIX "daily") #e.g. beta1, beta2, rc1 -endif( NOT DEFINED MIRALL_VERSION_SUFFIX ) +# Composite defines +# Used e.g. for libraries Keep at x.y.z. +set( MIRALL_VERSION "${MIRALL_VERSION_MAJOR}.${MIRALL_VERSION_MINOR}.${MIRALL_VERSION_PATCH}" ) if( NOT DEFINED MIRALL_VERSION_BUILD ) set( MIRALL_VERSION_BUILD "0" ) # Integer ID. Generated by the build system endif( NOT DEFINED MIRALL_VERSION_BUILD ) -# Composite defines -# Used e.g. for libraries Keep at x.y.z. -set( MIRALL_VERSION "${MIRALL_VERSION_MAJOR}.${MIRALL_VERSION_MINOR}.${MIRALL_VERSION_PATCH}" ) -# Version with Build ID. Used in the installer -set( MIRALL_VERSION_FULL ${MIRALL_VERSION} ) -set( MIRALL_VERSION_STRING ${MIRALL_VERSION} ) -set( MIRALL_VERSION_FULL "${MIRALL_VERSION_FULL}.${MIRALL_VERSION_BUILD}" ) -set( MIRALL_VERSION_STRING "${MIRALL_VERSION}${MIRALL_VERSION_SUFFIX}" ) +# Version with Build ID. Used in the installer +set( MIRALL_VERSION_FULL "${MIRALL_VERSION}.${MIRALL_VERSION_BUILD}" ) + +# External version or version with suffix +if ( NOT DEFINED EXTERNAL_VERSION ) + if ( NOT DEFINED MIRALL_VERSION_SUFFIX ) + set ( MIRALL_VERSION_SUFFIX "daily") #e.g. beta1, beta2, rc1 + endif( NOT DEFINED MIRALL_VERSION_SUFFIX ) + include(GetGitRevisionDescription) + get_git_head_revision(GIT_REFSPEC GIT_SHA1) + # if we cannot get it from git, directly try .tag (packages) + # this will work if the tar balls have been properly created + # via git-archive. + if ("${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND") + file (READ ${CMAKE_SOURCE_DIR}/.tag sha1_candidate) + string(REPLACE "\n" "" sha1_candidate ${sha1_candidate}) + if (NOT ${sha1_candidate} STREQUAL "$Format:%H$") + message("sha1_candidate:${sha1_candidate}") + set (GIT_SHA1 "${sha1_candidate}") + endif (NOT ${sha1_candidate} STREQUAL "$Format:%H$") + endif ( "${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND" ) + message(STATUS "GIT_SHA1 ${GIT_SHA1}") + set ( MIRALL_VERSION_STRING "${MIRALL_VERSION}${MIRALL_VERSION_SUFFIX}" ) +else ( NOT DEFINED EXTERNAL_VERSION ) + set ( MIRALL_VERSION_STRING "${EXTERNAL_VERSION}" ) +endif ( NOT DEFINED EXTERNAL_VERSION ) if( MIRALL_VERSION_BUILD ) set( MIRALL_VERSION_STRING "${MIRALL_VERSION_STRING} (build ${MIRALL_VERSION_BUILD})" ) diff --git a/shell_integration/dolphin/CMakeLists.txt b/shell_integration/dolphin/CMakeLists.txt index b3d317b015da1..22f8d4ef4e218 100644 --- a/shell_integration/dolphin/CMakeLists.txt +++ b/shell_integration/dolphin/CMakeLists.txt @@ -39,7 +39,7 @@ add_library(${OWNCLOUDDOLPHINHELPER} SHARED ownclouddolphinpluginhelper.cpp) target_link_libraries(${OWNCLOUDDOLPHINHELPER} Qt${QT_MAJOR_VERSION}::Network) generate_export_header(${OWNCLOUDDOLPHINHELPER} BASE_NAME ownclouddolphinpluginhelper) -install(TARGETS ${OWNCLOUDDOLPHINHELPER} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS ${OWNCLOUDDOLPHINHELPER} LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/${APPLICATION_EXECUTABLE}") #---OVERLAY PLUGIN--- set(OWNCLOUDDOLPHINOVERLAYPLUGIN ${APPLICATION_EXECUTABLE}dolphinoverlayplugin) @@ -51,6 +51,7 @@ else() JSON ownclouddolphinoverlayplugin.json SOURCES ownclouddolphinoverlayplugin.cpp) endif() target_link_libraries(${OWNCLOUDDOLPHINOVERLAYPLUGIN} KF${QT_MAJOR_VERSION}::CoreAddons KF${QT_MAJOR_VERSION}::KIOCore KF${QT_MAJOR_VERSION}::KIOWidgets ${OWNCLOUDDOLPHINHELPER}) +set_target_properties(${OWNCLOUDDOLPHINOVERLAYPLUGIN} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/${APPLICATION_EXECUTABLE}") #---ACTION PLUGIN--- set(OWNCLOUDDOLPHINACTIONPLUGIN ${APPLICATION_EXECUTABLE}dolphinactionplugin) @@ -58,3 +59,4 @@ configure_file(ownclouddolphinactionplugin.json.in ${OWNCLOUDDOLPHINACTIONPLUGIN kcoreaddons_add_plugin(${OWNCLOUDDOLPHINACTIONPLUGIN} INSTALL_NAMESPACE "kf${QT_MAJOR_VERSION}/kfileitemaction" SOURCES ownclouddolphinactionplugin.cpp) target_link_libraries(${OWNCLOUDDOLPHINACTIONPLUGIN} KF${QT_MAJOR_VERSION}::CoreAddons KF${QT_MAJOR_VERSION}::KIOCore KF${QT_MAJOR_VERSION}::KIOWidgets ${OWNCLOUDDOLPHINHELPER}) +set_target_properties(${OWNCLOUDDOLPHINACTIONPLUGIN} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/${APPLICATION_EXECUTABLE}") diff --git a/src/csync/CMakeLists.txt b/src/csync/CMakeLists.txt index 7c7a8e5200a9b..00c7813cef795 100644 --- a/src/csync/CMakeLists.txt +++ b/src/csync/CMakeLists.txt @@ -14,7 +14,6 @@ set(LIBRARY_SOVERSION "0") # add definitions include(DefineCMakeDefaults) include(DefinePlatformDefaults) -include(DefineCompilerFlags) include(DefineOptions.cmake) include(DefineInstallationPaths) diff --git a/src/libsync/vfs/cfapi/CMakeLists.txt b/src/libsync/vfs/cfapi/CMakeLists.txt index 860a1c2dae652..eef9e6839d45b 100644 --- a/src/libsync/vfs/cfapi/CMakeLists.txt +++ b/src/libsync/vfs/cfapi/CMakeLists.txt @@ -35,7 +35,7 @@ if (WIN32) target_include_directories("nextcloudsync_vfs_cfapi" BEFORE PUBLIC ${CMAKE_CURRENT_BINARY_DIR} INTERFACE ${CMAKE_BINARY_DIR}) - set(vfs_installdir "${PLUGINDIR}") + set(vfs_installdir "${PLUGIN_INSTALL_DIR}") generate_export_header(nextcloudsync_vfs_cfapi BASE_NAME nextcloudsync_vfs_cfapi diff --git a/src/libsync/vfs/suffix/CMakeLists.txt b/src/libsync/vfs/suffix/CMakeLists.txt index 1106b0d42f469..80e97e7c9c4cf 100644 --- a/src/libsync/vfs/suffix/CMakeLists.txt +++ b/src/libsync/vfs/suffix/CMakeLists.txt @@ -32,7 +32,7 @@ if(APPLE) # For being loadable when client run from install dir (after make macdeployqt) set(vfs_installdir "${LIB_INSTALL_DIR}/../PlugIns") else() - set(vfs_installdir "${PLUGINDIR}") + set(vfs_installdir "${PLUGIN_INSTALL_DIR}") endif() install(TARGETS nextcloudsync_vfs_suffix diff --git a/src/libsync/vfs/xattr/CMakeLists.txt b/src/libsync/vfs/xattr/CMakeLists.txt index 9ddd0dedc44d5..07b4bc2f12d5a 100644 --- a/src/libsync/vfs/xattr/CMakeLists.txt +++ b/src/libsync/vfs/xattr/CMakeLists.txt @@ -41,7 +41,7 @@ if (LINUX) # For being loadable when client run from install dir (after make macdeployqt) set(vfs_installdir "${LIB_INSTALL_DIR}/../PlugIns") else() - set(vfs_installdir "${PLUGINDIR}") + set(vfs_installdir "${PLUGIN_INSTALL_DIR}") endif() generate_export_header(nextcloudsync_vfs_xattr From 6da2822777fe7bcc54048f34caee28c8811af8a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20V=C3=A1radi?= Date: Sun, 9 Feb 2025 08:46:31 +0100 Subject: [PATCH 2/2] Unified Qt6 patch --- CMakeLists.txt | 4 +- src/CMakeLists.txt | 2 +- src/common/common.cmake | 2 + src/common/qtcompat.cpp | 1 + src/common/qtcompat.h | 231 ++++++++++++++++++ src/csync/csync_exclude.cpp | 5 +- src/gui/CMakeLists.txt | 18 +- src/gui/application.cpp | 3 +- src/gui/folderwizard.cpp | 3 +- src/gui/generalsettings.cpp | 8 + src/gui/generalsettings.h | 2 + src/gui/sslerrordialog.cpp | 3 +- ...utton.qml => TrayFoldersMenuButton.qml.in} | 2 +- src/libsync/CMakeLists.txt | 11 +- src/libsync/clientsideencryption.cpp | 40 +-- src/libsync/filesystem.cpp | 1 + src/libsync/kfcompat.cpp | 176 +++++++++++++ src/libsync/kfcompat.h | 7 + src/libsync/networkjobs.cpp | 3 +- src/libsync/pushnotifications.cpp | 7 +- src/libsync/theme.cpp | 25 +- test/testdatefieldbackend.cpp | 1 + 22 files changed, 484 insertions(+), 71 deletions(-) create mode 100644 src/common/qtcompat.cpp create mode 100644 src/common/qtcompat.h rename src/gui/tray/{TrayFoldersMenuButton.qml => TrayFoldersMenuButton.qml.in} (99%) create mode 100644 src/libsync/kfcompat.cpp create mode 100644 src/libsync/kfcompat.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 53abf9d0e8874..c3fc0ecf06d9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") include(${CMAKE_SOURCE_DIR}/NEXTCLOUD.cmake) set(QT_VERSION_MAJOR "6") -set(REQUIRED_QT_VERSION "6.8.0") +set(REQUIRED_QT_VERSION "6.2.4") # CfAPI Shell Extensions set( CFAPI_SHELL_EXTENSIONS_LIB_NAME CfApiShellExtensions ) @@ -131,7 +131,7 @@ if(APPLE AND BUILD_OWNCLOUD_OSX_BUNDLE) add_definitions(-DBUILD_OWNCLOUD_OSX_BUNDLE) endif() -find_package(Qt${QT_MAJOR_VERSION} COMPONENTS Core) +find_package(QT REQUIRED COMPONENTS Core NAMES Qt${QT_MAJOR_VERSION} ) option(QUICK_COMPILER "Use QtQuick compiler to improve performance" OFF) # this option removes Http authentication, keychain, shibboleth etc and is intended for diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fe9d4d9affab3..b86fdeb5756f5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ include(ECMEnableSanitizers) -set(REQUIRED_QT_VERSION "6.5.0") +set(REQUIRED_QT_VERSION "6.2.4") find_package(Qt${QT_MAJOR_VERSION}Core ${REQUIRED_QT_VERSION} CONFIG QUIET) set_package_properties(Qt${QT_MAJOR_VERSION}Core PROPERTIES diff --git a/src/common/common.cmake b/src/common/common.cmake index 12654276970f8..94e2a035bf06e 100644 --- a/src/common/common.cmake +++ b/src/common/common.cmake @@ -32,3 +32,5 @@ elseif(UNIX AND NOT APPLE) endif() configure_file(${CMAKE_CURRENT_LIST_DIR}/vfspluginmetadata.json.in ${CMAKE_CURRENT_BINARY_DIR}/vfspluginmetadata.json) + +find_package(Qt6 REQUIRED COMPONENTS Widgets) diff --git a/src/common/qtcompat.cpp b/src/common/qtcompat.cpp new file mode 100644 index 0000000000000..ccded5d62eb9f --- /dev/null +++ b/src/common/qtcompat.cpp @@ -0,0 +1 @@ +#include "qtcompat.h" diff --git a/src/common/qtcompat.h b/src/common/qtcompat.h new file mode 100644 index 0000000000000..154bc35c19396 --- /dev/null +++ b/src/common/qtcompat.h @@ -0,0 +1,231 @@ + +#pragma once + +#include +#include +#include +#include + +#include + +//----------------------------------------------------------------------------- + +template +struct qt_atleast : public std::enable_if=QT_VERSION_CHECK(major, minor, 0), T> +{ +}; + +template +struct qt_before : public std::enable_if +{ +}; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +inline QString systemLocaleName() +{ +#if QT_VERSION>=QT_VERSION_CHECK(6, 8, 0) + return QLocale::system().uiLanguages(QLocale::TagSeparator::Underscore).first(); +#else + return QLocale::system().name(); +#endif +} + +//----------------------------------------------------------------------------- + +template +inline QRegularExpressionMatch +matchRegularExpression(const QRegularExpression& re, const T& s) +{ +#if QT_VERSION>=QT_VERSION_CHECK(6, 5, 0) + return re.matchView(s); +#else + return re.match(s); +#endif +} + +//----------------------------------------------------------------------------- + +#if QT_VERSION +inline QDebug& operator<<(QDebug& d, const std::basic_string& s) +{ + return d << s.c_str(); +} +#endif + +//----------------------------------------------------------------------------- + +#if QT_VERSION>=QT_VERSION_CHECK(6, 5, 0) +const auto QTimeZoneUTC = QTimeZone::UTC; +#else +const auto QTimeZoneUTC = Qt::UTC; +#endif + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +#ifdef QT_WIDGETS_LIB + +//----------------------------------------------------------------------------- + +#include + +//----------------------------------------------------------------------------- + +template +inline QMetaObject::Connection connectCheckBoxStateChanged( + const QCheckBox* sender, const QObject* context, Functor functor) +{ + return QObject::connect(sender, +#if QT_VERSION>=QT_VERSION_CHECK(6, 8, 0) + &QCheckBox::checkStateChanged, +#else + &QCheckBox::stateChanged, +#endif + context, functor); +} + +//----------------------------------------------------------------------------- + +#endif // QT_WIDGETS_LIB + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +#ifdef QT_WEBSOCKETS_LIB + +//----------------------------------------------------------------------------- + +#include + +//----------------------------------------------------------------------------- + +#if QT_VERSION>=QT_VERSION_CHECK(6, 5, 0) +#define QWebSocketErrorOccurred &QWebSocket::errorOccurred +#else +#define QWebSocketErrorOccurred &QWebSocket::error +#endif + +//----------------------------------------------------------------------------- + +#endif // QT_WEBSOCKETS_LIB + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +#ifdef QT_XML_LIB + +//----------------------------------------------------------------------------- + +#include + +//----------------------------------------------------------------------------- + +#if QT_VERSION>=QT_VERSION_CHECK(6, 5, 0) + +inline QDomDocument::ParseResult +QDomDocumentSetContentsUseNamespaceProcessing(QDomDocument& doc, QIODevice* device) +{ + return doc.setContent(device, QDomDocument::ParseOption::UseNamespaceProcessing); +} + +#else // QT_VERSION>=QT_VERSION_CHECK(6, 5, 0) + +struct QDomDocumentParseResult { + bool retval = false; + + QString errorMessage; + + int errorLine = -1; + + int errorColumn = -1; + + inline operator bool() const { + return retval; + } +}; + +inline QDomDocumentParseResult +QDomDocumentSetContentsUseNamespaceProcessing(QDomDocument& doc, QIODevice* device) +{ + QDomDocumentParseResult result; + result.retval = doc.setContent(device, true, &result.errorMessage, + &result.errorLine, &result.errorColumn); + return result; +} + +#endif // QT_VERSION>=QT_VERSION_CHECK(6, 5, 0) + +//----------------------------------------------------------------------------- + +#endif // QT_XML_LIB + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +#ifdef QT_GUI_LIB + +//----------------------------------------------------------------------------- + +#include +#include + +//----------------------------------------------------------------------------- + +inline double getColorDarkness(const QColor &color) +{ + // account for different sensitivity of the human eye to certain colors + const double threshold = 1.0 - (0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255.0; + return threshold; +} + +//----------------------------------------------------------------------------- + +inline bool isDarkColor(const QColor& color) +{ + return getColorDarkness(color) > 0.5; +} + +//----------------------------------------------------------------------------- + +template +inline void connectQStyleHintsColorSchemeChanged(QGuiApplication* app, + const Target* context, + Functor functor) +{ +#if QT_VERSION>=QT_VERSION_CHECK(6, 5, 0) + QObject::connect(app->styleHints(), &QStyleHints::colorSchemeChanged, + context, functor, Qt::UniqueConnection); +#else + QObject::connect(app, &QGuiApplication::paletteChanged, context, functor); +#endif +} + +//----------------------------------------------------------------------------- + +inline bool isDarkMode() { +#if QT_VERSION>=QT_VERSION_CHECK(6, 5, 0) + switch (qGuiApp->styleHints()->colorScheme()) + { + case Qt::ColorScheme::Dark: + return true; + case Qt::ColorScheme::Light: + return false; + case Qt::ColorScheme::Unknown: + return isDarkColor(QGuiApplication::palette().window().color()); + } + + return false; +#else // QT_VERSION>=QT_VERSION_CHECK(6, 5, 0) + return isDarkColor(QGuiApplication::palette().window().color()); +#endif // QT_VERSION>=QT_VERSION_CHECK(6, 5, 0) +} + +//----------------------------------------------------------------------------- + +#endif // QT_GUI_LIB + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- diff --git a/src/csync/csync_exclude.cpp b/src/csync/csync_exclude.cpp index 2c23656f2320f..1dad0bdbaebb0 100644 --- a/src/csync/csync_exclude.cpp +++ b/src/csync/csync_exclude.cpp @@ -32,6 +32,7 @@ #include "common/utility.h" #include "common/filesystembase.h" +#include "common/qtcompat.h" #include "../version.h" #include @@ -461,10 +462,10 @@ CSYNC_EXCLUDE_TYPE ExcludedFiles::traversalPatternMatch(const QString &path, Ite QRegularExpressionMatch m; if (filetype == ItemTypeDirectory && _bnameTraversalRegexDir.contains(basePath)) { - m = _bnameTraversalRegexDir[basePath].matchView(bnameStr); + m = matchRegularExpression(_bnameTraversalRegexDir[basePath], bnameStr); } else if (filetype == ItemTypeFile && _bnameTraversalRegexFile.contains(basePath)) { - m = _bnameTraversalRegexFile[basePath].matchView(bnameStr); + m = matchRegularExpression(_bnameTraversalRegexFile[basePath], bnameStr); } else { continue; } diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 4bd77fabad294..2bf590f21dff7 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -1,6 +1,6 @@ project(gui) find_package(Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS Widgets Svg Qml Quick QuickControls2 QuickWidgets Xml Network) -find_package(KF6Archive REQUIRED) +find_package(KF6Archive) find_package(KF6GuiAddons) if (NOT TARGET Qt::GuiPrivate) @@ -561,9 +561,16 @@ target_link_libraries(nextcloudCore Qt::Quick Qt::QuickControls2 Qt::QuickWidgets - KF6::Archive ) +if(KF6Archive_FOUND) + target_link_libraries(nextcloudCore + PUBLIC + KF6::Archive + ) + add_definitions(-DHAVE_KARCHIVE) +endif() + if(KF6GuiAddons_FOUND) target_link_libraries(nextcloudCore PUBLIC @@ -781,3 +788,10 @@ if(NOT BUILD_OWNCLOUD_OSX_BUNDLE AND NOT WIN32) endif() configure_file(configgui.h.in ${CMAKE_CURRENT_BINARY_DIR}/configgui.h) + +if ("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" VERSION_GREATER_EQUAL "6.5") + set(QML_ACCEPTTHISOBJECT_PRAGMA "pragma NativeMethodBehavior: AcceptThisObject") +else() + set(QML_ACCEPTTHISOBJECT_PRAGMA "") +endif() +configure_file(tray/TrayFoldersMenuButton.qml.in ${CMAKE_CURRENT_SOURCE_DIR}/tray/TrayFoldersMenuButton.qml) diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 4175ae5f0649b..6019643300774 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -46,6 +46,7 @@ #include "version.h" #include "csync_exclude.h" #include "common/vfs.h" +#include "common/qtcompat.h" #include "config.h" @@ -979,7 +980,7 @@ QString substLang(const QString &lang) void Application::setupTranslations() { const auto enforcedLocale = Theme::instance()->enforcedLocale(); - const auto lang = substLang(!enforcedLocale.isEmpty() ? enforcedLocale : QLocale::system().uiLanguages(QLocale::TagSeparator::Underscore).first()); + const auto lang = substLang(!enforcedLocale.isEmpty() ? enforcedLocale : systemLocaleName()); auto *translator = new QTranslator(this); auto *qtTranslator = new QTranslator(this); diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp index 6a45da8a15aed..b96d390b3b7e2 100644 --- a/src/gui/folderwizard.cpp +++ b/src/gui/folderwizard.cpp @@ -23,6 +23,7 @@ #include "creds/abstractcredentials.h" #include "wizard/owncloudwizard.h" #include "common/asserts.h" +#include "common/qtcompat.h" #include #include @@ -570,7 +571,7 @@ FolderWizardSelectiveSync::FolderWizardSelectiveSync(const AccountPtr &account) if (Theme::instance()->showVirtualFilesOption() && bestAvailableVfsMode() != Vfs::Off) { _virtualFilesCheckBox = new QCheckBox(tr("Use virtual files instead of downloading content immediately %1").arg(bestAvailableVfsMode() == Vfs::WindowsCfApi ? QString() : tr("(experimental)"))); connect(_virtualFilesCheckBox, &QCheckBox::clicked, this, &FolderWizardSelectiveSync::virtualFilesCheckboxClicked); - connect(_virtualFilesCheckBox, &QCheckBox::checkStateChanged, this, [this](int state) { + connectCheckBoxStateChanged(_virtualFilesCheckBox, this, [this](int state) { _selectiveSync->setEnabled(state == Qt::Unchecked); }); _virtualFilesCheckBox->setChecked(bestAvailableVfsMode() == Vfs::WindowsCfApi); diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 843be0dd568b6..dff1148d5435d 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -49,6 +49,7 @@ #include #include +#ifdef HAVE_KARCHIVE #include namespace { @@ -178,6 +179,7 @@ bool createDebugArchive(const QString &filename) } } +#endif // HAVE_KARCHIVE namespace OCC { @@ -270,7 +272,11 @@ GeneralSettings::GeneralSettings(QWidget *parent) _ui->monoIconsCheckBox->setVisible(Theme::instance()->monoIconsAvailable()); connect(_ui->ignoredFilesButton, &QAbstractButton::clicked, this, &GeneralSettings::slotIgnoreFilesEditor); +#ifdef HAVE_KARCHIVE connect(_ui->debugArchiveButton, &QAbstractButton::clicked, this, &GeneralSettings::slotCreateDebugArchive); +#else + _ui->debugArchiveButton->setEnabled(false); +#endif // accountAdded means the wizard was finished and the wizard might change some options. connect(AccountManager::instance(), &AccountManager::accountAdded, this, &GeneralSettings::loadMiscSettings); @@ -581,6 +587,7 @@ void GeneralSettings::slotIgnoreFilesEditor() } } +#ifdef HAVE_KARCHIVE void GeneralSettings::slotCreateDebugArchive() { const auto filename = QFileDialog::getSaveFileName( @@ -602,6 +609,7 @@ void GeneralSettings::slotCreateDebugArchive() ); } } +#endif void GeneralSettings::slotShowLegalNotice() { diff --git a/src/gui/generalsettings.h b/src/gui/generalsettings.h index 83067799a9753..c20029945c6ea 100644 --- a/src/gui/generalsettings.h +++ b/src/gui/generalsettings.h @@ -56,7 +56,9 @@ private slots: void slotToggleCallNotifications(bool); void slotShowInExplorerNavigationPane(bool); void slotIgnoreFilesEditor(); +#if defined(HAVE_KARCHIVE) void slotCreateDebugArchive(); +#endif void loadMiscSettings(); void slotShowLegalNotice(); #if defined(BUILD_UPDATER) diff --git a/src/gui/sslerrordialog.cpp b/src/gui/sslerrordialog.cpp index b8c65e556c530..24d0d2f1eed7a 100644 --- a/src/gui/sslerrordialog.cpp +++ b/src/gui/sslerrordialog.cpp @@ -14,6 +14,7 @@ #include "configfile.h" #include "sslerrordialog.h" #include "theme.h" +#include "common/qtcompat.h" #include #include @@ -201,7 +202,7 @@ QString SslErrorDialog::certDiv(QSslCertificate cert) const msg += QL("

"); - if (cert.effectiveDate() < QDateTime(QDate(2016, 1, 1), QTime(), QTimeZone::UTC)) { + if (cert.effectiveDate() < QDateTime(QDate(2016, 1, 1), QTime(), QTimeZoneUTC)) { QString sha1sum = Utility::formatFingerprint(cert.digest(QCryptographicHash::Sha1).toHex()); msg += tr("Fingerprint (SHA1): %1").arg(sha1sum) + QL("
"); } diff --git a/src/gui/tray/TrayFoldersMenuButton.qml b/src/gui/tray/TrayFoldersMenuButton.qml.in similarity index 99% rename from src/gui/tray/TrayFoldersMenuButton.qml rename to src/gui/tray/TrayFoldersMenuButton.qml.in index f98cad514b920..8925c87c77b0a 100644 --- a/src/gui/tray/TrayFoldersMenuButton.qml +++ b/src/gui/tray/TrayFoldersMenuButton.qml.in @@ -11,7 +11,7 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ -pragma NativeMethodBehavior: AcceptThisObject +@QML_ACCEPTTHISOBJECT_PRAGMA@ import QtQuick import QtQuick.Controls import QtQuick.Layouts diff --git a/src/libsync/CMakeLists.txt b/src/libsync/CMakeLists.txt index 72ec2eedee479..7f8536d793d2e 100644 --- a/src/libsync/CMakeLists.txt +++ b/src/libsync/CMakeLists.txt @@ -1,5 +1,5 @@ project(libsync) -find_package(KF6Archive REQUIRED) +find_package(KF6Archive) include(DefinePlatformDefaults) set(CMAKE_AUTOMOC TRUE) @@ -157,6 +157,8 @@ set(libsync_SRCS creds/keychainchunk.cpp caseclashconflictsolver.h caseclashconflictsolver.cpp + kfcompat.h + kfcompat.cpp ) if (WIN32) @@ -223,10 +225,15 @@ target_link_libraries(nextcloudsync Qt::Gui Qt::Svg Qt::Widgets - KF6::Archive + Qt::Core5Compat ) +if (KF6Archive_FOUND) + target_link_libraries(nextcloudsync PUBLIC KF6::Archive) + add_definitions(-DHAVE_KARCHIVE) +endif() + target_compile_features(nextcloudsync PRIVATE cxx_std_17 diff --git a/src/libsync/clientsideencryption.cpp b/src/libsync/clientsideencryption.cpp index c65c6639a8fbe..bee7a9cc8b76b 100644 --- a/src/libsync/clientsideencryption.cpp +++ b/src/libsync/clientsideencryption.cpp @@ -28,7 +28,7 @@ #include -#include +#include "kfcompat.h" #include #include @@ -2698,26 +2698,12 @@ bool EncryptionHelper::dataDecryption(const QByteArray &key, const QByteArray &i QByteArray EncryptionHelper::gzipThenEncryptData(const QByteArray &key, const QByteArray &inputData, const QByteArray &iv, QByteArray &returnTag) { - QBuffer gZipBuffer; - auto gZipCompressionDevice = KCompressionDevice(&gZipBuffer, false, KCompressionDevice::GZip); - if (!gZipCompressionDevice.open(QIODevice::WriteOnly)) { - return {}; - } - const auto bytesWritten = gZipCompressionDevice.write(inputData); - gZipCompressionDevice.close(); - if (bytesWritten < 0) { - return {}; - } - - if (!gZipBuffer.open(QIODevice::ReadOnly)) { - return {}; - } - QByteArray outputData; returnTag.clear(); - const auto gZippedAndNotEncrypted = gZipBuffer.readAll(); + + const auto gZippedAndNotEncrypted = gZipData(inputData); + EncryptionHelper::dataEncryption(key, iv, gZippedAndNotEncrypted, outputData, returnTag); - gZipBuffer.close(); return outputData; } @@ -2729,23 +2715,7 @@ QByteArray EncryptionHelper::decryptThenUnGzipData(const QByteArray &key, const return {}; } - QBuffer gZipBuffer; - if (!gZipBuffer.open(QIODevice::WriteOnly)) { - return {}; - } - const auto bytesWritten = gZipBuffer.write(decryptedAndUnGzipped); - gZipBuffer.close(); - if (bytesWritten < 0) { - return {}; - } - - auto gZipUnCompressionDevice = KCompressionDevice(&gZipBuffer, false, KCompressionDevice::GZip); - if (!gZipUnCompressionDevice.open(QIODevice::ReadOnly)) { - return {}; - } - - decryptedAndUnGzipped = gZipUnCompressionDevice.readAll(); - gZipUnCompressionDevice.close(); + decryptedAndUnGzipped = unGzipData(decryptedAndUnGzipped); return decryptedAndUnGzipped; } diff --git a/src/libsync/filesystem.cpp b/src/libsync/filesystem.cpp index 8361d8af550ee..6394fef7f378c 100644 --- a/src/libsync/filesystem.cpp +++ b/src/libsync/filesystem.cpp @@ -15,6 +15,7 @@ #include "filesystem.h" #include "common/utility.h" +#include "common/qtcompat.h" #include "csync.h" #include "vio/csync_vio_local.h" #include "std/c_time.h" diff --git a/src/libsync/kfcompat.cpp b/src/libsync/kfcompat.cpp new file mode 100644 index 0000000000000..09a05528833ab --- /dev/null +++ b/src/libsync/kfcompat.cpp @@ -0,0 +1,176 @@ + +#include "kfcompat.h" + +//----------------------------------------------------------------------------- + +#include +#include + +//----------------------------------------------------------------------------- + +#ifdef HAVE_KARCHIVE + +//----------------------------------------------------------------------------- + +#include + +//----------------------------------------------------------------------------- + +QByteArray gZipData(const QByteArray& inputData) +{ + QBuffer gZipBuffer; + auto gZipCompressionDevice = KCompressionDevice(&gZipBuffer, false, KCompressionDevice::GZip); + if (!gZipCompressionDevice.open(QIODevice::WriteOnly)) { + return {}; + } + const auto bytesWritten = gZipCompressionDevice.write(inputData); + gZipCompressionDevice.close(); + if (bytesWritten < 0) { + return {}; + } + + if (!gZipBuffer.open(QIODevice::ReadOnly)) { + return {}; + } + + const auto gZipped = gZipBuffer.readAll(); + gZipBuffer.close(); + return gZipped; +} + +//----------------------------------------------------------------------------- + +QByteArray unGzipData(const QByteArray& inputData) +{ + QBuffer gZipBuffer; + if (!gZipBuffer.open(QIODevice::WriteOnly)) { + return {}; + } + const auto bytesWritten = gZipBuffer.write(inputData); + gZipBuffer.close(); + if (bytesWritten < 0) { + return {}; + } + + auto gZipUnCompressionDevice = KCompressionDevice(&gZipBuffer, false, KCompressionDevice::GZip); + if (!gZipUnCompressionDevice.open(QIODevice::ReadOnly)) { + return {}; + } + + auto unGzipped = gZipUnCompressionDevice.readAll(); + gZipUnCompressionDevice.close(); + return unGzipped; +} + + +//----------------------------------------------------------------------------- +#else // HAVE_KARCHIVE +//----------------------------------------------------------------------------- + +#include +#include + +//----------------------------------------------------------------------------- + +QByteArray gZipData(const QByteArray& inputData) +{ + auto fd = memfd_create("gzipThenEncryptData", 0); + if (fd < 0) { + return {}; + } + + auto gzFile = gzdopen(fd, "wb"); + if (gzFile == nullptr) { + close(fd); + return {}; + } + + if (gzwrite(gzFile, inputData.data(), inputData.length())!=inputData.length()) { + gzclose(gzFile); + close(fd); + return {}; + } + + if (gzflush(gzFile, Z_FINISH)!=Z_OK) { + close(fd); + return {}; + } + + auto gzippedSize = lseek(fd, 0, SEEK_CUR); + if (gzippedSize < 0) { + close(fd); + return {}; + } + + if (lseek(fd, 0, SEEK_SET)!=0) { + close(fd); + return {}; + } + + QByteArray gZipped(gzippedSize, Qt::Initialization::Uninitialized); + + if (read(fd, gZipped.data(), gzippedSize)!=gzippedSize) { + close(fd); + return {}; + } + + close(fd); + return gZipped; +} + +//----------------------------------------------------------------------------- + +QByteArray unGzipData(const QByteArray& inputData) +{ + auto fd = memfd_create("decryptThenUnGzipData", 0); + if (fd < 0) { + return {}; + } + + if (write(fd, inputData.data(), inputData.length())!=inputData.length()) { + close(fd); + return {}; + } + + auto gzippedSize = lseek(fd, 0, SEEK_CUR); + if (gzippedSize < 0) { + close(fd); + return {}; + } + + if (lseek(fd, 0, SEEK_SET)!=0) { + close(fd); + return {}; + } + + auto gzFile = gzdopen(fd, "rb"); + if (gzFile == nullptr) { + close(fd); + return {}; + } + + QBuffer gunzipBuffer; + if (!gunzipBuffer.open(QIODevice::WriteOnly)) { + return {}; + } + + while(!gzeof(gzFile)) { + char buf[4096]; + auto a = gzread(gzFile, buf, sizeof(buf)); + if (a<0) { + gunzipBuffer.close(); + gzclose(gzFile); + return {}; + } + + gunzipBuffer.write(buf, a); + } + + gzclose(gzFile); + gunzipBuffer.close(); + + return gunzipBuffer.data(); +} + +//----------------------------------------------------------------------------- +#endif // HAVE_KARCHIVE diff --git a/src/libsync/kfcompat.h b/src/libsync/kfcompat.h new file mode 100644 index 0000000000000..ba7eb440677aa --- /dev/null +++ b/src/libsync/kfcompat.h @@ -0,0 +1,7 @@ +#pragma once + +class QByteArray; + +QByteArray gZipData(const QByteArray& inputData); + +QByteArray unGzipData(const QByteArray& inputData); diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index c01ab82e2b01d..99270ade3d336 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -42,6 +42,7 @@ #include "owncloudpropagator.h" #include "clientsideencryption.h" +#include "common/qtcompat.h" #include "creds/abstractcredentials.h" #include "creds/httpcredentials.h" #include "configfile.h" @@ -664,7 +665,7 @@ bool PropfindJob::finished() // Parse DAV response auto domDocument = QDomDocument(); - if (const auto res = domDocument.setContent(reply(), QDomDocument::ParseOption::UseNamespaceProcessing); !res) { + if (const auto res = QDomDocumentSetContentsUseNamespaceProcessing(domDocument, reply()); !res) { qCWarning(lcPropfindJob) << "XML parser error: " << res.errorMessage << res.errorLine << res.errorColumn; emit finishedWithError(reply()); diff --git a/src/libsync/pushnotifications.cpp b/src/libsync/pushnotifications.cpp index 6bfad9d62a535..ca34f0ada8da2 100644 --- a/src/libsync/pushnotifications.cpp +++ b/src/libsync/pushnotifications.cpp @@ -12,6 +12,7 @@ * for more details. */ +#include "common/qtcompat.h" #include "pushnotifications.h" #include "creds/abstractcredentials.h" #include "account.h" @@ -30,7 +31,7 @@ PushNotifications::PushNotifications(Account *account, QObject *parent) , _account(account) , _webSocket(new QWebSocket(QString(), QWebSocketProtocol::VersionLatest, this)) { - connect(_webSocket, QOverload::of(&QWebSocket::errorOccurred), this, &PushNotifications::onWebSocketError); + connect(_webSocket, QOverload::of(QWebSocketErrorOccurred), this, &PushNotifications::onWebSocketError); connect(_webSocket, &QWebSocket::sslErrors, this, &PushNotifications::onWebSocketSslErrors); connect(_webSocket, &QWebSocket::connected, this, &PushNotifications::onWebSocketConnected); connect(_webSocket, &QWebSocket::disconnected, this, &PushNotifications::onWebSocketDisconnected); @@ -76,7 +77,7 @@ void PushNotifications::closeWebSocket() _reconnectTimer->stop(); } - disconnect(_webSocket, QOverload::of(&QWebSocket::errorOccurred), this, &PushNotifications::onWebSocketError); + disconnect(_webSocket, QOverload::of(QWebSocketErrorOccurred), this, &PushNotifications::onWebSocketError); disconnect(_webSocket, &QWebSocket::sslErrors, this, &PushNotifications::onWebSocketSslErrors); _webSocket->close(); @@ -174,7 +175,7 @@ void PushNotifications::openWebSocket() const auto webSocketUrl = capabilities.pushNotificationsWebSocketUrl(); qCInfo(lcPushNotifications) << "Open connection to websocket on" << webSocketUrl << "for account" << _account->url(); - connect(_webSocket, QOverload::of(&QWebSocket::errorOccurred), this, &PushNotifications::onWebSocketError); + connect(_webSocket, QOverload::of(QWebSocketErrorOccurred), this, &PushNotifications::onWebSocketError); connect(_webSocket, &QWebSocket::sslErrors, this, &PushNotifications::onWebSocketSslErrors); _webSocket->open(webSocketUrl); } diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index f25ff9b58f079..a3b2f66ea80d5 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -18,6 +18,7 @@ #include "version.h" #include "configfile.h" #include "common/vfs.h" +#include "common/qtcompat.h" #include #ifndef TOKEN_AUTH_ONLY @@ -858,14 +859,12 @@ QString Theme::versionSwitchOutput() const double Theme::getColorDarkness(const QColor &color) { - // account for different sensitivity of the human eye to certain colors - const double threshold = 1.0 - (0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255.0; - return threshold; + return ::getColorDarkness(color); } bool Theme::isDarkColor(const QColor &color) { - return getColorDarkness(color) > 0.5; + return ::isDarkColor(color); } QColor Theme::getBackgroundAwareLinkColor(const QColor &backgroundColor) @@ -968,7 +967,7 @@ QColor Theme::defaultColor() void Theme::connectToPaletteSignal() const { if (const auto ptr = qobject_cast(qApp)) { - connect(ptr->styleHints(), &QStyleHints::colorSchemeChanged, this, &Theme::darkModeChanged, Qt::UniqueConnection); + connectQStyleHintsColorSchemeChanged(ptr, this, &Theme::darkModeChanged); } } @@ -1011,19 +1010,6 @@ QVariantMap Theme::systemPalette() const bool Theme::darkMode() const { connectToPaletteSignal(); - const auto isDarkFromStyle = [] { - switch (qGuiApp->styleHints()->colorScheme()) - { - case Qt::ColorScheme::Dark: - return true; - case Qt::ColorScheme::Light: - return false; - case Qt::ColorScheme::Unknown: - return Theme::isDarkColor(QGuiApplication::palette().window().color()); - } - - return false; - }; #ifdef Q_OS_WIN static const auto darkModeSubkey = QStringLiteral("Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"); @@ -1033,7 +1019,8 @@ bool Theme::darkMode() const return true; } #endif - return isDarkFromStyle(); + + return isDarkMode(); } bool Theme::displayLegacyImportDialog() const diff --git a/test/testdatefieldbackend.cpp b/test/testdatefieldbackend.cpp index 96f2ba1dafa64..aab73a0d97f5e 100644 --- a/test/testdatefieldbackend.cpp +++ b/test/testdatefieldbackend.cpp @@ -19,6 +19,7 @@ #include #include #include +#include using namespace OCC;