diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4a8ccfca3..b5d04bbe2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -65,6 +65,18 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Clone flatpak manifest from Flathub + uses: GuillaumeFalourd/clone-github-repo-action@v2 + with: + owner: 'flathub' + repository: 'com.github.Murmele.Gittyup' + + # just until the new release is out + - name: Checkout restructureCMake + run: | + cd com.github.Murmele.Gittyup + git checkout Qt6 + - name: Replace git tag by the commit id on which it runs if: github.ref_type != 'tag' run: > @@ -120,11 +132,7 @@ jobs: fail-fast: false matrix: qt: - - version: 5.15.2 - check_only: false - - - version: 5.12.0 - check_only: true + - version: 6.5.3 env: - name: linux @@ -161,23 +169,6 @@ jobs: CXX: clang++ pack: 1 - - name: win32 - os: windows-latest - ninja_platform: win - qt_platform: windows - qt_arch: win32_msvc2019 - qt_arch_check_only: win32_msvc2017 - openssl_arch: VC-WIN32 - msvc_arch: x86 - cmake_flags: "-DUSE_BUNDLED_ZLIB=1" - cmake_env: - CMAKE_RC_FLAGS: "/C 1252" - CC: clang - CXX: clang++ - CMAKE_C_FLAGS: -m32 - CMAKE_CXX_FLAGS: -m32 - pack: 1 - steps: # otherwise the testcases will fail, because signature is invalid - name: Set git name and email @@ -206,7 +197,6 @@ jobs: - name: Install Qt uses: jurplel/install-qt-action@v3.3.0 timeout-minutes: 10 - if: "!matrix.qt.check_only" with: version: ${{ matrix.qt.version }} target: desktop @@ -215,18 +205,6 @@ jobs: install-deps: true modules: qtwebengine - - name: Install Qt - uses: jurplel/install-qt-action@v3.3.0 - timeout-minutes: 10 - if: matrix.qt.check_only - with: - version: ${{ matrix.qt.version }} - target: desktop - host: ${{ matrix.env.qt_platform }} - arch: ${{ matrix.env.qt_arch_check_only }} - install-deps: true - modules: qtwebengine - - name: Install Ninja uses: seanmiddleditch/gha-setup-ninja@v4 with: @@ -256,10 +234,6 @@ jobs: run: | cd dep/openssl/openssl - # this is necessary until https://github.com/openssl/openssl/issues/18720 - # is fixed in OpenSSL 1.1.1r - export CFLAGS=-Wno-error=implicit-function-declaration - ./Configure ${{ matrix.env.openssl_arch }} no-shared make @@ -291,7 +265,7 @@ jobs: # Command copied from flathub build process - name: Validate appdata file - if: matrix.env.ninja_platform == 'linux' && !matrix.qt.check_only + if: matrix.env.ninja_platform == 'linux' run: | echo "Show generated appdata file" cat ./build/release/rsrc/linux/com.github.Murmele.Gittyup.appdata.xml @@ -302,14 +276,14 @@ jobs: flatpak run --env=G_DEBUG=fatal-criticals org.freedesktop.appstream-glib validate ./build/release/rsrc/linux/com.github.Murmele.Gittyup.appdata.xml - name: Publish build artifacts - if: matrix.env.pack && !matrix.qt.check_only + if: matrix.env.pack uses: actions/upload-artifact@v3 with: path: build/release/pack/Gittyup-* name: Gittyup ${{ matrix.env.name }} - name: Publish version file - if: matrix.env.pack && !matrix.qt.check_only + if: matrix.env.pack uses: actions/upload-artifact@v3 with: path: build/release/Version.txt @@ -334,12 +308,12 @@ jobs: ninja check_no_win32_offscreen - name: Build Appimage - if: matrix.env.ninja_platform == 'linux' && !matrix.qt.check_only + if: matrix.env.ninja_platform == 'linux' run: | cd build/release sudo apt -y install appstream sudo apt -y install libfuse2 - sudo apt -y install libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0 + sudo apt -y install libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0 libxcb-cursor0 libxkbcommon0 libx11-xcb1 sudo apt -y install libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xinerama0 libxcb-xinput0 libxcb-xkb1 libxcb-xrm0 libxcb-xv0 libxcb-xvmc0 libxcb1 mkdir -p AppDir @@ -352,6 +326,12 @@ jobs: wget -c https://github.com/$(wget -q https://github.com/probonopd/go-appimage/releases/expanded_assets/continuous -O - | grep "appimagetool-.*-x86_64.AppImage" | head -n 1 | cut -d '"' -f 2) chmod +x appimagetool-*.AppImage + echo Show QTDIR + ls $QTDIR + echo Show QTDIR plugins + ls $QTDIR/plugins + echo Show QTDIR plugins platforms + ls $QTDIR/plugins/platforms QTDIR=$QTDIR ./appimagetool-*.AppImage -s deploy ./AppDir/usr/share/applications/*.desktop --appimage-extract-and-run # Bundle EVERYTHING # Modify the AppDir: move ld-linux into the same directory as the payload application @@ -365,7 +345,7 @@ jobs: #ls -lh Gittyup-* - name: Publish Appimage - if: matrix.env.ninja_platform == 'linux' && !matrix.qt.check_only + if: matrix.env.ninja_platform == 'linux' uses: actions/upload-artifact@v3 with: path: build/release/*.AppImage @@ -402,7 +382,6 @@ jobs: automatic_release_tag: 'development' files: | **/artifacts/Gittyup win64/Gittyup*.exe - **/artifacts/Gittyup win32/Gittyup*.exe **/artifacts/Gittyup macos/Gittyup*.dmg **/artifacts/GittyupFlatpak/*.flatpak **/artifacts/GittyupAppImage/Gittyup*.AppImage @@ -417,7 +396,6 @@ jobs: automatic_release_tag: ${{ github.ref_name }} files: | **/artifacts/Gittyup win64/Gittyup*.exe - **/artifacts/Gittyup win32/Gittyup*.exe **/artifacts/Gittyup macos/Gittyup*.dmg **/artifacts/GittyupFlatpak/*.flatpak **/artifacts/GittyupAppImage/Gittyup*.AppImage diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bd47318e..a1ce27660 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,14 +114,10 @@ else() endif() find_package( - Qt5 5.12 + Qt6 COMPONENTS ${QT_MODULES} LinguistTools REQUIRED) if(FLATPAK) - find_package( - Qt5 5.15 - COMPONENTS XcbQpa - REQUIRED) add_compile_definitions(FLATPAK) endif() @@ -135,7 +131,7 @@ endif() include(GNUInstallDirs) # Defines some variables as BINDIR, LIBDIR, ... -set(QT_TRANSLATIONS_DIR "${Qt5_DIR}/../../../translations") +set(QT_TRANSLATIONS_DIR "${Qt6_DIR}/../../../translations") set(QT_TRANSLATIONS_DIR "/usr/share/qt/translations") if(APPLE) @@ -145,8 +141,8 @@ if(APPLE) # dependencies are to the release libraries (e.g. QtGui_debug depends on # QtCore). This causes multiple symbol definition errors at application load # time. - get_target_property(LOCATION Qt5::${QT_MODULE} LOCATION) - set_target_properties(Qt5::${QT_MODULE} PROPERTIES IMPORTED_LOCATION_DEBUG + get_target_property(LOCATION Qt6::${QT_MODULE} LOCATION) + set_target_properties(Qt6::${QT_MODULE} PROPERTIES IMPORTED_LOCATION_DEBUG ${LOCATION}) endforeach() endif() diff --git a/com.github.Murmele.Gittyup.yml b/com.github.Murmele.Gittyup.yml index 32f8b0f11..dfa892ec9 100644 --- a/com.github.Murmele.Gittyup.yml +++ b/com.github.Murmele.Gittyup.yml @@ -1,6 +1,6 @@ app-id: com.github.Murmele.Gittyup runtime: org.kde.Platform -runtime-version: 5.15-23.08 +runtime-version: 6.7 sdk: org.kde.Sdk command: gittyup desktop-file-name-suffix: "" # used to create development version diff --git a/dep/openssl/openssl b/dep/openssl/openssl index 3f499b24f..1c01dbcbe 160000 --- a/dep/openssl/openssl +++ b/dep/openssl/openssl @@ -1 +1 @@ -Subproject commit 3f499b24f3bcd66db022074f7e8b4f6ee266a3ae +Subproject commit 1c01dbcbebc08d629d02326d941b8491ae99597d diff --git a/dep/scintilla/CMakeLists.txt b/dep/scintilla/CMakeLists.txt index a7a11972c..9de63ddd1 100644 --- a/dep/scintilla/CMakeLists.txt +++ b/dep/scintilla/CMakeLists.txt @@ -54,7 +54,7 @@ target_compile_definitions( target_include_directories(scintilla PUBLIC ${SCINTILLA_DIR}/src) -target_link_libraries(scintilla Qt5::Widgets lexilla) +target_link_libraries(scintilla Qt6::Widgets lexilla) set_target_properties(scintilla PROPERTIES AUTOMOC ON) diff --git a/l10n/CMakeLists.txt b/l10n/CMakeLists.txt index 14543f0bb..dfd68fc63 100644 --- a/l10n/CMakeLists.txt +++ b/l10n/CMakeLists.txt @@ -28,9 +28,9 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/languages.cpp.inc" if(UPDATE_TRANSLATIONS) # FIXME: Clean removes the .ts files. - qt5_create_translation(QM_FILES ${SOURCE_FILES} ${TS_FILES}) + qt6_create_translation(QM_FILES ${SOURCE_FILES} ${TS_FILES}) else() - qt5_add_translation(QM_FILES ${TS_FILES}) + qt6_add_translation(QM_FILES ${TS_FILES}) endif() add_custom_target(translations DEPENDS ${QM_FILES}) @@ -38,7 +38,7 @@ add_dependencies(gittyup translations) add_library(translation ${LANGUAGE_SOURCE_FILE}) target_include_directories(translation PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") -target_link_libraries(translation Qt5::Core) +target_link_libraries(translation Qt6::Core) # install language files diff --git a/pack/CMakeLists.txt b/pack/CMakeLists.txt index c9b5f4de4..fac5dac7f 100644 --- a/pack/CMakeLists.txt +++ b/pack/CMakeLists.txt @@ -28,13 +28,13 @@ if(FLATPAK) qt_import_plugins(gittyup INCLUDE ${QT_PLUGINS}) elseif(NOT USE_SYSTEM_QT) foreach(QT_PLUGIN ${QT_PLUGINS}) - if(NOT TARGET Qt5::${QT_PLUGIN}) + if(NOT TARGET Qt6::${QT_PLUGIN}) if(UNIX OR APPLE) continue() endif() endif() - get_target_property(PLUGIN Qt5::${QT_PLUGIN} LOCATION_${CMAKE_BUILD_TYPE}) + get_target_property(PLUGIN Qt6::${QT_PLUGIN} LOCATION_${CMAKE_BUILD_TYPE}) get_filename_component(FILE_NAME ${PLUGIN} NAME) get_filename_component(DIR ${PLUGIN} DIRECTORY) get_filename_component(DIR_NAME ${DIR} NAME) @@ -78,11 +78,16 @@ elseif(NOT USE_SYSTEM_QT) # Install Qt libraries. foreach(QT_MODULE ${QT_MODULES}) - get_target_property(QT_LIBRARY Qt5::${QT_MODULE} + get_target_property(QT_LIBRARY Qt6::${QT_MODULE} LOCATION_${CMAKE_BUILD_TYPE}) if(APPLE) get_filename_component(QT_FRAMEWORK ${QT_LIBRARY} DIRECTORY) + + # FIXME: QT_LIBRARY points directly to the library bin instead of the + # symlink 2 directories above (since qt6) + string(REGEX REPLACE "/Versions/.*" "" QT_FRAMEWORK "${QT_FRAMEWORK}") + set(DEST_DIR ${CONTENTS_DIR}/Frameworks) install( DIRECTORY ${QT_FRAMEWORK} @@ -102,7 +107,7 @@ elseif(NOT USE_SYSTEM_QT) else() # Strip minor and patch version extensions. get_filename_component(TARGET_NAME_WE ${QT_LIBRARY} NAME_WE) - set(TARGET_NAME ${TARGET_NAME_WE}.so.5) + set(TARGET_NAME ${TARGET_NAME_WE}.so.6) endif() install( @@ -131,8 +136,8 @@ endif() # Install XcbQpa library. if(UNIX AND NOT APPLE) - set(LIB_NAME libQt5XcbQpa) - get_target_property(QT_CORE_LIBRARY Qt5::Core LOCATION) + set(LIB_NAME libQt6XcbQpa) + get_target_property(QT_CORE_LIBRARY Qt6::Core LOCATION) get_filename_component(LIB_PATH ${QT_CORE_LIBRARY} PATH) get_filename_component(LIB_EXT ${QT_CORE_LIBRARY} EXT) @@ -148,7 +153,7 @@ if(UNIX AND NOT APPLE) WORLD_READ WORLD_EXECUTE COMPONENT ${GITTYUP_NAME} - RENAME ${LIB_NAME}.so.5) + RENAME ${LIB_NAME}.so.6) endif() # Install SSL libraries. @@ -156,12 +161,12 @@ if(NOT APPLE) if(NOT USE_SYSTEM_OPENSSL) if(WIN32) if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(SSL_LIB_SUFFIX "-1_1-x64.dll") + set(SSL_LIB_SUFFIX "-3-x64.dll") else() - set(SSL_LIB_SUFFIX "-1_1.dll") + set(SSL_LIB_SUFFIX "-3.dll") endif() else() - set(SSL_LIB_SUFFIX ".so.1.1") + set(SSL_LIB_SUFFIX ".so.3") endif() foreach(SSL_LIB_NAME ssl crypto) diff --git a/src/app/Application.cpp b/src/app/Application.cpp index fc948333a..dac82df53 100644 --- a/src/app/Application.cpp +++ b/src/app/Application.cpp @@ -63,19 +63,20 @@ static LONG WINAPI exceptionFilter(PEXCEPTION_POINTERS info) { SYSTEMTIME localTime; GetLocalTime(&localTime); - char temp[MAX_PATH]; + wchar_t temp[MAX_PATH]; GetTempPath(MAX_PATH, temp); - char dir[MAX_PATH]; - StringCchPrintf(dir, MAX_PATH, "%sGittyup", temp); + wchar_t dir[MAX_PATH]; + const wchar_t *gittyup_name = L"%sGittyup"; + StringCchPrintf(dir, MAX_PATH, gittyup_name, temp); CreateDirectory(dir, NULL); - char fileName[MAX_PATH]; - StringCchPrintf( - fileName, MAX_PATH, "%s\\%s-%s-%04d%02d%02d-%02d%02d%02d-%ld-%ld.dmp", - dir, GITTYUP_NAME, GITTYUP_VERSION, localTime.wYear, localTime.wMonth, - localTime.wDay, localTime.wHour, localTime.wMinute, localTime.wSecond, - GetCurrentProcessId(), GetCurrentThreadId()); + wchar_t fileName[MAX_PATH]; + const wchar_t *s = L"%s\\%s-%s-%04d%02d%02d-%02d%02d%02d-%ld-%ld.dmp"; + StringCchPrintf(fileName, MAX_PATH, s, dir, GITTYUP_NAME, GITTYUP_VERSION, + localTime.wYear, localTime.wMonth, localTime.wDay, + localTime.wHour, localTime.wMinute, localTime.wSecond, + GetCurrentProcessId(), GetCurrentThreadId()); HANDLE dumpFile = CreateFile(fileName, GENERIC_READ | GENERIC_WRITE, @@ -359,7 +360,7 @@ class CopyDataWindow : public QWindow { protected: virtual bool nativeEvent(const QByteArray &eventType, void *message, - long *result) Q_DECL_OVERRIDE { + qintptr *result) Q_DECL_OVERRIDE { MSG *msg = (MSG *)message; if (msg->message == WM_COPYDATA) { diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 82bdc3331..46def17fd 100755 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -22,7 +22,7 @@ file(GLOB SCINTILLUA_LEXERS ${SRC_SCINTILLUA_LEXERS_DIR}/*.lua) file(GLOB LUA_PLUGINS ${CONF_DIR}/plugins/*.lua ${CONF_DIR}/plugins/*.txt) # Build resources. -qt5_add_resources(RESOURCES ${RSRC_DIR}/resources.qrc) +qt6_add_resources(RESOURCES ${RSRC_DIR}/resources.qrc) # Generate acknowledgments. set(DOC_SOURCE_DIR ${CMAKE_SOURCE_DIR}/docs) @@ -74,12 +74,12 @@ target_link_libraries( git ui update - Qt5::Widgets) + Qt6::Widgets) set_target_properties(app PROPERTIES AUTOMOC ON) if(UNIX AND NOT APPLE) - target_link_libraries(app Qt5::DBus) + target_link_libraries(app Qt6::DBus) endif() # Add main executable. @@ -171,7 +171,7 @@ install( COMPONENT ${GITTYUP_NAME}) if(APPLE) - get_target_property(QT_LIBRARY Qt5::Core LOCATION) + get_target_property(QT_LIBRARY Qt6::Core LOCATION) get_filename_component(QT_FRAMEWORK ${QT_LIBRARY} DIRECTORY) get_filename_component(RPATH ${QT_FRAMEWORK} DIRECTORY) diff --git a/src/app/CustomTheme.cpp b/src/app/CustomTheme.cpp index b23138d51..c4ec31c71 100644 --- a/src/app/CustomTheme.cpp +++ b/src/app/CustomTheme.cpp @@ -15,6 +15,7 @@ #include #include #include +#include namespace { diff --git a/src/app/CustomTheme_mac.mm b/src/app/CustomTheme_mac.mm index 46983231a..46e250d8f 100644 --- a/src/app/CustomTheme_mac.mm +++ b/src/app/CustomTheme_mac.mm @@ -25,7 +25,7 @@ if (color.lightnessF() < 0.5) win.appearance = [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]; - qreal r,g,b,a; + float r,g,b,a; color.getRgbF(&r,&g,&b,&a); win.backgroundColor = [NSColor colorWithDeviceRed:r green:g blue:b alpha:a]; } diff --git a/src/app/Gittyup.cpp b/src/app/Gittyup.cpp index 69649f8c2..5238195e7 100644 --- a/src/app/Gittyup.cpp +++ b/src/app/Gittyup.cpp @@ -13,8 +13,6 @@ #include int main(int argc, char *argv[]) { - Application::setAttribute(Qt::AA_EnableHighDpiScaling); - Application::setAttribute(Qt::AA_UseHighDpiPixmaps); Application app(argc, argv, true); // Check if only one running instance is allowed and already running diff --git a/src/app/Theme.cpp b/src/app/Theme.cpp index 628842462..b677c3084 100644 --- a/src/app/Theme.cpp +++ b/src/app/Theme.cpp @@ -17,6 +17,7 @@ #include #include #include +#include namespace { diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index 74dcd7e16..156fc39bf 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -7,4 +7,4 @@ endif() add_library(cli Installer.cpp ${INSTALLER_IMPL_FILE}) -target_link_libraries(cli Qt5::Core ${INSTALLER_IMPL_LIBS}) +target_link_libraries(cli Qt6::Core ${INSTALLER_IMPL_LIBS}) diff --git a/src/conf/CMakeLists.txt b/src/conf/CMakeLists.txt index bbb0f2ce2..e3e06f2cc 100644 --- a/src/conf/CMakeLists.txt +++ b/src/conf/CMakeLists.txt @@ -1,7 +1,7 @@ add_library(conf ConfFile.cpp Settings.cpp Setting.cpp RecentRepositories.cpp RecentRepository.cpp) -target_link_libraries(conf lua Qt5::Core util translation) +target_link_libraries(conf lua Qt6::Core util translation) # SRC_ definitions point to the source directly target_compile_definitions( diff --git a/src/conf/Settings.cpp b/src/conf/Settings.cpp index f3a6ff440..ccd84780f 100644 --- a/src/conf/Settings.cpp +++ b/src/conf/Settings.cpp @@ -9,13 +9,14 @@ #include "Settings.h" #include "ConfFile.h" -#include "Debug.h" #include "qtsupport.h" #include "languages.h" #include #include +#include #include #include +#include #ifdef Q_OS_WIN #define CS Qt::CaseInsensitive @@ -125,8 +126,9 @@ QString Settings::lexer(const QString &filename) { QVariantMap map(lexers.value(key).toMap()); if (map.contains("patterns")) { foreach (QString pattern, map.value("patterns").toString().split(",")) { - QRegExp regExp(pattern, CS, QRegExp::Wildcard); - if (regExp.exactMatch(name)) + QRegularExpression regExp{ + QRegularExpression::fromWildcard(pattern, CS)}; + if (regExp.match(name).hasMatch()) return key; } } diff --git a/src/cred/CMakeLists.txt b/src/cred/CMakeLists.txt index e3516b2a6..b4fe01a7d 100644 --- a/src/cred/CMakeLists.txt +++ b/src/cred/CMakeLists.txt @@ -1,5 +1,5 @@ add_library(cred Cache.cpp Store.cpp CredentialHelper.cpp GitCredential.cpp) -target_link_libraries(cred conf git Qt5::Core) +target_link_libraries(cred conf git Qt6::Core) set_target_properties(cred PROPERTIES AUTOMOC ON) diff --git a/src/dialogs/AmendDialog.h b/src/dialogs/AmendDialog.h index 670be074f..10e6f846e 100644 --- a/src/dialogs/AmendDialog.h +++ b/src/dialogs/AmendDialog.h @@ -26,6 +26,7 @@ struct AmendInfo { }; class AmendDialog : public QDialog { + Q_OBJECT public: AmendDialog(const git::Signature &author, const git::Signature &committer, const QString &commitMessage, QWidget *parent = nullptr); diff --git a/src/dialogs/CMakeLists.txt b/src/dialogs/CMakeLists.txt index 0295257e2..f306af706 100644 --- a/src/dialogs/CMakeLists.txt +++ b/src/dialogs/CMakeLists.txt @@ -46,6 +46,6 @@ target_link_libraries( cred host index - Qt5::Widgets) + Qt6::Widgets) set_target_properties(dialogs PROPERTIES AUTOMOC ON) diff --git a/src/dialogs/ConfigDialog.cpp b/src/dialogs/ConfigDialog.cpp index 7327532f2..a1844c109 100644 --- a/src/dialogs/ConfigDialog.cpp +++ b/src/dialogs/ConfigDialog.cpp @@ -30,6 +30,7 @@ #include "ui/MainWindow.h" #include "ui/RepoView.h" #include +#include #include #include #include @@ -506,7 +507,7 @@ class LfsPanel : public QWidget { watcher->deleteLater(); }); - watcher->setFuture(QtConcurrent::run(repo, &git::Repository::lfsTracked)); + watcher->setFuture(QtConcurrent::run(&git::Repository::lfsTracked, repo)); Footer *footer = new Footer(includedList); connect(footer, &Footer::plusClicked, this, diff --git a/src/dialogs/DeleteBranchDialog.cpp b/src/dialogs/DeleteBranchDialog.cpp index 20741b0c3..4c2e4c49b 100644 --- a/src/dialogs/DeleteBranchDialog.cpp +++ b/src/dialogs/DeleteBranchDialog.cpp @@ -61,8 +61,9 @@ DeleteBranchDialog::DeleteBranchDialog(const git::Branch &branch, entry->setBusy(true); QStringList refspecs(QString(":%1").arg(upstreamName)); - watcher->setFuture( - QtConcurrent::run(remote, &git::Remote::push, callbacks, refspecs)); + git::Result (git::Remote::*push)( + git::Remote::Callbacks *, const QStringList &) = &git::Remote::push; + watcher->setFuture(QtConcurrent::run(push, remote, callbacks, refspecs)); connect(watcher, &QFutureWatcher::finished, watcher, [entry, watcher, callbacks, remoteName] { diff --git a/src/dialogs/DeleteTagDialog.cpp b/src/dialogs/DeleteTagDialog.cpp index cd0db7af9..45b1e2be6 100644 --- a/src/dialogs/DeleteTagDialog.cpp +++ b/src/dialogs/DeleteTagDialog.cpp @@ -53,8 +53,9 @@ DeleteTagDialog::DeleteTagDialog(const git::TagRef &tag, QWidget *parent) entry->setBusy(true); QStringList refspecs(QString(":refs/tags/%1").arg(name)); - watcher->setFuture( - QtConcurrent::run(remote, &git::Remote::push, callbacks, refspecs)); + git::Result (git::Remote::*push)( + git::Remote::Callbacks *, const QStringList &) = &git::Remote::push; + watcher->setFuture(QtConcurrent::run(push, remote, callbacks, refspecs)); connect(watcher, &QFutureWatcher::finished, watcher, [entry, watcher, callbacks, remoteName] { diff --git a/src/dialogs/DiffPanel.cpp b/src/dialogs/DiffPanel.cpp index 40ad124c7..c8cf46a0e 100644 --- a/src/dialogs/DiffPanel.cpp +++ b/src/dialogs/DiffPanel.cpp @@ -21,7 +21,6 @@ #include #include #include -#include DiffPanel::DiffPanel(const git::Repository &repo, QWidget *parent) : QWidget(parent), @@ -45,12 +44,18 @@ DiffPanel::DiffPanel(const git::Repository &repo, QWidget *parent) }); // encoding + + static std::array encodings{ + "Utf8", "Utf16", "Utf16LE", "Utf16BE", + "Utf32", "Utf32LE", "Utf32BE", "Latin1", + }; + QComboBox *encoding = new QComboBox(this); encoding->addItem(tr("System Locale"), -1); encoding->insertSeparator(encoding->count()); - foreach (int mib, QTextCodec::availableMibs()) - encoding->addItem(QTextCodec::codecForMib(mib)->name(), mib); - + for (int i = 0; i < encodings.size(); i++) { + encoding->addItem(encodings[i], i); + } QString name = mConfig.value("gui.encoding"); if (!name.isEmpty()) encoding->setCurrentIndex(encoding->findText(name)); diff --git a/src/dialogs/IconLabel.cpp b/src/dialogs/IconLabel.cpp index 6bd33e1f0..ac7d418de 100644 --- a/src/dialogs/IconLabel.cpp +++ b/src/dialogs/IconLabel.cpp @@ -22,8 +22,7 @@ QSize IconLabel::minimumSizeHint() const { return sizeHint(); } void IconLabel::paintEvent(QPaintEvent *event) { QSize size = sizeHint(); - QWidget *win = window(); QPainter(this).drawPixmap( QStyle::alignedRect(Qt::LeftToRight, Qt::AlignHCenter, size, rect()), - mIcon.pixmap(win ? win->windowHandle() : nullptr, size)); + mIcon.pixmap(size, window()->devicePixelRatio())); } diff --git a/src/dialogs/SettingsDialog.cpp b/src/dialogs/SettingsDialog.cpp index 7dfcc3b62..68da02938 100644 --- a/src/dialogs/SettingsDialog.cpp +++ b/src/dialogs/SettingsDialog.cpp @@ -28,6 +28,7 @@ #include "languages.h" #include "update/Updater.h" #include +#include #include #include #include diff --git a/src/editor/PlatQt.cpp b/src/editor/PlatQt.cpp index e054f5cec..630acfab5 100644 --- a/src/editor/PlatQt.cpp +++ b/src/editor/PlatQt.cpp @@ -329,7 +329,7 @@ void SurfaceImpl::MeasureWidths(Font &font, std::string_view s, XYPOSITION SurfaceImpl::WidthText(Font &font, std::string_view s) { QFontMetricsF metrics(*static_cast(font.GetID()), device); - return metrics.width(QString::fromUtf8(s.data(), s.length())); + return metrics.horizontalAdvance(QString::fromUtf8(s.data(), s.length())); } XYPOSITION SurfaceImpl::Ascent(Font &font) { @@ -629,14 +629,15 @@ void Platform::DebugPrintf(const char *format, ...) { char buffer[2000]; va_list pArguments; va_start(pArguments, format); - vsprintf(buffer, format, pArguments); + vsnprintf(buffer, sizeof(buffer), format, pArguments); va_end(pArguments); Platform::DebugDisplay(buffer); } void Platform::Assert(const char *c, const char *file, int line) { char buffer[2000]; - sprintf(buffer, "Assertion [%s] failed at %s %d\n", c, file, line); + snprintf(buffer, sizeof(buffer), "Assertion [%s] failed at %s %d\n", c, file, + line); Platform::DebugDisplay(buffer); } diff --git a/src/editor/ScintillaQt.cpp b/src/editor/ScintillaQt.cpp index 5df0cc9f9..1ced345a8 100644 --- a/src/editor/ScintillaQt.cpp +++ b/src/editor/ScintillaQt.cpp @@ -327,7 +327,9 @@ void ScintillaQt::keyPressEvent(QKeyEvent *event) { QString text = event->text(); if (input && !text.isEmpty() && text[0].isPrint()) { - InsertCharacter(text.toStdString(), CharacterSource::directInput); + QByteArray utext = text.toUtf8(); + InsertCharacter(std::string_view(utext.data(), utext.size()), + CharacterSource::directInput); } else { event->ignore(); } @@ -430,7 +432,7 @@ void ScintillaQt::dragEnterEvent(QDragEnterEvent *event) { if (event->mimeData()->hasText()) { event->acceptProposedAction(); - Point point = PointFromQPoint(event->pos()); + Point point = PointFromQPoint(event->position().toPoint()); SetDragPosition( SPositionFromLocation(point, false, false, UserVirtualSpace())); } else { @@ -447,7 +449,7 @@ void ScintillaQt::dragMoveEvent(QDragMoveEvent *event) { if (event->mimeData()->hasText()) { event->acceptProposedAction(); - Point point = PointFromQPoint(event->pos()); + Point point = PointFromQPoint(event->position().toPoint()); SetDragPosition( SPositionFromLocation(point, false, false, UserVirtualSpace())); } else { @@ -460,7 +462,7 @@ void ScintillaQt::dropEvent(QDropEvent *event) { event->acceptProposedAction(); const QMimeData *data = event->mimeData(); - Point point = PointFromQPoint(event->pos()); + Point point = PointFromQPoint(event->position().toPoint()); bool move = (event->source() == this && event->proposedAction() == Qt::MoveAction); @@ -520,8 +522,9 @@ void ScintillaQt::inputMethodEvent(QInputMethodEvent *event) { const unsigned int ucWidth = commitStr.at(i).isHighSurrogate() ? 2 : 1; const QString oneCharUTF16 = commitStr.mid(i, ucWidth); const QByteArray oneChar = oneCharUTF16.toUtf8(); - - InsertCharacter(oneChar.toStdString(), CharacterSource::directInput); + const int oneCharLen = oneChar.length(); + InsertCharacter(std::string_view(oneChar.data(), oneCharLen), + CharacterSource::directInput); i += ucWidth; } @@ -604,7 +607,8 @@ void ScintillaQt::inputMethodEvent(QInputMethodEvent *event) { numBytes += oneCharLen; imeCharPos[i + 1] = numBytes; - InsertCharacter(oneChar.toStdString(), CharacterSource::directInput); + InsertCharacter(std::string_view(oneChar.data(), oneCharLen), + CharacterSource::directInput); #ifdef Q_OS_LINUX // Segment marked with imeCaretPos is for target input. @@ -628,7 +632,7 @@ void ScintillaQt::inputMethodEvent(QInputMethodEvent *event) { MoveImeCarets(-imeCharPos[preeditStrLen] + imeCharPos[imeCaretPos]); } - // Set candidate box position for Qt::ImMicroFocus. + // Set candidate box position for Qt::ImCursorRectangle. preeditPos = CurrentPosition(); EnsureCaretVisible(); updateMicroFocus(); @@ -704,6 +708,7 @@ QVariant ScintillaQt::inputMethodQuery(Qt::InputMethodQuery query) const { case Qt::ImPlatformData: // fall through case Qt::ImQueryInput: // fall through case Qt::ImQueryAll: // fall through + case Qt::ImReadOnly: // fall through break; } return QVariant(); @@ -1021,7 +1026,7 @@ bool ScintillaQt::SetIdle(bool on) { idler.state = false; QTimer *timer = static_cast(idler.idlerID); timer->stop(); - disconnect(timer, &QTimer::timeout, 0, 0); + disconnect(timer, &QTimer::timeout, nullptr, nullptr); delete timer; idler.idlerID = nullptr; } diff --git a/src/git/CMakeLists.txt b/src/git/CMakeLists.txt index c9553149b..479eae927 100644 --- a/src/git/CMakeLists.txt +++ b/src/git/CMakeLists.txt @@ -27,6 +27,6 @@ add_library( TagRef.cpp Tree.cpp) -target_link_libraries(git git2 Qt5::Core Qt5::Network util) +target_link_libraries(git git2 Qt6::Core Qt6::Network util) set_target_properties(git PROPERTIES AUTOMOC ON) diff --git a/src/git/Commit.cpp b/src/git/Commit.cpp index 1cdae15f1..b051d9a48 100644 --- a/src/git/Commit.cpp +++ b/src/git/Commit.cpp @@ -26,7 +26,8 @@ #include #include #include -#include +#include +#include #include namespace git { @@ -294,8 +295,9 @@ void Commit::setStarred(bool starred) { QString Commit::decodeMessage(const char *msg) const { if (const char *encoding = git_commit_message_encoding(*this)) { - if (QTextCodec *codec = QTextCodec::codecForName(encoding)) - return codec->toUnicode(msg); + auto conv = QStringConverter::encodingForName(encoding); + if (conv.has_value()) + return QStringDecoder{conv.value()}.decode(msg); } return msg; diff --git a/src/git/Commit.h b/src/git/Commit.h index 11c73a1c5..adae4fb15 100644 --- a/src/git/Commit.h +++ b/src/git/Commit.h @@ -15,6 +15,7 @@ #include "git2/revwalk.h" #include "git2/reset.h" #include "Blob.h" +#include class QDateTime; diff --git a/src/git/Diff.cpp b/src/git/Diff.cpp index a85ae545d..2497aa82f 100644 --- a/src/git/Diff.cpp +++ b/src/git/Diff.cpp @@ -12,14 +12,15 @@ #include "Debug.h" #include "git2/patch.h" #include +#include bool containsPath(QString &str, QString &occurence, Qt::CaseSensitivity cs) { if (str.contains(occurence, cs)) { - if (str.count() == occurence.count()) { + if (str.size() == occurence.size()) { // file/folder matches exactly return true; - } else if (str.count() >= occurence.length() + 1 && - str[occurence.length()] == "/") { + } else if (str.size() >= occurence.length() + 1 && + str[occurence.length()] == '/') { // file or folder in occurence return true; } diff --git a/src/git/Diff.h b/src/git/Diff.h index d1f7d278a..042b06156 100644 --- a/src/git/Diff.h +++ b/src/git/Diff.h @@ -59,7 +59,7 @@ class Diff { * \return */ QByteArray print(); - bool isValid() const { return d; } + bool isValid() const { return d ? true : false; } explicit operator bool() const { return isValid(); } bool isConflicted() const; diff --git a/src/git/Index.cpp b/src/git/Index.cpp index b80b81870..95cd8926e 100644 --- a/src/git/Index.cpp +++ b/src/git/Index.cpp @@ -180,7 +180,7 @@ void Index::setStaged(const QStringList &files, bool staged, bool yieldFocus) { if (!smHead.isValid()) continue; - git_time_t time = smHead.committer().date().toTime_t(); + git_time_t time = smHead.committer().date().toSecsSinceEpoch(); entry.ctime.seconds = time; entry.ctime.nanoseconds = 0; entry.mtime.seconds = time; diff --git a/src/git/Remote.cpp b/src/git/Remote.cpp index dfd1013ba..fd5f0b9cf 100644 --- a/src/git/Remote.cpp +++ b/src/git/Remote.cpp @@ -175,8 +175,9 @@ class ConfigFile { bool matched = false; for (const QString &pattern : host.patterns) { - QRegExp re(pattern, Qt::CaseSensitive, QRegExp::Wildcard); - if (re.exactMatch(hostname)) { + QRegularExpression re{ + QRegularExpression::wildcardToRegularExpression(pattern)}; + if (re.match(hostname).hasMatch()) { handler(host); matched = true; break; diff --git a/src/git/Repository.cpp b/src/git/Repository.cpp index d7f91016f..ff0a799c9 100644 --- a/src/git/Repository.cpp +++ b/src/git/Repository.cpp @@ -51,7 +51,6 @@ #include #include #include -#include #include #ifdef Q_OS_UNIX @@ -1032,14 +1031,14 @@ void Repository::cleanupState() { } } -QTextCodec *Repository::codec() const { +QStringConverter::Encoding Repository::encoding() const { QString encoding = gitConfig().value("gui.encoding"); - QTextCodec *codec = QTextCodec::codecForName(encoding.toUtf8()); - return codec ? codec : QTextCodec::codecForLocale(); + auto conv = QStringConverter::encodingForName(encoding.toLocal8Bit().data()); + return conv ? conv.value() : QStringConverter::System; } QString Repository::decode(const QByteArray &text) const { - return codec()->toUnicode(text); + return QStringDecoder{encoding()}.decode(text); } bool Repository::lfsIsInitialized() { return dir().exists("hooks/pre-push"); } diff --git a/src/git/Repository.h b/src/git/Repository.h index 0abb27794..8b9b65afe 100644 --- a/src/git/Repository.h +++ b/src/git/Repository.h @@ -26,6 +26,7 @@ #include #include #include +#include struct git_repository; class QProcess; @@ -225,7 +226,7 @@ class Repository { void cleanupState(); // encoding - QTextCodec *codec() const; + QStringConverter::Encoding encoding() const; QString decode(const QByteArray &text) const; // clean diff --git a/src/git/Signature.cpp b/src/git/Signature.cpp index 55cace9ef..e366de228 100644 --- a/src/git/Signature.cpp +++ b/src/git/Signature.cpp @@ -42,7 +42,7 @@ QString Signature::email() const { return d->email; } QDateTime Signature::date() const { int offset = d->when.offset * 60; // Convert from minutes to seconds. - return QDateTime::fromTime_t(d->when.time, Qt::OffsetFromUTC, offset); + return QDateTime::fromSecsSinceEpoch(d->when.time, Qt::OffsetFromUTC, offset); } git_time Signature::gitDate() const { return d->when; } diff --git a/src/git/Signature.h b/src/git/Signature.h index c3a516e0c..2f916923d 100644 --- a/src/git/Signature.h +++ b/src/git/Signature.h @@ -21,7 +21,7 @@ namespace git { class Signature { public: - bool isValid() const { return d; } + bool isValid() const { return d ? true : false; } explicit operator bool() const { return isValid(); } QString name() const; diff --git a/src/host/Account.cpp b/src/host/Account.cpp index 0e2af7030..1abbac572 100644 --- a/src/host/Account.cpp +++ b/src/host/Account.cpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace { diff --git a/src/host/CMakeLists.txt b/src/host/CMakeLists.txt index 027107356..d189c0aa6 100644 --- a/src/host/CMakeLists.txt +++ b/src/host/CMakeLists.txt @@ -9,7 +9,7 @@ add_library( GitLab.cpp Repository.cpp) -target_link_libraries(host conf cred Qt5::Core Qt5::Gui Qt5::Network) +target_link_libraries(host conf cred Qt6::Core Qt6::Gui Qt6::Network) target_compile_definitions( host diff --git a/src/host/Repository.h b/src/host/Repository.h index 02f389baf..b6011f67a 100644 --- a/src/host/Repository.h +++ b/src/host/Repository.h @@ -10,6 +10,7 @@ #ifndef HOST_REPOSITORY_H #define HOST_REPOSITORY_H +#include #include #include #include diff --git a/src/index/CMakeLists.txt b/src/index/CMakeLists.txt index 26b911754..0fe9b1452 100644 --- a/src/index/CMakeLists.txt +++ b/src/index/CMakeLists.txt @@ -7,8 +7,8 @@ target_link_libraries( git lpeg lua - Qt5::Core - Qt5::Concurrent) + Qt6::Core + Qt6::Concurrent) set_target_properties(index PROPERTIES AUTOMOC ON) @@ -16,7 +16,7 @@ add_executable(lexer_test lexer_test.cpp) target_link_libraries(lexer_test index) add_executable(index_test index_test.cpp) -target_link_libraries(index_test index Qt5::Widgets) +target_link_libraries(index_test index Qt6::Widgets) add_executable(indexer indexer.cpp) target_link_libraries(indexer index) diff --git a/src/index/Index.cpp b/src/index/Index.cpp index d48ad5d8d..d448b2db2 100644 --- a/src/index/Index.cpp +++ b/src/index/Index.cpp @@ -22,6 +22,8 @@ #include #include +#include + namespace { const QString kLogKey = "debug/indexer"; diff --git a/src/index/Query.cpp b/src/index/Query.cpp index 11d143085..c293a8b0d 100644 --- a/src/index/Query.cpp +++ b/src/index/Query.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include namespace { @@ -89,9 +89,10 @@ class WildcardQuery : public TermQuery { WildcardQuery(const Index::Term &term) : TermQuery(term) {} QList commits(const Index *index) const override { - QRegExp re(mTerm.text, Qt::CaseInsensitive, QRegExp::Wildcard); + QRegularExpression re{ + QRegularExpression::fromWildcard(mTerm.text, Qt::CaseInsensitive)}; Index::Predicate pred = [re](const QByteArray &word) { - return re.exactMatch(word); + return re.match(word).hasMatch(); }; return index->commits(index->postings(pred, mTerm.field)); @@ -182,24 +183,16 @@ class BooleanQuery : public Query { QList rhs = mRhs->commits(index); QList commits = mLhs->commits(index); if (mKind == And) { -// Remove commits that don't match the right hand side. -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + // Remove commits that don't match the right hand side. QSet set(rhs.begin(), rhs.end()); -#else - QSet set = QSet::fromList(rhs); -#endif QMutableListIterator it(commits); while (it.hasNext()) { if (!set.contains(it.next())) it.remove(); } } else { -// Add commits that aren't already in the result set. -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + // Add commits that aren't already in the result set. QSet set(commits.begin(), commits.end()); -#else - QSet set = QSet::fromList(commits); -#endif foreach (const git::Commit &commit, rhs) { if (!set.contains(commit)) commits.append(commit); @@ -222,9 +215,10 @@ class PathspecQuery : public TermQuery { QList commits(const Index *index) const override { QByteArray term = mTerm.text.toUtf8(); QByteArray prefix = term.endsWith('/') ? term : term + '/'; - QRegExp re(mTerm.text, Qt::CaseInsensitive, QRegExp::Wildcard); + QRegularExpression re{ + QRegularExpression::fromWildcard(mTerm.text, Qt::CaseInsensitive)}; Index::Predicate pred = [prefix, re](const QByteArray &word) { - return word.startsWith(prefix) || re.exactMatch(word); + return word.startsWith(prefix) || re.match(word).hasMatch(); }; return index->commits(index->postings(pred, Index::Path)); diff --git a/src/index/indexer.cpp b/src/index/indexer.cpp index b6473a171..78220f10b 100644 --- a/src/index/indexer.cpp +++ b/src/index/indexer.cpp @@ -53,19 +53,20 @@ static LONG WINAPI exceptionFilter(PEXCEPTION_POINTERS info) { SYSTEMTIME localTime; GetLocalTime(&localTime); - char temp[MAX_PATH]; + wchar_t temp[MAX_PATH]; GetTempPath(MAX_PATH, temp); - char dir[MAX_PATH]; - StringCchPrintf(dir, MAX_PATH, "%sGittyup", temp); + wchar_t dir[MAX_PATH]; + const wchar_t *gittyup_name = L"%sGittyup"; + StringCchPrintf(dir, MAX_PATH, gittyup_name, temp); CreateDirectory(dir, NULL); - char fileName[MAX_PATH]; - StringCchPrintf( - fileName, MAX_PATH, "%s\\%s-%s-%04d%02d%02d-%02d%02d%02d-%ld-%ld.dmp", - dir, "indexer", GITTYUP_VERSION, localTime.wYear, localTime.wMonth, - localTime.wDay, localTime.wHour, localTime.wMinute, localTime.wSecond, - GetCurrentProcessId(), GetCurrentThreadId()); + wchar_t fileName[MAX_PATH]; + const wchar_t *s = L"%s\\%s-%s-%04d%02d%02d-%02d%02d%02d-%ld-%ld.dmp"; + StringCchPrintf(fileName, MAX_PATH, s, dir, "indexer", GITTYUP_VERSION, + localTime.wYear, localTime.wMonth, localTime.wDay, + localTime.wHour, localTime.wMinute, localTime.wSecond, + GetCurrentProcessId(), GetCurrentThreadId()); HANDLE dumpFile = CreateFile(fileName, GENERIC_READ | GENERIC_WRITE, @@ -427,12 +428,8 @@ class Indexer : public QObject, public QAbstractNativeEventFilter { int count = 0; QList commits; git::Commit commit = mWalker.next(); - -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QSet ids(mIndex.ids().begin(), mIndex.ids().end()); -#else - QSet ids = QSet::fromList(mIndex.ids()); -#endif + while (commit.isValid() && count < 8192) { // Don't index merge commits. if (!commit.isMerge() && !ids.contains(commit.id())) { @@ -453,7 +450,7 @@ class Indexer : public QObject, public QAbstractNativeEventFilter { using CommitList = QList; mWatcher.setFuture( QtConcurrent::mappedReduced( - commits, Map(mIndex.repo(), mLexers, mOut), + std::move(commits), Map(mIndex.repo(), mLexers, mOut), Reduce(mIndex.ids(), mOut))); return true; } @@ -476,7 +473,7 @@ class Indexer : public QObject, public QAbstractNativeEventFilter { } bool nativeEventFilter(const QByteArray &type, void *message, - long *result) override { + qintptr *result) override { Q_UNUSED(result); #ifdef Q_OS_WIN MSG *msg = static_cast(message); diff --git a/src/log/CMakeLists.txt b/src/log/CMakeLists.txt index 675c3c2f4..a6d385bbe 100644 --- a/src/log/CMakeLists.txt +++ b/src/log/CMakeLists.txt @@ -1,5 +1,5 @@ add_library(loglib LogDelegate.cpp LogEntry.cpp LogModel.cpp LogView.cpp) -target_link_libraries(loglib Qt5::Widgets) +target_link_libraries(loglib Qt6::Widgets) set_target_properties(loglib PROPERTIES AUTOMOC ON) diff --git a/src/log/LogDelegate.cpp b/src/log/LogDelegate.cpp index d461a5989..0a3dd2fb5 100644 --- a/src/log/LogDelegate.cpp +++ b/src/log/LogDelegate.cpp @@ -78,7 +78,7 @@ void LogDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, return; QRect rect = decorationRect(option, index); - if (static_cast(variant.type()) == QMetaType::QChar) { + if (variant.typeId() == QMetaType::QChar) { Badge::paint(painter, {Badge::Label(Badge::Label::Type::Log, variant.toChar())}, rect, &opt); @@ -127,7 +127,7 @@ void LogDelegate::initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const { QStyledItemDelegate::initStyleOption(option, index); QVariant variant = index.data(Qt::DecorationRole); - if (static_cast(variant.type()) == QMetaType::QChar) { + if (variant.typeId() == QMetaType::QChar) { option->decorationSize = Badge::size(option->font, Badge::Label(Badge::Label::Type::Log)) - ADJUSTMENT_SIZE; diff --git a/src/log/LogModel.cpp b/src/log/LogModel.cpp index 66e4c82fd..9bcf9dbd5 100644 --- a/src/log/LogModel.cpp +++ b/src/log/LogModel.cpp @@ -11,6 +11,7 @@ #include "LogEntry.h" #include #include +#include namespace { diff --git a/src/log/LogView.cpp b/src/log/LogView.cpp index 878611e31..3f1fc99d6 100644 --- a/src/log/LogView.cpp +++ b/src/log/LogView.cpp @@ -18,6 +18,7 @@ #include #include #include +#include namespace { @@ -93,8 +94,8 @@ void LogView::copy() { prefix += isExpanded(index) ? "[-]" : "[+]"; QString text = index.data().toString(); - plainText += - QString("%1 %2\n").arg(prefix, text.remove(QRegExp("<[^>]*>"))); + plainText += QString("%1 %2\n").arg( + prefix, text.remove(QRegularExpression("<[^>]*>"))); richText += QString("%1 %2
").arg(prefix, text); } @@ -169,7 +170,8 @@ QString LogView::linkAt(const QModelIndex &index, const QPoint &pos) { return QString(); LogDelegate *delegate = static_cast(itemDelegate()); - QStyleOptionViewItem options = viewOptions(); + QStyleOptionViewItem options; + initViewItemOption(&options); options.rect = visualRect(index); QPoint docPos = pos - delegate->documentPosition(options, index); return delegate->document(index)->documentLayout()->anchorAt(docPos); @@ -180,7 +182,8 @@ bool LogView::isDecoration(const QModelIndex &index, const QPoint &pos) { return false; LogDelegate *delegate = static_cast(itemDelegate()); - QStyleOptionViewItem options = viewOptions(); + QStyleOptionViewItem options; + initViewItemOption(&options); options.rect = visualRect(index); return delegate->decorationRect(options, index).contains(pos); } diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index a2246fb84..91538b5e8 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -1,5 +1,5 @@ add_library(plugins Plugin.cpp) -target_link_libraries(plugins editor git lua Qt5::Core) +target_link_libraries(plugins editor git lua Qt6::Core) set_target_properties(plugins PROPERTIES AUTOMOC ON) diff --git a/src/plugins/Plugin.cpp b/src/plugins/Plugin.cpp index 54190c1f3..945873dc9 100644 --- a/src/plugins/Plugin.cpp +++ b/src/plugins/Plugin.cpp @@ -15,6 +15,8 @@ #include #include +#include + extern "C" { #include "lua.h" #include "lauxlib.h" diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 6c2dd8055..405ea8543 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -1,6 +1,6 @@ add_library(tools DiffTool.cpp EditTool.cpp ExternalTool.cpp MergeTool.cpp ShowTool.cpp) -target_link_libraries(tools conf git Qt5::Gui util) +target_link_libraries(tools conf git Qt6::Gui util) set_target_properties(tools PROPERTIES AUTOMOC ON) diff --git a/src/tools/DiffTool.cpp b/src/tools/DiffTool.cpp index 67019a67d..8ae5a01e1 100644 --- a/src/tools/DiffTool.cpp +++ b/src/tools/DiffTool.cpp @@ -91,7 +91,7 @@ bool DiffTool::start() { if (!bash.isEmpty()) { process->start(bash, {"-c", command}); } else if (!shell) { - process->start(git::Command::substitute(env, command)); + process->start(git::Command::substitute(env, command), QStringList()); } else { emit error(BashNotFound); return false; diff --git a/src/tools/MergeTool.cpp b/src/tools/MergeTool.cpp index 677f679b2..0c03d9173 100644 --- a/src/tools/MergeTool.cpp +++ b/src/tools/MergeTool.cpp @@ -128,7 +128,7 @@ bool MergeTool::start() { if (!bash.isEmpty()) { process->start(bash, {"-c", command}); } else if (!shell) { - process->start(git::Command::substitute(env, command)); + process->start(git::Command::substitute(env, command), QStringList()); } else { emit error(BashNotFound); return false; diff --git a/src/ui/AdvancedSearchWidget.cpp b/src/ui/AdvancedSearchWidget.cpp index a4181ea3f..ad10e269a 100644 --- a/src/ui/AdvancedSearchWidget.cpp +++ b/src/ui/AdvancedSearchWidget.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -144,7 +143,7 @@ void AdvancedSearchWidget::exec(QLineEdit *parent, Index *index) { } // Load completion data in the background. - QtConcurrent::run([this, index] { + std::ignore = QtConcurrent::run([this, index] { QMap fields = index->fieldMap(); foreach (QLineEdit *lineEdit, mLineEdits) { QVariant var = lineEdit->property(kFieldProp); diff --git a/src/ui/BlameEditor.cpp b/src/ui/BlameEditor.cpp index e3a610bb4..53275caae 100644 --- a/src/ui/BlameEditor.cpp +++ b/src/ui/BlameEditor.cpp @@ -157,7 +157,7 @@ bool BlameEditor::load(const QString &name, const git::Blob &blob, // Calculate blame. if (mRepo.isValid() && !content.isEmpty()) { mMargin->startBlame(name); - mBlame.setFuture(QtConcurrent::run(mRepo, &git::Repository::blame, name, + mBlame.setFuture(QtConcurrent::run(&git::Repository::blame, mRepo, name, commit, mCallbacks.data())); } @@ -192,8 +192,7 @@ void BlameEditor::save() { QTextStream out(&file); if (mRepo.isValid()) - out.setCodec(mRepo.codec()); - + out.setEncoding(mRepo.encoding()); out << mEditor->text(); file.commit(); diff --git a/src/ui/BlameMargin.cpp b/src/ui/BlameMargin.cpp index a8b4ea7ec..5950c2012 100644 --- a/src/ui/BlameMargin.cpp +++ b/src/ui/BlameMargin.cpp @@ -67,8 +67,8 @@ void BlameMargin::setBlame(const git::Repository &repo, .toBool()) { git::Commit first = repo.walker(GIT_SORT_TIME | GIT_SORT_REVERSE).next(); git::Commit last = repo.walker(GIT_SORT_TIME).next(); - mMinTime = first ? first.committer().date().toTime_t() : -1; - mMaxTime = last ? last.committer().date().toTime_t() : -1; + mMinTime = first ? first.committer().date().toSecsSinceEpoch() : -1; + mMaxTime = last ? last.committer().date().toSecsSinceEpoch() : -1; } mTimer.stop(); @@ -136,11 +136,12 @@ bool BlameMargin::event(QEvent *event) { } void BlameMargin::mousePressEvent(QMouseEvent *event) { - mIndex = mBlame.isValid() ? index(event->y()) : -1; + mIndex = mBlame.isValid() ? index(event->position().y()) : -1; } void BlameMargin::mouseReleaseEvent(QMouseEvent *event) { - if (mBlame.isValid() && mIndex >= 0 && mIndex == index(event->y())) { + if (mBlame.isValid() && mIndex >= 0 && + mIndex == index(event->position().y())) { // Update selection. git::Id id = mBlame.id(mIndex); mSelection = (mSelection != id) ? id : git::Id(); @@ -154,7 +155,7 @@ void BlameMargin::mouseDoubleClickEvent(QMouseEvent *event) { if (!mBlame.isValid()) return; - int index = this->index(event->y()); + int index = this->index(event->position().y()); if (index < 0) return; @@ -172,7 +173,7 @@ void BlameMargin::mouseDoubleClickEvent(QMouseEvent *event) { void BlameMargin::paintEvent(QPaintEvent *event) { // Draw background. QStyleOption opt; - opt.init(this); + opt.initFrom(this); QPainter painter(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); @@ -225,7 +226,7 @@ void BlameMargin::paintEvent(QPaintEvent *event) { date = (dateTime.date() == today) ? QLocale().toString(dateTime.time(), QLocale::ShortFormat) : QLocale().toString(dateTime.date(), QLocale::ShortFormat); - time = dateTime.toTime_t(); + time = dateTime.toSecsSinceEpoch(); } // Draw background. diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 79d96f803..99b337771 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -75,8 +75,8 @@ target_link_libraries( tools update watcher - Qt5::Concurrent - Qt5::Network - Qt5::Widgets) + Qt6::Concurrent + Qt6::Network + Qt6::Widgets) set_target_properties(ui PROPERTIES AUTOMOC ON) diff --git a/src/ui/ColumnView.cpp b/src/ui/ColumnView.cpp index da2da30dd..6d607cdcd 100644 --- a/src/ui/ColumnView.cpp +++ b/src/ui/ColumnView.cpp @@ -84,7 +84,8 @@ class PreviewWidget : public QFrame { QWindow *win = window()->windowHandle(); QIcon icon = index.data(Qt::DecorationRole).value(); - mIcon->setPixmap(icon.pixmap(win, QSize(ICON_SIZE, ICON_SIZE))); + mIcon->setPixmap( + icon.pixmap(QSize(ICON_SIZE, ICON_SIZE), window()->devicePixelRatio())); mName->setText(kNameFmt.arg(index.data(Qt::DisplayRole).toString())); @@ -139,7 +140,8 @@ void ColumnView::setModel(QAbstractItemModel *model) { bool ColumnView::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::MouseButtonPress) { QWidget *columnViewport = static_cast(obj); - QPoint globalPos = static_cast(event)->globalPos(); + QPoint globalPos = + static_cast(event)->globalPosition().toPoint(); QModelIndex index = indexAt(viewport()->mapFromGlobal(globalPos)); if (!columnViewport->hasFocus() && index.row() < 0) { columnViewport->setFocus(); diff --git a/src/ui/CommitEditor.cpp b/src/ui/CommitEditor.cpp index c885c235e..816e2721c 100644 --- a/src/ui/CommitEditor.cpp +++ b/src/ui/CommitEditor.cpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace { const QString kDictKey = "commit.spellcheck.dict"; diff --git a/src/ui/CommitList.cpp b/src/ui/CommitList.cpp index 4f303a97b..9f17001dd 100644 --- a/src/ui/CommitList.cpp +++ b/src/ui/CommitList.cpp @@ -327,6 +327,8 @@ class CommitModel : public QAbstractListModel { } QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const { + if (index.row() >= mRows.size()) + return QVariant(); const Row &row = mRows.at(index.row()); bool status = !row.commit.isValid(); switch (role) { @@ -1280,8 +1282,10 @@ git::Diff CommitList::selectedDiff() const { if (indexes.isEmpty()) return git::Diff(); - if (indexes.size() == 1) - return indexes.first().data(DiffRole).value(); + if (indexes.size() == 1) { + auto first = indexes.first().data(DiffRole); + return first.isValid() ? first.value() : git::Diff(); + } git::Commit first = indexes.first().data(CommitRole).value(); if (!first.isValid()) @@ -1863,7 +1867,8 @@ bool CommitList::isDecoration(const QModelIndex &index, const QPoint &pos) { return false; CommitDelegate *delegate = static_cast(itemDelegate()); - QStyleOptionViewItem options = viewOptions(); + QStyleOptionViewItem options; + initViewItemOption(&options); options.rect = visualRect(index); return delegate->decorationRect(options, index).contains(pos); } @@ -1873,7 +1878,8 @@ bool CommitList::isStar(const QModelIndex &index, const QPoint &pos) { return false; CommitDelegate *delegate = static_cast(itemDelegate()); - QStyleOptionViewItem options = viewOptions(); + QStyleOptionViewItem options; + initViewItemOption(&options); options.rect = visualRect(index); return delegate->starRect(options, index).contains(pos); } diff --git a/src/ui/CommitToolBar.cpp b/src/ui/CommitToolBar.cpp index f4c5178d3..0384b2fe8 100644 --- a/src/ui/CommitToolBar.cpp +++ b/src/ui/CommitToolBar.cpp @@ -14,6 +14,7 @@ #include "ConfigKeys.h" #include "conf/Settings.h" #include "git/Config.h" +#include #include #include #include diff --git a/src/ui/DetailView.cpp b/src/ui/DetailView.cpp index 95b280f12..bb57f1201 100644 --- a/src/ui/DetailView.cpp +++ b/src/ui/DetailView.cpp @@ -23,6 +23,7 @@ #include "git/Signature.h" #include #include +#include #include #include #include @@ -122,8 +123,9 @@ class AuthorCommitterDate : public QWidget { mDate = new QLabel(this); mDate->setTextInteractionFlags(kTextFlags); - mSpacing.setX(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing)); - mSpacing.setY(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing)); + mHorizontalSpacing = + style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing); + mVerticalSpacing = style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing); } void moveEvent(QMoveEvent *event) override { updateLayout(); } @@ -134,13 +136,13 @@ class AuthorCommitterDate : public QWidget { QSize date = mDate->sizeHint(); QSize author = mAuthor->sizeHint(); QSize committer = mCommitter->sizeHint(); - int width = author.width() + date.width() + mSpacing.x(); + int width = author.width() + date.width() + mHorizontalSpacing; int height; if (mSameAuthorCommitter) height = qMax(qMax(author.height(), committer.height()), date.height()); else height = qMax(author.height(), date.height()) + committer.height() + - mSpacing.y(); + mVerticalSpacing; return QSize(width, height); } @@ -154,7 +156,7 @@ class AuthorCommitterDate : public QWidget { height = qMax(qMax(author.height(), committer.height()), date.height()); else height = qMax(author.height(), date.height()) + committer.height() + - mSpacing.y(); + mVerticalSpacing; return QSize(width, height); } @@ -165,10 +167,11 @@ class AuthorCommitterDate : public QWidget { int author = mAuthor->sizeHint().height(); int committer = mCommitter->sizeHint().height(); bool wrapped = (width < sizeHint().width()); - int unwrappedHeight = mSameAuthorCommitter - ? qMax(committer, qMax(author, date)) - : qMax(author + committer + mSpacing.y(), date); - return wrapped ? (author + committer + date + 2 * mSpacing.y()) + int unwrappedHeight = + mSameAuthorCommitter + ? qMax(committer, qMax(author, date)) + : qMax(author + committer + mVerticalSpacing, date); + return wrapped ? (author + committer + date + 2 * mVerticalSpacing) : unwrappedHeight; } @@ -198,13 +201,13 @@ class AuthorCommitterDate : public QWidget { void updateLayout() { mAuthor->move(0, 0); if (mCommitter->isVisible()) - mCommitter->move(0, mAuthor->height() + mSpacing.y()); + mCommitter->move(0, mAuthor->height() + mVerticalSpacing); bool wrapped = (width() < sizeHint().width()); int x = wrapped ? 0 : width() - mDate->width(); - int y = wrapped - ? mAuthor->height() + mCommitter->height() + 2 * mSpacing.y() - : 0; + int y = wrapped ? mAuthor->height() + mCommitter->height() + + 2 * mVerticalSpacing + : 0; mDate->move(x, y); updateGeometry(); } @@ -213,7 +216,8 @@ class AuthorCommitterDate : public QWidget { QLabel *mCommitter; QLabel *mDate; - QPoint mSpacing; + int mHorizontalSpacing; + int mVerticalSpacing; bool mSameAuthorCommitter{false}; }; @@ -306,7 +310,7 @@ class CommitDetail : public QFrame { // Compute description asynchronously. if (commits.size() == 1) mWatcher.setFuture( - QtConcurrent::run(commits.first(), &git::Commit::description)); + QtConcurrent::run(&git::Commit::description, commits.first())); } void setCommits(const QList &commits) { diff --git a/src/ui/DiffView/HunkWidget.cpp b/src/ui/DiffView/HunkWidget.cpp index 24bc5eff4..8224004b2 100644 --- a/src/ui/DiffView/HunkWidget.cpp +++ b/src/ui/DiffView/HunkWidget.cpp @@ -281,7 +281,7 @@ HunkWidget::HunkWidget(DiffView *view, const git::Diff &diff, return; QTextStream out(&file); - out.setCodec(repo.codec()); + out.setEncoding(repo.encoding()); out << editor.text(); file.commit(); @@ -408,7 +408,7 @@ HunkWidget::HunkWidget(DiffView *view, const git::Diff &diff, return; QTextStream out(&file); - out.setCodec(repo.codec()); + out.setEncoding(repo.encoding()); out << editor.text(); file.commit(); diff --git a/src/ui/DiffView/Images.cpp b/src/ui/DiffView/Images.cpp index f3098bb93..c51d4c06d 100644 --- a/src/ui/DiffView/Images.cpp +++ b/src/ui/DiffView/Images.cpp @@ -120,7 +120,7 @@ QPixmap Images::loadPixmap(git::Diff::File type, int &size, bool lfs) { QFileIconProvider provider; QString path = mPatch.repo().workdir().filePath(mPatch.name()); QIcon icon = provider.icon(QFileInfo(path)); - return icon.pixmap(windowHandle(), QSize(64, 64)); + return icon.pixmap(QSize(64, 64), window()->devicePixelRatio()); } QVBoxLayout *Images::imageLayout(const QPixmap pixmap, int size) { diff --git a/src/ui/FindWidget.cpp b/src/ui/FindWidget.cpp index 2404599b5..e047417c0 100644 --- a/src/ui/FindWidget.cpp +++ b/src/ui/FindWidget.cpp @@ -227,7 +227,7 @@ void FindWidget::showAndSetFocus() { void FindWidget::paintEvent(QPaintEvent *) { QStyleOption opt; - opt.init(this); + opt.initFrom(this); QPainter painter(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); } diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index 5b6971a90..a5e150ae2 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ui/MenuBar.cpp b/src/ui/MenuBar.cpp index 77c76dae6..89763fe5b 100644 --- a/src/ui/MenuBar.cpp +++ b/src/ui/MenuBar.cpp @@ -502,7 +502,7 @@ MenuBar::MenuBar(QWidget *parent) : QMenuBar(parent) { mToggleMaximize = new StateAction(tr("Normal"), tr("Maximize"), viewMenu); viewMenu->addAction(mToggleMaximize); toggleMaximizeHotkey.use(mToggleMaximize); - mToggleMaximize->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); + mToggleMaximize->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_M)); connect(mToggleMaximize, &QAction::triggered, [this] { bool maximize = mToggleMaximize->isActive(); RepoView *view = this->view(); diff --git a/src/ui/ReferenceView.cpp b/src/ui/ReferenceView.cpp index 84b3b39df..9cab9739a 100644 --- a/src/ui/ReferenceView.cpp +++ b/src/ui/ReferenceView.cpp @@ -40,7 +40,8 @@ class FilterProxyModel : public QSortFilterProxyModel { FilterProxyModel(QObject *parent = nullptr) : QSortFilterProxyModel(parent) {} void setFilter(const QString &filter) { - setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::FixedString)); + setFilterCaseSensitivity(Qt::CaseSensitivity::CaseInsensitive); + setFilterFixedString(filter); } protected: diff --git a/src/ui/RepoView.cpp b/src/ui/RepoView.cpp index ff398a5cf..dc6878cdb 100644 --- a/src/ui/RepoView.cpp +++ b/src/ui/RepoView.cpp @@ -1806,8 +1806,11 @@ void RepoView::push(const git::Remote &rmt, const git::Reference &src, &RepoView::notifyReferenceUpdated); entry->setBusy(true); - mWatcher->setFuture(QtConcurrent::run(remote, &git::Remote::push, mCallbacks, - ref, dst, force, tags)); + git::Result (git::Remote::*push)(git::Remote::Callbacks *, + const git::Reference &, const QString &, + bool, bool) = &git::Remote::push; + mWatcher->setFuture( + QtConcurrent::run(push, remote, mCallbacks, ref, dst, force, tags)); } bool RepoView::commit(const QString &message, @@ -2376,7 +2379,7 @@ void RepoView::resetSubmodulesAsync(const QList &submodules, QString(), mWatcher, repo); entry->setBusy(true); - mWatcher->setFuture(QtConcurrent::run(submodule, &git::Submodule::update, + mWatcher->setFuture(QtConcurrent::run(&git::Submodule::update, submodule, mCallbacks, false, true)); } @@ -2539,7 +2542,7 @@ void RepoView::updateSubmodulesAsync(const QList &submodules, QString(), mWatcher, repo); entry->setBusy(true); - mWatcher->setFuture(QtConcurrent::run(submodule, &git::Submodule::update, + mWatcher->setFuture(QtConcurrent::run(&git::Submodule::update, submodule, mCallbacks, init, checkout_force)); } diff --git a/src/ui/SpellChecker.cpp b/src/ui/SpellChecker.cpp index fb1563e13..d161cf9c4 100644 --- a/src/ui/SpellChecker.cpp +++ b/src/ui/SpellChecker.cpp @@ -4,7 +4,7 @@ #include "SpellChecker.h" #include #include -#include +#include SpellChecker::SpellChecker(const QString &dictionaryPath, const QString &userDictionary) @@ -26,12 +26,14 @@ SpellChecker::SpellChecker(const QString &dictionaryPath, QFile affixFile(affixFileName); if (affixFile.open(QIODevice::ReadOnly)) { QTextStream stream(&affixFile); - QRegExp enc_detector("^\\s*SET\\s+([A-Z0-9\\-]+)\\s*", - Qt::CaseInsensitive); + QRegularExpression enc_detector( + "^\\s*SET\\s+([A-Z0-9\\-]+)\\s*", + QRegularExpression::CaseInsensitiveOption); QString line = stream.readLine(); while (!line.isEmpty()) { - if (enc_detector.indexIn(line) >= 0) { - encoding = enc_detector.cap(1); + auto match = enc_detector.match(line); + if (match.hasMatch() >= 0) { + encoding = match.captured(1); break; } line = stream.readLine(); @@ -40,7 +42,9 @@ SpellChecker::SpellChecker(const QString &dictionaryPath, mValid = true; } - mCodec = QTextCodec::codecForName(encoding.toLatin1().constData()); + auto conv = + QStringConverter::encodingForName(encoding.toLocal8Bit().data()); + mEncoding = conv ? conv.value() : QStringConverter::System; // Add user dictionary words to spell checker. if (!mUserDictionary.isEmpty()) { @@ -49,7 +53,8 @@ SpellChecker::SpellChecker(const QString &dictionaryPath, QTextStream stream(&userDictonaryFile); QString line = stream.readLine(); while (!line.isEmpty()) { - mHunspell->add(mCodec->fromUnicode(line).constData()); + QByteArray ba = QStringEncoder{mEncoding}.encode(line); + mHunspell->add(ba.toStdString()); line = stream.readLine(); } userDictonaryFile.close(); @@ -62,29 +67,33 @@ SpellChecker::~SpellChecker() { delete mHunspell; } bool SpellChecker::spell(const QString &word) { // Encode from Unicode to the encoding used by current dictionary. - return mHunspell->spell(mCodec->fromUnicode(word).toStdString()); + QByteArray ba = QStringEncoder{mEncoding}.encode(word); + return mHunspell->spell(ba.toStdString()); } QStringList SpellChecker::suggest(const QString &word) { QStringList suggestions; // Retrive suggestions for word. - std::vector suggestion = - mHunspell->suggest(mCodec->fromUnicode(word).toStdString()); + QByteArray ba = QStringEncoder{mEncoding}.encode(word); + std::vector suggestion = mHunspell->suggest(ba.toStdString()); // Decode from the encoding used by current dictionary to Unicode. + auto decoder = QStringDecoder{mEncoding}; foreach (const std::string &str, suggestion) - suggestions.append(mCodec->toUnicode(str.data())); + suggestions.append(decoder.decode(str.data())); return suggestions; } void SpellChecker::ignoreWord(const QString &word) { - mHunspell->add(mCodec->fromUnicode(word).constData()); + QByteArray ba = QStringEncoder{mEncoding}.encode(word); + mHunspell->add(ba.toStdString()); } void SpellChecker::addToUserDict(const QString &word) { - mHunspell->add(mCodec->fromUnicode(word).constData()); + QByteArray ba = QStringEncoder{mEncoding}.encode(word); + mHunspell->add(ba.toStdString()); if (!mUserDictionary.isEmpty()) { QFile userDictonaryFile(mUserDictionary); diff --git a/src/ui/SpellChecker.h b/src/ui/SpellChecker.h index f244bee6c..4dd1d88ce 100644 --- a/src/ui/SpellChecker.h +++ b/src/ui/SpellChecker.h @@ -4,6 +4,7 @@ #define SPELLCHECKER_H #include +#include class Hunspell; @@ -24,7 +25,7 @@ class SpellChecker { private: Hunspell *mHunspell = nullptr; - QTextCodec *mCodec; + QStringConverter::Encoding mEncoding; QString mUserDictionary; bool mValid = false; diff --git a/src/ui/ToolBar.cpp b/src/ui/ToolBar.cpp index 2be9e76fe..4ec2a2a89 100644 --- a/src/ui/ToolBar.cpp +++ b/src/ui/ToolBar.cpp @@ -29,6 +29,7 @@ #include #include #include +#include namespace { @@ -944,7 +945,7 @@ ToolBar::ToolBar(MainWindow *parent) : QToolBar(parent) { // Hook up star button to search field. connect(mStarButton, &QToolButton::toggled, [this](bool checked) { - QStringList terms = mSearchField->text().split(QRegExp("\\s+")); + QStringList terms = mSearchField->text().split(QRegularExpression("\\s+")); if (checked) { terms.append(kStarredQuery); } else { @@ -958,7 +959,7 @@ ToolBar::ToolBar(MainWindow *parent) : QToolBar(parent) { QSignalBlocker blocker(mStarButton); (void)blocker; - QStringList terms = mSearchField->text().split(QRegExp("\\s+")); + QStringList terms = mSearchField->text().split(QRegularExpression("\\s+")); mStarButton->setChecked(terms.contains(kStarredQuery)); }); } diff --git a/src/ui/TreeView.cpp b/src/ui/TreeView.cpp index 22a760be9..770847e3e 100644 --- a/src/ui/TreeView.cpp +++ b/src/ui/TreeView.cpp @@ -129,7 +129,8 @@ void TreeView::discard(DiffTreeModel *model, const QModelIndex &index) { bool TreeView::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::MouseButtonPress) { QWidget *TreeViewport = static_cast(obj); - QPoint globalPos = static_cast(event)->globalPos(); + QPoint globalPos = + static_cast(event)->globalPosition().toPoint(); QModelIndex index = indexAt(viewport()->mapFromGlobal(globalPos)); if (!TreeViewport->hasFocus() && index.row() < 0) { TreeViewport->setFocus(); @@ -292,7 +293,8 @@ void TreeView::deselectAll() { } QRect TreeView::checkRect(const QModelIndex &index) { - QStyleOptionViewItem options = viewOptions(); + QStyleOptionViewItem options; + initViewItemOption(&options); options.rect = visualRect(index); options.features |= QStyleOptionViewItem::HasCheckIndicator; diff --git a/src/ui/ViewDelegate.cpp b/src/ui/ViewDelegate.cpp index 8e69662ef..af130cdc2 100644 --- a/src/ui/ViewDelegate.cpp +++ b/src/ui/ViewDelegate.cpp @@ -31,7 +31,7 @@ void ViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, // Add extra space. opt.rect.adjust(leftAdjust, 0, rightAdjust, 0); - for (int i = 0; i < status.count(); ++i) { + for (int i = 0; i < status.size(); ++i) { int x = opt.rect.x() + opt.rect.width(); int y = opt.rect.y() + (opt.rect.height() / 2); QRect rect(mMultiColumn ? opt.rect.x() : x - width, y - (height / 2), diff --git a/src/update/CMakeLists.txt b/src/update/CMakeLists.txt index 530376d5b..fb980d3fc 100644 --- a/src/update/CMakeLists.txt +++ b/src/update/CMakeLists.txt @@ -13,14 +13,14 @@ target_link_libraries( conf ${LIBCMARK_LIBRARIES} git - Qt5::Network - Qt5::Widgets + Qt6::Network + Qt6::Widgets ${UPDATER_IMPL_LIBS}) set_target_properties(update PROPERTIES AUTOMOC ON) add_executable(relauncher relauncher.cpp) -target_link_libraries(relauncher Qt5::Core) +target_link_libraries(relauncher Qt6::Core) set_target_properties(relauncher PROPERTIES RUNTIME_OUTPUT_DIRECTORY $) diff --git a/src/update/relauncher.cpp b/src/update/relauncher.cpp index 0e0637c0a..ad14eab91 100644 --- a/src/update/relauncher.cpp +++ b/src/update/relauncher.cpp @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) { #endif // Restart from the path argument. - QProcess::startDetached(args.first()); + QProcess::startDetached(args.first(), QStringList()); return 0; } diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 4d039839f..b81930009 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -1,6 +1,6 @@ add_library(util Path.cpp Debug.h Debug.cpp) -target_link_libraries(util Qt5::Core) +target_link_libraries(util Qt6::Core) target_include_directories(util INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) set_target_properties(util PROPERTIES AUTOMOC ON) diff --git a/src/watcher/CMakeLists.txt b/src/watcher/CMakeLists.txt index 16de10f5b..2818a4f10 100644 --- a/src/watcher/CMakeLists.txt +++ b/src/watcher/CMakeLists.txt @@ -13,6 +13,6 @@ add_library(watcher RepositoryWatcher.cpp ${WATCHER_IMPL_FILE}) target_include_directories(watcher PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -target_link_libraries(watcher git Qt5::Core ${WATCHER_IMPL_LIBS}) +target_link_libraries(watcher git Qt6::Core ${WATCHER_IMPL_LIBS}) set_target_properties(watcher PROPERTIES AUTOMOC ON) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 10053099d..99ba8fe34 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -23,10 +23,10 @@ macro(test) endif() if(WIN32) - find_package(Qt5Gui) + find_package(Qt6Gui) string(REPLACE ";" "\;" NEWPATH "$ENV{PATH}") string(REPLACE ";" "\;" PLUGIN_PATH - "$") + "$") if(${ARG_NO_WIN32_OFFSCREEN}) set(PLATFORM "windows") @@ -73,7 +73,7 @@ set(CMAKE_DISABLE_TESTING ON) add_subdirectory(dep/zip) add_library(testlib EXCLUDE_FROM_ALL Test.cpp) -target_link_libraries(testlib app git ui Qt5::Test zip) +target_link_libraries(testlib app git ui Qt6::Test zip) target_include_directories(testlib PRIVATE ${CMAKE_SOURCE_DIR}/src) target_compile_definitions( testlib @@ -92,10 +92,10 @@ test(NAME bare_repo) test(NAME init_repo) test(NAME merge) test(NAME external_tools_dialog) -test(NAME branches_panel NO_WIN32_OFFSCREEN) -test(NAME editor NO_WIN32_OFFSCREEN) +test(NAME branches_panel) +test(NAME editor) test(NAME index) -test(NAME line_endings NO_WIN32_OFFSCREEN) +test(NAME line_endings) test(NAME log) test(NAME main_window) test(NAME new_branch_dialog) diff --git a/test/amend.cpp b/test/amend.cpp index 475aebee6..b85a40ed3 100644 --- a/test/amend.cpp +++ b/test/amend.cpp @@ -57,10 +57,12 @@ void TestAmend::testAmend() { auto authorSignature = repo.signature( "New Author", "New Author Email", - QDateTime::fromString("Sun May 23 10:36:26 2022 +0200", Qt::RFC2822Date)); + QDateTime::fromString("Mon May 23 10:36:26 2022 +0200", Qt::RFC2822Date)); + + QString dateAuthor = "Mon May 23 10:36:26 2022 +0200"; auto committerSignature = repo.signature( "New Committer", "New Committer Email", - QDateTime::fromString("Sun May 23 11:36:26 2022 +0200", Qt::RFC2822Date)); + QDateTime::fromString("Mon May 23 11:36:26 2022 +0200", Qt::RFC2822Date)); Tree tree; c.amend(authorSignature, committerSignature, commitMessage, tree); @@ -73,12 +75,12 @@ void TestAmend::testAmend() { QCOMPARE(c.author().name(), "New Author"); QCOMPARE( c.author().date(), - QDateTime::fromString("Sun May 23 10:36:26 2022 +0200", Qt::RFC2822Date)); + QDateTime::fromString("Mon May 23 10:36:26 2022 +0200", Qt::RFC2822Date)); QCOMPARE(c.committer().name(), "New Committer"); QCOMPARE(c.committer().email(), "New Committer Email"); QCOMPARE( c.committer().date(), - QDateTime::fromString("Sun May 23 11:36:26 2022 +0200", Qt::RFC2822Date)); + QDateTime::fromString("Mon May 23 11:36:26 2022 +0200", Qt::RFC2822Date)); } void TestAmend::testAmendAddFile() { @@ -196,10 +198,10 @@ void TestAmend::testAmendDialog() { Test::ScratchRepository repo; auto authorSignature = repo->signature( "New Author", "New Author Email", - QDateTime::fromString("Sun May 23 10:36:26 2022 +0200", Qt::RFC2822Date)); + QDateTime::fromString("Mon May 23 10:36:26 2022 +0200", Qt::RFC2822Date)); auto committerSignature = repo->signature( "New Committer", "New Committer Email", - QDateTime::fromString("Sun May 23 11:36:26 2022 +0200", Qt::RFC2822Date)); + QDateTime::fromString("Mon May 23 11:36:26 2022 +0200", Qt::RFC2822Date)); { AmendDialog d(authorSignature, committerSignature, "Test commit message"); @@ -241,7 +243,7 @@ void TestAmend::testAmendDialog() { ContributorInfo::SelectedDateTimeType::Original); QCOMPARE(authorCommitDate->isVisible(), false); QCOMPARE(info.authorInfo.commitDate, - QDateTime::fromString("Sun May 23 10:36:26 2022 +0200", + QDateTime::fromString("Mon May 23 10:36:26 2022 +0200", Qt::RFC2822Date)); // manual @@ -290,7 +292,7 @@ void TestAmend::testAmendDialog() { ContributorInfo::SelectedDateTimeType::Original); QCOMPARE(committerCommitDate->isVisible(), false); QCOMPARE(info.committerInfo.commitDate, - QDateTime::fromString("Sun May 23 11:36:26 2022 +0200", + QDateTime::fromString("Mon May 23 11:36:26 2022 +0200", Qt::RFC2822Date)); // manual @@ -318,10 +320,10 @@ void TestAmend::testAmendDialog2() { Test::ScratchRepository repo; auto authorSignature = repo->signature( "New Author", "New Author Email", - QDateTime::fromString("Sun May 23 10:36:26 2022 +0200", Qt::RFC2822Date)); + QDateTime::fromString("Mon May 23 10:36:26 2022 +0200", Qt::RFC2822Date)); auto committerSignature = repo->signature( "New Committer", "New Committer Email", - QDateTime::fromString("Sun May 23 11:36:26 2022 +0200", Qt::RFC2822Date)); + QDateTime::fromString("Mon May 23 11:36:26 2022 +0200", Qt::RFC2822Date)); AmendDialog d(authorSignature, committerSignature, "Test commit message"); @@ -373,10 +375,10 @@ void TestAmend::testAmendDialogNewLineInMessage() { Test::ScratchRepository repo; auto authorSignature = repo->signature( "New Author", "New Author Email", - QDateTime::fromString("Sun May 23 10:36:26 2022 +0200", Qt::RFC2822Date)); + QDateTime::fromString("Mon May 23 10:36:26 2022 +0200", Qt::RFC2822Date)); auto committerSignature = repo->signature( "New Committer", "New Committer Email", - QDateTime::fromString("Sun May 23 11:36:26 2022 +0200", Qt::RFC2822Date)); + QDateTime::fromString("Mon May 23 11:36:26 2022 +0200", Qt::RFC2822Date)); AmendDialog d(authorSignature, committerSignature, "Test commit message\nNewLine");