From 3843e83d380a2fca3b17c82ac71b027e985c138d Mon Sep 17 00:00:00 2001 From: varjolintu Date: Sat, 2 Dec 2023 17:22:12 +0200 Subject: [PATCH] Some changes. Lot TODO --- CMakeLists.txt | 50 ++-- release-tool | 14 +- share/translations/CMakeLists.txt | 8 +- src/CMakeLists.txt | 31 +-- src/autotype/AutoTypeMatch.h | 4 +- src/autotype/AutoTypeMatchView.cpp | 8 +- src/autotype/CMakeLists.txt | 2 - src/autotype/mac/AutoTypeMac.h | 8 +- src/autotype/mac/CMakeLists.txt | 2 +- src/autotype/test/CMakeLists.txt | 2 +- src/browser/BrowserService.cpp | 4 +- src/browser/CMakeLists.txt | 2 +- src/cli/CMakeLists.txt | 4 +- src/cli/TextStream.cpp | 3 +- src/cli/TextStream.h | 3 +- src/cli/Utils.h | 5 +- src/core/Clock.cpp | 5 +- src/core/Entry.cpp | 45 ++-- src/core/EntryAttachments.h | 5 +- src/core/Group.cpp | 2 +- src/core/HibpDownloader.cpp | 5 +- src/core/MacPasteboard.cpp | 6 +- src/core/MacPasteboard.h | 27 +- src/core/PassphraseGenerator.cpp | 6 +- src/core/PasswordGenerator.cpp | 68 ++--- src/core/SignalMultiplexer.h | 4 +- src/core/Tools.cpp | 4 +- src/crypto/Crypto.cpp | 3 +- src/crypto/SymmetricCipher.cpp | 2 +- src/format/CsvParser.cpp | 11 +- src/format/KdbxXmlReader.cpp | 248 +++++++++--------- src/format/KdbxXmlReader.h | 5 +- src/format/KdbxXmlWriter.cpp | 1 - src/format/KeePass1Reader.cpp | 25 +- src/format/OpVaultReader.cpp | 8 +- src/format/OpVaultReaderBandEntry.cpp | 6 +- src/format/OpVaultReaderSections.cpp | 6 +- src/gui/Clipboard.cpp | 11 +- src/gui/Clipboard.h | 6 +- src/gui/DatabaseIcons.h | 3 + src/gui/DatabaseOpenDialog.cpp | 8 +- src/gui/DatabaseWidget.cpp | 4 +- src/gui/MainWindow.cpp | 88 +++---- .../DatabaseSettingsWidgetDatabaseKey.cpp | 4 +- src/gui/entry/EntryModel.cpp | 3 +- src/gui/entry/EntryView.cpp | 4 +- src/gui/osutils/macutils/MacUtils.h | 5 +- src/gui/styles/base/BaseStyle.cpp | 25 +- src/keeshare/CMakeLists.txt | 18 +- src/keeshare/KeeShareSettings.cpp | 29 +- src/keys/CompositeKey.cpp | 3 +- src/keys/CompositeKey.h | 1 + src/keys/FileKey.cpp | 16 +- src/keys/PasswordKey.cpp | 3 +- src/keys/drivers/YubiKey.cpp | 4 +- src/proxy/CMakeLists.txt | 6 +- src/proxy/NativeMessagingProxy.cpp | 4 +- src/qrcode/CMakeLists.txt | 4 +- src/quickunlock/TouchID.h | 2 +- src/updatecheck/UpdateChecker.cpp | 5 +- tests/CMakeLists.txt | 4 +- tests/TestCsvParser.cpp | 3 +- tests/TestSharing.cpp | 4 +- 63 files changed, 469 insertions(+), 440 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b4b63a0bb..3e2d01b36b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2018 KeePassXC Team +# Copyright (C) 2023 KeePassXC Team # Copyright (C) 2010 Felix Geyer # # This program is free software: you can redistribute it and/or modify @@ -205,6 +205,9 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0") check_pie_supported() endif() +# Find Qt5 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") @@ -496,37 +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) -endif() - -if(Qt5Core_VERSION VERSION_LESS "5.9.5") - message(FATAL_ERROR "Qt version 5.9.5 or higher is required") + find_package(Qt6 COMPONENTS ${QT_COMPONENTS} REQUIRED) endif() -# CBOR for Passkeys requires Qt 5.12 -if(Qt5Core_VERSION VERSION_LESS "5.12.0") - message(STATUS "Qt version 5.12.0 or higher is required for Passkeys support") - set(WITH_XC_BROWSER_PASSKEYS OFF) +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) @@ -537,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. diff --git a/release-tool b/release-tool index 43f0580006..85780dfbc4 100755 --- a/release-tool +++ b/release-tool @@ -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 } @@ -379,7 +379,7 @@ performChecks() { logInfo "Validating toolset and repository..." checkTransifexCommandExists - checkQt5LUpdateExists + checkQt6LUpdateExists checkGitRepository checkReleaseDoesNotExist checkWorkingTreeClean @@ -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..." @@ -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 diff --git a/share/translations/CMakeLists.txt b/share/translations/CMakeLists.txt index bf18700421..07292ba11d 100644 --- a/share/translations/CMakeLists.txt +++ b/share/translations/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2017 KeePassXC Team +# Copyright (C) 2023 KeePassXC Team # Copyright (C) 2014 Felix Geyer # # This program is free software: you can redistribute it and/or modify @@ -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) + ${Qt6_PREFIX}/translations/qtbase_*.qm) endif() set(QM_FILES ${QM_FILES} ${QTBASE_TRANSLATIONS}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 82e548c8e1..cac85b2e69 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -220,7 +220,7 @@ if(UNIX AND NOT APPLE) list(APPEND keepassx_SOURCES gui/osutils/nixutils/X11Funcs.cpp) endif() - qt5_add_dbus_adaptor(keepassx_SOURCES + qt6_add_dbus_adaptor(keepassx_SOURCES gui/org.keepassxc.KeePassXC.MainWindow.xml gui/MainWindow.h MainWindow) @@ -230,7 +230,7 @@ if(UNIX AND NOT APPLE) PROPERTIES INCLUDE "quickunlock/PolkitDbusTypes.h" ) - qt5_add_dbus_interface(keepassx_SOURCES + qt6_add_dbus_interface(keepassx_SOURCES quickunlock/dbus/org.freedesktop.PolicyKit1.Authority.xml polkit_dbus ) @@ -359,20 +359,24 @@ configure_file(config-keepassx.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-keepas configure_file(git-info.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/git-info.h) add_library(autotype STATIC ${autotype_SOURCES}) -target_link_libraries(autotype Qt5::Core Qt5::Network Qt5::Widgets) +target_link_libraries(autotype Qt6::Core Qt6::Network Qt6::Widgets) add_library(keepassx_core STATIC ${keepassx_SOURCES}) +find_package(Qt6 REQUIRED COMPONENTS SvgWidgets) + set_target_properties(keepassx_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE) target_link_libraries(keepassx_core autotype ${keepassxcbrowser_LIB} ${qrcode_LIB} ${fdosecrets_LIB} - Qt5::Core - Qt5::Concurrent - Qt5::Network - Qt5::Widgets + Qt6::Core + Qt6::Core5Compat + Qt6::Concurrent + Qt6::Network + Qt6::SvgWidgets + Qt6::Widgets ${BOTAN_LIBRARIES} ${PCSC_LIBRARIES} ${ZXCVBN_LIBRARIES} @@ -391,19 +395,16 @@ endif() if(APPLE) target_link_libraries(keepassx_core "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication") - if(Qt5MacExtras_FOUND) - target_link_libraries(keepassx_core Qt5::MacExtras) - endif() endif() if(HAIKU) target_link_libraries(keepassx_core network) endif() if(UNIX AND NOT APPLE) - target_link_libraries(keepassx_core Qt5::DBus) + target_link_libraries(keepassx_core Qt6::DBus) if(WITH_XC_X11) - target_link_libraries(keepassx_core Qt5::X11Extras X11) + target_link_libraries(keepassx_core Qt6::X11Extras X11) endif() - include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) + include_directories(${Qt6Gui_PRIVATE_INCLUDE_DIRS}) endif() if(WIN32) target_link_libraries(keepassx_core Wtsapi32.lib Ws2_32.lib) @@ -523,7 +524,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") # TODO: Check this. set(WINDEPLOYQT_MODE "--release") if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug") set(WINDEPLOYQT_MODE "--debug") @@ -556,7 +557,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() diff --git a/src/autotype/AutoTypeMatch.h b/src/autotype/AutoTypeMatch.h index 1b8f2c740f..c202ada339 100644 --- a/src/autotype/AutoTypeMatch.h +++ b/src/autotype/AutoTypeMatch.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * * 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 @@ -18,10 +18,10 @@ #ifndef KPXC_AUTOTYPEMATCH_H #define KPXC_AUTOTYPEMATCH_H +#include "core/Entry.h" #include #include -class Entry; typedef QPair, QString> AutoTypeMatch; #endif // KPXC_AUTOTYPEMATCH_H diff --git a/src/autotype/AutoTypeMatchView.cpp b/src/autotype/AutoTypeMatchView.cpp index 91f9ce0838..12cab3ff1e 100644 --- a/src/autotype/AutoTypeMatchView.cpp +++ b/src/autotype/AutoTypeMatchView.cpp @@ -1,6 +1,6 @@ /* + * Copyright (C) 2023 KeePassXC Team * Copyright (C) 2015 David Wu - * Copyright (C) 2017 KeePassXC Team * * 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 @@ -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()); } }; diff --git a/src/autotype/CMakeLists.txt b/src/autotype/CMakeLists.txt index 79bb503722..6fbb7635c1 100644 --- a/src/autotype/CMakeLists.txt +++ b/src/autotype/CMakeLists.txt @@ -1,11 +1,9 @@ if(WITH_XC_AUTOTYPE) if(UNIX AND NOT APPLE AND NOT HAIKU) find_package(X11 REQUIRED COMPONENTS Xi XTest) - find_package(Qt5X11Extras 5.2 REQUIRED) if(PRINT_SUMMARY) add_feature_info(libXi X11_Xi_FOUND "The X11 Xi Protocol library is required for auto-type") add_feature_info(libXtst X11_XTest_FOUND "The X11 XTEST Protocol library is required for auto-type") - add_feature_info(Qt5X11Extras Qt5X11Extras_FOUND "The Qt5X11Extras library is required for auto-type") endif() add_subdirectory(xcb) diff --git a/src/autotype/mac/AutoTypeMac.h b/src/autotype/mac/AutoTypeMac.h index 54805a4e98..949d590088 100644 --- a/src/autotype/mac/AutoTypeMac.h +++ b/src/autotype/mac/AutoTypeMac.h @@ -1,6 +1,6 @@ /* + * Copyright (C) 2023 KeePassXC Team * Copyright (C) 2016 Lennart Glauer - * Copyright (C) 2017 KeePassXC Team * * 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 @@ -23,8 +23,8 @@ #include #include -#include "autotype/AutoTypePlatformPlugin.h" #include "autotype/AutoTypeAction.h" +#include "autotype/AutoTypePlatformPlugin.h" class AutoTypePlatformMac : public QObject, public AutoTypePlatformInterface { @@ -45,7 +45,7 @@ class AutoTypePlatformMac : public QObject, public AutoTypePlatformInterface bool raiseOwnWindow() override; void sendChar(const QChar& ch, bool isKeyDown); - void sendKey(Qt::Key key, bool isKeyDown, Qt::KeyboardModifiers modifiers = 0); + void sendKey(Qt::Key key, bool isKeyDown, Qt::KeyboardModifiers modifiers = Qt::NoModifier); private: static int windowLayer(CFDictionaryRef window); @@ -65,4 +65,4 @@ class AutoTypeExecutorMac : public AutoTypeExecutor AutoTypePlatformMac* const m_platform; }; -#endif // KEEPASSX_AUTOTYPEMAC_H +#endif // KEEPASSX_AUTOTYPEMAC_H diff --git a/src/autotype/mac/CMakeLists.txt b/src/autotype/mac/CMakeLists.txt index e0df901fdd..538bfdf86c 100644 --- a/src/autotype/mac/CMakeLists.txt +++ b/src/autotype/mac/CMakeLists.txt @@ -2,7 +2,7 @@ set(autotype_mac_SOURCES AutoTypeMac.cpp) add_library(keepassxc-autotype-cocoa MODULE ${autotype_mac_SOURCES}) set_target_properties(keepassxc-autotype-cocoa PROPERTIES LINK_FLAGS "-framework Foundation -framework AppKit -framework Carbon") -target_link_libraries(keepassxc-autotype-cocoa ${PROGNAME} Qt5::Core Qt5::Widgets) +target_link_libraries(keepassxc-autotype-cocoa ${PROGNAME} Qt6::Core Qt6::Widgets) install(TARGETS keepassxc-autotype-cocoa LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime) diff --git a/src/autotype/test/CMakeLists.txt b/src/autotype/test/CMakeLists.txt index 453e36af54..e0e4e694df 100644 --- a/src/autotype/test/CMakeLists.txt +++ b/src/autotype/test/CMakeLists.txt @@ -1,4 +1,4 @@ set(autotype_test_SOURCES AutoTypeTest.cpp) add_library(keepassxc-autotype-test MODULE ${autotype_test_SOURCES}) -target_link_libraries(keepassxc-autotype-test keepassx_core ${autotype_LIB} Qt5::Core Qt5::Widgets) +target_link_libraries(keepassxc-autotype-test keepassx_core ${autotype_LIB} Qt6::Core Qt6::Widgets) diff --git a/src/browser/BrowserService.cpp b/src/browser/BrowserService.cpp index 8205a22643..329fe9f70c 100644 --- a/src/browser/BrowserService.cpp +++ b/src/browser/BrowserService.cpp @@ -1355,7 +1355,7 @@ bool BrowserService::isPasskeyCredentialExcluded(const QJsonArray& excludeCreden { QStringList allIds; for (const auto& cred : excludeCredentials) { - allIds << cred["id"].toString(); + allIds << cred.toObject().value("id").toString(); } const auto passkeyEntries = getPasskeyEntries(origin, keyList); @@ -1604,7 +1604,7 @@ void BrowserService::processClientMessage(QLocalSocket* socket, const QJsonObjec m_browserClients.insert(clientID, QSharedPointer::create()); } - auto& action = m_browserClients.value(clientID); + const auto& action = m_browserClients.value(clientID); auto response = action->processClientMessage(socket, message); m_browserHost->sendClientMessage(socket, response); } diff --git a/src/browser/CMakeLists.txt b/src/browser/CMakeLists.txt index 656b5a5288..4795b48ef3 100755 --- a/src/browser/CMakeLists.txt +++ b/src/browser/CMakeLists.txt @@ -39,5 +39,5 @@ if(WITH_XC_BROWSER) endif() add_library(keepassxcbrowser STATIC ${keepassxcbrowser_SOURCES}) - target_link_libraries(keepassxcbrowser Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network ${BOTAN_LIBRARIES}) + target_link_libraries(keepassxcbrowser Qt6::Core Qt6::Concurrent Qt6::Widgets Qt6::Network ${BOTAN_LIBRARIES}) endif() diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index a3852c800f..5d1b7e16d4 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2019 KeePassXC Team +# Copyright (C) 2023 KeePassXC Team # # 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 @@ -45,7 +45,7 @@ set(cli_SOURCES Show.cpp) add_library(cli STATIC ${cli_SOURCES}) -target_link_libraries(cli Qt5::Core) +target_link_libraries(cli Qt6::Core) find_package(Readline) diff --git a/src/cli/TextStream.cpp b/src/cli/TextStream.cpp index e2e6e15f46..086787c285 100644 --- a/src/cli/TextStream.cpp +++ b/src/cli/TextStream.cpp @@ -94,6 +94,7 @@ void TextStream::detectCodec() codecName = env.value("ENCODING_OVERRIDE", codecName); auto* codec = QTextCodec::codecForName(codecName.toLatin1()); if (codec) { - setCodec(codec); + // TODO: Solve + // setCodec(codec); } } diff --git a/src/cli/TextStream.h b/src/cli/TextStream.h index 0091ec1087..99b0b60022 100644 --- a/src/cli/TextStream.h +++ b/src/cli/TextStream.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * * 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 @@ -18,6 +18,7 @@ #ifndef KEEPASSXC_TEXTSTREAM_H #define KEEPASSXC_TEXTSTREAM_H +#include #include /** diff --git a/src/cli/Utils.h b/src/cli/Utils.h index 84ddbbb4b3..d20af74182 100644 --- a/src/cli/Utils.h +++ b/src/cli/Utils.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * * 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 @@ -19,6 +19,9 @@ #define KEEPASSXC_UTILS_H #include +#include +#include +#include class CompositeKey; class Database; diff --git a/src/core/Clock.cpp b/src/core/Clock.cpp index f501daee73..991783f559 100644 --- a/src/core/Clock.cpp +++ b/src/core/Clock.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * * 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 @@ -32,8 +32,7 @@ QDateTime Clock::currentDateTime() uint Clock::currentSecondsSinceEpoch() { - // TODO: change to toSecsSinceEpoch() when min Qt >= 5.8 - return instance().currentDateTimeImpl().toTime_t(); + return instance().currentDateTimeImpl().toSecsSinceEpoch(); } qint64 Clock::currentMilliSecondsSinceEpoch() diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index 3efe55c456..1abbe93a66 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -28,6 +28,7 @@ #include "totp/totp.h" #include +#include #include #include @@ -665,40 +666,40 @@ void Entry::setOverrideUrl(const QString& url) void Entry::setTags(const QString& tags) { - static QRegExp rx("(\\,|\\t|\\;)"); - auto taglist = tags.split(rx, Qt::SkipEmptyParts); + static QRegularExpression rx(R"(\\,|\\t|\\;)"); + auto tagList = tags.split(rx, Qt::SkipEmptyParts); // Trim whitespace before/after tag text - for (auto itr = taglist.begin(); itr != taglist.end(); ++itr) { + for (auto itr = tagList.begin(); itr != tagList.end(); ++itr) { *itr = itr->trimmed(); } // Remove duplicates - taglist = Tools::asSet(taglist).values(); + tagList = Tools::asSet(tagList).values(); // Sort alphabetically - taglist.sort(); - set(m_data.tags, taglist); + tagList.sort(); + set(m_data.tags, tagList); } void Entry::addTag(const QString& tag) { auto cleanTag = tag.trimmed(); - cleanTag.remove(QRegExp("(\\,|\\t|\\;)")); + cleanTag.remove(QRegularExpression(R"(\\,|\\t|\\;)")); - auto taglist = m_data.tags; - if (!taglist.contains(cleanTag)) { - taglist.append(cleanTag); - taglist.sort(); - set(m_data.tags, taglist); + auto tagList = m_data.tags; + if (!tagList.contains(cleanTag)) { + tagList.append(cleanTag); + tagList.sort(); + set(m_data.tags, tagList); } } void Entry::removeTag(const QString& tag) { auto cleanTag = tag.trimmed(); - cleanTag.remove(QRegExp("(\\,|\\t|\\;)")); + cleanTag.remove(QRegularExpression(R"(\\,|\\t|\\;)")); - auto taglist = m_data.tags; - if (taglist.removeAll(tag) > 0) { - set(m_data.tags, taglist); + auto tagList = m_data.tags; + if (tagList.removeAll(tag) > 0) { + set(m_data.tags, tagList); } } @@ -1311,7 +1312,7 @@ Database* Entry::database() QString Entry::maskPasswordPlaceholders(const QString& str) const { QString result = str; - result.replace(QRegExp("(\\{PASSWORD\\})", Qt::CaseInsensitive, QRegExp::RegExp2), "******"); + result.replace(QRegularExpression("(\\{PASSWORD\\})", QRegularExpression::CaseInsensitiveOption), "******"); return result; } @@ -1381,10 +1382,10 @@ Entry::PlaceholderType Entry::placeholderType(const QString& placeholder) const if (!placeholder.startsWith(QLatin1Char('{')) || !placeholder.endsWith(QLatin1Char('}'))) { return PlaceholderType::NotPlaceholder; } - if (placeholder.startsWith(QLatin1Literal("{S:"))) { + if (placeholder.startsWith(QLatin1StringView("{S:"))) { return PlaceholderType::CustomAttribute; } - if (placeholder.startsWith(QLatin1Literal("{REF:"))) { + if (placeholder.startsWith(QLatin1StringView("{REF:"))) { return PlaceholderType::Reference; } @@ -1430,8 +1431,8 @@ QString Entry::resolveUrl(const QString& url) const { QString newUrl = url; - QRegExp fileRegEx("^([a-z]:)?[\\\\/]", Qt::CaseInsensitive, QRegExp::RegExp2); - if (fileRegEx.indexIn(newUrl) != -1) { + QRegularExpression fileRegEx("^([a-z]:)?[\\\\/]", QRegularExpression::CaseInsensitiveOption); + if (!fileRegEx.match(newUrl).hasMatch()) { // Match possible file paths without the scheme and convert it to a file URL newUrl = QDir::fromNativeSeparators(newUrl); newUrl = QUrl::fromLocalFile(newUrl).toString(); @@ -1440,7 +1441,7 @@ QString Entry::resolveUrl(const QString& url) const for (int i = 1; i < cmdList.size(); ++i) { // Don't pass arguments to the resolveUrl function (they look like URL's) if (!cmdList[i].startsWith("-") && !cmdList[i].startsWith("/")) { - return resolveUrl(cmdList[i].remove(QRegExp("'|\""))); + return resolveUrl(cmdList[i].remove(QRegularExpression("'|\""))); } } diff --git a/src/core/EntryAttachments.h b/src/core/EntryAttachments.h index c07c9cbf7d..4dbe70b216 100644 --- a/src/core/EntryAttachments.h +++ b/src/core/EntryAttachments.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Felix Geyer + * Copyright (C) 2023 Felix Geyer * * 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 @@ -25,8 +25,7 @@ #include #include #include - -class QStringList; +#include class EntryAttachments : public ModifiableObject { diff --git a/src/core/Group.cpp b/src/core/Group.cpp index 6498331788..aa2b9e5999 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -848,7 +848,7 @@ QList Group::usernamesRecursive(int topN) const // Take first topN usernames if set QList usernames; - int actualUsernames = topN < 0 ? sortedUsernames.size() : std::min(topN, sortedUsernames.size()); + int actualUsernames = topN < 0 ? sortedUsernames.size() : qMin(topN, sortedUsernames.size()); for (int i = 0; i < actualUsernames; i++) { usernames.append(sortedUsernames[i].first); } diff --git a/src/core/HibpDownloader.cpp b/src/core/HibpDownloader.cpp index 9ff1810931..69095a2370 100644 --- a/src/core/HibpDownloader.cpp +++ b/src/core/HibpDownloader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * * 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 @@ -20,6 +20,7 @@ #include #include +#include namespace { @@ -60,7 +61,7 @@ namespace } // Extract the count, remove remaining whitespace, and convert to int - return hibpResult.midRef(pos, end - pos).trimmed().toInt(); + return QStringView{hibpResult}.mid(pos, end - pos).trimmed().toInt(); } } // namespace diff --git a/src/core/MacPasteboard.cpp b/src/core/MacPasteboard.cpp index ae63ea4e49..fb5bef18cf 100644 --- a/src/core/MacPasteboard.cpp +++ b/src/core/MacPasteboard.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * * 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 @@ -14,7 +14,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - +/* +#include #include "MacPasteboard.h" QString MacPasteboard::convertorName() @@ -97,3 +98,4 @@ QList MacPasteboard::convertFromMime(const QString&, QVariant data, ret.append(QTextCodec::codecForName("UTF-16")->fromUnicode(string)); return ret; } +*/ \ No newline at end of file diff --git a/src/core/MacPasteboard.h b/src/core/MacPasteboard.h index 503741ca88..2cd9bf49f1 100644 --- a/src/core/MacPasteboard.h +++ b/src/core/MacPasteboard.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * * 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 @@ -14,28 +14,27 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - +/* #ifndef KEEPASSXC_MACPASTEBOARD_H #define KEEPASSXC_MACPASTEBOARD_H #include -#include -#include +//#include +#include -class MacPasteboard : public QObject, public QMacPasteboardMime +class MacPasteboard : public QObject, public QUtiMimeConverter { public: - explicit MacPasteboard() - : QMacPasteboardMime(MIME_ALL) + explicit MacPasteboard() : QUtiMimeConverter() { } - QString convertorName() override; - bool canConvert(const QString& mime, QString flav) override; - QString mimeFor(QString flav) override; - QString flavorFor(const QString& mime) override; - QVariant convertToMime(const QString& mime, QList data, QString flav) override; - QList convertFromMime(const QString& mime, QVariant data, QString flav) override; + //QString convertorName() override; + virtual bool canConvert(const QString &mime, const QString &uti) override; + QString mimeForUti(const QString &uti) override; + QString utiForMime(const QString &mime) override; + QVariant convertToMime(const QString &mime, const QList &data, const QString &uti) override; + QList convertFromMime(const QString &mime, const QVariant &data, const QString &uti) override; }; -#endif // KEEPASSXC_MACPASTEBOARD_H +#endif // KEEPASSXC_MACPASTEBOARD_H*/ diff --git a/src/core/PassphraseGenerator.cpp b/src/core/PassphraseGenerator.cpp index 79227817ed..d559a8bf81 100644 --- a/src/core/PassphraseGenerator.cpp +++ b/src/core/PassphraseGenerator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * * 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 @@ -18,6 +18,7 @@ #include "PassphraseGenerator.h" #include +#include #include #include @@ -75,7 +76,8 @@ void PassphraseGenerator::setWordList(const QString& path) line = in.readLine(); } } - QRegExp rx("^[0-9]+(-[0-9]+)*\\s+([^\\s]+)$"); + + QRegularExpression rx("^[0-9]+(-[0-9]+)*\\s+([^\\s]+)$"); while (!line.isNull()) { if (isSigned && line.startsWith("-----BEGIN PGP SIGNATURE-----")) { break; diff --git a/src/core/PasswordGenerator.cpp b/src/core/PasswordGenerator.cpp index 01641bc802..d2cd560797 100644 --- a/src/core/PasswordGenerator.cpp +++ b/src/core/PasswordGenerator.cpp @@ -132,7 +132,7 @@ QVector PasswordGenerator::passwordGroups() const continue; } - group.append(i); + group.append(QChar(i)); } passwordGroups.append(group); @@ -146,7 +146,7 @@ QVector PasswordGenerator::passwordGroups() const continue; } - group.append(i); + group.append(QChar(i)); } passwordGroups.append(group); @@ -159,7 +159,7 @@ QVector PasswordGenerator::passwordGroups() const continue; } - group.append(i); + group.append(QChar(i)); } passwordGroups.append(group); @@ -168,12 +168,12 @@ QVector PasswordGenerator::passwordGroups() const PasswordGroup group; // ()[]{} - group.append(40); - group.append(41); - group.append(91); - group.append(93); - group.append(123); - group.append(125); + group.append(QChar(40)); + group.append(QChar(41)); + group.append(QChar(91)); + group.append(QChar(93)); + group.append(QChar(123)); + group.append(QChar(125)); passwordGroups.append(group); } @@ -181,10 +181,10 @@ QVector PasswordGenerator::passwordGroups() const PasswordGroup group; // .,:; - group.append(44); - group.append(46); - group.append(58); - group.append(59); + group.append(QChar(44)); + group.append(QChar(46)); + group.append(QChar(58)); + group.append(QChar(59)); passwordGroups.append(group); } @@ -192,8 +192,8 @@ QVector PasswordGenerator::passwordGroups() const PasswordGroup group; // "' - group.append(34); - group.append(39); + group.append(QChar(34)); + group.append(QChar(39)); passwordGroups.append(group); } @@ -201,12 +201,12 @@ QVector PasswordGenerator::passwordGroups() const PasswordGroup group; // -/\_| - group.append(45); - group.append(47); - group.append(92); - group.append(95); + group.append(QChar(45)); + group.append(QChar(47)); + group.append(QChar(92)); + group.append(QChar(95)); if (!(m_flags & ExcludeLookAlike)) { - group.append(124); // "|" + group.append(QChar(124)); // "|" } passwordGroups.append(group); @@ -215,13 +215,13 @@ QVector PasswordGenerator::passwordGroups() const PasswordGroup group; // !*+<=>? - group.append(33); - group.append(42); - group.append(43); - group.append(60); - group.append(61); - group.append(62); - group.append(63); + group.append(QChar(33)); + group.append(QChar(42)); + group.append(QChar(43)); + group.append(QChar(60)); + group.append(QChar(61)); + group.append(QChar(62)); + group.append(QChar(63)); passwordGroups.append(group); } @@ -230,13 +230,13 @@ QVector PasswordGenerator::passwordGroups() const // #$%& for (int i = 35; i <= 38; i++) { - group.append(i); + group.append(QChar(i)); } // @^`~ - group.append(64); - group.append(94); - group.append(96); - group.append(126); + group.append(QChar(64)); + group.append(QChar(94)); + group.append(QChar(96)); + group.append(QChar(126)); passwordGroups.append(group); } @@ -246,14 +246,14 @@ QVector PasswordGenerator::passwordGroups() const // [U+0080, U+009F] are C1 control characters, // U+00A0 is non-breaking space for (int i = 161; i <= 172; i++) { - group.append(i); + group.append(QChar(i)); } // U+00AD is soft hyphen (format character) for (int i = 174; i <= 255; i++) { if ((m_flags & ExcludeLookAlike) && (i == 249)) { // "﹒" continue; } - group.append(i); + group.append(QChar(i)); } passwordGroups.append(group); diff --git a/src/core/SignalMultiplexer.h b/src/core/SignalMultiplexer.h index 727c4a3a35..6cca1dcd7a 100644 --- a/src/core/SignalMultiplexer.h +++ b/src/core/SignalMultiplexer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Felix Geyer + * Copyright (C) 2023 Felix Geyer * * 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 @@ -18,6 +18,8 @@ #ifndef KEEPASSX_SIGNALMULTIPLEXER_H #define KEEPASSX_SIGNALMULTIPLEXER_H +#include +#include #include class SignalMultiplexer diff --git a/src/core/Tools.cpp b/src/core/Tools.cpp index 448e5fba87..d3b9de50cf 100644 --- a/src/core/Tools.cpp +++ b/src/core/Tools.cpp @@ -226,11 +226,11 @@ namespace Tools bool isBase64(const QByteArray& ba) { constexpr auto pattern = R"(^(?:[a-z0-9+/]{4})*(?:[a-z0-9+/]{3}=|[a-z0-9+/]{2}==)?$)"; - QRegExp regexp(pattern, Qt::CaseInsensitive, QRegExp::RegExp2); + QRegularExpression regexp(pattern, QRegularExpression::CaseInsensitiveOption); QString base64 = QString::fromLatin1(ba.constData(), ba.size()); - return regexp.exactMatch(base64); + return regexp.match(base64).hasMatch(); } void sleep(int ms) diff --git a/src/crypto/Crypto.cpp b/src/crypto/Crypto.cpp index 233c89907a..2c156bb594 100644 --- a/src/crypto/Crypto.cpp +++ b/src/crypto/Crypto.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * Copyright (C) 2010 Felix Geyer * * This program is free software: you can redistribute it and/or modify @@ -23,6 +23,7 @@ #include "crypto/CryptoHash.h" #include "crypto/SymmetricCipher.h" +#include #include namespace diff --git a/src/crypto/SymmetricCipher.cpp b/src/crypto/SymmetricCipher.cpp index 1253763bc9..4ead89c7dd 100644 --- a/src/crypto/SymmetricCipher.cpp +++ b/src/crypto/SymmetricCipher.cpp @@ -61,7 +61,7 @@ bool SymmetricCipher::init(Mode mode, Direction direction, const QByteArray& key bool SymmetricCipher::isInitalized() const { - return m_cipher; + return !m_cipher.isNull(); } bool SymmetricCipher::process(char* data, int len) diff --git a/src/format/CsvParser.cpp b/src/format/CsvParser.cpp index a376e3662b..1bd05d0464 100644 --- a/src/format/CsvParser.cpp +++ b/src/format/CsvParser.cpp @@ -1,6 +1,6 @@ /* + * Copyright (C) 2023 KeePassXC Team * Copyright (C) 2016 Enrico Mariotti - * Copyright (C) 2017 KeePassXC Team * * 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 @@ -41,7 +41,6 @@ CsvParser::CsvParser() m_csv.setBuffer(&m_array); m_ts.setDevice(&m_csv); m_csv.open(QIODevice::ReadOnly); - m_ts.setCodec("UTF-8"); } CsvParser::~CsvParser() @@ -98,7 +97,7 @@ bool CsvParser::readFile(QFile* device) void CsvParser::reset() { - m_ch = 0; + m_ch = QChar(0); m_currCol = 1; m_currRow = 1; m_isEof = false; @@ -389,7 +388,9 @@ void CsvParser::setComment(const QChar& c) void CsvParser::setCodec(const QString& s) { - m_ts.setCodec(QTextCodec::codecForName(s.toLocal8Bit())); + Q_UNUSED(s) + // TODO: Solve + //m_ts.setCodec(QTextCodec::codecForName(s.toLocal8Bit())); } void CsvParser::setFieldSeparator(const QChar& c) @@ -433,6 +434,6 @@ int CsvParser::getCsvRows() const void CsvParser::appendStatusMsg(const QString& s, bool isCritical) { - m_statusMsg += QObject::tr("%1: (row, col) %2,%3").arg(s, m_currRow, m_currCol).append("\n"); + m_statusMsg += QObject::tr("%1: (row, col) %2,%3").arg(s, m_currRow, QChar(m_currCol)).append("\n"); m_isGood = !isCritical; } diff --git a/src/format/KdbxXmlReader.cpp b/src/format/KdbxXmlReader.cpp index 4ff47d9659..548a27a10e 100644 --- a/src/format/KdbxXmlReader.cpp +++ b/src/format/KdbxXmlReader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * * 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 @@ -104,7 +104,7 @@ void KdbxXmlReader::readDatabase(QIODevice* device, Database* db, KeePass2Random return; } - if (m_xml.readNextStartElement() && m_xml.name() == "KeePassFile") { + if (m_xml.readNextStartElement() && m_xml.name().compare("KeePassFile") == 0) { rootGroupParsed = parseKeePassFile(); } @@ -114,11 +114,13 @@ void KdbxXmlReader::readDatabase(QIODevice* device, Database* db, KeePass2Random } if (!m_tmpParent->children().isEmpty()) { - qWarning("KdbxXmlReader::readDatabase: found %d invalid group reference(s)", m_tmpParent->children().size()); + qWarning("KdbxXmlReader::readDatabase: found %" PRIdQSIZETYPE " invalid group reference(s)", + m_tmpParent->children().size()); } if (!m_tmpParent->entries().isEmpty()) { - qWarning("KdbxXmlReader::readDatabase: found %d invalid entry reference(s)", m_tmpParent->children().size()); + qWarning("KdbxXmlReader::readDatabase: found %" PRIdQSIZETYPE " invalid entry reference(s)", + m_tmpParent->children().size()); } const QSet poolKeys = Tools::asSet(m_binaryPool.keys()); @@ -187,9 +189,9 @@ QString KdbxXmlReader::errorString() const return {}; } -bool KdbxXmlReader::isTrueValue(const QStringRef& value) +bool KdbxXmlReader::isTrueValue(const QStringView& value) { - return value.compare(QLatin1String("true"), Qt::CaseInsensitive) == 0 || value == "1"; + return value.compare(QLatin1String("true"), Qt::CaseInsensitive) == 0 || value.compare("1") == 0; } void KdbxXmlReader::raiseError(const QString& errorMessage) @@ -205,18 +207,18 @@ QByteArray KdbxXmlReader::headerHash() const bool KdbxXmlReader::parseKeePassFile() { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "KeePassFile"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("KeePassFile") == 0); bool rootElementFound = false; bool rootParsedSuccessfully = false; while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "Meta") { + if (m_xml.name().compare("Meta") == 0) { parseMeta(); continue; } - if (m_xml.name() == "Root") { + if (m_xml.name().compare("Root") == 0) { if (rootElementFound) { rootParsedSuccessfully = false; qWarning("Multiple root elements"); @@ -235,72 +237,72 @@ bool KdbxXmlReader::parseKeePassFile() void KdbxXmlReader::parseMeta() { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Meta"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("Meta") == 0); while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "Generator") { + if (m_xml.name().compare("Generator") == 0) { m_meta->setGenerator(readString()); - } else if (m_xml.name() == "HeaderHash") { + } else if (m_xml.name().compare("HeaderHash") == 0) { m_headerHash = readBinary(); - } else if (m_xml.name() == "DatabaseName") { + } else if (m_xml.name().compare("DatabaseName") == 0) { m_meta->setName(readString()); - } else if (m_xml.name() == "DatabaseNameChanged") { + } else if (m_xml.name().compare("DatabaseNameChanged") == 0) { m_meta->setNameChanged(readDateTime()); - } else if (m_xml.name() == "DatabaseDescription") { + } else if (m_xml.name().compare("DatabaseDescription") == 0) { m_meta->setDescription(readString()); - } else if (m_xml.name() == "DatabaseDescriptionChanged") { + } else if (m_xml.name().compare("DatabaseDescriptionChanged") == 0) { m_meta->setDescriptionChanged(readDateTime()); - } else if (m_xml.name() == "DefaultUserName") { + } else if (m_xml.name().compare("DefaultUserName") == 0) { m_meta->setDefaultUserName(readString()); - } else if (m_xml.name() == "DefaultUserNameChanged") { + } else if (m_xml.name().compare("DefaultUserNameChanged") == 0) { m_meta->setDefaultUserNameChanged(readDateTime()); - } else if (m_xml.name() == "MaintenanceHistoryDays") { + } else if (m_xml.name().compare("MaintenanceHistoryDays") == 0) { m_meta->setMaintenanceHistoryDays(readNumber()); - } else if (m_xml.name() == "Color") { + } else if (m_xml.name().compare("Color") == 0) { m_meta->setColor(readColor()); - } else if (m_xml.name() == "MasterKeyChanged") { + } else if (m_xml.name().compare("MasterKeyChanged") == 0) { m_meta->setDatabaseKeyChanged(readDateTime()); - } else if (m_xml.name() == "MasterKeyChangeRec") { + } else if (m_xml.name().compare("MasterKeyChangeRec") == 0) { m_meta->setMasterKeyChangeRec(readNumber()); - } else if (m_xml.name() == "MasterKeyChangeForce") { + } else if (m_xml.name().compare("MasterKeyChangeForce") == 0) { m_meta->setMasterKeyChangeForce(readNumber()); - } else if (m_xml.name() == "MemoryProtection") { + } else if (m_xml.name().compare("MemoryProtection") == 0) { parseMemoryProtection(); - } else if (m_xml.name() == "CustomIcons") { + } else if (m_xml.name().compare("CustomIcons") == 0) { parseCustomIcons(); - } else if (m_xml.name() == "RecycleBinEnabled") { + } else if (m_xml.name().compare("RecycleBinEnabled") == 0) { m_meta->setRecycleBinEnabled(readBool()); - } else if (m_xml.name() == "RecycleBinUUID") { + } else if (m_xml.name().compare("RecycleBinUUID") == 0) { m_meta->setRecycleBin(getGroup(readUuid())); - } else if (m_xml.name() == "RecycleBinChanged") { + } else if (m_xml.name().compare("RecycleBinChanged") == 0) { m_meta->setRecycleBinChanged(readDateTime()); - } else if (m_xml.name() == "EntryTemplatesGroup") { + } else if (m_xml.name().compare("EntryTemplatesGroup") == 0) { m_meta->setEntryTemplatesGroup(getGroup(readUuid())); - } else if (m_xml.name() == "EntryTemplatesGroupChanged") { + } else if (m_xml.name().compare("EntryTemplatesGroupChanged") == 0) { m_meta->setEntryTemplatesGroupChanged(readDateTime()); - } else if (m_xml.name() == "LastSelectedGroup") { + } else if (m_xml.name().compare("LastSelectedGroup") == 0) { m_meta->setLastSelectedGroup(getGroup(readUuid())); - } else if (m_xml.name() == "LastTopVisibleGroup") { + } else if (m_xml.name().compare("LastTopVisibleGroup") == 0) { m_meta->setLastTopVisibleGroup(getGroup(readUuid())); - } else if (m_xml.name() == "HistoryMaxItems") { + } else if (m_xml.name().compare("HistoryMaxItems") == 0) { int value = readNumber(); if (value >= -1) { m_meta->setHistoryMaxItems(value); } else { qWarning("HistoryMaxItems invalid number"); } - } else if (m_xml.name() == "HistoryMaxSize") { + } else if (m_xml.name().compare("HistoryMaxSize") == 0) { int value = readNumber(); if (value >= -1) { m_meta->setHistoryMaxSize(value); } else { qWarning("HistoryMaxSize invalid number"); } - } else if (m_xml.name() == "Binaries") { + } else if (m_xml.name().compare("Binaries") == 0) { parseBinaries(); - } else if (m_xml.name() == "CustomData") { + } else if (m_xml.name().compare("CustomData") == 0) { parseCustomData(m_meta->customData()); - } else if (m_xml.name() == "SettingsChanged") { + } else if (m_xml.name().compare("SettingsChanged") == 0) { m_meta->setSettingsChanged(readDateTime()); } else { skipCurrentElement(); @@ -310,18 +312,18 @@ void KdbxXmlReader::parseMeta() void KdbxXmlReader::parseMemoryProtection() { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "MemoryProtection"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("MemoryProtection") == 0); while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "ProtectTitle") { + if (m_xml.name().compare("ProtectTitle") == 0) { m_meta->setProtectTitle(readBool()); - } else if (m_xml.name() == "ProtectUserName") { + } else if (m_xml.name().compare("ProtectUserName") == 0) { m_meta->setProtectUsername(readBool()); - } else if (m_xml.name() == "ProtectPassword") { + } else if (m_xml.name().compare("ProtectPassword") == 0) { m_meta->setProtectPassword(readBool()); - } else if (m_xml.name() == "ProtectURL") { + } else if (m_xml.name().compare("ProtectURL") == 0) { m_meta->setProtectUrl(readBool()); - } else if (m_xml.name() == "ProtectNotes") { + } else if (m_xml.name().compare("ProtectNotes") == 0) { m_meta->setProtectNotes(readBool()); } else { skipCurrentElement(); @@ -331,10 +333,10 @@ void KdbxXmlReader::parseMemoryProtection() void KdbxXmlReader::parseCustomIcons() { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "CustomIcons"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("CustomIcons") == 0); while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "Icon") { + if (m_xml.name().compare("Icon") == 0) { parseIcon(); } else { skipCurrentElement(); @@ -344,7 +346,7 @@ void KdbxXmlReader::parseCustomIcons() void KdbxXmlReader::parseIcon() { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Icon"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("Icon") == 0); QUuid uuid; QByteArray iconData; @@ -354,15 +356,15 @@ void KdbxXmlReader::parseIcon() bool iconSet = false; while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "UUID") { + if (m_xml.name().compare("UUID") == 0) { uuid = readUuid(); uuidSet = !uuid.isNull(); - } else if (m_xml.name() == "Data") { + } else if (m_xml.name().compare("Data") == 0) { iconData = readBinary(); iconSet = true; - } else if (m_xml.name() == "Name") { + } else if (m_xml.name().compare("Name") == 0) { name = readString(); - } else if (m_xml.name() == "LastModificationTime") { + } else if (m_xml.name().compare("LastModificationTime") == 0) { lastModified = readDateTime(); } else { skipCurrentElement(); @@ -383,10 +385,10 @@ void KdbxXmlReader::parseIcon() void KdbxXmlReader::parseBinaries() { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Binaries"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("Binaries") == 0); while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() != "Binary") { + if (m_xml.name().compare("Binary") != 0) { skipCurrentElement(); continue; } @@ -405,10 +407,10 @@ void KdbxXmlReader::parseBinaries() void KdbxXmlReader::parseCustomData(CustomData* customData) { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "CustomData"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("CustomData") == 0); while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "Item") { + if (m_xml.name().compare("Item") == 0) { parseCustomDataItem(customData); continue; } @@ -418,7 +420,7 @@ void KdbxXmlReader::parseCustomData(CustomData* customData) void KdbxXmlReader::parseCustomDataItem(CustomData* customData) { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Item"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("Item") == 0); QString key; CustomData::CustomDataItem item; @@ -426,13 +428,13 @@ void KdbxXmlReader::parseCustomDataItem(CustomData* customData) bool valueSet = false; while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "Key") { + if (m_xml.name().compare("Key") == 0) { key = readString(); keySet = true; - } else if (m_xml.name() == "Value") { + } else if (m_xml.name().compare("Value") == 0) { item.value = readString(); valueSet = true; - } else if (m_xml.name() == "LastModificationTime") { + } else if (m_xml.name().compare("LastModificationTime") == 0) { item.lastModified = readDateTime(); } else { skipCurrentElement(); @@ -449,13 +451,13 @@ void KdbxXmlReader::parseCustomDataItem(CustomData* customData) bool KdbxXmlReader::parseRoot() { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Root"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("Root") == 0); bool groupElementFound = false; bool groupParsedSuccessfully = false; while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "Group") { + if (m_xml.name().compare("Group") == 0) { if (groupElementFound) { groupParsedSuccessfully = false; raiseError(tr("Multiple group elements")); @@ -471,7 +473,7 @@ bool KdbxXmlReader::parseRoot() } groupElementFound = true; - } else if (m_xml.name() == "DeletedObjects") { + } else if (m_xml.name().compare("DeletedObjects") == 0){ parseDeletedObjects(); } else { skipCurrentElement(); @@ -483,14 +485,14 @@ bool KdbxXmlReader::parseRoot() Group* KdbxXmlReader::parseGroup() { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Group"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("Group") == 0); auto group = new Group(); group->setUpdateTimeinfo(false); QList children; QList entries; while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "UUID") { + if (m_xml.name().compare("UUID") == 0) { QUuid uuid = readUuid(); if (uuid.isNull()) { if (m_strictMode) { @@ -503,19 +505,19 @@ Group* KdbxXmlReader::parseGroup() } continue; } - if (m_xml.name() == "Name") { + if (m_xml.name().compare("Name") == 0) { group->setName(readString()); continue; } - if (m_xml.name() == "Notes") { + if (m_xml.name().compare("Notes") == 0) { group->setNotes(readString()); continue; } - if (m_xml.name() == "Tags") { + if (m_xml.name().compare("Tags") == 0) { group->setTags(readString()); continue; } - if (m_xml.name() == "IconID") { + if (m_xml.name().compare("IconID") == 0) { int iconId = readNumber(); if (iconId < 0) { if (m_strictMode) { @@ -527,26 +529,26 @@ Group* KdbxXmlReader::parseGroup() group->setIcon(iconId); continue; } - if (m_xml.name() == "CustomIconUUID") { + if (m_xml.name().compare("CustomIconUUID") == 0) { QUuid uuid = readUuid(); if (!uuid.isNull()) { group->setIcon(uuid); } continue; } - if (m_xml.name() == "Times") { + if (m_xml.name().compare("Times") == 0) { group->setTimeInfo(parseTimes()); continue; } - if (m_xml.name() == "IsExpanded") { + if (m_xml.name().compare("IsExpanded") == 0) { group->setExpanded(readBool()); continue; } - if (m_xml.name() == "DefaultAutoTypeSequence") { + if (m_xml.name().compare("DefaultAutoTypeSequence") == 0) { group->setDefaultAutoTypeSequence(readString()); continue; } - if (m_xml.name() == "EnableAutoType") { + if (m_xml.name().compare("EnableAutoType") == 0) { QString str = readString(); if (str.compare("null", Qt::CaseInsensitive) == 0) { @@ -560,7 +562,7 @@ Group* KdbxXmlReader::parseGroup() } continue; } - if (m_xml.name() == "EnableSearching") { + if (m_xml.name().compare("EnableSearching") == 0) { QString str = readString(); if (str.compare("null", Qt::CaseInsensitive) == 0) { @@ -574,29 +576,29 @@ Group* KdbxXmlReader::parseGroup() } continue; } - if (m_xml.name() == "LastTopVisibleEntry") { + if (m_xml.name().compare("LastTopVisibleEntry") == 0) { group->setLastTopVisibleEntry(getEntry(readUuid())); continue; } - if (m_xml.name() == "Group") { + if (m_xml.name().compare("Group") == 0) { Group* newGroup = parseGroup(); if (newGroup) { children.append(newGroup); } continue; } - if (m_xml.name() == "Entry") { + if (m_xml.name().compare("Entry") == 0) { Entry* newEntry = parseEntry(false); if (newEntry) { entries.append(newEntry); } continue; } - if (m_xml.name() == "CustomData") { + if (m_xml.name().compare("CustomData") == 0) { parseCustomData(group->customData()); continue; } - if (m_xml.name() == "PreviousParentGroup") { + if (m_xml.name().compare("PreviousParentGroup") == 0) { group->setPreviousParentGroupUuid(readUuid()); continue; } @@ -631,10 +633,10 @@ Group* KdbxXmlReader::parseGroup() void KdbxXmlReader::parseDeletedObjects() { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "DeletedObjects"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("DeletedObjects") == 0); while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "DeletedObject") { + if (m_xml.name().compare("DeletedObject") == 0) { parseDeletedObject(); } else { skipCurrentElement(); @@ -644,12 +646,12 @@ void KdbxXmlReader::parseDeletedObjects() void KdbxXmlReader::parseDeletedObject() { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "DeletedObject"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("DeletedObject") == 0); DeletedObject delObj{{}, {}}; while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "UUID") { + if (m_xml.name().compare("UUID") == 0) { QUuid uuid = readUuid(); if (uuid.isNull()) { if (m_strictMode) { @@ -661,7 +663,7 @@ void KdbxXmlReader::parseDeletedObject() delObj.uuid = uuid; continue; } - if (m_xml.name() == "DeletionTime") { + if (m_xml.name().compare("DeletionTime") == 0) { delObj.deletionTime = readDateTime(); continue; } @@ -680,7 +682,7 @@ void KdbxXmlReader::parseDeletedObject() Entry* KdbxXmlReader::parseEntry(bool history) { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Entry"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("Entry") == 0); auto entry = new Entry(); entry->setUpdateTimeinfo(false); @@ -688,7 +690,7 @@ Entry* KdbxXmlReader::parseEntry(bool history) QList binaryRefs; while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "UUID") { + if (m_xml.name().compare("UUID") == 0) { QUuid uuid = readUuid(); if (uuid.isNull()) { if (m_strictMode) { @@ -701,7 +703,7 @@ Entry* KdbxXmlReader::parseEntry(bool history) } continue; } - if (m_xml.name() == "IconID") { + if (m_xml.name().compare("IconID") == 0) { int iconId = readNumber(); if (iconId < 0) { if (m_strictMode) { @@ -712,53 +714,53 @@ Entry* KdbxXmlReader::parseEntry(bool history) entry->setIcon(iconId); continue; } - if (m_xml.name() == "CustomIconUUID") { + if (m_xml.name().compare("CustomIconUUID") == 0) { QUuid uuid = readUuid(); if (!uuid.isNull()) { entry->setIcon(uuid); } continue; } - if (m_xml.name() == "ForegroundColor") { + if (m_xml.name().compare("ForegroundColor") == 0) { entry->setForegroundColor(readColor()); continue; } - if (m_xml.name() == "BackgroundColor") { + if (m_xml.name().compare("BackgroundColor") == 0) { entry->setBackgroundColor(readColor()); continue; } - if (m_xml.name() == "OverrideURL") { + if (m_xml.name().compare("OverrideURL") == 0) { entry->setOverrideUrl(readString()); continue; } - if (m_xml.name() == "Tags") { + if (m_xml.name().compare("Tags") == 0) { entry->setTags(readString()); continue; } - if (m_xml.name() == "Times") { + if (m_xml.name().compare("Times") == 0) { entry->setTimeInfo(parseTimes()); continue; } - if (m_xml.name() == "String") { + if (m_xml.name().compare("String") == 0) { parseEntryString(entry); continue; } - if (m_xml.name() == "QualityCheck") { + if (m_xml.name().compare("QualityCheck") == 0) { entry->setExcludeFromReports(!readBool()); continue; } - if (m_xml.name() == "Binary") { + if (m_xml.name().compare("Binary") == 0) { QPair ref = parseEntryBinary(entry); if (!ref.first.isEmpty() && !ref.second.isEmpty()) { binaryRefs.append(ref); } continue; } - if (m_xml.name() == "AutoType") { + if (m_xml.name().compare("AutoType") == 0) { parseAutoType(entry); continue; } - if (m_xml.name() == "History") { + if (m_xml.name().compare("History") == 0) { if (history) { raiseError(tr("History element in history entry")); } else { @@ -766,7 +768,7 @@ Entry* KdbxXmlReader::parseEntry(bool history) } continue; } - if (m_xml.name() == "CustomData") { + if (m_xml.name().compare("CustomData") == 0) { parseCustomData(entry->customData()); // Upgrade pre-KDBX-4.1 password report exclude flag @@ -777,7 +779,7 @@ Entry* KdbxXmlReader::parseEntry(bool history) } continue; } - if (m_xml.name() == "PreviousParentGroup") { + if (m_xml.name().compare("PreviousParentGroup") == 0) { entry->setPreviousParentGroupUuid(readUuid()); continue; } @@ -824,7 +826,7 @@ Entry* KdbxXmlReader::parseEntry(bool history) void KdbxXmlReader::parseEntryString(Entry* entry) { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "String"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("String") == 0); QString key; QString value; @@ -833,13 +835,13 @@ void KdbxXmlReader::parseEntryString(Entry* entry) bool valueSet = false; while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "Key") { + if (m_xml.name().compare("Key") == 0) { key = readString(); keySet = true; continue; } - if (m_xml.name() == "Value") { + if (m_xml.name().compare("Value") == 0) { QXmlStreamAttributes attr = m_xml.attributes(); bool isProtected; bool protectInMemory; @@ -867,7 +869,7 @@ void KdbxXmlReader::parseEntryString(Entry* entry) QPair KdbxXmlReader::parseEntryBinary(Entry* entry) { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Binary"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("Binary") == 0); QPair poolRef; @@ -877,12 +879,12 @@ QPair KdbxXmlReader::parseEntryBinary(Entry* entry) bool valueSet = false; while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "Key") { + if (m_xml.name().compare("Key") == 0) { key = readString(); keySet = true; continue; } - if (m_xml.name() == "Value") { + if (m_xml.name().compare("Value") == 0) { QXmlStreamAttributes attr = m_xml.attributes(); if (attr.hasAttribute("Ref")) { @@ -916,16 +918,16 @@ QPair KdbxXmlReader::parseEntryBinary(Entry* entry) void KdbxXmlReader::parseAutoType(Entry* entry) { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "AutoType"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("AutoType") == 0); while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "Enabled") { + if (m_xml.name().compare("Enabled") == 0) { entry->setAutoTypeEnabled(readBool()); - } else if (m_xml.name() == "DataTransferObfuscation") { + } else if (m_xml.name().compare("DataTransferObfuscation") == 0) { entry->setAutoTypeObfuscation(readNumber()); - } else if (m_xml.name() == "DefaultSequence") { + } else if (m_xml.name().compare("DefaultSequence") == 0) { entry->setDefaultAutoTypeSequence(readString()); - } else if (m_xml.name() == "Association") { + } else if (m_xml.name().compare("Association") == 0) { parseAutoTypeAssoc(entry); } else { skipCurrentElement(); @@ -935,17 +937,17 @@ void KdbxXmlReader::parseAutoType(Entry* entry) void KdbxXmlReader::parseAutoTypeAssoc(Entry* entry) { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Association"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("Association") == 0); AutoTypeAssociations::Association assoc; bool windowSet = false; bool sequenceSet = false; while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "Window") { + if (m_xml.name().compare("Window") == 0) { assoc.window = readString(); windowSet = true; - } else if (m_xml.name() == "KeystrokeSequence") { + } else if (m_xml.name().compare("KeystrokeSequence") == 0) { assoc.sequence = readString(); sequenceSet = true; } else { @@ -962,12 +964,12 @@ void KdbxXmlReader::parseAutoTypeAssoc(Entry* entry) QList KdbxXmlReader::parseEntryHistory() { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "History"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("History") == 0); QList historyItems; while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "Entry") { + if (m_xml.name().compare("Entry") == 0) { historyItems.append(parseEntry(true)); } else { skipCurrentElement(); @@ -979,23 +981,23 @@ QList KdbxXmlReader::parseEntryHistory() TimeInfo KdbxXmlReader::parseTimes() { - Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Times"); + Q_ASSERT(m_xml.isStartElement() && m_xml.name().compare("Times") == 0); TimeInfo timeInfo; while (!m_xml.hasError() && m_xml.readNextStartElement()) { - if (m_xml.name() == "LastModificationTime") { + if (m_xml.name().compare("LastModificationTime") == 0) { timeInfo.setLastModificationTime(readDateTime()); - } else if (m_xml.name() == "CreationTime") { + } else if (m_xml.name().compare("CreationTime") == 0) { timeInfo.setCreationTime(readDateTime()); - } else if (m_xml.name() == "LastAccessTime") { + } else if (m_xml.name().compare("LastAccessTime") == 0) { timeInfo.setLastAccessTime(readDateTime()); - } else if (m_xml.name() == "ExpiryTime") { + } else if (m_xml.name().compare("ExpiryTime") == 0) { timeInfo.setExpiryTime(readDateTime()); - } else if (m_xml.name() == "Expires") { + } else if (m_xml.name().compare("Expires") == 0) { timeInfo.setExpires(readBool()); - } else if (m_xml.name() == "UsageCount") { + } else if (m_xml.name().compare("UsageCount") == 0) { timeInfo.setUsageCount(readNumber()); - } else if (m_xml.name() == "LocationChanged") { + } else if (m_xml.name().compare("LocationChanged") == 0) { timeInfo.setLocationChanged(readDateTime()); } else { skipCurrentElement(); diff --git a/src/format/KdbxXmlReader.h b/src/format/KdbxXmlReader.h index 1b6305eeaf..c7aef522c3 100644 --- a/src/format/KdbxXmlReader.h +++ b/src/format/KdbxXmlReader.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * * 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 @@ -23,6 +23,7 @@ #include #include +#include #include class QIODevice; @@ -93,7 +94,7 @@ class KdbxXmlReader virtual Group* getGroup(const QUuid& uuid); virtual Entry* getEntry(const QUuid& uuid); - virtual bool isTrueValue(const QStringRef& value); + virtual bool isTrueValue(const QStringView& value); virtual void raiseError(const QString& errorMessage); const quint32 m_kdbxVersion; diff --git a/src/format/KdbxXmlWriter.cpp b/src/format/KdbxXmlWriter.cpp index 35ed5ffdb3..f22c5a90d6 100644 --- a/src/format/KdbxXmlWriter.cpp +++ b/src/format/KdbxXmlWriter.cpp @@ -44,7 +44,6 @@ void KdbxXmlWriter::writeDatabase(QIODevice* device, m_xml.setAutoFormatting(true); m_xml.setAutoFormattingIndent(-1); // 1 tab - m_xml.setCodec("UTF-8"); generateIdMap(); diff --git a/src/format/KeePass1Reader.cpp b/src/format/KeePass1Reader.cpp index 144e1b4732..a4fc61b2ec 100644 --- a/src/format/KeePass1Reader.cpp +++ b/src/format/KeePass1Reader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Felix Geyer + * Copyright (C) 2023 Felix Geyer * * 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 @@ -18,6 +18,7 @@ #include "KeePass1Reader.h" #include +#include #include #include "core/Endian.h" @@ -696,8 +697,8 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream) void KeePass1Reader::parseNotes(const QString& rawNotes, Entry* entry) { - QRegExp sequenceRegexp("Auto-Type(?:-(\\d+))?: (.+)", Qt::CaseInsensitive, QRegExp::RegExp2); - QRegExp windowRegexp("Auto-Type-Window(?:-(\\d+))?: (.+)", Qt::CaseInsensitive, QRegExp::RegExp2); + QRegularExpression sequenceRegexp("Auto-Type(?:-(\\d+))?: (.+)", QRegularExpression::CaseInsensitiveOption); + QRegularExpression windowRegexp("Auto-Type-Window(?:-(\\d+))?: (.+)", QRegularExpression::CaseInsensitiveOption); QHash sequences; QMap windows; @@ -708,23 +709,25 @@ void KeePass1Reader::parseNotes(const QString& rawNotes, Entry* entry) for (QString line : rawNotesLines) { line.remove("\r"); - if (sequenceRegexp.exactMatch(line)) { - if (sequenceRegexp.cap(1).isEmpty()) { - entry->setDefaultAutoTypeSequence(sequenceRegexp.cap(2)); + auto sequenceMatch = sequenceRegexp.match(line); + auto windowMatch = windowRegexp.match(line); + if (sequenceMatch.hasMatch()) { + if (sequenceMatch.captured(1).isEmpty()) { + entry->setDefaultAutoTypeSequence(sequenceMatch.captured(2)); } else { - sequences[sequenceRegexp.cap(1).toInt()] = sequenceRegexp.cap(2); + sequences[sequenceMatch.captured(1).toInt()] = sequenceMatch.captured(2); } lastLineAutoType = true; - } else if (windowRegexp.exactMatch(line)) { + } else if (windowMatch.hasMatch()) { int nr; - if (windowRegexp.cap(1).isEmpty()) { + if (windowMatch.captured(1).isEmpty()) { nr = -1; // special number that matches no other sequence } else { - nr = windowRegexp.cap(1).toInt(); + nr = windowMatch.captured(1).toInt(); } - windows[nr].append(windowRegexp.cap(2)); + windows[nr].append(windowMatch.captured(2)); lastLineAutoType = true; } else { diff --git a/src/format/OpVaultReader.cpp b/src/format/OpVaultReader.cpp index 44f0d85eca..5cae9a0f98 100644 --- a/src/format/OpVaultReader.cpp +++ b/src/format/OpVaultReader.cpp @@ -177,9 +177,9 @@ bool OpVaultReader::processProfileJson(QJsonObject& profileJson, const QString& } auto rootGroupTime = rootGroup->timeInfo(); auto createdAt = static_cast(profileJson["createdAt"].toInt()); - rootGroupTime.setCreationTime(QDateTime::fromTime_t(createdAt, Qt::UTC)); + rootGroupTime.setCreationTime(QDateTime::fromSecsSinceEpoch(createdAt, Qt::UTC)); auto updatedAt = static_cast(profileJson["updatedAt"].toInt()); - rootGroupTime.setLastModificationTime(QDateTime::fromTime_t(updatedAt, Qt::UTC)); + rootGroupTime.setLastModificationTime(QDateTime::fromSecsSinceEpoch(updatedAt, Qt::UTC)); rootGroup->setUuid(Tools::hexToUuid(profileJson["uuid"].toString())); const auto derivedKeys = deriveKeysFromPassPhrase(salt, password, iterations); @@ -266,12 +266,12 @@ bool OpVaultReader::processFolderJson(QJsonObject& foldersJson, Group* rootGroup bool timeInfoOk = false; if (folder.contains("created")) { auto createdTime = static_cast(folder["created"].toInt()); - ti.setCreationTime(QDateTime::fromTime_t(createdTime, Qt::UTC)); + ti.setCreationTime(QDateTime::fromSecsSinceEpoch(createdTime, Qt::UTC)); timeInfoOk = true; } if (folder.contains("updated")) { auto updateTime = static_cast(folder["updated"].toInt()); - ti.setLastModificationTime(QDateTime::fromTime_t(updateTime, Qt::UTC)); + ti.setLastModificationTime(QDateTime::fromSecsSinceEpoch(updateTime, Qt::UTC)); timeInfoOk = true; } // "tx" is modified by sync, not by user; maybe a custom attribute? diff --git a/src/format/OpVaultReaderBandEntry.cpp b/src/format/OpVaultReaderBandEntry.cpp index 3a9774b68a..3cfa0c5e09 100644 --- a/src/format/OpVaultReaderBandEntry.cpp +++ b/src/format/OpVaultReaderBandEntry.cpp @@ -61,7 +61,7 @@ bool OpVaultReader::decryptBandEntry(const QJsonObject& bandEntry, QByteArray kBA = QByteArray::fromBase64(entKStr.toUtf8()); const int wantKsize = 16 + 32 + 32 + 32; if (kBA.size() != wantKsize) { - qCritical("Malformed \"k\" size; expected %d got %d\n", wantKsize, kBA.size()); + qCritical("Malformed \"k\" size; expected %d got %" PRIdQPTRDIFF "\n", wantKsize, kBA.size()); return false; } @@ -150,12 +150,12 @@ Entry* OpVaultReader::processBandEntry(const QJsonObject& bandEntry, const QDir& bool timeInfoOk = false; if (bandEntry.contains("created")) { auto createdTime = static_cast(bandEntry["created"].toInt()); - ti.setCreationTime(QDateTime::fromTime_t(createdTime, Qt::UTC)); + ti.setCreationTime(QDateTime::fromSecsSinceEpoch(createdTime, Qt::UTC)); timeInfoOk = true; } if (bandEntry.contains("updated")) { auto updateTime = static_cast(bandEntry["updated"].toInt()); - ti.setLastModificationTime(QDateTime::fromTime_t(updateTime, Qt::UTC)); + ti.setLastModificationTime(QDateTime::fromSecsSinceEpoch(updateTime, Qt::UTC)); timeInfoOk = true; } // "tx" is modified by sync, not by user; maybe a custom attribute? diff --git a/src/format/OpVaultReaderSections.cpp b/src/format/OpVaultReaderSections.cpp index 9a50f36246..b0de85cbdd 100644 --- a/src/format/OpVaultReaderSections.cpp +++ b/src/format/OpVaultReaderSections.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * * 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 @@ -37,9 +37,9 @@ namespace date = QDateTime::fromString(dateValue, "yyyyMM"); date.setTimeSpec(Qt::UTC); } else if (value.isString()) { - date = QDateTime::fromTime_t(value.toString().toUInt(), Qt::UTC); + date = QDateTime::fromSecsSinceEpoch(value.toString().toUInt(), Qt::UTC); } else { - date = QDateTime::fromTime_t(value.toInt(), Qt::UTC); + date = QDateTime::fromSecsSinceEpoch(value.toInt(), Qt::UTC); } return date; } diff --git a/src/gui/Clipboard.cpp b/src/gui/Clipboard.cpp index f0fbf01ab1..960e7946b6 100644 --- a/src/gui/Clipboard.cpp +++ b/src/gui/Clipboard.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * Copyright (C) 2012 Felix Geyer * * This program is free software: you can redistribute it and/or modify @@ -22,12 +22,13 @@ #include #include #include +#include #include "core/Config.h" Clipboard* Clipboard::m_instance(nullptr); #ifdef Q_OS_MACOS -QPointer Clipboard::m_pasteboard(nullptr); +//QPointer Clipboard::m_pasteboard(nullptr); #endif Clipboard::Clipboard(QObject* parent) @@ -35,9 +36,9 @@ Clipboard::Clipboard(QObject* parent) , m_timer(new QTimer(this)) { #ifdef Q_OS_MACOS - if (!m_pasteboard) { - m_pasteboard = new MacPasteboard(); - } + /*if (!m_pasteboard) { + m_pasteboard = new QUtiMimeConverter(); + }*/ #endif connect(m_timer, SIGNAL(timeout()), SLOT(countdownTick())); connect(qApp, SIGNAL(aboutToQuit()), SLOT(clearCopiedText())); diff --git a/src/gui/Clipboard.h b/src/gui/Clipboard.h index 4dc2f31277..f0376dff7a 100644 --- a/src/gui/Clipboard.h +++ b/src/gui/Clipboard.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * Copyright (C) 2012 Felix Geyer * * This program is free software: you can redistribute it and/or modify @@ -22,8 +22,8 @@ #include #include #ifdef Q_OS_MACOS -#include "core/MacPasteboard.h" #include +#include #endif class QTimer; @@ -60,7 +60,7 @@ private slots: #ifdef Q_OS_MACOS // This object lives for the whole program lifetime and we cannot delete it on exit, // so ignore leak warnings. See https://bugreports.qt.io/browse/QTBUG-54832 - static QPointer m_pasteboard; + static QPointer m_pasteboard; #endif QString m_lastCopied; }; diff --git a/src/gui/DatabaseIcons.h b/src/gui/DatabaseIcons.h index 38d1590c79..e39eacfac5 100644 --- a/src/gui/DatabaseIcons.h +++ b/src/gui/DatabaseIcons.h @@ -1,4 +1,5 @@ /* + * Copyright (C) 2023 KeePassXC Team * Copyright (C) 2010 Felix Geyer * * This program is free software: you can redistribute it and/or modify @@ -18,7 +19,9 @@ #ifndef KEEPASSX_DATABASEICONS_H #define KEEPASSX_DATABASEICONS_H +#include #include +#include enum IconSize { diff --git a/src/gui/DatabaseOpenDialog.cpp b/src/gui/DatabaseOpenDialog.cpp index c4a52e2a0c..cfbf026f02 100644 --- a/src/gui/DatabaseOpenDialog.cpp +++ b/src/gui/DatabaseOpenDialog.cpp @@ -69,13 +69,13 @@ DatabaseOpenDialog::DatabaseOpenDialog(QWidget* parent) auto* shortcut = new QShortcut(Qt::CTRL + Qt::Key_PageUp, this); shortcut->setContext(Qt::WidgetWithChildrenShortcut); connect(shortcut, &QShortcut::activated, this, [this]() { selectTabOffset(-1); }); - shortcut = new QShortcut(dbTabModifier + Qt::SHIFT + Qt::Key_Tab, this); + shortcut = new QShortcut(dbTabModifier | Qt::SHIFT | Qt::Key_Tab, this); shortcut->setContext(Qt::WidgetWithChildrenShortcut); connect(shortcut, &QShortcut::activated, this, [this]() { selectTabOffset(-1); }); - shortcut = new QShortcut(Qt::CTRL + Qt::Key_PageDown, this); + shortcut = new QShortcut(Qt::CTRL | Qt::Key_PageDown, this); shortcut->setContext(Qt::WidgetWithChildrenShortcut); connect(shortcut, &QShortcut::activated, this, [this]() { selectTabOffset(1); }); - shortcut = new QShortcut(dbTabModifier + Qt::Key_Tab, this); + shortcut = new QShortcut(dbTabModifier | Qt::Key_Tab, this); shortcut->setContext(Qt::WidgetWithChildrenShortcut); connect(shortcut, &QShortcut::activated, this, [this]() { selectTabOffset(1); }); } @@ -142,7 +142,7 @@ void DatabaseOpenDialog::tabChanged(int index) setTarget(dbWidget, dbWidget->database()->filePath()); } else { // if these list sizes don't match, there's a bug somewhere nearby - qWarning("DatabaseOpenDialog: mismatch between tab count %d and DB count %d", + qWarning("DatabaseOpenDialog: mismatch between tab count %d and DB count %" PRIdQSIZETYPE "", m_tabBar->count(), m_tabDbWidgets.count()); } diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 3ba14f80c6..46e602e84e 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -118,7 +118,7 @@ DatabaseWidget::DatabaseWidget(QSharedPointer db, QWidget* parent) tagsWidget->setLayout(tagsLayout); tagsLayout->addWidget(tagsTitle); tagsLayout->addWidget(m_tagView); - tagsLayout->setMargin(0); + tagsLayout->setContentsMargins(0, 0, 0, 0); m_groupSplitter->setOrientation(Qt::Vertical); m_groupSplitter->setChildrenCollapsible(true); @@ -129,7 +129,7 @@ DatabaseWidget::DatabaseWidget(QSharedPointer db, QWidget* parent) auto rightHandSideWidget = new QWidget(m_mainSplitter); auto rightHandSideVBox = new QVBoxLayout(); - rightHandSideVBox->setMargin(0); + rightHandSideVBox->setContentsMargins(0, 0, 0, 0); rightHandSideVBox->addWidget(m_searchingLabel); #ifdef WITH_XC_KEESHARE rightHandSideVBox->addWidget(m_shareLabel); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index a41f631e4a..3bb339d47d 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -262,35 +262,35 @@ MainWindow::MainWindow() connect(m_inactivityTimer, SIGNAL(inactivityDetected()), this, SLOT(lockDatabasesAfterInactivity())); applySettingsChanges(); - m_ui->actionDatabaseNew->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N); - setShortcut(m_ui->actionDatabaseOpen, QKeySequence::Open, Qt::CTRL + Qt::Key_O); - setShortcut(m_ui->actionDatabaseSave, QKeySequence::Save, Qt::CTRL + Qt::Key_S); - setShortcut(m_ui->actionDatabaseSaveAs, QKeySequence::SaveAs, Qt::CTRL + Qt::SHIFT + Qt::Key_S); + m_ui->actionDatabaseNew->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_N); + setShortcut(m_ui->actionDatabaseOpen, QKeySequence::Open, Qt::CTRL | Qt::Key_O); + setShortcut(m_ui->actionDatabaseSave, QKeySequence::Save, Qt::CTRL | Qt::Key_S); + setShortcut(m_ui->actionDatabaseSaveAs, QKeySequence::SaveAs, Qt::CTRL | Qt::SHIFT | Qt::Key_S); setShortcut(m_ui->actionDatabaseClose, QKeySequence::Close, Qt::CTRL + Qt::Key_W); - m_ui->actionDatabaseSettings->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Comma); - m_ui->actionReports->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_R); - setShortcut(m_ui->actionSettings, QKeySequence::Preferences, Qt::CTRL + Qt::Key_Comma); - m_ui->actionLockDatabase->setShortcut(Qt::CTRL + Qt::Key_L); - m_ui->actionLockAllDatabases->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_L); - setShortcut(m_ui->actionQuit, QKeySequence::Quit, Qt::CTRL + Qt::Key_Q); - setShortcut(m_ui->actionEntryNew, QKeySequence::New, Qt::CTRL + Qt::Key_N); - m_ui->actionEntryEdit->setShortcut(Qt::CTRL + Qt::Key_E); - m_ui->actionEntryDelete->setShortcut(Qt::CTRL + Qt::Key_D); + m_ui->actionDatabaseSettings->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_Comma); + m_ui->actionReports->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_R); + setShortcut(m_ui->actionSettings, QKeySequence::Preferences, Qt::CTRL | Qt::Key_Comma); + m_ui->actionLockDatabase->setShortcut(Qt::CTRL | Qt::Key_L); + m_ui->actionLockAllDatabases->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_L); + setShortcut(m_ui->actionQuit, QKeySequence::Quit, Qt::CTRL | Qt::Key_Q); + setShortcut(m_ui->actionEntryNew, QKeySequence::New, Qt::CTRL | Qt::Key_N); + m_ui->actionEntryEdit->setShortcut(Qt::CTRL | Qt::Key_E); + m_ui->actionEntryDelete->setShortcut(Qt::CTRL | Qt::Key_D); m_ui->actionEntryDelete->setShortcut(Qt::Key_Delete); - m_ui->actionEntryClone->setShortcut(Qt::CTRL + Qt::Key_K); - m_ui->actionEntryTotp->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_T); - m_ui->actionEntryDownloadIcon->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_D); - m_ui->actionEntryCopyTotp->setShortcut(Qt::CTRL + Qt::Key_T); - m_ui->actionEntryCopyPasswordTotp->setShortcut(Qt::CTRL + Qt::Key_Y); - m_ui->actionEntryMoveUp->setShortcut(Qt::CTRL + Qt::ALT + Qt::Key_Up); - m_ui->actionEntryMoveDown->setShortcut(Qt::CTRL + Qt::ALT + Qt::Key_Down); - m_ui->actionEntryCopyUsername->setShortcut(Qt::CTRL + Qt::Key_B); - m_ui->actionEntryCopyPassword->setShortcut(Qt::CTRL + Qt::Key_C); - m_ui->actionEntryCopyTitle->setShortcut(Qt::CTRL + Qt::Key_I); - m_ui->actionEntryAutoTypeSequence->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_V); - m_ui->actionEntryOpenUrl->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_U); - m_ui->actionEntryCopyURL->setShortcut(Qt::CTRL + Qt::Key_U); - m_ui->actionEntryRestore->setShortcut(Qt::CTRL + Qt::Key_R); + m_ui->actionEntryClone->setShortcut(Qt::CTRL | Qt::Key_K); + m_ui->actionEntryTotp->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_T); + m_ui->actionEntryDownloadIcon->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_D); + m_ui->actionEntryCopyTotp->setShortcut(Qt::CTRL | Qt::Key_T); + m_ui->actionEntryCopyPasswordTotp->setShortcut(Qt::CTRL | Qt::Key_Y); + m_ui->actionEntryMoveUp->setShortcut(Qt::CTRL | Qt::ALT | Qt::Key_Up); + m_ui->actionEntryMoveDown->setShortcut(Qt::CTRL | Qt::ALT | Qt::Key_Down); + m_ui->actionEntryCopyUsername->setShortcut(Qt::CTRL | Qt::Key_B); + m_ui->actionEntryCopyPassword->setShortcut(Qt::CTRL | Qt::Key_C); + m_ui->actionEntryCopyTitle->setShortcut(Qt::CTRL | Qt::Key_I); + m_ui->actionEntryAutoTypeSequence->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_V); + m_ui->actionEntryOpenUrl->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_U); + m_ui->actionEntryCopyURL->setShortcut(Qt::CTRL | Qt::Key_U); + m_ui->actionEntryRestore->setShortcut(Qt::CTRL | Qt::Key_R); // Prevent conflicts with global Mac shortcuts (force Control on all platforms) #ifdef Q_OS_MAC @@ -298,8 +298,8 @@ MainWindow::MainWindow() #else auto modifier = Qt::CTRL; #endif - m_ui->actionEntryAddToAgent->setShortcut(modifier + Qt::Key_H); - m_ui->actionEntryRemoveFromAgent->setShortcut(modifier + Qt::SHIFT + Qt::Key_H); + m_ui->actionEntryAddToAgent->setShortcut(modifier | Qt::Key_H); + m_ui->actionEntryRemoveFromAgent->setShortcut(modifier | Qt::SHIFT | Qt::Key_H); #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // Qt 5.10 introduced a new "feature" to hide shortcuts in context menus @@ -335,18 +335,18 @@ MainWindow::MainWindow() connect(m_ui->menuGroups, SIGNAL(aboutToHide()), SLOT(releaseContextFocusLock())); // Control window state - new QShortcut(Qt::CTRL + Qt::Key_M, this, SLOT(minimizeOrHide())); - new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_M, this, SLOT(hideWindow())); + new QShortcut(Qt::CTRL | Qt::Key_M, this, SLOT(minimizeOrHide())); + new QShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_M, this, SLOT(hideWindow())); // Control database tabs // Ctrl+Tab is broken on Mac, so use Alt (i.e. the Option key) - https://bugreports.qt.io/browse/QTBUG-8596 auto dbTabModifier2 = Qt::CTRL; #ifdef Q_OS_MACOS dbTabModifier2 = Qt::ALT; #endif - new QShortcut(dbTabModifier2 + Qt::Key_Tab, this, SLOT(selectNextDatabaseTab())); - new QShortcut(Qt::CTRL + Qt::Key_PageDown, this, SLOT(selectNextDatabaseTab())); - new QShortcut(dbTabModifier2 + Qt::SHIFT + Qt::Key_Tab, this, SLOT(selectPreviousDatabaseTab())); - new QShortcut(Qt::CTRL + Qt::Key_PageUp, this, SLOT(selectPreviousDatabaseTab())); + new QShortcut(dbTabModifier2 | Qt::Key_Tab, this, SLOT(selectNextDatabaseTab())); + new QShortcut(Qt::CTRL | Qt::Key_PageDown, this, SLOT(selectNextDatabaseTab())); + new QShortcut(dbTabModifier2 | Qt::SHIFT | Qt::Key_Tab, this, SLOT(selectPreviousDatabaseTab())); + new QShortcut(Qt::CTRL | Qt::Key_PageUp, this, SLOT(selectPreviousDatabaseTab())); // Tab selection by number, Windows uses Ctrl, macOS uses Command, // and Linux uses Alt to emulate a browser-like experience @@ -354,23 +354,23 @@ MainWindow::MainWindow() #ifdef Q_OS_LINUX dbTabModifier = Qt::ALT; #endif - auto shortcut = new QShortcut(dbTabModifier + Qt::Key_1, this); + auto shortcut = new QShortcut(dbTabModifier | Qt::Key_1, this); connect(shortcut, &QShortcut::activated, [this]() { selectDatabaseTab(0); }); - shortcut = new QShortcut(dbTabModifier + Qt::Key_2, this); + shortcut = new QShortcut(dbTabModifier | Qt::Key_2, this); connect(shortcut, &QShortcut::activated, [this]() { selectDatabaseTab(1); }); - shortcut = new QShortcut(dbTabModifier + Qt::Key_3, this); + shortcut = new QShortcut(dbTabModifier | Qt::Key_3, this); connect(shortcut, &QShortcut::activated, [this]() { selectDatabaseTab(2); }); - shortcut = new QShortcut(dbTabModifier + Qt::Key_4, this); + shortcut = new QShortcut(dbTabModifier | Qt::Key_4, this); connect(shortcut, &QShortcut::activated, [this]() { selectDatabaseTab(3); }); - shortcut = new QShortcut(dbTabModifier + Qt::Key_5, this); + shortcut = new QShortcut(dbTabModifier | Qt::Key_5, this); connect(shortcut, &QShortcut::activated, [this]() { selectDatabaseTab(4); }); - shortcut = new QShortcut(dbTabModifier + Qt::Key_6, this); + shortcut = new QShortcut(dbTabModifier | Qt::Key_6, this); connect(shortcut, &QShortcut::activated, [this]() { selectDatabaseTab(5); }); - shortcut = new QShortcut(dbTabModifier + Qt::Key_7, this); + shortcut = new QShortcut(dbTabModifier | Qt::Key_7, this); connect(shortcut, &QShortcut::activated, [this]() { selectDatabaseTab(6); }); - shortcut = new QShortcut(dbTabModifier + Qt::Key_8, this); + shortcut = new QShortcut(dbTabModifier | Qt::Key_8, this); connect(shortcut, &QShortcut::activated, [this]() { selectDatabaseTab(7); }); - shortcut = new QShortcut(dbTabModifier + Qt::Key_9, this); + shortcut = new QShortcut(dbTabModifier | Qt::Key_9, this); connect(shortcut, &QShortcut::activated, [this]() { selectDatabaseTab(m_ui->tabWidget->count() - 1); }); m_ui->actionDatabaseNew->setIcon(icons()->icon("document-new")); diff --git a/src/gui/dbsettings/DatabaseSettingsWidgetDatabaseKey.cpp b/src/gui/dbsettings/DatabaseSettingsWidgetDatabaseKey.cpp index bac749979c..cdf83f06c6 100644 --- a/src/gui/dbsettings/DatabaseSettingsWidgetDatabaseKey.cpp +++ b/src/gui/dbsettings/DatabaseSettingsWidgetDatabaseKey.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * * 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 @@ -52,7 +52,7 @@ DatabaseSettingsWidgetDatabaseKey::DatabaseSettingsWidgetDatabaseKey(QWidget* pa vbox->addWidget(m_additionalKeyOptions); vbox->setSizeConstraint(QLayout::SetMinimumSize); m_additionalKeyOptions->setLayout(new QVBoxLayout()); - m_additionalKeyOptions->layout()->setMargin(0); + m_additionalKeyOptions->layout()->setContentsMargins(0, 0, 0, 0); m_additionalKeyOptions->layout()->addWidget(m_keyFileEditWidget); #ifdef WITH_XC_YUBIKEY m_additionalKeyOptions->layout()->addWidget(m_yubiKeyEditWidget); diff --git a/src/gui/entry/EntryModel.cpp b/src/gui/entry/EntryModel.cpp index f809e2b2a6..3f717b1b37 100644 --- a/src/gui/entry/EntryModel.cpp +++ b/src/gui/entry/EntryModel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Felix Geyer + * Copyright (C) 2023 Felix Geyer * * 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 @@ -18,6 +18,7 @@ #include "EntryModel.h" #include +#include #include #include diff --git a/src/gui/entry/EntryView.cpp b/src/gui/entry/EntryView.cpp index 7c5768ef4b..d248946bdb 100644 --- a/src/gui/entry/EntryView.cpp +++ b/src/gui/entry/EntryView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * Copyright (C) 2010 Felix Geyer * * This program is free software: you can redistribute it and/or modify @@ -19,13 +19,13 @@ #include "EntryView.h" #include +#include #include #include #include #include #include #include -#include #include #include #include diff --git a/src/gui/osutils/macutils/MacUtils.h b/src/gui/osutils/macutils/MacUtils.h index 1281aa0720..4204bdaddc 100644 --- a/src/gui/osutils/macutils/MacUtils.h +++ b/src/gui/osutils/macutils/MacUtils.h @@ -1,6 +1,6 @@ /* + * Copyright (C) 2023 KeePassXC Team * Copyright (C) 2012 Felix Geyer - * Copyright (C) 2017 KeePassXC Team * * 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 @@ -24,8 +24,11 @@ #include #include +#include #include #include +#include +#include #include class MacUtils : public OSUtilsBase diff --git a/src/gui/styles/base/BaseStyle.cpp b/src/gui/styles/base/BaseStyle.cpp index 824468b2db..1829f6bd56 100644 --- a/src/gui/styles/base/BaseStyle.cpp +++ b/src/gui/styles/base/BaseStyle.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * Copyright (C) 2019 Andrew Richards * * Derived from Phantomstyle and relicensed under the GPLv2 or v3. @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -523,7 +524,7 @@ namespace Phantom // generated changes. If that happens, change to use the definition of // `fastfragile_hash_qpalette` below, which is less likely to collide with an // arbitrarily numbered key but also does more work. -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0) // TODO: What to do here? x.u = x.u ^ (static_cast(p.currentColorGroup()) << (64 - 3)); return x.u; #else @@ -882,7 +883,7 @@ namespace Phantom { QRect ra = bar->rect; QRect rb = ra; - bool isHorizontal = bar->orientation != Qt::Vertical; + bool isHorizontal = bar->state == QStyle::State_Horizontal; bool isInverted = bar->invertedAppearance; bool isIndeterminate = bar->minimum == 0 && bar->maximum == 0; bool isForward = !isHorizontal || bar->direction != Qt::RightToLeft; @@ -2590,7 +2591,7 @@ void BaseStyle::drawControl(ControlElement element, QRect r = bar->rect.adjusted(2, 2, -2, -2); if (r.isEmpty() || !r.isValid()) break; - QSize textSize = option->fontMetrics.size(Qt::TextBypassShaping, bar->text); + QSize textSize = option->fontMetrics.size(0, bar->text); QRect textRect = QStyle::alignedRect(option->direction, Qt::AlignCenter, textSize, option->rect); textRect &= r; if (textRect.isEmpty()) @@ -2750,10 +2751,10 @@ void BaseStyle::drawControl(ControlElement element, } // Draw main text and mnemonic text - QStringRef s(&menuItem->text); + QStringView s(menuItem->text); if (!s.isEmpty()) { - QRect textRect = - Ph::menuItemTextRect(metrics, option->direction, itemRect, hasSubMenu, hasIcon, menuItem->tabWidth); + QRect textRect = Ph::menuItemTextRect( + metrics, option->direction, itemRect, hasSubMenu, hasIcon, menuItem->reservedShortcutWidth); int t = s.indexOf(QLatin1Char('\t')); int text_flags = Qt::AlignLeft | Qt::AlignTop | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; @@ -2824,14 +2825,14 @@ void BaseStyle::drawControl(ControlElement element, // Draw mnemonic text if (t >= 0) { - QRect mnemonicR = - Ph::menuItemMnemonicRect(metrics, option->direction, itemRect, hasSubMenu, menuItem->tabWidth); - const QStringRef textToDrawRef = s.mid(t + 1); + QRect mnemonicR = Ph::menuItemMnemonicRect( + metrics, option->direction, itemRect, hasSubMenu, menuItem->reservedShortcutWidth); + const auto textToDrawRef = QStringView{s}.mid(t + 1); const QString unsafeTextToDraw = QString::fromRawData(textToDrawRef.constData(), textToDrawRef.size()); painter->drawText(mnemonicR, text_flags, unsafeTextToDraw); s = s.left(t); } - const QStringRef textToDrawRef = s.left(t); + const auto textToDrawRef = QStringView{s}.left(t); const QString unsafeTextToDraw = QString::fromRawData(textToDrawRef.constData(), textToDrawRef.size()); painter->drawText(textRect, text_flags, unsafeTextToDraw); @@ -4151,7 +4152,7 @@ QSize BaseStyle::sizeFromContents(ContentsType type, bool nullIcon = hdr->icon.isNull(); int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, hdr, widget); int iconSize = nullIcon ? 0 : option->fontMetrics.height(); - QSize txt = hdr->fontMetrics.size(Qt::TextSingleLine | Qt::TextBypassShaping, hdr->text); + QSize txt = hdr->fontMetrics.size(Qt::TextSingleLine, hdr->text); QSize sz; sz.setHeight(margin + qMax(iconSize, txt.height()) + margin); sz.setWidth((nullIcon ? 0 : margin) + iconSize + (hdr->text.isNull() ? 0 : margin) + txt.width() + margin); diff --git a/src/keeshare/CMakeLists.txt b/src/keeshare/CMakeLists.txt index 3adf272add..1d01482081 100644 --- a/src/keeshare/CMakeLists.txt +++ b/src/keeshare/CMakeLists.txt @@ -1,3 +1,18 @@ +# Copyright (C) 2023 KeePassXC Team +# +# 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 +# the Free Software Foundation, either version 2 or (at your option) +# version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + if(WITH_XC_KEESHARE) set(keeshare_SOURCES SettingsPageKeeShare.cpp @@ -14,8 +29,9 @@ if(WITH_XC_KEESHARE) ) find_package(Minizip REQUIRED) + find_package(Qt6 REQUIRED COMPONENTS Core5Compat) add_library(keeshare STATIC ${keeshare_SOURCES}) - target_link_libraries(keeshare PUBLIC Qt5::Core Qt5::Widgets ${BOTAN_LIBRARIES} ${ZLIB_LIBRARIES} PRIVATE ${MINIZIP_LIBRARIES}) + target_link_libraries(keeshare PUBLIC Qt6::Core Qt6::Core5Compat Qt6::Widgets ${BOTAN_LIBRARIES} ${ZLIB_LIBRARIES} PRIVATE ${MINIZIP_LIBRARIES}) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) endif(WITH_XC_KEESHARE) diff --git a/src/keeshare/KeeShareSettings.cpp b/src/keeshare/KeeShareSettings.cpp index 4f53fc25fe..01e56cc4d1 100644 --- a/src/keeshare/KeeShareSettings.cpp +++ b/src/keeshare/KeeShareSettings.cpp @@ -41,7 +41,6 @@ namespace KeeShareSettings QString buffer; QXmlStreamWriter writer(&buffer); - writer.setCodec(QTextCodec::codecForName("UTF-8")); writer.writeStartDocument(); writer.writeStartElement("KeeShare"); specific(writer); @@ -53,7 +52,7 @@ namespace KeeShareSettings void xmlDeserialize(const QString& raw, std::function specific) { QXmlStreamReader reader(raw); - if (!reader.readNextStartElement() || reader.qualifiedName() != "KeeShare") { + if (!reader.readNextStartElement() || reader.qualifiedName().compare("KeeShare") != 0) { return; } specific(reader); @@ -106,9 +105,9 @@ namespace KeeShareSettings { Certificate certificate; while (!reader.error() && reader.readNextStartElement()) { - if (reader.name() == "Signer") { + if (reader.name().compare("Signer") == 0) { certificate.signer = reader.readElementText(); - } else if (reader.name() == "Key") { + } else if (reader.name().compare("Key") == 0) { auto rawKey = QByteArray::fromBase64(reader.readElementText().toLatin1()); if (!rawKey.isEmpty()) { try { @@ -200,12 +199,12 @@ namespace KeeShareSettings Active active; xmlDeserialize(raw, [&](QXmlStreamReader& reader) { while (!reader.error() && reader.readNextStartElement()) { - if (reader.name() == "Active") { + if (reader.name().compare("Active") == 0) { while (reader.readNextStartElement()) { - if (reader.name() == "Import") { + if (reader.name().compare("Import") == 0) { active.in = true; reader.skipCurrentElement(); - } else if (reader.name() == "Export") { + } else if (reader.name().compare("Export") == 0) { active.out = true; reader.skipCurrentElement(); } else { @@ -248,9 +247,9 @@ namespace KeeShareSettings Own own; xmlDeserialize(raw, [&](QXmlStreamReader& reader) { while (!reader.error() && reader.readNextStartElement()) { - if (reader.name() == "PrivateKey") { + if (reader.name().compare("PrivateKey") == 0) { own.key = Key::deserialize(reader); - } else if (reader.name() == "PublicKey") { + } else if (reader.name().compare("PublicKey") == 0) { own.certificate = Certificate::deserialize(reader); } else { qWarning("Unknown KeeShareSettings element %s", qPrintable(reader.name().toString())); @@ -328,23 +327,23 @@ namespace KeeShareSettings Reference reference; xmlDeserialize(raw, [&](QXmlStreamReader& reader) { while (!reader.error() && reader.readNextStartElement()) { - if (reader.name() == "Type") { + if (reader.name().compare("Type") == 0) { while (reader.readNextStartElement()) { - if (reader.name() == "Import") { + if (reader.name().compare("Import") == 0) { reference.type |= ImportFrom; reader.skipCurrentElement(); - } else if (reader.name() == "Export") { + } else if (reader.name().compare("Export") == 0) { reference.type |= ExportTo; reader.skipCurrentElement(); } else { break; } } - } else if (reader.name() == "Group") { + } else if (reader.name().compare("Group") == 0) { reference.uuid = QUuid::fromRfc4122(QByteArray::fromBase64(reader.readElementText().toLatin1())); - } else if (reader.name() == "Path") { + } else if (reader.name().compare("Path") == 0) { reference.path = QString::fromUtf8(QByteArray::fromBase64(reader.readElementText().toLatin1())); - } else if (reader.name() == "Password") { + } else if (reader.name().compare("Password") == 0) { reference.password = QString::fromUtf8(QByteArray::fromBase64(reader.readElementText().toLatin1())); } else { qWarning("Unknown Reference element %s", qPrintable(reader.name().toString())); diff --git a/src/keys/CompositeKey.cpp b/src/keys/CompositeKey.cpp index 7054916673..6270ca2659 100644 --- a/src/keys/CompositeKey.cpp +++ b/src/keys/CompositeKey.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * Copyright (C) 2010 Felix Geyer * * This program is free software: you can redistribute it and/or modify @@ -27,6 +27,7 @@ #include #include +#include QUuid CompositeKey::UUID("76a7ae25-a542-4add-9849-7c06be945b94"); diff --git a/src/keys/CompositeKey.h b/src/keys/CompositeKey.h index 451f88e4fd..74a0283265 100644 --- a/src/keys/CompositeKey.h +++ b/src/keys/CompositeKey.h @@ -19,6 +19,7 @@ #ifndef KEEPASSX_COMPOSITEKEY_H #define KEEPASSX_COMPOSITEKEY_H +#include #include #include "keys/Key.h" diff --git a/src/keys/FileKey.cpp b/src/keys/FileKey.cpp index 167b0462dd..694553273e 100644 --- a/src/keys/FileKey.cpp +++ b/src/keys/FileKey.cpp @@ -301,7 +301,7 @@ bool FileKey::loadXml(QIODevice* device, QString* errorMsg) if (xmlReader.error()) { return false; } - if (xmlReader.readNextStartElement() && xmlReader.name() != "KeyFile") { + if (xmlReader.readNextStartElement() && xmlReader.name().compare("KeyFile") != 0) { return false; } @@ -313,9 +313,9 @@ bool FileKey::loadXml(QIODevice* device, QString* errorMsg) } keyFileData; while (!xmlReader.error() && xmlReader.readNextStartElement()) { - if (xmlReader.name() == "Meta") { + if (xmlReader.name().compare("Meta") == 0) { while (!xmlReader.error() && xmlReader.readNextStartElement()) { - if (xmlReader.name() == "Version") { + if (xmlReader.name().compare("Version") == 0) { keyFileData.version = xmlReader.readElementText(); if (keyFileData.version.startsWith("1.0")) { m_type = KeePass2XML; @@ -329,9 +329,9 @@ bool FileKey::loadXml(QIODevice* device, QString* errorMsg) } } } - } else if (xmlReader.name() == "Key") { + } else if (xmlReader.name().compare("Key") == 0) { while (!xmlReader.error() && xmlReader.readNextStartElement()) { - if (xmlReader.name() == "Data") { + if (xmlReader.name().compare("Data") == 0) { keyFileData.hash = QByteArray::fromHex(xmlReader.attributes().value("Hash").toLatin1()); keyFileData.data = xmlReader.readElementText().simplified().replace(" ", "").toLatin1(); @@ -362,7 +362,7 @@ bool FileKey::loadXml(QIODevice* device, QString* errorMsg) bool ok = false; if (!xmlReader.error() && !keyFileData.data.isEmpty()) { - std::memcpy(m_key.data(), keyFileData.data.data(), std::min(SHA256_SIZE, keyFileData.data.size())); + std::memcpy(m_key.data(), keyFileData.data.data(), qMin(SHA256_SIZE, keyFileData.data.size())); ok = true; } @@ -421,7 +421,7 @@ bool FileKey::loadHex(QIODevice* device) return false; } - std::memcpy(m_key.data(), data.data(), std::min(SHA256_SIZE, data.size())); + std::memcpy(m_key.data(), data.data(), qMin(SHA256_SIZE, data.size())); Botan::secure_scrub_memory(data.data(), static_cast(data.capacity())); m_type = FixedBinaryHex; @@ -447,7 +447,7 @@ bool FileKey::loadHashed(QIODevice* device) } while (!buffer.isEmpty()); buffer = cryptoHash.result(); - std::memcpy(m_key.data(), buffer.data(), std::min(SHA256_SIZE, buffer.size())); + std::memcpy(m_key.data(), buffer.data(), qMin(SHA256_SIZE, buffer.size())); Botan::secure_scrub_memory(buffer.data(), static_cast(buffer.capacity())); m_type = Hashed; diff --git a/src/keys/PasswordKey.cpp b/src/keys/PasswordKey.cpp index 7e06706472..4a4294a517 100644 --- a/src/keys/PasswordKey.cpp +++ b/src/keys/PasswordKey.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * * 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 @@ -20,6 +20,7 @@ #include "crypto/CryptoHash.h" #include +#include #include QUuid PasswordKey::UUID("77e90411-303a-43f2-b773-853b05635ead"); diff --git a/src/keys/drivers/YubiKey.cpp b/src/keys/drivers/YubiKey.cpp index a5603de985..664f5acc85 100644 --- a/src/keys/drivers/YubiKey.cpp +++ b/src/keys/drivers/YubiKey.cpp @@ -1,6 +1,6 @@ /* + * Copyright (C) 2023 KeePassXC Team * Copyright (C) 2014 Kyle Manna - * Copyright (C) 2017-2021 KeePassXC Team * * 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 @@ -80,7 +80,7 @@ bool YubiKey::findValidKeys() void YubiKey::findValidKeysAsync() { - QtConcurrent::run([this] { + auto res = QtConcurrent::run([this] { bool found = findValidKeys(); emit detectComplete(found); }); diff --git a/src/proxy/CMakeLists.txt b/src/proxy/CMakeLists.txt index be756672dd..15cf59a104 100755 --- a/src/proxy/CMakeLists.txt +++ b/src/proxy/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2020 KeePassXC Team +# Copyright (C) 2023 KeePassXC Team # # 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 @@ -21,10 +21,10 @@ if(WITH_XC_BROWSER) # Alloc must be defined in a static library to prevent clashing with clang ASAN definitions add_library(proxy_alloc STATIC ../core/Alloc.cpp) - target_link_libraries(proxy_alloc PRIVATE Qt5::Core ${BOTAN_LIBRARIES}) + target_link_libraries(proxy_alloc PRIVATE Qt6::Core ${BOTAN_LIBRARIES}) add_executable(keepassxc-proxy ${proxy_SOURCES}) - target_link_libraries(keepassxc-proxy proxy_alloc Qt5::Core Qt5::Network) + target_link_libraries(keepassxc-proxy proxy_alloc Qt6::Core Qt6::Network) install(TARGETS keepassxc-proxy BUNDLE DESTINATION . COMPONENT Runtime RUNTIME DESTINATION ${PROXY_INSTALL_DIR} COMPONENT Runtime) diff --git a/src/proxy/NativeMessagingProxy.cpp b/src/proxy/NativeMessagingProxy.cpp index 964383dc5d..86ff7aaaa9 100644 --- a/src/proxy/NativeMessagingProxy.cpp +++ b/src/proxy/NativeMessagingProxy.cpp @@ -57,7 +57,7 @@ void NativeMessagingProxy::setupStandardInput() #endif #endif - QtConcurrent::run([this] { + auto res = QtConcurrent::run([this] { while (std::cin.good()) { if (std::cin.peek() != EOF) { uint length = 0; @@ -68,7 +68,7 @@ void NativeMessagingProxy::setupStandardInput() QString msg; msg.reserve(length); for (uint i = 0; i < length; ++i) { - msg.append(getchar()); + msg.append(QChar(getchar())); } if (msg.length() > 0) { diff --git a/src/qrcode/CMakeLists.txt b/src/qrcode/CMakeLists.txt index 10e3684062..c5c145d7d7 100644 --- a/src/qrcode/CMakeLists.txt +++ b/src/qrcode/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2017 KeePassXC Team +# Copyright (C) 2023 KeePassXC Team # # 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 @@ -21,4 +21,4 @@ find_package(QREncode REQUIRED) add_library(qrcode STATIC ${qrcode_SOURCES}) target_include_directories(qrcode PRIVATE ${QRENCODE_INCLUDE_DIR}) -target_link_libraries(qrcode PUBLIC Qt5::Core Qt5::Svg ${QRENCODE_LIBRARY}) +target_link_libraries(qrcode PUBLIC Qt6::Core Qt6::Svg ${QRENCODE_LIBRARY}) diff --git a/src/quickunlock/TouchID.h b/src/quickunlock/TouchID.h index 2cca7ea464..d0913fd899 100644 --- a/src/quickunlock/TouchID.h +++ b/src/quickunlock/TouchID.h @@ -31,7 +31,7 @@ class TouchID : public QuickUnlockInterface bool getKey(const QUuid& dbUuid, QByteArray& passwordKey) override; bool hasKey(const QUuid& dbUuid) const override; - void reset(const QUuid& dbUuid = "") override; + void reset(const QUuid& dbUuid) override; void reset() override; private: diff --git a/src/updatecheck/UpdateChecker.cpp b/src/updatecheck/UpdateChecker.cpp index ff2240628f..4aa6fe11ac 100644 --- a/src/updatecheck/UpdateChecker.cpp +++ b/src/updatecheck/UpdateChecker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * * 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 @@ -103,8 +103,7 @@ void UpdateChecker::fetchFinished() } // Check again in 7 days - // TODO: change to toSecsSinceEpoch() when min Qt >= 5.8 - config()->set(Config::GUI_CheckForUpdatesNextCheck, Clock::currentDateTime().addDays(7).toTime_t()); + config()->set(Config::GUI_CheckForUpdatesNextCheck, Clock::currentDateTime().addDays(7).toSecsSinceEpoch()); } else { version = ErrorVersion; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4c311b69ef..ec946e78f7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -90,7 +90,7 @@ macro(add_unit_test) endif() endmacro(add_unit_test) -set(TEST_LIBRARIES keepassx_core Qt5::Test) +set(TEST_LIBRARIES keepassx_core Qt6::Test) set(testsupport_SOURCES modeltest.cpp @@ -98,7 +98,7 @@ set(testsupport_SOURCES mock/MockClock.cpp util/TemporaryFile.cpp) add_library(testsupport STATIC ${testsupport_SOURCES}) -target_link_libraries(testsupport Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Test) +target_link_libraries(testsupport Qt6::Core Qt6::Concurrent Qt6::Widgets Qt6::Test) add_unit_test(NAME testgroup SOURCES TestGroup.cpp LIBS testsupport ${TEST_LIBRARIES}) diff --git a/tests/TestCsvParser.cpp b/tests/TestCsvParser.cpp index 758c31eccf..14bf0027ec 100644 --- a/tests/TestCsvParser.cpp +++ b/tests/TestCsvParser.cpp @@ -1,6 +1,6 @@ /* + * Copyright (C) 2023 KeePassXC Team * Copyright (C) 2015 Enrico Mariotti - * Copyright (C) 2017 KeePassXC Team * * 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 @@ -333,7 +333,6 @@ void TestCsvParser::testUnicode() // ERROR QChar g("\u20AC"); parser->setFieldSeparator(QChar('A')); QTextStream out(file.data()); - out.setCodec("UTF-8"); out << QString("€1A2śA\"3śAż\"Ażac"); QVERIFY(parser->parse(file.data())); diff --git a/tests/TestSharing.cpp b/tests/TestSharing.cpp index 14a72b1421..5390eebba8 100644 --- a/tests/TestSharing.cpp +++ b/tests/TestSharing.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 KeePassXC Team + * Copyright (C) 2023 KeePassXC Team * * 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 @@ -83,7 +83,7 @@ void TestSharing::testKeySerialization() writer.writeEndDocument(); QXmlStreamReader reader(buffer); reader.readNextStartElement(); - QVERIFY(reader.name() == "Key"); + QVERIFY(reader.name().compare("Key") == 0); KeeShareSettings::Key restored = KeeShareSettings::Key::deserialize(reader); QCOMPARE(restored.key->private_key_bits(), original.key->private_key_bits());