From 3ca7910d78dfd0c34754daaaca6c05dae3d169bc Mon Sep 17 00:00:00 2001 From: Zhangtingan Date: Thu, 16 Jan 2025 15:36:54 +0800 Subject: [PATCH 1/3] feat: adapt for Qt6.8 Log: as title --- 3rdparty/CMakeLists.txt | 4 +- .../diff-match-patch/diff_match_patch.cpp | 45 ++++++++++--------- 3rdparty/diff-match-patch/diff_match_patch.h | 4 +- .../unioncode-qscintilla214/CMakeLists.txt | 11 +++-- .../lib/qtermwidget.cpp | 4 ++ CMakeLists.txt | 24 +++++++--- assets/CMakeLists.txt | 6 +-- debian/control | 24 +++++----- debian/rules | 12 +++++ src/base/CMakeLists.txt | 4 +- src/common/CMakeLists.txt | 9 ++-- src/common/actionmanager/actionmanager.cpp | 1 + src/common/dialog/propertiesdialog.cpp | 2 +- .../lsp/protocol/new/languagefeatures.h | 2 +- src/common/lsp/server/serverapplication.h | 10 +++-- src/common/settings/settings.cpp | 19 ++++++-- src/common/widget/detailsbutton.cpp | 7 ++- src/common/widget/detailsbutton.h | 4 ++ src/common/widget/variablechooser.cpp | 10 ++++- src/framework/CMakeLists.txt | 4 +- src/framework/event/eventcallproxy.cpp | 3 +- src/framework/log/logutils.cpp | 8 ++-- src/plugins/CMakeLists.txt | 8 ++-- src/plugins/aimanager/CMakeLists.txt | 12 ----- src/plugins/aimanager/option/detailwidget.h | 2 +- .../configure/binarytoolsmanager.cpp | 4 ++ .../builder/mainframe/settingdialog.cpp | 1 + src/plugins/codeeditor/CMakeLists.txt | 9 ++++ src/plugins/codeeditor/codelens/codelens.cpp | 4 +- src/plugins/codeeditor/encodes/detectcode.cpp | 3 +- .../gui/completion/codecompletionmodel.cpp | 15 +++++-- .../gui/completion/codecompletionwidget.cpp | 9 +++- .../codeeditor/gui/private/tabwidget_p.h | 2 +- src/plugins/codeeditor/gui/tabwidget.cpp | 2 +- src/plugins/codeeditor/gui/texteditor.cpp | 15 ++++--- .../codeeditor/gui/workspacewidget.cpp | 8 ++-- .../codeeditor/lsp/languageclienthandler.cpp | 2 +- src/plugins/codeeditor/lsp/stylesettings.h | 2 +- .../codeeditor/statusbar/encodecombobox.cpp | 2 +- src/plugins/codeeditor/symbol/symbolbar.cpp | 11 ++++- src/plugins/codeeditor/symbol/symbolbar.h | 4 ++ src/plugins/codegeex/CMakeLists.txt | 4 +- src/plugins/codegeex/codegeexmanager.cpp | 2 +- src/plugins/codegeex/data/messagedata.cpp | 4 ++ .../codegeex/widgets/askpagewidget.cpp | 2 +- .../codegeex/widgets/codeeditcomponent.cpp | 6 ++- .../codegeex/widgets/codegeexwidget.cpp | 21 ++++----- .../codegeex/widgets/historylistwidget.cpp | 2 +- .../codegeex/widgets/inlinechatwidget.cpp | 18 ++++---- src/plugins/codegeex/widgets/intropage.cpp | 4 +- .../codegeex/widgets/messagecomponent.cpp | 4 +- .../codegeex/widgets/pagecontrolcomponent.cpp | 4 +- .../codegeex/widgets/sessionrecorditem.cpp | 6 +-- src/plugins/codeporting/codeporting.cpp | 16 +++---- src/plugins/commandproxy/commandexecuter.cpp | 4 ++ src/plugins/core/CMakeLists.txt | 9 ++-- src/plugins/core/depend/dependencemanager.cpp | 4 +- src/plugins/core/gui/dockheader.cpp | 4 +- src/plugins/core/gui/navigationbar.h | 4 ++ src/plugins/core/gui/plugindetailsview.cpp | 6 +-- src/plugins/core/gui/pluginlistview.cpp | 2 +- src/plugins/core/gui/pluginstorewidget.cpp | 1 - src/plugins/core/notify/gui/bubble.cpp | 4 ++ src/plugins/core/notify/gui/bubble.h | 4 ++ .../core/notify/gui/notificationmodel.cpp | 2 +- .../core/notify/notificationmanager.cpp | 2 +- src/plugins/core/session/sessiondialog.cpp | 2 +- src/plugins/core/session/sessionmodel.cpp | 2 +- src/plugins/core/uicontroller/controller.cpp | 16 ++++--- src/plugins/core/uicontroller/mainwindow.cpp | 4 +- src/plugins/cxx/CMakeLists.txt | 5 +-- .../cxx/cmake/builder/parser/cmakeparser.cpp | 4 +- src/plugins/cxx/cmake/option/kit.cpp | 2 +- src/plugins/cxx/cmake/option/kit.h | 2 +- .../cxx/cmake/project/cbp/cbpparser.cpp | 8 ++-- .../cxx/cmake/project/cmakeasynparse.cpp | 33 +++++++------- .../cmake/project/cmakeprojectgenerator.cpp | 3 +- .../bulidCfgWidget/buildpropertypage.cpp | 4 +- .../cmakeCfgWidget/cmakeitemmodel.cpp | 2 +- .../cmake/project/properties/configutil.cpp | 4 ++ .../project/properties/environmentwidget.cpp | 2 +- .../properties/runCfgWidget/runconfigpane.cpp | 2 +- .../runCfgWidget/runpropertypage.cpp | 2 +- .../project/properties/targetsmanager.cpp | 6 ++- .../cxx/ninja/builder/parser/ninjaparser.cpp | 4 +- src/plugins/debugger/dap/dapdebugger.cpp | 10 +++-- src/plugins/debugger/debugmanager.cpp | 6 ++- .../debugger/interface/attachinfodialog.cpp | 4 ++ .../debugger/interface/localtreeitem.cpp | 2 +- .../debugger/interface/localtreeitem.h | 1 + .../debugger/interface/localtreemodel.cpp | 7 +-- .../debugger/reversedebug/reversedebugger.cpp | 6 +-- src/plugins/debugger/runner/runner.cpp | 6 +-- src/plugins/filebrowser/filebrowser.cpp | 2 +- .../filebrowser/mainframe/filetreeview.cpp | 2 +- src/plugins/find/constants.h | 2 +- src/plugins/find/gui/advancedsearchwidget.cpp | 12 +++-- .../find/gui/searchresultitemdelegate.cpp | 4 +- .../worker/searchreplaceworker.cpp | 4 ++ src/plugins/git/gui/gitblamewidget.cpp | 6 +++ src/plugins/git/utils/gitcommand.cpp | 4 ++ src/plugins/java/CMakeLists.txt | 5 +-- .../gradle/builder/parser/gradleparser.cpp | 4 +- .../gradle/project/gradleprojectgenerator.cpp | 2 +- src/plugins/java/javautil.cpp | 6 +-- .../java/maven/builder/parser/mavenparser.cpp | 8 ++-- src/plugins/java/maven/mavengenerator.cpp | 2 +- src/plugins/javascript/CMakeLists.txt | 7 +-- .../linglong/builder/parser/llparser.cpp | 4 +- src/plugins/option/optioncore/CMakeLists.txt | 6 +-- .../mainframe/persistentsettings.cpp | 14 +++--- .../mainframe/profilesettingwidget.cpp | 2 +- .../performance/mainframe/mainwindow.cpp | 2 +- .../project/locator/allprojectfilelocator.cpp | 2 +- .../project/locator/currentprojectlocator.cpp | 2 +- src/plugins/python/CMakeLists.txt | 5 +-- .../python/option/interpreterwidget.cpp | 8 ++-- .../properties/configpropertywidget.cpp | 16 +++---- src/plugins/python/python/pythongenerator.cpp | 6 +-- .../recent/mainframe/sessionitemwidget.cpp | 4 +- src/plugins/reversedebug/loadcoredialog.cpp | 2 - .../reversedebug/reversedebuggermgr.cpp | 2 +- src/plugins/reversedebug/taskwindow.cpp | 2 +- .../smartut/common/projectitemdelegate.cpp | 2 +- src/plugins/smartut/gui/projecttreeview.cpp | 1 + .../gui/widget/promptsettingwidget.cpp | 1 + .../gui/widget/resourcesettingwidget.cpp | 3 +- src/plugins/smartut/utils/utils.cpp | 6 ++- src/plugins/symbol/mainframe/symbolparser.cpp | 16 +++---- src/plugins/template/wizard/maindialog.cpp | 2 +- .../valgrind/mainframe/valgrindbar.cpp | 4 +- src/services/option/toolchaindata.h | 2 +- src/services/project/directoryasynparse.cpp | 5 ++- src/services/project/directorygenerator.cpp | 2 +- src/services/project/projectgenerator.cpp | 2 +- src/tools/debugadapter/CMakeLists.txt | 2 +- src/tools/debugadapter/dapsession.cpp | 38 ++++++++-------- .../debugger/gdbmi/gdbdebugger.cpp | 15 ++++--- .../debugadapter/debugger/gdbmi/gdbmi.cpp | 13 +++++- .../debugger/python/pythondebugger.cpp | 2 +- src/tools/debugadapter/debugmanager.cpp | 2 +- src/tools/languageadapter/CMakeLists.txt | 4 +- src/tools/performancedapter/CMakeLists.txt | 4 +- src/tools/performancedapter/tools.cpp | 4 +- 144 files changed, 536 insertions(+), 361 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 531eb9c0f..b62e64d0d 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -1,5 +1,7 @@ add_subdirectory(cppdap) -add_subdirectory(unioncode-GitQlient) add_subdirectory(unioncode-qscintilla214) +if (QT_VERSION_MAJOR MATCHES 5) +add_subdirectory(unioncode-GitQlient) add_subdirectory(unioncode-qtermwidget-0.14.1) +endif() add_subdirectory(unioncode-jsonrpccpp) diff --git a/3rdparty/diff-match-patch/diff_match_patch.cpp b/3rdparty/diff-match-patch/diff_match_patch.cpp index 92a992f87..7173fd513 100644 --- a/3rdparty/diff-match-patch/diff_match_patch.cpp +++ b/3rdparty/diff-match-patch/diff_match_patch.cpp @@ -64,7 +64,7 @@ QString Diff::strOperation(Operation op) { QString Diff::toString() const { QString prettyText = text; // Replace linebreaks with Pilcrow signs. - prettyText.replace('\n', L'\u00b6'); + prettyText.replace('\n', QChar(L'\u00b6')); return QString("Diff(") + strOperation(operation) + QString(",\"") + prettyText + QString("\")"); } @@ -954,8 +954,8 @@ int diff_match_patch::diff_cleanupSemanticScore(const QString &one, bool whitespace2 = nonAlphaNumeric2 && char2.isSpace(); bool lineBreak1 = whitespace1 && char1.category() == QChar::Other_Control; bool lineBreak2 = whitespace2 && char2.category() == QChar::Other_Control; - bool blankLine1 = lineBreak1 && BLANKLINEEND.indexIn(one) != -1; - bool blankLine2 = lineBreak2 && BLANKLINESTART.indexIn(two) != -1; + bool blankLine1 = lineBreak1 && BLANKLINEEND.match(one).hasMatch(); + bool blankLine2 = lineBreak2 && BLANKLINESTART.match(two).hasMatch(); if (blankLine1 || blankLine2) { // Five points for blank lines. @@ -978,8 +978,8 @@ int diff_match_patch::diff_cleanupSemanticScore(const QString &one, // Define some regex patterns for matching boundaries. -QRegExp diff_match_patch::BLANKLINEEND = QRegExp("\\n\\r?\\n$"); -QRegExp diff_match_patch::BLANKLINESTART = QRegExp("^\\r?\\n\\r?\\n"); +QRegularExpression diff_match_patch::BLANKLINEEND = QRegularExpression("\\n\\r?\\n$"); +QRegularExpression diff_match_patch::BLANKLINESTART = QRegularExpression("^\\r?\\n\\r?\\n"); void diff_match_patch::diff_cleanupEfficiency(QList &diffs) { @@ -1429,7 +1429,7 @@ int diff_match_patch::match_main(const QString &text, const QString &pattern, throw "Null inputs. (match_main)"; } - loc = std::max(0, std::min(loc, text.length())); + loc = std::max(0, std::min(loc, int(text.length()))); if (text == pattern) { // Shortcut (potentially not guaranteed by the algorithm) return 0; @@ -1497,7 +1497,7 @@ int diff_match_patch::match_bitap(const QString &text, const QString &pattern, // Use the result from this iteration as the maximum for the next. bin_max = bin_mid; int start = std::max(1, loc - bin_mid + 1); - int finish = std::min(loc + bin_mid, text.length()) + pattern.length(); + int finish = std::min(loc + bin_mid, int(text.length()) + int(pattern.length())); rd = new int[finish + 2]; rd[finish + 1] = (1 << d) - 1; @@ -1592,7 +1592,7 @@ void diff_match_patch::patch_addContext(Patch &patch, const QString &text) { && pattern.length() < Match_MaxBits - Patch_Margin - Patch_Margin) { padding += Patch_Margin; pattern = safeMid(text, std::max(0, patch.start2 - padding), - std::min(text.length(), patch.start2 + patch.length1 + padding) + std::min(int(text.length()), patch.start2 + patch.length1 + padding) - std::max(0, patch.start2 - padding)); } // Add one chunk for good luck. @@ -1606,7 +1606,7 @@ void diff_match_patch::patch_addContext(Patch &patch, const QString &text) { } // Add the suffix. QString suffix = safeMid(text, patch.start2 + patch.length1, - std::min(text.length(), patch.start2 + patch.length1 + padding) + std::min(int(text.length()), patch.start2 + patch.length1 + padding) - (patch.start2 + patch.length1)); if (!suffix.isEmpty()) { patch.diffs.append(Diff(EQUAL, suffix)); @@ -1974,7 +1974,7 @@ void diff_match_patch::patch_splitMax(QList &patches) { bigpatch.diffs.removeFirst(); } else { // Deletion or equality. Only take as much as we can stomach. - diff_text = diff_text.left(std::min(diff_text.length(), + diff_text = diff_text.left(std::min(int(diff_text.length()), patch_size - patch.length1 - Patch_Margin)); patch.length1 += diff_text.length(); start1 += diff_text.length(); @@ -2035,37 +2035,42 @@ QList diff_match_patch::patch_fromText(const QString &textline) { if (textline.isEmpty()) { return patches; } +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QStringList text = textline.split("\n", QString::SkipEmptyParts); +#else + QStringList text = textline.split("\n", Qt::SkipEmptyParts); +#endif Patch patch; - QRegExp patchHeader("^@@ -(\\d+),?(\\d*) \\+(\\d+),?(\\d*) @@$"); + QRegularExpression patchHeader("^@@ -(\\d+),?(\\d*) \\+(\\d+),?(\\d*) @@$"); char sign; QString line; while (!text.isEmpty()) { - if (!patchHeader.exactMatch(text.front())) { + auto match = patchHeader.match(text.front()); + if (!match.hasMatch()) { throw QString("Invalid patch string: %1").arg(text.front()); } patch = Patch(); - patch.start1 = patchHeader.cap(1).toInt(); - if (patchHeader.cap(2).isEmpty()) { + patch.start1 = match.captured(1).toInt(); + if (match.captured(2).isEmpty()) { patch.start1--; patch.length1 = 1; - } else if (patchHeader.cap(2) == "0") { + } else if (match.captured(2) == "0") { patch.length1 = 0; } else { patch.start1--; - patch.length1 = patchHeader.cap(2).toInt(); + patch.length1 = match.captured(2).toInt(); } - patch.start2 = patchHeader.cap(3).toInt(); - if (patchHeader.cap(4).isEmpty()) { + patch.start2 = match.captured(3).toInt(); + if (match.captured(4).isEmpty()) { patch.start2--; patch.length2 = 1; - } else if (patchHeader.cap(4) == "0") { + } else if (match.captured(4) == "0") { patch.length2 = 0; } else { patch.start2--; - patch.length2 = patchHeader.cap(4).toInt(); + patch.length2 = match.captured(4).toInt(); } text.removeFirst(); diff --git a/3rdparty/diff-match-patch/diff_match_patch.h b/3rdparty/diff-match-patch/diff_match_patch.h index d915294fd..472870afb 100644 --- a/3rdparty/diff-match-patch/diff_match_patch.h +++ b/3rdparty/diff-match-patch/diff_match_patch.h @@ -152,8 +152,8 @@ class diff_match_patch { private: // Define some regex patterns for matching boundaries. - static QRegExp BLANKLINEEND; - static QRegExp BLANKLINESTART; + static QRegularExpression BLANKLINEEND; + static QRegularExpression BLANKLINESTART; public: diff --git a/3rdparty/unioncode-qscintilla214/CMakeLists.txt b/3rdparty/unioncode-qscintilla214/CMakeLists.txt index 8307a3bf7..c20179531 100644 --- a/3rdparty/unioncode-qscintilla214/CMakeLists.txt +++ b/3rdparty/unioncode-qscintilla214/CMakeLists.txt @@ -8,12 +8,11 @@ set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) - -find_package(Qt5 COMPONENTS +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets PrintSupport REQUIRED) -find_package(Dtk COMPONENTS Widget REQUIRED) +find_package(Dtk${DTK_VERSION_MAJOR} COMPONENTS Widget REQUIRED) file(GLOB_RECURSE SRCS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h" @@ -40,9 +39,9 @@ target_include_directories(${PROJECT_NAME} target_link_libraries( ${PROJECT_NAME} - Qt5::Widgets - Qt5::PrintSupport + Qt${QT_VERSION_MAJOR}::Widgets + Qt${QT_VERSION_MAJOR}::PrintSupport ${DtkWidget_LIBRARIES} ) -install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${LIBRARY_INSTALL_PREFIX}) +install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${LIBRARY_INSTALL_PREFIX}) \ No newline at end of file diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/qtermwidget.cpp b/3rdparty/unioncode-qtermwidget-0.14.1/lib/qtermwidget.cpp index 5c3e56fad..2d92a8b59 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/qtermwidget.cpp +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/qtermwidget.cpp @@ -259,7 +259,11 @@ void QTermWidget::init(int startnow) // translations // First check $XDG_DATA_DIRS. This follows the implementation in libqtxdg QString d = QFile::decodeName(qgetenv("XDG_DATA_DIRS")); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + QStringList dirs = d.split(QLatin1Char(':'), Qt::SkipEmptyParts); + #else QStringList dirs = d.split(QLatin1Char(':'), QString::SkipEmptyParts); + #endif if (dirs.isEmpty()) { dirs.append(QString::fromLatin1("/usr/local/share")); dirs.append(QString::fromLatin1("/usr/share")); diff --git a/CMakeLists.txt b/CMakeLists.txt index fbb4efa74..947922ae3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1.0) +cmake_minimum_required(VERSION 3.18.0) project(deepin-unioncode) @@ -10,6 +10,7 @@ function(print_directory arg) endfunction() set(VERSION $ENV{VERSION}) + if (NOT VERSION) set(VERSION "0.0.1") endif() @@ -79,17 +80,30 @@ endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wl,--as-need -fPIE") -find_package(Dtk COMPONENTS Widget REQUIRED) +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) +message(" >>> Found Qt version: ${QT_VERSION_MAJOR}") +if (QT_VERSION_MAJOR MATCHES 6) + set(DTK_VERSION_MAJOR 6) + set(KF_VERSION_MAJOR 6) +else() + set(DTK_VERSION_MAJOR "") + set(KF_VERSION_MAJOR 5) + +endif() +message(" >>> Build with DTK: ${DTK_VERSION_MAJOR}") + +find_package(Dtk${DTK_VERSION_MAJOR} COMPONENTS Widget REQUIRED) include_directories(${PROJECT_NAME} PRIVATE ${DtkWidget_INCLUDE_DIRS}) # Use Qt modules no WebEngineWidgets WebChannel set(QtFindModules Core Gui Widgets Concurrent Network DBus) + foreach(QtModule ${QtFindModules}) - find_package(Qt5 COMPONENTS ${QtModule} REQUIRED) + find_package(Qt${QT_VERSION_MAJOR} COMPONENTS ${QtModule} REQUIRED) # include qt module private include directors - include_directories(${Qt5${QtModule}_PRIVATE_INCLUDE_DIRS}) + include_directories(${Qt${QT_VERSION_MAJOR}${QtModule}_PRIVATE_INCLUDE_DIRS}) # can use target_link_libraries(xxx ${QtUseModules}) - list(APPEND QtUseModules "Qt5::${QtModule}") + list(APPEND QtUseModules "Qt${QT_VERSION_MAJOR}::${QtModule}") message("QtModule found ${QtModule} OK!") endforeach() diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt index c1c45fb58..d51e495d4 100644 --- a/assets/CMakeLists.txt +++ b/assets/CMakeLists.txt @@ -4,14 +4,14 @@ install(DIRECTORY templates/ install(DIRECTORY models/ DESTINATION "${SOURCES_INSTALL_RPEFIX}/models") -find_package(Qt5 COMPONENTS LinguistTools) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS LinguistTools) # install translation. if (CMAKE_BUILD_TYPE STREQUAL "Release") file(GLOB TS_FILES "translations/*.ts") foreach(TS_FILE IN LISTS TS_FILES) message(STATUS "process ts file: ${TS_FILE}") - find_program(LUPDATE_COMMAND NAMES lupdate lupdate-qt5 lupdate-qt4 lupdate-pro) + find_program(LUPDATE_COMMAND NAMES lupdate lupdate-Qt${QT_VERSION_MAJOR} lupdate-qt4 lupdate-pro) if (NOT LUPDATE_COMMAND) message(FATAL_ERROR "lupdate command not found") endif() @@ -46,4 +46,4 @@ file(GLOB ICON "${CMAKE_CURRENT_SOURCE_DIR}/configures/*.svg") install(FILES ${SUPPORTFILES} DESTINATION "${SOURCES_INSTALL_RPEFIX}/configures") install(FILES ${DESKTOPFILES} DESTINATION "/usr/share/applications") -install(FILES ${ICON} DESTINATION "${SOURCES_INSTALL_RPEFIX}/configures/icons") +install(FILES ${ICON} DESTINATION "${SOURCES_INSTALL_RPEFIX}/configures/icons") \ No newline at end of file diff --git a/debian/control b/debian/control index 64a61c39b..42127b4a3 100644 --- a/debian/control +++ b/debian/control @@ -5,11 +5,12 @@ Maintainer: Deepin Packages Builder Build-Depends: debhelper (>=9), cmake, - qt5-qmake, - qtbase5-dev, - qttools5-dev, - qttools5-dev-tools, - qtwebengine5-dev[!loong64], + qt6-qmake | qt5-qmake, + qt6-base-dev | qtbase5-dev, + qt6-tools-dev-tools | qttools5-dev-tools, + qt6-tools-dev | qttools5-dev, + qt6-webengine-dev[!loong64] | qtwebengine5-dev[!loong64], + qt6-multimedia-dev, lxqt-build-tools (>= 0.6.0~), libssl-dev, llvm (>=1:7~), @@ -29,15 +30,16 @@ Build-Depends: libelfin-dev, libdbus-1-dev, libxi-dev, - qtscript5-dev, + qt6-script-dev | qtscript5-dev, + qt6-5compat-dev, libqt5scripttools5, clang[!mips64], doxygen, - libdtkgui-dev, - libdtkwidget-dev, - libdtkcore-dev, - libdtkcore5-bin, - libkf5syntaxhighlighting-dev, + libdtk6widget-dev | libdtkwidget-dev, + libdtk6gui-dev | libdtkgui-dev, + libdtk6core-dev | libdtkcore-dev, + libdtkcore5-bin | libdtk6core5-bin, + libkf6syntaxhighlighting-dev | libkf5syntaxhighlighting-dev, libyaml-cpp-dev, libcmark-dev, libchardet-dev, diff --git a/debian/rules b/debian/rules index f79188157..58e746a98 100755 --- a/debian/rules +++ b/debian/rules @@ -3,6 +3,16 @@ include /usr/share/dpkg/default.mk export QT_SELECT=5 DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) +define detect_qt_version +ifneq (,$(shell which qmake6 2>/dev/null)) + QT_DIR="/usr/lib/$(DEB_HOST_MULTIARCH)/cmake/Qt6" +else + QT_DIR="/usr/lib/$(DEB_HOST_MULTIARCH)/cmake/Qt5" +endif +endef + +$(eval $(call detect_qt_version)) + %: dh $@ --parallel @@ -10,6 +20,8 @@ override_dh_auto_configure: dh_auto_configure -- \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ + -DVERSION=$(PACK_VER) \ + -DQT_DIR=$(QT_DIR) \ -DAPP_VERSION=$(DEB_VERSION_UPSTREAM) -DVERSION=$(DEB_VERSION_UPSTREAM) LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 95fb8e1a8..f0aa4a7d0 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -13,7 +13,7 @@ add_library( ${PROJECT_SOURCES} ) -find_package(Dtk COMPONENTS Widget Core Gui REQUIRED) +find_package(Dtk${DTK_VERSION_MAJOR} COMPONENTS Widget Core Gui REQUIRED) target_link_libraries( ${PROJECT_NAME} @@ -36,4 +36,4 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE # config cmake file configure_file(${CMAKE_SOURCE_DIR}/assets/dev/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake.in ${PROJECT_NAME}Config.cmake @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) \ No newline at end of file diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 3ad35ec01..5f9be39fd 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -5,7 +5,6 @@ include(${CMAKE_SOURCE_DIR}/3rdparty/unioncode-jsonrpccpp.cmake) install(FILES ${CMAKE_SOURCE_DIR}/src/common/resource/icons/ide.svg DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/) configure_file(util/config.h.in config.h) -find_package(Qt5Network) set(CMAKE_CXX_STANDARD 17) @@ -37,13 +36,13 @@ target_include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR} ) -find_package(Qt5 COMPONENTS Concurrent REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Concurrent REQUIRED) target_link_libraries( ${PROJECT_NAME} unioncode-jsonrpcclient - Qt5::Network - Qt5::Concurrent + Qt${QT_VERSION_MAJOR}::Network + Qt${QT_VERSION_MAJOR}::Concurrent ${DtkWidget_LIBRARIES} ) @@ -62,4 +61,4 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE # config cmake file configure_file(${CMAKE_SOURCE_DIR}/assets/dev/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake.in ${PROJECT_NAME}Config.cmake @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) \ No newline at end of file diff --git a/src/common/actionmanager/actionmanager.cpp b/src/common/actionmanager/actionmanager.cpp index f486f616f..ac4022bdb 100644 --- a/src/common/actionmanager/actionmanager.cpp +++ b/src/common/actionmanager/actionmanager.cpp @@ -11,6 +11,7 @@ #include #include #include +#include constexpr char kKeyboardShortcuts[] = "KeyboardShortcuts"; static ActionManager *m_instance = nullptr; diff --git a/src/common/dialog/propertiesdialog.cpp b/src/common/dialog/propertiesdialog.cpp index 1c1225d7e..8b46c1ce6 100644 --- a/src/common/dialog/propertiesdialog.cpp +++ b/src/common/dialog/propertiesdialog.cpp @@ -174,7 +174,7 @@ void PropertiesDialog::setupUi(DAbstractDialog *Dialog) bgGroup->setItemMargins(QMargins(0, 0, 0, 0)); bgGroup->setBackgroundRole(QPalette::Window); bgGroup->setUseWidgetBackground(false); - bgGpLayout->setMargin(0); + bgGpLayout->setContentsMargins(0, 0, 0, 0); DFrame *wrapperFrame = new DFrame(bgGroup); wrapperFrame->setLineWidth(0); diff --git a/src/common/lsp/protocol/new/languagefeatures.h b/src/common/lsp/protocol/new/languagefeatures.h index e012ba46d..e4123188f 100644 --- a/src/common/lsp/protocol/new/languagefeatures.h +++ b/src/common/lsp/protocol/new/languagefeatures.h @@ -289,7 +289,7 @@ struct MarkedString : std::string std::string language; std::string value; MarkedString() = default; - MarkedString(const std::string &language, const std::string value) + MarkedString(const std::string &language, const std::string &value) : language(language), value(value){} MarkedString(const std::string &other) : std::string(other){ diff --git a/src/common/lsp/server/serverapplication.h b/src/common/lsp/server/serverapplication.h index b700ee21f..fc833adea 100644 --- a/src/common/lsp/server/serverapplication.h +++ b/src/common/lsp/server/serverapplication.h @@ -63,10 +63,12 @@ class COMMON_EXPORT ServerApplication : public QObject, ServerCmdParse return operator<<(std::list(qListStr.begin(), qListStr.end())); } - std::string operator << (const QStringList &qStrList) - { - return operator<<(std::list(qStrList.begin(), qStrList.end())); - } +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + std::string operator << (const QStringList &qStrList) + { + return operator<<(std::list(qStrList.begin(), qStrList.end())); + } +#endif }; struct Stderr : LogFormat, LogValue{ diff --git a/src/common/settings/settings.cpp b/src/common/settings/settings.cpp index 801fe5087..bb731df78 100644 --- a/src/common/settings/settings.cpp +++ b/src/common/settings/settings.cpp @@ -157,10 +157,17 @@ Settings::~Settings() QStringList Settings::groupList() const { QSet groupList; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) groupList += QSet::fromList(d->settingData.values.keys()); groupList += QSet::fromList(d->defaultData.values.keys()); - return groupList.toList(); +#else + for (auto i : d->settingData.values.keys()) + groupList += i; + for (auto i : d->defaultData.values.keys()) + groupList += i; + return groupList.values(); +#endif } QStringList Settings::keyList(const QString &group) const @@ -168,11 +175,17 @@ QStringList Settings::keyList(const QString &group) const QSet keyList; const auto &&kg = d->settingData.values.value(group); const auto &&dkg = d->defaultData.values.value(group); - +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) keyList += QSet::fromList(kg.keys()); keyList += QSet::fromList(dkg.keys()); - return keyList.toList(); +#else + for (auto i : kg) + keyList += i.toString(); + for (auto i : dkg) + keyList += i.toString(); + return keyList.values(); +#endif } bool Settings::contains(const QString &group, const QString &key) const diff --git a/src/common/widget/detailsbutton.cpp b/src/common/widget/detailsbutton.cpp index 5b52dbf72..3667310e3 100644 --- a/src/common/widget/detailsbutton.cpp +++ b/src/common/widget/detailsbutton.cpp @@ -76,8 +76,11 @@ void DetailsButton::paintEvent(QPaintEvent *event) arrowOpt.palette = pal; style()->drawPrimitive(checked ? QStyle::PE_IndicatorArrowUp : QStyle::PE_IndicatorArrowDown, &arrowOpt, &p, this); } - +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) void DetailsButton::enterEvent(QEvent *event) +#else +void DetailsButton::enterEvent(QEnterEvent *event) +#endif { d->hover = true; return QAbstractButton::enterEvent(event); @@ -86,5 +89,5 @@ void DetailsButton::enterEvent(QEvent *event) void DetailsButton::leaveEvent(QEvent *event) { d->hover = false; - return QAbstractButton::enterEvent(event); + return QAbstractButton::leaveEvent(event); } diff --git a/src/common/widget/detailsbutton.h b/src/common/widget/detailsbutton.h index eb87c3f75..71383c8e1 100644 --- a/src/common/widget/detailsbutton.h +++ b/src/common/widget/detailsbutton.h @@ -18,7 +18,11 @@ class DetailsButton : public QAbstractButton protected: void paintEvent(QPaintEvent *event) override; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) void enterEvent(QEvent *event) override; +#else + void enterEvent(QEnterEvent *event) override; +#endif void leaveEvent(QEvent *event) override; }; diff --git a/src/common/widget/variablechooser.cpp b/src/common/widget/variablechooser.cpp index c3c0efe37..99e46d9f4 100644 --- a/src/common/widget/variablechooser.cpp +++ b/src/common/widget/variablechooser.cpp @@ -68,7 +68,11 @@ class VariableSortFilterProxyModel : public QSortFilterProxyModel if (!index.isValid()) return false; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) const QRegExp regexp = filterRegExp(); +#else + const QRegularExpression regexp = filterRegularExpression(); +#endif if (regexp.pattern().isEmpty() || sourceModel()->rowCount(index) > 0) return true; @@ -246,7 +250,11 @@ void VariableChooserPrivate::updateDescription(const QModelIndex &index, const Q void VariableChooserPrivate::updateFilter(const QString &filter) { - sortModel->setFilterRegExp(QRegExp::escape(filter)); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + sortModel->setFilterRegExp(QRegularExpression::escape(filter)); +#else + sortModel->setFilterRegularExpression(QRegularExpression::escape(filter)); +#endif treeView->expandAll(); } diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt index af74691b4..79b36086b 100644 --- a/src/framework/CMakeLists.txt +++ b/src/framework/CMakeLists.txt @@ -79,7 +79,7 @@ add_library(${PROJECT_NAME} SHARED ${PUBLIC_CPP} ) -find_package(Dtk COMPONENTS Widget Core Gui REQUIRED) +find_package(Dtk${DTK_VERSION_MAJOR} COMPONENTS Widget Core Gui REQUIRED) target_link_libraries( ${PROJECT_NAME} @@ -117,4 +117,4 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE # config cmake file configure_file(${CMAKE_SOURCE_DIR}/assets/dev/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake.in ${PROJECT_NAME}Config.cmake @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) \ No newline at end of file diff --git a/src/framework/event/eventcallproxy.cpp b/src/framework/event/eventcallproxy.cpp index 49cb8045f..b6f3c99ee 100644 --- a/src/framework/event/eventcallproxy.cpp +++ b/src/framework/event/eventcallproxy.cpp @@ -57,7 +57,8 @@ void EventCallProxy::registerHandler(EventHandler::Type type, const QStringList if (type == EventHandler::Type::Async) { invoke = [creator] (HandlerInfo &info, const Event &event) { fillInfo(info, creator); - info.future = QtConcurrent::run(info.handler.data(), &EventHandler::eventProcess, event); + EventHandler *handler = info.handler.data(); + info.future = QtConcurrent::run([handler, event](){handler->eventProcess(event);}); }; } qDebug() << "Register Handler, type " << static_cast(type) << ", topics" << topics; diff --git a/src/framework/log/logutils.cpp b/src/framework/log/logutils.cpp index 78cfd291e..d2910615b 100644 --- a/src/framework/log/logutils.cpp +++ b/src/framework/log/logutils.cpp @@ -89,7 +89,7 @@ QString LogUtils::localDataTimeCSV() */ uint LogUtils::lastTimeStamp(const QDateTime &dateTime, uint dayCount) { - return dateTime.toTime_t() - (86400 * dayCount); + return dateTime.toSecsSinceEpoch() - (86400 * dayCount); } /** @@ -101,7 +101,7 @@ uint LogUtils::lastTimeStamp(const QDateTime &dateTime, uint dayCount) */ QDateTime LogUtils::lastDateTime(const QDateTime &dateTime, uint dayCount) { - return QDateTime::fromTime_t(lastTimeStamp(dateTime,dayCount)); + return QDateTime::fromSecsSinceEpoch(lastTimeStamp(dateTime,dayCount)); } /** @@ -122,8 +122,8 @@ QDateTime LogUtils::lastDateTime(const QDateTime &dateTime, uint dayCount) */ bool LogUtils::containLastDay(const QDateTime &src, const QDateTime &dst, uint dayCount) { - uint srcStamp = src.toTime_t(); - uint dstStamp = dst.toTime_t(); + uint srcStamp = src.toSecsSinceEpoch(); + uint dstStamp = dst.toSecsSinceEpoch(); return dstStamp - (86400 * dayCount) < srcStamp && srcStamp <= dstStamp; } diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 2f66f01b9..db9294701 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -10,8 +10,11 @@ add_subdirectory(recent) add_subdirectory(debugger) add_subdirectory(codeeditor) add_subdirectory(filebrowser) -add_subdirectory(collaborators) -add_subdirectory(console) +if (QT_VERSION_MAJOR MATCHES 5) +#add_subdirectory(collaborators) +#add_subdirectory(console) +# add_subdirectory(javascript) +endif() add_subdirectory(builder) #remove it until system lock issue resolved. #add_subdirectory(container) @@ -35,7 +38,6 @@ else() endif() add_subdirectory(cxx) -add_subdirectory(javascript) add_subdirectory(java) add_subdirectory(python) add_subdirectory(template) diff --git a/src/plugins/aimanager/CMakeLists.txt b/src/plugins/aimanager/CMakeLists.txt index 1f879a94f..41596c09b 100644 --- a/src/plugins/aimanager/CMakeLists.txt +++ b/src/plugins/aimanager/CMakeLists.txt @@ -4,18 +4,6 @@ set(CMAKE_CXX_STANDARD 17) project(aimanager) -find_package(Dtk COMPONENTS Widget REQUIRED) - -set(QtFindModules Core Gui Widgets Concurrent) -foreach(QtModule ${QtFindModules}) - find_package(Qt5 COMPONENTS ${QtModule} REQUIRED) - # include qt module private include directors - include_directories(${Qt5${QtModule}_PRIVATE_INCLUDE_DIRS}) - # can use target_link_libraries(xxx ${QtUseModules}) - list(APPEND QtUseModules "Qt5::${QtModule}") - message("QtModule found ${QtModule} OK!") -endforeach() - FILE(GLOB CODEGEEX_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" diff --git a/src/plugins/aimanager/option/detailwidget.h b/src/plugins/aimanager/option/detailwidget.h index cc6042f75..b1e9ca1fc 100644 --- a/src/plugins/aimanager/option/detailwidget.h +++ b/src/plugins/aimanager/option/detailwidget.h @@ -19,7 +19,7 @@ class TwoLineDelegate : public DTK_WIDGET_NAMESPACE::DStyledItemDelegate { TwoLineDelegate(QAbstractItemView *parent = nullptr) : DStyledItemDelegate(parent) {} void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override { - QStyleOptionViewItemV4 opt = option; + QStyleOptionViewItem opt = option; initStyleOption(&opt, index); DStyledItemDelegate::paint(painter, opt, index); diff --git a/src/plugins/binarytools/configure/binarytoolsmanager.cpp b/src/plugins/binarytools/configure/binarytoolsmanager.cpp index 622675f50..8af592f00 100644 --- a/src/plugins/binarytools/configure/binarytoolsmanager.cpp +++ b/src/plugins/binarytools/configure/binarytoolsmanager.cpp @@ -666,7 +666,11 @@ bool BinaryToolsManager::checkAndSetProcessParams(QSharedPointer pr process->setId(tool.id); process->setProgram(tool.command); auto args = globalMacroExpander()->expandArguments(tool.arguments); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + QStringList argList = args.split(" ", Qt::SkipEmptyParts); + #else QStringList argList = args.split(" ", QString::SkipEmptyParts); + #endif process->setArguments(argList); if (!tool.workingDirectory.isEmpty()) { diff --git a/src/plugins/builder/mainframe/settingdialog.cpp b/src/plugins/builder/mainframe/settingdialog.cpp index 7b2b7f465..a44d72f9a 100644 --- a/src/plugins/builder/mainframe/settingdialog.cpp +++ b/src/plugins/builder/mainframe/settingdialog.cpp @@ -12,6 +12,7 @@ #include #include +#include DWIDGET_USE_NAMESPACE diff --git a/src/plugins/codeeditor/CMakeLists.txt b/src/plugins/codeeditor/CMakeLists.txt index 4b6a6fd1c..cd3d60d2a 100644 --- a/src/plugins/codeeditor/CMakeLists.txt +++ b/src/plugins/codeeditor/CMakeLists.txt @@ -8,6 +8,9 @@ set(CMAKE_INCLUDE_CURRENT_DIR true) add_definitions(-DLIBRARY_INSTALL_PREFIX="${LIBRARY_INSTALL_PREFIX}") find_package(ICU COMPONENTS i18n uc REQUIRED) +if(${QT_VERSION_MAJOR} MATCHES 6) + find_package(Qt6 COMPONENTS Core5Compat REQUIRED) +endif() find_package(PkgConfig REQUIRED) pkg_check_modules(CMARK REQUIRED libcmark) pkg_check_modules(CHARDET REQUIRED chardet) @@ -53,4 +56,10 @@ target_link_libraries(${PROJECT_NAME} ICU::uc ) +if(${QT_VERSION_MAJOR} MATCHES 6) +target_link_libraries(${PROJECT_NAME} + Qt6::Core5Compat +) +endif() + install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH}) diff --git a/src/plugins/codeeditor/codelens/codelens.cpp b/src/plugins/codeeditor/codelens/codelens.cpp index 3659c63c8..92fa6a850 100644 --- a/src/plugins/codeeditor/codelens/codelens.cpp +++ b/src/plugins/codeeditor/codelens/codelens.cpp @@ -34,12 +34,12 @@ CodeLens::CodeLens(QWidget *parent) d->lens = new CodeLensTree(); d->gLayout = new QGridLayout(); d->gLayout->addWidget(d->lens); - d->gLayout->setMargin(0); + d->gLayout->setContentsMargins(0, 0, 0, 0); QHBoxLayout *mainLayout = new QHBoxLayout(); DFrame *mainFrame = new DFrame(this); mainLayout->addWidget(mainFrame); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0, 0, 0, 0); mainFrame->setLayout(d->gLayout); mainFrame->setLineWidth(0); DStyle::setFrameRadius(mainFrame, 0); diff --git a/src/plugins/codeeditor/encodes/detectcode.cpp b/src/plugins/codeeditor/encodes/detectcode.cpp index 68f972b36..217e46534 100644 --- a/src/plugins/codeeditor/encodes/detectcode.cpp +++ b/src/plugins/codeeditor/encodes/detectcode.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -143,7 +144,7 @@ QByteArray DetectCode::getFileEncodingFormat(QString filepath, QByteArray conten /* chardet encoding recognition */ QString str(content); // Match is Chinese (only in UTF-8 encoding) - bool bFlag = str.contains(QRegExp("[\\x4e00-\\x9fa5]+")); + bool bFlag = str.contains(QRegularExpression("[\\x4e00-\\x9fa5]+")); if (bFlag) { const QByteArray suffix = "为增加探测率保留的中文"; QByteArray newContent = content; diff --git a/src/plugins/codeeditor/gui/completion/codecompletionmodel.cpp b/src/plugins/codeeditor/gui/completion/codecompletionmodel.cpp index de4c82822..484315924 100644 --- a/src/plugins/codeeditor/gui/completion/codecompletionmodel.cpp +++ b/src/plugins/codeeditor/gui/completion/codecompletionmodel.cpp @@ -6,6 +6,8 @@ #include "gui/texteditor.h" #include "lsp/languageclienthandler.h" +#include + CompletionSortFilterProxyModel::CompletionSortFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent) { @@ -17,7 +19,11 @@ bool CompletionSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QMode if (!index.isValid()) return false; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) const QRegExp regexp = filterRegExp(); +#else + const QRegularExpression regexp = filterRegularExpression(); +#endif if (regexp.pattern().isEmpty() || sourceModel()->rowCount(index) > 0) return true; @@ -30,11 +36,13 @@ bool CompletionSortFilterProxyModel::lessThan(const QModelIndex &sourceLeft, con auto leftStr = sourceLeft.data(CodeCompletionModel::SortTextRole).toString(); auto rightStr = sourceRight.data(CodeCompletionModel::SortTextRole).toString(); bool ret = leftStr < rightStr; - - const QRegExp regexp = filterRegExp(); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + QRegExp regexp = filterRegExp(); +#else + QRegularExpression regexp = filterRegularExpression(); +#endif if (regexp.pattern().isEmpty()) return ret; - auto leftTextStr = sourceLeft.data(CodeCompletionModel::FilterTextRole).toString(); auto rightTextStr = sourceRight.data(CodeCompletionModel::FilterTextRole).toString(); bool leftStartsWith = leftTextStr.startsWith(regexp.pattern(), Qt::CaseInsensitive); @@ -43,7 +51,6 @@ bool CompletionSortFilterProxyModel::lessThan(const QModelIndex &sourceLeft, con return true; else if (!leftStartsWith && rightStartsWith) return false; - return ret; } diff --git a/src/plugins/codeeditor/gui/completion/codecompletionwidget.cpp b/src/plugins/codeeditor/gui/completion/codecompletionwidget.cpp index 09f177798..5f531fd14 100644 --- a/src/plugins/codeeditor/gui/completion/codecompletionwidget.cpp +++ b/src/plugins/codeeditor/gui/completion/codecompletionwidget.cpp @@ -58,7 +58,11 @@ void CodeCompletionWidget::initConnection() { connect(completionView, &CodeCompletionView::doubleClicked, this, &CodeCompletionWidget::execute); connect(proxyModel, &CodeCompletionModel::modelReset, this, [this] { +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) proxyModel->setFilterRegExp(filterString()); +#else + proxyModel->setFilterRegularExpression(filterString()); +#endif modelContentChanged(); }); connect(proxyModel, &CodeCompletionModel::layoutChanged, this, &CodeCompletionWidget::modelContentChanged); @@ -555,7 +559,10 @@ void CodeCompletionWidget::cursorPositionChanged() QString filter = filterString(); if (filter.isEmpty()) return; - +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) proxyModel->setFilterRegExp(filter); +#else + proxyModel->setFilterRegularExpression(filter); +#endif proxyModel->invalidate(); } diff --git a/src/plugins/codeeditor/gui/private/tabwidget_p.h b/src/plugins/codeeditor/gui/private/tabwidget_p.h index 894f5ffb6..c17aa2224 100644 --- a/src/plugins/codeeditor/gui/private/tabwidget_p.h +++ b/src/plugins/codeeditor/gui/private/tabwidget_p.h @@ -25,7 +25,7 @@ class TabWidgetPrivate : public QObject int pos = 0; QString fileName; - bool operator==(const PosRecord &other) + bool operator==(const PosRecord &other) const { return pos == other.pos && fileName == other.fileName; } diff --git a/src/plugins/codeeditor/gui/tabwidget.cpp b/src/plugins/codeeditor/gui/tabwidget.cpp index fc3d18ce8..7d4e55560 100644 --- a/src/plugins/codeeditor/gui/tabwidget.cpp +++ b/src/plugins/codeeditor/gui/tabwidget.cpp @@ -115,7 +115,7 @@ void TabWidgetPrivate::initUI() editorLayout = new QStackedLayout(); editorLayout->setSpacing(0); - editorLayout->setMargin(0); + editorLayout->setContentsMargins(0, 0, 0, 0); editorLayout->addWidget(spaceWidget); tabBar = new TabBar(q); diff --git a/src/plugins/codeeditor/gui/texteditor.cpp b/src/plugins/codeeditor/gui/texteditor.cpp index 351814099..ffa406aca 100644 --- a/src/plugins/codeeditor/gui/texteditor.cpp +++ b/src/plugins/codeeditor/gui/texteditor.cpp @@ -23,6 +23,7 @@ #include #include #include +#include DWIDGET_USE_NAMESPACE @@ -473,7 +474,7 @@ void TextEditor::addAnnotation(const QString &title, const QString &content, int break; } - d->annotationRecords.insertMulti(title, line); + d->annotationRecords.insert(title, line); static QString formatText("%1:\n%2:\n%3"); auto msg = formatText.arg(title, typeStr, content); addAnnotation(msg, line, type); @@ -499,7 +500,7 @@ void TextEditor::removeAnnotation(const QString &title) void TextEditor::addEOLAnnotation(const QString &title, const QString &content, int line, int type) { - d->eOLAnnotationRecords.insertMulti(title, line); + d->eOLAnnotationRecords.insert(title, line); auto style = d->createAnnotationStyle(type); eOLAnnotate(line, content, style); } @@ -578,7 +579,7 @@ bool TextEditor::hasUncommentedLines(const int &lineFrom, const int &lineTo, con return true; } setSelection(lineFrom, indexFrom, lineTo, indexTo); - QStringList lines = selectedText().split(QRegExp("\\r\\n|\\n|\\r")); + QStringList lines = selectedText().split(QRegularExpression("\\r\\n|\\n|\\r")); for (const QString &line : lines) { if (line.trimmed().isEmpty()) continue; @@ -617,7 +618,7 @@ void TextEditor::addCommentToSelectedLines(const int &lineFrom, const int &lineT QString TextEditor::addCommentPrefix(const QString &selectedTexts, const QString &commentSymbol) { - QStringList lines = selectedTexts.split(QRegExp("\\r\\n|\\n|\\r")); + QStringList lines = selectedTexts.split(QRegularExpression("\\r\\n|\\n|\\r")); QStringList prefixedLines; for (const QString &line : lines) { @@ -634,7 +635,7 @@ QString TextEditor::addCommentPrefix(const QString &selectedTexts, const QString QString TextEditor::delCommentPrefix(const QString &selectedTexts, const QString &commentSymbol) { - QStringList lines = selectedTexts.split(QRegExp("\\r\\n|\\n|\\r")); + QStringList lines = selectedTexts.split(QRegularExpression("\\r\\n|\\n|\\r")); QStringList prefixedLines; QRegularExpression regex(commentSymbol); @@ -708,7 +709,7 @@ void TextEditor::replaceRange(int startPosition, int endPosition, const QString SendScintilla(SCI_SETTARGETEND, endPosition); SendScintilla(SCI_REPLACETARGET, -1, textAsBytes(text).constData()); if (changePos) - SendScintilla(SCI_GOTOPOS, startPosition + text.length()); + SendScintilla(SCI_GOTOPOS, startPosition + int(text.length())); } void TextEditor::insertText(const QString &text) @@ -716,7 +717,7 @@ void TextEditor::insertText(const QString &text) auto textData = text.toLocal8Bit(); SendScintilla(SCI_INSERTTEXT, static_cast(d->cursorPosition()), textData.constData()); - SendScintilla(SCI_SETEMPTYSELECTION, d->cursorPosition() + textData.size()); + SendScintilla(SCI_SETEMPTYSELECTION, d->cursorPosition() + int(textData.size())); } LanguageClientHandler *TextEditor::languageClient() const diff --git a/src/plugins/codeeditor/gui/workspacewidget.cpp b/src/plugins/codeeditor/gui/workspacewidget.cpp index 3ae62a111..424732572 100644 --- a/src/plugins/codeeditor/gui/workspacewidget.cpp +++ b/src/plugins/codeeditor/gui/workspacewidget.cpp @@ -1073,8 +1073,8 @@ QStringList WorkspaceWidget::modifiedFiles() const files << tabWidget->modifiedFiles(); // Delete duplicates - auto tmp = files.toSet(); - return tmp.toList(); + files.removeDuplicates(); + return files; } QString WorkspaceWidget::rangeText(const QString &fileName, const dpfservice::Edit::Range &range) @@ -1190,8 +1190,8 @@ QStringList WorkspaceWidget::openedFiles() const files << tabWidget->openedFiles(); // Delete duplicates - auto tmp = files.toSet(); - return tmp.toList(); + files.removeDuplicates(); + return files; } QString WorkspaceWidget::fileText(const QString &fileName) const diff --git a/src/plugins/codeeditor/lsp/languageclienthandler.cpp b/src/plugins/codeeditor/lsp/languageclienthandler.cpp index cf6d5dbb1..69557b339 100644 --- a/src/plugins/codeeditor/lsp/languageclienthandler.cpp +++ b/src/plugins/codeeditor/lsp/languageclienthandler.cpp @@ -20,7 +20,7 @@ #include "Qsci/qscilexer.h" #include -#include +#include #include #include diff --git a/src/plugins/codeeditor/lsp/stylesettings.h b/src/plugins/codeeditor/lsp/stylesettings.h index 3e723292c..7d5cd1423 100644 --- a/src/plugins/codeeditor/lsp/stylesettings.h +++ b/src/plugins/codeeditor/lsp/stylesettings.h @@ -82,7 +82,7 @@ class StyleSettings : public QObject }; explicit StyleSettings(QObject *parent = nullptr); - explicit StyleSettings(const StyleSettings &other); + StyleSettings(const StyleSettings &other); ~StyleSettings(); StyleSettings &operator=(const StyleSettings &other); diff --git a/src/plugins/codeeditor/statusbar/encodecombobox.cpp b/src/plugins/codeeditor/statusbar/encodecombobox.cpp index 7baa756e7..60aab3acc 100644 --- a/src/plugins/codeeditor/statusbar/encodecombobox.cpp +++ b/src/plugins/codeeditor/statusbar/encodecombobox.cpp @@ -152,7 +152,7 @@ QIcon EncodeComboBox::createIcon() } QFontMetrics metrics(font()); - int fontWidth = metrics.width(curEncodeName) + 20; + int fontWidth = metrics.horizontalAdvance(curEncodeName) + 20; int fontHeight = metrics.size(Qt::TextSingleLine, curEncodeName).height(); int iconW = 8; int iconH = 5; diff --git a/src/plugins/codeeditor/symbol/symbolbar.cpp b/src/plugins/codeeditor/symbol/symbolbar.cpp index bc43e33b3..50f3d850a 100644 --- a/src/plugins/codeeditor/symbol/symbolbar.cpp +++ b/src/plugins/codeeditor/symbol/symbolbar.cpp @@ -95,7 +95,11 @@ void CurmbItem::mousePressEvent(QMouseEvent *event) QWidget::mousePressEvent(event); } +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) void CurmbItem::enterEvent(QEvent *event) +#else +void CurmbItem::enterEvent(QEnterEvent *event) +#endif { isHover = true; update(); @@ -188,15 +192,18 @@ void SymbolBar::setPath(const QString &path) break; } } - +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + auto itemList = displayPath.split(QDir::separator(), Qt::SkipEmptyParts); + #else auto itemList = displayPath.split(QDir::separator(), QString::SkipEmptyParts); + #endif for (int i = 0; i < itemList.size(); ++i) { CurmbItem *item = new CurmbItem(CurmbItem::FilePath, i, this); setFixedHeight(item->height()); item->setText(itemList[i]); item->setToolTip(path); if (i == itemList.size() - 1) - item->setIcon(DFileIconProvider::globalProvider()->icon(path)); + item->setIcon(DFileIconProvider::globalProvider()->icon(QFileInfo(path))); QString filePath = workspaceDir + QDir::separator() + itemList.mid(0, i + 1).join(QDir::separator()); item->setUserData(filePath); diff --git a/src/plugins/codeeditor/symbol/symbolbar.h b/src/plugins/codeeditor/symbol/symbolbar.h index e964a5f29..eb6613679 100644 --- a/src/plugins/codeeditor/symbol/symbolbar.h +++ b/src/plugins/codeeditor/symbol/symbolbar.h @@ -35,7 +35,11 @@ class CurmbItem : public QWidget protected: void mousePressEvent(QMouseEvent *event) override; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) void enterEvent(QEvent *event) override; +#else + void enterEvent(QEnterEvent *event) override; +#endif void leaveEvent(QEvent *event) override; void paintEvent(QPaintEvent *event) override; diff --git a/src/plugins/codegeex/CMakeLists.txt b/src/plugins/codegeex/CMakeLists.txt index ad02fb180..5499cb697 100644 --- a/src/plugins/codegeex/CMakeLists.txt +++ b/src/plugins/codegeex/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0.2) project(codegeex) -find_package(KF5SyntaxHighlighting) +find_package(KF${KF_VERSION_MAJOR}SyntaxHighlighting) pkg_check_modules(CMARK REQUIRED libcmark) FILE(GLOB CODEGEEX_FILES @@ -34,7 +34,7 @@ target_link_libraries(${PROJECT_NAME} ${QtUseModules} ${PkgUserModules} ${DtkWidget_LIBRARIES} - KF5::SyntaxHighlighting + KF${KF_VERSION_MAJOR}::SyntaxHighlighting ${CMARK_LIBRARIES} ) diff --git a/src/plugins/codegeex/codegeexmanager.cpp b/src/plugins/codegeex/codegeexmanager.cpp index c3acb97bf..d68b89461 100644 --- a/src/plugins/codegeex/codegeexmanager.cpp +++ b/src/plugins/codegeex/codegeexmanager.cpp @@ -166,7 +166,7 @@ QString CodeGeeXManager::getChunks(const QString &queryText) context += "\n\n"; for (auto chunk : chunks) { context += chunk.toObject()["fileName"].toString(); - context += '\n```'; + context += QChar('\n```'); context += chunk.toObject()["content"].toString(); context += "```\n\n"; } diff --git a/src/plugins/codegeex/data/messagedata.cpp b/src/plugins/codegeex/data/messagedata.cpp index 0d02dcb1c..2ee6c058a 100644 --- a/src/plugins/codegeex/data/messagedata.cpp +++ b/src/plugins/codegeex/data/messagedata.cpp @@ -18,7 +18,11 @@ MessageData::MessageData(const QString &id, Type type) void MessageData::updateData(const QString &data) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + QStringList lines = data.split("\n", Qt::SkipEmptyParts); + #else QStringList lines = data.split("\n", QString::SkipEmptyParts); + #endif if (lines.length() < msgDataLines.length()) return; diff --git a/src/plugins/codegeex/widgets/askpagewidget.cpp b/src/plugins/codegeex/widgets/askpagewidget.cpp index 00d748d7e..460dc6dca 100644 --- a/src/plugins/codegeex/widgets/askpagewidget.cpp +++ b/src/plugins/codegeex/widgets/askpagewidget.cpp @@ -138,7 +138,7 @@ void AskPageWidget::onLLMChanged(int index) void AskPageWidget::initUI() { QVBoxLayout *layout = new QVBoxLayout; - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); setLayout(layout); diff --git a/src/plugins/codegeex/widgets/codeeditcomponent.cpp b/src/plugins/codegeex/widgets/codeeditcomponent.cpp index 503c3bfb1..b53208083 100644 --- a/src/plugins/codegeex/widgets/codeeditcomponent.cpp +++ b/src/plugins/codegeex/widgets/codeeditcomponent.cpp @@ -186,7 +186,11 @@ void CodeEditComponent::paintEvent(QPaintEvent *event) painter.setPen(Qt::NoPen); painter.setBrush(Qt::black); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) painter.setRenderHint(QPainter::HighQualityAntialiasing); +#else + painter.setRenderHint(QPainter::Antialiasing); +#endif painter.drawRoundedRect(bmp.rect(), 8, 8); setMask(bmp); @@ -199,7 +203,7 @@ void CodeEditComponent::initUI() QVBoxLayout *layout = new QVBoxLayout; layout->setSpacing(0); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); setLayout(layout); titleWidget = new DWidget(this); diff --git a/src/plugins/codegeex/widgets/codegeexwidget.cpp b/src/plugins/codegeex/widgets/codegeexwidget.cpp index c683b5a8c..8748cb63d 100644 --- a/src/plugins/codegeex/widgets/codegeexwidget.cpp +++ b/src/plugins/codegeex/widgets/codegeexwidget.cpp @@ -94,21 +94,18 @@ void CodeGeeXWidget::initUI() // welcome_label->setText(tr("Welcome to CodeGeeX"));//\nA must-have all-round AI tool for developers // welcome_label->setWordWrap(true); // welcome_label->setAlignment(Qt::AlignCenter); - -// auto font = welcome_label->font(); -// font.setPixelSize(14); -// font.setWeight(500); -// welcome_label->setFont(font); - + // auto font = welcome_label->font(); + // font.setPixelSize(14); + // font.setWeight(QFont::Medium); + // welcome_label->setFont(font); // auto descrption_label = new DLabel(loginWidget); // descrption_label->setText(tr("A must-have all-round AI tool for developers")); // descrption_label->setWordWrap(true); // descrption_label->setAlignment(Qt::AlignCenter); - -// font = descrption_label->font(); -// font.setPixelSize(12); -// font.setWeight(400); -// descrption_label->setFont(font); + // font = descrption_label->font(); + // font.setPixelSize(12); + // font.setWeight(QFont::Normal); + // descrption_label->setFont(font); // verticalLayout->addSpacing(30); // verticalLayout->addWidget(welcome_label); @@ -141,7 +138,7 @@ void CodeGeeXWidget::initAskWidget() stackWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored); auto mainLayout = qobject_cast(layout()); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); mainLayout->addWidget(stackWidget); diff --git a/src/plugins/codegeex/widgets/historylistwidget.cpp b/src/plugins/codegeex/widgets/historylistwidget.cpp index 805f40b08..a206186eb 100644 --- a/src/plugins/codegeex/widgets/historylistwidget.cpp +++ b/src/plugins/codegeex/widgets/historylistwidget.cpp @@ -79,7 +79,7 @@ void HistoryListWidget::initUI() mainLayout->addWidget(itemsContainer); QVBoxLayout *containerLayout = new QVBoxLayout; - containerLayout->setMargin(0); + containerLayout->setContentsMargins(0, 0, 0, 0); containerLayout->setSpacing(10); itemsContainer->setLayout(containerLayout); diff --git a/src/plugins/codegeex/widgets/inlinechatwidget.cpp b/src/plugins/codegeex/widgets/inlinechatwidget.cpp index 16d6e7b88..1244e0694 100644 --- a/src/plugins/codegeex/widgets/inlinechatwidget.cpp +++ b/src/plugins/codegeex/widgets/inlinechatwidget.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include @@ -397,13 +397,14 @@ void InlineChatWidgetPrivate::handleAskFinished(const QString &response) // Remove needless datas if (codeInfo.isSelectEmpty) { while (i < lines.size()) { - QRegExp rx("(\\d+)"); - if (rx.indexIn(lines[i]) == -1) { + QRegularExpression rx("(\\d+)"); + if (!rx.match(lines[i]).hasMatch()) { ++i; continue; } - int number = rx.cap(1).toInt(); + // int number = rx.captured(1).toInt(); + int number = rx.match(lines[1]).captured(1).toInt(); if (number < codeInfo.curosrLine) { lines.removeAt(i); continue; @@ -414,7 +415,7 @@ void InlineChatWidgetPrivate::handleAskFinished(const QString &response) // Remove numbers at the beginning of each line for (int i = 0; i < lines.size(); ++i) { - lines[i] = lines[i].remove(QRegExp("^\\d+\\s{2}")); + lines[i] = lines[i].remove(QRegularExpression("^\\d+\\s{2}")); } codePart = lines.join('\n'); codePart.remove("【cursor】"); @@ -555,7 +556,8 @@ bool InlineChatWidgetPrivate::askForCodeGeeX() answerLabel->clear(); auto *futureWatcher = new QFutureWatcher(); - futureWatcher->setFuture(QtConcurrent::run(this, &InlineChatWidgetPrivate::createPrompt, question, false)); + // futureWatcher->setFuture(QtConcurrent::run(this, &InlineChatWidgetPrivate::createPrompt, question, false)); + futureWatcher->setFuture(QtConcurrent::run([this, &question](){ return this->createPrompt(question, false); })); connect(futureWatcher, &QFutureWatcher::finished, this, &InlineChatWidgetPrivate::handleCreatePromptFinished); futureWatcherList << futureWatcher; return true; @@ -706,7 +708,7 @@ QString InlineChatWidgetPrivate::createFormatCode(const QString &file, const QSt codeInfo.isSelectEmpty = false; QString tempCode = code; - tempCode.remove(QRegExp("\\s+")); + tempCode.remove(QRegularExpression("\\s+")); if (tempCode.isEmpty()) { Edit::Range beforeRange = range; beforeRange.start.line -= 3; @@ -760,7 +762,7 @@ void InlineChatWidget::start() const auto &textRange = d->calculateTextRange(d->chatInfo.fileName, pos); // TODO: Inline chat in the blank space auto rangeText = d->editSrv->rangeText(d->chatInfo.fileName, textRange); - rangeText.remove(QRegExp("\\s+")); + rangeText.remove(QRegularExpression("\\s+")); if (rangeText.isEmpty()) return; diff --git a/src/plugins/codegeex/widgets/intropage.cpp b/src/plugins/codegeex/widgets/intropage.cpp index 446f97087..88278cd29 100644 --- a/src/plugins/codegeex/widgets/intropage.cpp +++ b/src/plugins/codegeex/widgets/intropage.cpp @@ -37,7 +37,7 @@ void SuggestButton::paintEvent(QPaintEvent *event) QFontMetrics fm(font()); if (event->rect().width() < minimumWidth) { auto gap = minimumWidth - event->rect().width(); - auto length = fm.width(originalText) - gap; + auto length = fm.horizontalAdvance(originalText) - gap; if (length < 0) return DPushButton::paintEvent(event); setText(fm.elidedText(text(), Qt::ElideRight, length)); @@ -123,7 +123,7 @@ void IntroPage::appendDescLabel(QVBoxLayout *layout, const QString &text) descLayout->setAlignment(Qt::AlignTop); DLabel *icon = new DLabel(this); - icon->setMargin(2); + icon->setContentsMargins(2, 2, 2, 2); icon->setFixedSize(16, 16); labelToPaint.append(icon); diff --git a/src/plugins/codegeex/widgets/messagecomponent.cpp b/src/plugins/codegeex/widgets/messagecomponent.cpp index 3f83a9e72..ced477335 100644 --- a/src/plugins/codegeex/widgets/messagecomponent.cpp +++ b/src/plugins/codegeex/widgets/messagecomponent.cpp @@ -288,8 +288,8 @@ bool MessageComponent::createCodeEdit(const MessageData &newData) updateMessage(addedMsgData); } - QRegExp re("```([a-z]*|[A-Z]*)"); - if (re.exactMatch(addedLine) && currentUpdateState == Label) { + QRegularExpression re("```([a-z]*|[A-Z]*)"); + if (re.match(addedLine).hasMatch() && currentUpdateState == Label) { // create new code edit component messageData.appendData({ addedLine }); currentUpdateState = CodeEdit; diff --git a/src/plugins/codegeex/widgets/pagecontrolcomponent.cpp b/src/plugins/codegeex/widgets/pagecontrolcomponent.cpp index fb27fe268..a8450b43b 100644 --- a/src/plugins/codegeex/widgets/pagecontrolcomponent.cpp +++ b/src/plugins/codegeex/widgets/pagecontrolcomponent.cpp @@ -80,7 +80,7 @@ void PageControlComponent::initUI() { QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->setSpacing(3); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0, 0, 0, 0); setLayout(mainLayout); initPageButtons(); @@ -90,7 +90,7 @@ void PageControlComponent::initPageButtons() { pageButtonsLayout = new QHBoxLayout; pageButtonsLayout->setSpacing(3); - pageButtonsLayout->setMargin(0); + pageButtonsLayout->setContentsMargins(0, 0, 0, 0); preButton = createPushButton(); preButton->setText("<"); diff --git a/src/plugins/codegeex/widgets/sessionrecorditem.cpp b/src/plugins/codegeex/widgets/sessionrecorditem.cpp index c3bcf6235..72980fbc0 100644 --- a/src/plugins/codegeex/widgets/sessionrecorditem.cpp +++ b/src/plugins/codegeex/widgets/sessionrecorditem.cpp @@ -46,7 +46,7 @@ void SessionRecordItem::onRecordClicked() void SessionRecordItem::initUI() { QHBoxLayout *layout = new QHBoxLayout; - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); setLayout(layout); @@ -55,13 +55,13 @@ void SessionRecordItem::initUI() layout->addWidget(recordButton); QHBoxLayout *btnLayout = new QHBoxLayout; - btnLayout->setMargin(10); + btnLayout->setContentsMargins(10, 10, 10, 10); btnLayout->setSpacing(10); recordButton->setLayout(btnLayout); QVBoxLayout *textLayout = new QVBoxLayout; - textLayout->setMargin(0); + textLayout->setContentsMargins(0, 0, 0, 0); textLayout->setSpacing(5); promotLabel = new DLabel(recordButton); diff --git a/src/plugins/codeporting/codeporting.cpp b/src/plugins/codeporting/codeporting.cpp index b7d61f436..526f465d8 100644 --- a/src/plugins/codeporting/codeporting.cpp +++ b/src/plugins/codeporting/codeporting.cpp @@ -157,16 +157,12 @@ const QList CodePorting::getDependLibReport() const */ QList findAll(QString pattern, QString str, bool Greedy) { - QRegExp rxlen(pattern); - rxlen.setMinimal(Greedy); - int position = 0; - QList strList; - while (position >= 0) { - position = rxlen.indexIn(str, position); - if (position < 0) - break; - strList << rxlen.cap(1); - position += rxlen.matchedLength(); + QRegularExpression re(pattern); + QRegularExpressionMatchIterator i = re.globalMatch(str); + QStringList strList; + while (i.hasNext()) { + QRegularExpressionMatch match = i.next(); + strList << match.captured(1); } return strList; } diff --git a/src/plugins/commandproxy/commandexecuter.cpp b/src/plugins/commandproxy/commandexecuter.cpp index 4077cd50b..17e28ee28 100644 --- a/src/plugins/commandproxy/commandexecuter.cpp +++ b/src/plugins/commandproxy/commandexecuter.cpp @@ -26,7 +26,11 @@ void CommandExecuter::buildProject() QString sourcePath = CommandParser::instance().value("b"); QString destPath = CommandParser::instance().value("d"); QString kit = CommandParser::instance().value("k"); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + QStringList args = CommandParser::instance().value("a").trimmed().split(" ", Qt::SkipEmptyParts); + #else QStringList args = CommandParser::instance().value("a").trimmed().split(" ", QString::SkipEmptyParts); + #endif QString elfPath = CommandParser::instance().value("t"); if (sourcePath.isEmpty()) { diff --git a/src/plugins/core/CMakeLists.txt b/src/plugins/core/CMakeLists.txt index f8db41e21..18106bbab 100644 --- a/src/plugins/core/CMakeLists.txt +++ b/src/plugins/core/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0.2) +cmake_minimum_required(VERSION 3.18) project(core) @@ -32,11 +32,10 @@ target_link_libraries(${PROJECT_NAME} if(NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "loongarch64") # loogarch not support web engine now, maybe remove this condition later. - find_package(Qt5 COMPONENTS WebEngineWidgets REQUIRED) - target_link_libraries(${PROJECT_NAME} Qt5::WebEngineWidgets) + find_package(Qt${QT_VERSION_MAJOR} COMPONENTS WebEngineWidgets REQUIRED) + target_link_libraries(${PROJECT_NAME} Qt${QT_VERSION_MAJOR}::WebEngineWidgets) else() - message(STATUS "Skipping Qt5::WebEngineWidgets for loongarch64 platform.") + message(STATUS "Skipping WebEngineWidgets for loongarch64 platform.") endif() install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH}) - diff --git a/src/plugins/core/depend/dependencemanager.cpp b/src/plugins/core/depend/dependencemanager.cpp index f4428373e..04f9e51d5 100644 --- a/src/plugins/core/depend/dependencemanager.cpp +++ b/src/plugins/core/depend/dependencemanager.cpp @@ -183,7 +183,9 @@ bool DependenceManager::installPackageList(const QString &plugin, const QString return false; } - QtConcurrent::run(d, &DependenceManagerPrivate::checkInstalled, plugin, name, packageList); + QtConcurrent::run([this, plugin, name, packageList]() { + return d->checkInstalled(plugin, name, packageList); + }); return true; } diff --git a/src/plugins/core/gui/dockheader.cpp b/src/plugins/core/gui/dockheader.cpp index 7aa7b0452..25f50a658 100644 --- a/src/plugins/core/gui/dockheader.cpp +++ b/src/plugins/core/gui/dockheader.cpp @@ -80,11 +80,11 @@ void DockHeader::setHeaderNames(const QList &headers) DMenu *menu = new DMenu(this); menu->addActions(headers); d->select->show(); - connect(d->select, &DPushButton::clicked, this, [=]() { + connect(d->select, &DPushButton::clicked, menu, [=]() { auto action = menu->exec(mapToGlobal(geometry().bottomLeft())); if (action) setHeaderName(action->text()); - }, Qt::UniqueConnection); + }); } void DockHeader::mousePressEvent(QMouseEvent *event) diff --git a/src/plugins/core/gui/navigationbar.h b/src/plugins/core/gui/navigationbar.h index 476ad52a6..63cde316e 100644 --- a/src/plugins/core/gui/navigationbar.h +++ b/src/plugins/core/gui/navigationbar.h @@ -35,7 +35,11 @@ class NavigationBar : public DTK_WIDGET_NAMESPACE::DFrame void leave(); protected: +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) void enterEvent(QEvent *event) override { emit enter(); } +#else + void enterEvent(QEnterEvent *event) override { emit enter(); } +#endif void leaveEvent(QEvent *event) override { emit leave(); } private: diff --git a/src/plugins/core/gui/plugindetailsview.cpp b/src/plugins/core/gui/plugindetailsview.cpp index 324629a51..66d1842cd 100644 --- a/src/plugins/core/gui/plugindetailsview.cpp +++ b/src/plugins/core/gui/plugindetailsview.cpp @@ -170,7 +170,7 @@ void DetailsView::setupUi() { auto mainLayout = new QVBoxLayout(this); mainLayout->setSpacing(2); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0, 0, 0, 0); DFrame *detailFrame = new DFrame(this); auto detailLayout = new QHBoxLayout(detailFrame); DStyle::setFrameRadius(detailFrame, 0); @@ -178,12 +178,12 @@ void DetailsView::setupUi() auto midLayout = new QVBoxLayout(); midLayout->setSpacing(0); - midLayout->setMargin(0); + midLayout->setContentsMargins(0, 0, 0, 0); initMetaInfoLayout(); auto operationLayout = new QHBoxLayout(); operationLayout->setSpacing(0); - operationLayout->setMargin(0); + operationLayout->setContentsMargins(0, 0, 0, 0); loadBtn = new DSuggestButton(this); loadBtn->setFixedSize(86, 36); loadBtn->setToolTip(tr("reLaunch when changed!")); diff --git a/src/plugins/core/gui/pluginlistview.cpp b/src/plugins/core/gui/pluginlistview.cpp index 6f8aea11f..6fd2a243f 100644 --- a/src/plugins/core/gui/pluginlistview.cpp +++ b/src/plugins/core/gui/pluginlistview.cpp @@ -113,7 +113,7 @@ PluginMetaObjectPointer PluginListView::currentPlugin() const QString category = item->data(PluginListView::Category).toString(); const QHash> &pluginCollections = LifeCycle::getPluginManagerInstance()->pluginCollections(); - auto &metaObjects = pluginCollections.value(category); + const auto &metaObjects = pluginCollections.value(category); for (auto metaObject : metaObjects) { if (metaObject->name() == pluginName) return metaObject; diff --git a/src/plugins/core/gui/pluginstorewidget.cpp b/src/plugins/core/gui/pluginstorewidget.cpp index b2455a49e..f7a62f437 100644 --- a/src/plugins/core/gui/pluginstorewidget.cpp +++ b/src/plugins/core/gui/pluginstorewidget.cpp @@ -42,6 +42,5 @@ void PluginStoreWidget::initializeUi() vLayout->addWidget(inputEdit); vLayout->addSpacing(5); vLayout->addWidget(pluginListView); - vLayout->setMargin(0); vLayout->setContentsMargins(10, 0, 10, 0); } diff --git a/src/plugins/core/notify/gui/bubble.cpp b/src/plugins/core/notify/gui/bubble.cpp index 2e143f4ff..63cfac4ca 100644 --- a/src/plugins/core/notify/gui/bubble.cpp +++ b/src/plugins/core/notify/gui/bubble.cpp @@ -96,7 +96,11 @@ void Bubble::showEvent(QShowEvent *event) DFloatingWidget::showEvent(event); } +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) void Bubble::enterEvent(QEvent *event) +#else +void Bubble::enterEvent(QEnterEvent *event) +#endif { if (d->timer && d->timer->isActive()) d->timer->stop(); diff --git a/src/plugins/core/notify/gui/bubble.h b/src/plugins/core/notify/gui/bubble.h index 2410a2a0a..168123e10 100644 --- a/src/plugins/core/notify/gui/bubble.h +++ b/src/plugins/core/notify/gui/bubble.h @@ -28,7 +28,11 @@ class Bubble : public DTK_WIDGET_NAMESPACE::DFloatingWidget protected: virtual void showEvent(QShowEvent *event) override; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) virtual void enterEvent(QEvent *event) override; +#else + virtual void enterEvent(QEnterEvent *event) override; +#endif virtual void leaveEvent(QEvent *event) override; private: diff --git a/src/plugins/core/notify/gui/notificationmodel.cpp b/src/plugins/core/notify/gui/notificationmodel.cpp index 0cc0d7822..5aad16dc3 100644 --- a/src/plugins/core/notify/gui/notificationmodel.cpp +++ b/src/plugins/core/notify/gui/notificationmodel.cpp @@ -76,7 +76,7 @@ QVariant NotificationModel::data(const QModelIndex &index, int role) const return tr("Source: %1").arg(source); } case kEntityRole: - return qVariantFromValue(entity); + return QVariant::fromValue(entity); default: break; } diff --git a/src/plugins/core/notify/notificationmanager.cpp b/src/plugins/core/notify/notificationmanager.cpp index ab91403aa..bca3a3b7e 100644 --- a/src/plugins/core/notify/notificationmanager.cpp +++ b/src/plugins/core/notify/notificationmanager.cpp @@ -89,7 +89,7 @@ void NotificationManagerPrivate::addContent(QWidget *widget) mainWindow->installEventFilter(q); QVBoxLayout *layout = new QVBoxLayout(notificationContent); layout->setSpacing(0); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->setDirection(QBoxLayout::BottomToTop); notificationContent->show(); } diff --git a/src/plugins/core/session/sessiondialog.cpp b/src/plugins/core/session/sessiondialog.cpp index 1350a68b9..b733e7ffa 100644 --- a/src/plugins/core/session/sessiondialog.cpp +++ b/src/plugins/core/session/sessiondialog.cpp @@ -182,7 +182,7 @@ void SessionNameInputDialog::initUI() setSpacing(10); setIcon(QIcon::fromTheme("ide")); lineEdit = new DLineEdit(this); - QRegExpValidator *validator = new QRegExpValidator(QRegExp("[^/\?:\\\\*]*"), lineEdit); + QRegularExpressionValidator *validator = new QRegularExpressionValidator(QRegularExpression("[^/\?:\\\\*]*"), lineEdit); lineEdit->lineEdit()->setValidator(validator); lineEdit->setPlaceholderText(tr("Please input session name")); connect(lineEdit, &DLineEdit::textChanged, this, [this](const QString &text) { diff --git a/src/plugins/core/session/sessionmodel.cpp b/src/plugins/core/session/sessionmodel.cpp index 1d5445146..8748e66f8 100644 --- a/src/plugins/core/session/sessionmodel.cpp +++ b/src/plugins/core/session/sessionmodel.cpp @@ -80,7 +80,7 @@ QVariant SessionModel::headerData(int section, Qt::Orientation orientation, int void SessionModel::sort(int column, Qt::SortOrder order) { beginResetModel(); - qSort(sessionList.begin(), sessionList.end(), + std::sort(sessionList.begin(), sessionList.end(), [column, order](const QString &s1, const QString &s2) { bool ret = false; if (column == 0) { diff --git a/src/plugins/core/uicontroller/controller.cpp b/src/plugins/core/uicontroller/controller.cpp index ee2d6a7bc..206681d07 100644 --- a/src/plugins/core/uicontroller/controller.cpp +++ b/src/plugins/core/uicontroller/controller.cpp @@ -35,10 +35,11 @@ #include #include #include -#include #include #include - +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) +#include +#endif static Controller *ins { nullptr }; inline const QString WN_LOADINGWIDGET = "loadingWidget"; @@ -915,18 +916,22 @@ void Controller::initMainWindow() loading(); if (!d->mainWindow->isMaximized()) { +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) auto desktop = QApplication::desktop(); int currentScreenIndex = desktop->screenNumber(d->mainWindow); QList screenList = QGuiApplication::screens(); - if (currentScreenIndex < screenList.count()) { QRect screenRect = screenList[currentScreenIndex]->geometry(); +#else + QScreen *currentScreen = d->mainWindow->screen(); + if (currentScreen) { + QRect screenRect = currentScreen->geometry(); +#endif int screenWidth = screenRect.width(); int screenHeight = screenRect.height(); d->mainWindow->move((screenWidth - d->mainWindow->width()) / 2, (screenHeight - d->mainWindow->height()) / 2); } } - connect(d->mainWindow, &MainWindow::dockHidden, this, [=](const QString &dockName) { if (d->allWidgets.contains(dockName)) { auto &info = d->allWidgets[dockName]; @@ -1363,8 +1368,7 @@ DToolButton *Controller::createDockButton(const WidgetInfo &info) btn->setChecked(true); dockInfo.hiddenByManual = false; } - }, - Qt::UniqueConnection); + }); return btn; } diff --git a/src/plugins/core/uicontroller/mainwindow.cpp b/src/plugins/core/uicontroller/mainwindow.cpp index cc916acfb..0a8663685 100644 --- a/src/plugins/core/uicontroller/mainwindow.cpp +++ b/src/plugins/core/uicontroller/mainwindow.cpp @@ -87,7 +87,7 @@ MainWindow::~MainWindow() DDockWidget *MainWindow::createDockWidget(DWidget *widget) { DDockWidget *dock = new DDockWidget(this); - dock->setFeatures(QDockWidget::AllDockWidgetFeatures); + dock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); if (dock->titleBarWidget()) delete dock->titleBarWidget(); @@ -447,7 +447,7 @@ void MainWindow::setToolbar(Qt::ToolBarArea area, QWidget *widget) { DToolBar *tb = new DToolBar(this); tb->setContentsMargins(0, 0, 0, 0); - tb->layout()->setMargin(0); + tb->layout()->setContentsMargins(0, 0, 0, 0); tb->setMovable(false); tb->setFloatable(false); diff --git a/src/plugins/cxx/CMakeLists.txt b/src/plugins/cxx/CMakeLists.txt index f9d9a9ac6..8f0661243 100644 --- a/src/plugins/cxx/CMakeLists.txt +++ b/src/plugins/cxx/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0.2) project(cxx) -find_package(Qt5 COMPONENTS Xml REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Xml REQUIRED) include_directories("${CMAKE_CURRENT_SOURCE_DIR}/cmake/project/") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/cmake/project/properties") @@ -40,11 +40,10 @@ target_link_libraries(${PROJECT_NAME} duc-base duc-services duc-common - Qt5::Xml + Qt${QT_VERSION_MAJOR}::Xml ${QtUseModules} ${PkgUserModules} ) install_logo(${PROJECT_NAME}.svg) install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH}) - diff --git a/src/plugins/cxx/cmake/builder/parser/cmakeparser.cpp b/src/plugins/cxx/cmake/builder/parser/cmakeparser.cpp index 434ac9ba6..b43842f14 100644 --- a/src/plugins/cxx/cmake/builder/parser/cmakeparser.cpp +++ b/src/plugins/cxx/cmake/builder/parser/cmakeparser.cpp @@ -42,6 +42,8 @@ void CMakeParser::stdOutput(const QString &line, OutputPane::OutputFormat format void CMakeParser::stdError(const QString &line) { QString trimmedLine = rightTrimmed(line); + QRegularExpressionMatch commonMatch = commonError.match(trimmedLine); + QRegularExpressionMatch nextMatch = nextSubError.match(trimmedLine); auto commonErrorMatch = commonError.match(trimmedLine); auto nextSubErrorMatch = nextSubError.match(trimmedLine); @@ -61,7 +63,7 @@ void CMakeParser::stdError(const QString &line) commonErrorMatch.captured(2).toInt(), TASK_CATEGORY_BUILDSYSTEM); lines = 1; return; - } else if (trimmedLine.startsWith(QLatin1String(" ")) && !lastTask.isNull()) { + } else if (trimmedLine.startsWith(QLatin1String(" ")) && !lastTask.isNull()) { if (!lastTask.description.isEmpty()) lastTask.description.append(QLatin1Char(' ')); lastTask.description.append(trimmedLine.trimmed()); diff --git a/src/plugins/cxx/cmake/option/kit.cpp b/src/plugins/cxx/cmake/option/kit.cpp index 7b5346bc6..af529d8d6 100644 --- a/src/plugins/cxx/cmake/option/kit.cpp +++ b/src/plugins/cxx/cmake/option/kit.cpp @@ -175,7 +175,7 @@ Kit &Kit::operator=(const Kit &other) return *this; } -bool Kit::operator==(const Kit &other) +bool Kit::operator==(const Kit &other) const { return d->id == other.d->id; } diff --git a/src/plugins/cxx/cmake/option/kit.h b/src/plugins/cxx/cmake/option/kit.h index cbbd92f81..31f95cf31 100644 --- a/src/plugins/cxx/cmake/option/kit.h +++ b/src/plugins/cxx/cmake/option/kit.h @@ -38,7 +38,7 @@ class Kit : public QObject static Kit fromVariantMap(const QVariantMap &map); Kit &operator=(const Kit &other); - bool operator==(const Kit &other); + bool operator==(const Kit &other) const; private: KitPrivate *const d; diff --git a/src/plugins/cxx/cmake/project/cbp/cbpparser.cpp b/src/plugins/cxx/cmake/project/cbp/cbpparser.cpp index b4098a59c..984030817 100644 --- a/src/plugins/cxx/cmake/project/cbp/cbpparser.cpp +++ b/src/plugins/cxx/cmake/project/cbp/cbpparser.cpp @@ -220,12 +220,12 @@ void CMakeCbpParser::parseBuildTargetOption() if (attributes().hasAttribute("output")) { buildTarget.output = (attributes().value("output").toString()); } else if (attributes().hasAttribute("type")) { - const QStringRef value = attributes().value("type"); - if (value == "0" || value == "1") + const QStringView value = attributes().value("type"); + if (value == QString("0") || value == QString("1")) buildTarget.type = kExecutable; - else if (value == "2") + else if (value == QString("2")) buildTarget.type = kStaticLibrary; - else if (value == "3") + else if (value == QString("3")) buildTarget.type = kDynamicLibrary; else buildTarget.type = kUtility; diff --git a/src/plugins/cxx/cmake/project/cmakeasynparse.cpp b/src/plugins/cxx/cmake/project/cmakeasynparse.cpp index a13011652..55eda522b 100644 --- a/src/plugins/cxx/cmake/project/cmakeasynparse.cpp +++ b/src/plugins/cxx/cmake/project/cmakeasynparse.cpp @@ -35,32 +35,35 @@ void sortParentItem(QStandardItem *parentItem) QList fileList; QList directoryList; QList others; - int count = parentItem->rowCount(); - - for (int row = 0; row < count; row++) { - auto child = parentItem->child(row); + // Traverse in reverse to avoid issues with changing index + for (int row = count - 1; row >= 0; --row) { + QStandardItem *child = parentItem->child(row); if (child->text() == kProjectFile) { cmakeFileList.append(parentItem->takeChild(row)); continue; } - auto absolutePath = child->toolTip(); QFileInfo fileInfo(absolutePath); - if (fileInfo.isFile()) - fileList.append(parentItem->takeChild(row)); - else if (fileInfo.isDir()) - directoryList.append(parentItem->takeChild(row)); - else - others.append(parentItem->takeChild(row)); + child = parentItem->takeRow(row).first(); + if (fileInfo.isFile()) { + fileList.append(child); + } else if (fileInfo.isDir()) { + directoryList.append(child); + } else { + others.append(child); + } } - parentItem->removeRows(0, parentItem->rowCount()); - - //fileList is already sorted + // Sort directories, files, and others std::sort(directoryList.begin(), directoryList.end(), [](const QStandardItem *item1, const QStandardItem *item2) { return item1->text().toLower().localeAwareCompare(item2->text().toLower()) < 0; }); + std::sort(fileList.begin(), fileList.end(), [](const QStandardItem *item1, const QStandardItem *item2) { + return item1->text().toLower().localeAwareCompare(item2->text().toLower()) < 0; + }); + parentItem->removeRows(0, parentItem->rowCount()); + // Append lists in desired order for (auto item : cmakeFileList) parentItem->appendRow(item); for (auto item : directoryList) @@ -281,7 +284,7 @@ void CmakeAsynParse::parseProject(QStandardItem *rootItem, const dpfservice::Pro tempInfo.setSourceFiles(commonFiles + cmakeFiles); auto exePrograms = TargetsManager::instance()->getExeTargetNamesList(); - qSort(exePrograms.begin(), exePrograms.end(), [](const QString &s1, const QString &s2) { + std::sort(exePrograms.begin(), exePrograms.end(), [](const QString &s1, const QString &s2){ return s1.toLower() < s2.toLower(); }); tempInfo.setExePrograms(exePrograms); diff --git a/src/plugins/cxx/cmake/project/cmakeprojectgenerator.cpp b/src/plugins/cxx/cmake/project/cmakeprojectgenerator.cpp index 38763e480..7ad5e7da5 100644 --- a/src/plugins/cxx/cmake/project/cmakeprojectgenerator.cpp +++ b/src/plugins/cxx/cmake/project/cmakeprojectgenerator.cpp @@ -270,7 +270,6 @@ QStandardItem *CmakeProjectGenerator::createRootItem(const dpfservice::ProjectIn [=](const QString &path) { if (d->projectsWaitingUpdate.contains(thisProject)) return; - auto windowService = dpfGetService(WindowService); windowService->notify(0, "CMakeProject", tr("Files in project %1 have changed, needs to run cmake to update").arg(thisProject->text()), {}); d->projectsWaitingUpdate.append(thisProject); @@ -573,7 +572,7 @@ void CmakeProjectGenerator::projectParseFinished(const CmakeAsynParse::ParseInfo return; auto prjService = dpfGetService(ProjectService); - prjService->expandItemByFile(d->toExpand.toList()); + prjService->expandItemByFile(d->toExpand.values()); } void CmakeProjectGenerator::initCMakeParser() diff --git a/src/plugins/cxx/cmake/project/properties/bulidCfgWidget/buildpropertypage.cpp b/src/plugins/cxx/cmake/project/properties/bulidCfgWidget/buildpropertypage.cpp index 4dbace47f..3b3204ba7 100644 --- a/src/plugins/cxx/cmake/project/properties/bulidCfgWidget/buildpropertypage.cpp +++ b/src/plugins/cxx/cmake/project/properties/bulidCfgWidget/buildpropertypage.cpp @@ -101,7 +101,7 @@ DetailPropertyWidget::DetailPropertyWidget(QWidget *parent) QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->addWidget(mainFrame); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0, 0, 0, 0); } DetailPropertyWidget::~DetailPropertyWidget() @@ -259,7 +259,7 @@ void BuildPropertyPage::setupOverviewUI() hLayout->setSpacing(10); overviewLayout->setSpacing(0); - overviewLayout->setMargin(0); + overviewLayout->setContentsMargins(0, 0, 0, 0); overviewLayout->setSpacing(10); auto formlayout = new QFormLayout(this); diff --git a/src/plugins/cxx/cmake/project/properties/cmakeCfgWidget/cmakeitemmodel.cpp b/src/plugins/cxx/cmake/project/properties/cmakeCfgWidget/cmakeitemmodel.cpp index 9f2b129e6..211de97ef 100644 --- a/src/plugins/cxx/cmake/project/properties/cmakeCfgWidget/cmakeitemmodel.cpp +++ b/src/plugins/cxx/cmake/project/properties/cmakeCfgWidget/cmakeitemmodel.cpp @@ -46,7 +46,7 @@ CMakeItem::CMakeItem() CMakeItem::CMakeItem(const QByteArray *key, const QByteArray *value) { this->key = QString::fromStdString(key->toStdString()); - this->value = value; + this->value = QVariant(*value); } CMakeItem::itemType CMakeItem::dataToType(const QByteArray &data) diff --git a/src/plugins/cxx/cmake/project/properties/configutil.cpp b/src/plugins/cxx/cmake/project/properties/configutil.cpp index 131432e2d..a4fb0616b 100644 --- a/src/plugins/cxx/cmake/project/properties/configutil.cpp +++ b/src/plugins/cxx/cmake/project/properties/configutil.cpp @@ -266,7 +266,11 @@ bool ConfigUtil::updateProjectInfo(dpfservice::ProjectInfo &info, const ProjectC info.setRunProgram(iterRun->targetPath); QStringList arguments; if (!iterRun->arguments.isEmpty()) + #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + arguments = iterRun->arguments.split(" ", Qt::SkipEmptyParts); + #else arguments = iterRun->arguments.split(" ", QString::SkipEmptyParts); + #endif info.setRunCustomArgs(arguments); info.setRunWorkspaceDir(iterRun->workDirectory); info.setCurrentProgram(iterRun->targetName); diff --git a/src/plugins/cxx/cmake/project/properties/environmentwidget.cpp b/src/plugins/cxx/cmake/project/properties/environmentwidget.cpp index 6b37bcf2b..6809289fd 100644 --- a/src/plugins/cxx/cmake/project/properties/environmentwidget.cpp +++ b/src/plugins/cxx/cmake/project/properties/environmentwidget.cpp @@ -113,7 +113,7 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, EnvType type) // instert to layout. d->vLayout->setSpacing(0); - d->vLayout->setMargin(0); + d->vLayout->setContentsMargins(0, 0, 0, 0); d->vLayout->addWidget(d->tableView); d->vLayout->addLayout(btnLayout); d->vLayout->addWidget(d->enableEnvCB); diff --git a/src/plugins/cxx/cmake/project/properties/runCfgWidget/runconfigpane.cpp b/src/plugins/cxx/cmake/project/properties/runCfgWidget/runconfigpane.cpp index 2d332d847..ab7526315 100644 --- a/src/plugins/cxx/cmake/project/properties/runCfgWidget/runconfigpane.cpp +++ b/src/plugins/cxx/cmake/project/properties/runCfgWidget/runconfigpane.cpp @@ -112,7 +112,7 @@ void RunConfigPane::setupUi() d->environmentWidget->getValues(d->targetRunParam->env); }); - vLayout->setMargin(0); + vLayout->setContentsMargins(0, 0, 0, 0); } void RunConfigPane::updateUi() diff --git a/src/plugins/cxx/cmake/project/properties/runCfgWidget/runpropertypage.cpp b/src/plugins/cxx/cmake/project/properties/runCfgWidget/runpropertypage.cpp index e48952e3a..d073e415a 100644 --- a/src/plugins/cxx/cmake/project/properties/runCfgWidget/runpropertypage.cpp +++ b/src/plugins/cxx/cmake/project/properties/runCfgWidget/runpropertypage.cpp @@ -91,7 +91,7 @@ void RunPropertyPage::updateData() d->exeComboBox->insertItem(index, iterExe->targetName); if (iter->runConfigure.defaultTargetName == iterExe->targetName) { d->exeComboBox->setCurrentIndex(index); - d->runConfigPane->setTargetRunParam(iterExe); + d->runConfigPane->setTargetRunParam(&(*iterExe)); } } break; diff --git a/src/plugins/cxx/cmake/project/properties/targetsmanager.cpp b/src/plugins/cxx/cmake/project/properties/targetsmanager.cpp index aa36c3b73..8b0c81fbb 100644 --- a/src/plugins/cxx/cmake/project/properties/targetsmanager.cpp +++ b/src/plugins/cxx/cmake/project/properties/targetsmanager.cpp @@ -133,8 +133,10 @@ void TargetsManager::readTargets(const QString &buildDirectory, const QString &w targetNameList.append(target.buildTarget); } - buildTargetNameList = targetNameList.toSet().values(); - exeTargetNameList = tempExeTargetNameList.toSet().values(); + targetNameList.removeDuplicates(); + buildTargetNameList = targetNameList; + tempExeTargetNameList.removeDuplicates(); + exeTargetNameList = tempExeTargetNameList; if (exeTargetSelected.name.isEmpty() && exeTargets.size() > 0) { exeTargetSelected = exeTargets.front(); diff --git a/src/plugins/cxx/ninja/builder/parser/ninjaparser.cpp b/src/plugins/cxx/ninja/builder/parser/ninjaparser.cpp index d0d4202a2..8ce2a8f77 100644 --- a/src/plugins/cxx/ninja/builder/parser/ninjaparser.cpp +++ b/src/plugins/cxx/ninja/builder/parser/ninjaparser.cpp @@ -7,6 +7,8 @@ #include "common/type/task.h" #include "common/util/fileutils.h" +#include + const char TASK_CATEGORY_BUILDSYSTEM[] = "Task.Category.Buildsystem"; NinjaParser::NinjaParser() @@ -25,7 +27,7 @@ void NinjaParser::stdOutput(const QString &line, OutputPane::OutputFormat format void NinjaParser::stdError(const QString &line) { QString newContent = line; - QRegExp exp("/.*:(\\d*):"); + QRegularExpression exp("/.*:(\\d*):"); int ret = newContent.indexOf(exp); QString filePath; int lineNumber = -1; diff --git a/src/plugins/debugger/dap/dapdebugger.cpp b/src/plugins/debugger/dap/dapdebugger.cpp index 5fe6536cc..ba2dbb548 100644 --- a/src/plugins/debugger/dap/dapdebugger.cpp +++ b/src/plugins/debugger/dap/dapdebugger.cpp @@ -241,7 +241,7 @@ void DAPDebugger::startRerverseDebug(const QString &target) QMap param; param.insert("program", "rr"); - d->requestDAPPortPpid = QString(getpid()); + d->requestDAPPortPpid = QString::number(getpid()); QDBusMessage msg = QDBusMessage::createSignal("/path", "com.deepin.unioncode.interface", "getDebugPort"); @@ -316,7 +316,7 @@ void DAPDebugger::attachDebug(const QString &processId) QDBusMessage msg = QDBusMessage::createSignal("/path", "com.deepin.unioncode.interface", "getDebugPort"); - d->requestDAPPortPpid = QString(getpid()); + d->requestDAPPortPpid = QString::number(getpid()); msg << d->requestDAPPortPpid << debuggerTool << processId @@ -1226,7 +1226,11 @@ void DAPDebugger::initializeView() d->threadSelector = new DComboBox(d->stackPane); d->threadSelector->setMinimumWidth(240); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) connect(d->threadSelector, QOverload::of(&DComboBox::activated), this, &DAPDebugger::currentThreadChanged); +#else + connect(d->threadSelector, &DComboBox::textActivated, this, &DAPDebugger::currentThreadChanged); +#endif QHBoxLayout *hLayout = new QHBoxLayout(d->stackPane); hLayout->setAlignment(Qt::AlignLeft); @@ -1460,7 +1464,7 @@ bool DAPDebugger::requestDebugPort(const QMap ¶m, const Q if (generator) { d->isCustomDap = customDap; QString retMsg; - d->requestDAPPortPpid = QString(getpid()); + d->requestDAPPortPpid = QString::number(getpid()); printOutput(tr("Requesting debug port...")); if (!generator->requestDAPPort(d->requestDAPPortPpid, param, retMsg)) { printOutput(retMsg, OutputPane::ErrorMessage); diff --git a/src/plugins/debugger/debugmanager.cpp b/src/plugins/debugger/debugmanager.cpp index 3ce1f3db3..e8a7393b9 100644 --- a/src/plugins/debugger/debugmanager.cpp +++ b/src/plugins/debugger/debugmanager.cpp @@ -253,7 +253,11 @@ void DebugManager::handleEvents(const dpf::Event &event) bool DebugManager::runCoredump(const QString &target, const QString &core, const QString &kit) { - return QtConcurrent::run(currentDebugger, &AbstractDebugger::runCoredump, target, core, kit); + // return QtConcurrent::run(currentDebugger, &AbstractDebugger::runCoredump, target, core, kit); + auto future = QtConcurrent::run([&, this](){ + currentDebugger->runCoredump(target, core, kit); + }); + return future.isRunning(); } void DebugManager::rrReplay(const QString &target) diff --git a/src/plugins/debugger/interface/attachinfodialog.cpp b/src/plugins/debugger/interface/attachinfodialog.cpp index cd3dfe76c..457be4342 100644 --- a/src/plugins/debugger/interface/attachinfodialog.cpp +++ b/src/plugins/debugger/interface/attachinfodialog.cpp @@ -56,7 +56,11 @@ void AttachInfoDialog::initUi() insertContent(1, view); connect(edit, &DLineEdit::textChanged, this, [=](const QString &text){ +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) proxy->setFilterRegExp(QString(".*%1.*").arg(text)); +#else + proxy->setFilterRegularExpression(QString(".*%1.*").arg(text)); +#endif }); updateProcess(); diff --git a/src/plugins/debugger/interface/localtreeitem.cpp b/src/plugins/debugger/interface/localtreeitem.cpp index c359c6e14..d174521a3 100644 --- a/src/plugins/debugger/interface/localtreeitem.cpp +++ b/src/plugins/debugger/interface/localtreeitem.cpp @@ -50,7 +50,7 @@ void LocalTreeItem::setChildrenUpdated(bool updated) LocalTreeItem *LocalTreeItem::updateVariable(dap::Variable &var) { - auto it = std::find_if(children.begin(), children.end(), [&](const auto& child) { + auto it = std::find_if(children.begin(), children.end(), [&](const auto &child) { return child->itemVariable.name == var.name; }); diff --git a/src/plugins/debugger/interface/localtreeitem.h b/src/plugins/debugger/interface/localtreeitem.h index b9abf4e68..aacd4e2af 100644 --- a/src/plugins/debugger/interface/localtreeitem.h +++ b/src/plugins/debugger/interface/localtreeitem.h @@ -10,6 +10,7 @@ #include #include #include +#include enum ColumnType { kName, diff --git a/src/plugins/debugger/interface/localtreemodel.cpp b/src/plugins/debugger/interface/localtreemodel.cpp index 35998ddae..42022dede 100644 --- a/src/plugins/debugger/interface/localtreemodel.cpp +++ b/src/plugins/debugger/interface/localtreemodel.cpp @@ -53,7 +53,7 @@ QVariant LocalTreeModel::data(const QModelIndex &index, int role) const if (role == Qt::ToolTipRole) QToolTip::showText(QCursor::pos(), item->data(index.column()).toString()); - if(role == Qt::TextColorRole && item->hasUpdated() == true && index.column() == 1) + if(role == Qt::ForegroundRole && item->hasUpdated() == true && index.column() == 1) return QVariant(QColor(Qt::red)); if (role != Qt::DisplayRole) @@ -161,10 +161,8 @@ void LocalTreeModel::clearHighlightItems() void LocalTreeModel::appendItem(LocalTreeItem *parent, const IVariables &vars) { - QWriteLocker locker(&mutex); if (!items.contains(parent) && parent != rootItem) return; - locker.unlock(); if (parent) { QList newItems; @@ -183,9 +181,7 @@ void LocalTreeModel::appendItem(LocalTreeItem *parent, const IVariables &vars) item->setVariable(var.var); parent->appendChild(item); - locker.relock(); items.append(item); - locker.unlock(); endInsertRows(); } @@ -198,6 +194,7 @@ void LocalTreeModel::appendItem(LocalTreeItem *parent, const IVariables &vars) void LocalTreeModel::setDatas(IVariables &datas) { + QWriteLocker locker(&mutex); appendItem(rootItem, datas); } diff --git a/src/plugins/debugger/reversedebug/reversedebugger.cpp b/src/plugins/debugger/reversedebug/reversedebugger.cpp index 64557f5c3..10f5b46be 100644 --- a/src/plugins/debugger/reversedebug/reversedebugger.cpp +++ b/src/plugins/debugger/reversedebug/reversedebugger.cpp @@ -97,7 +97,7 @@ bool ReverseDebugger::execCommand(const dpfservice::RunCommandInfo &info) process.setReadChannel(QProcess::StandardOutput); while (process.canReadLine()) { QString line = QString::fromUtf8(process.readLine()); - outputMsg(process.pid(), line, OutputPane::OutputFormat::StdOut); + outputMsg(process.processId(), line, OutputPane::OutputFormat::StdOut); } }); @@ -105,13 +105,13 @@ bool ReverseDebugger::execCommand(const dpfservice::RunCommandInfo &info) process.setReadChannel(QProcess::StandardError); while (process.canReadLine()) { QString line = QString::fromUtf8(process.readLine()); - outputMsg(process.pid(), line, OutputPane::OutputFormat::StdErr); + outputMsg(process.processId(), line, OutputPane::OutputFormat::StdErr); } }); process.start(program, arguments); uiController.switchContext(tr("&Application Output")); - quint64 pid = process.pid(); + quint64 pid = process.processId(); QString startMsg = tr("Start execute command: \"%1\" \"%2\" in workspace \"%3\".\n") .arg(program, arguments.join(" "), info.workingDir); QMetaObject::invokeMethod(AppOutputPane::instance(), "createApplicationPane", diff --git a/src/plugins/debugger/runner/runner.cpp b/src/plugins/debugger/runner/runner.cpp index 1bad27e7c..ce9ea8049 100644 --- a/src/plugins/debugger/runner/runner.cpp +++ b/src/plugins/debugger/runner/runner.cpp @@ -206,7 +206,7 @@ bool Runner::execCommand(const RunCommandInfo &info) process.setReadChannel(QProcess::StandardOutput); while (process.canReadLine()) { QString line = QString::fromUtf8(process.readLine()); - outputMsg(process.pid(), line, OutputPane::OutputFormat::StdOut); + outputMsg(process.processId(), line, OutputPane::OutputFormat::StdOut); } }); @@ -214,12 +214,12 @@ bool Runner::execCommand(const RunCommandInfo &info) process.setReadChannel(QProcess::StandardError); while (process.canReadLine()) { QString line = QString::fromUtf8(process.readLine()); - outputMsg(process.pid(), line, OutputPane::OutputFormat::StdErr); + outputMsg(process.processId(), line, OutputPane::OutputFormat::StdErr); } }); process.start(info.program, info.arguments); - quint64 pid = process.pid(); + quint64 pid = process.processId(); QMetaObject::invokeMethod(AppOutputPane::instance(), "createApplicationPane", Q_ARG(const QString &, QString::number(pid)), Q_ARG(QString, info.program)); outputMsg(pid, startMsg, OutputPane::OutputFormat::NormalMessage); diff --git a/src/plugins/filebrowser/filebrowser.cpp b/src/plugins/filebrowser/filebrowser.cpp index f3dc7d88c..9bfc03725 100644 --- a/src/plugins/filebrowser/filebrowser.cpp +++ b/src/plugins/filebrowser/filebrowser.cpp @@ -57,7 +57,7 @@ AbstractWidget *FileBrowser::createTreeWidget() auto treeView = TreeViewKeeper::instance()->treeView(); auto folderLabel = new DLabel(); - folderLabel->setMargin(3); + folderLabel->setContentsMargins(3, 3, 3, 3); folderLabel->setElideMode(Qt::TextElideMode::ElideMiddle); QObject::connect(treeView, &FileTreeView::rootPathChanged, folderLabel, &DLabel::setText, diff --git a/src/plugins/filebrowser/mainframe/filetreeview.cpp b/src/plugins/filebrowser/mainframe/filetreeview.cpp index 6d08ef72e..04a1763fd 100644 --- a/src/plugins/filebrowser/mainframe/filetreeview.cpp +++ b/src/plugins/filebrowser/mainframe/filetreeview.cpp @@ -120,7 +120,7 @@ void FileTreeView::selRemove() countPaths << d->model->filePath(index); } // Remove duplicates - countPaths = countPaths.toSet().toList(); + countPaths.removeDuplicates(); QString message = tr("Delete operation not be recoverable, delete anyway?"); diff --git a/src/plugins/find/constants.h b/src/plugins/find/constants.h index f196d748b..11711b193 100644 --- a/src/plugins/find/constants.h +++ b/src/plugins/find/constants.h @@ -46,7 +46,7 @@ struct FindItem QStringList capturedTexts; QString context; - inline bool operator==(const FindItem &other) + inline bool operator==(const FindItem &other) const { return filePathName == other.filePathName && line == other.line && column == other.column; diff --git a/src/plugins/find/gui/advancedsearchwidget.cpp b/src/plugins/find/gui/advancedsearchwidget.cpp index ddb575c2e..b59f600ad 100644 --- a/src/plugins/find/gui/advancedsearchwidget.cpp +++ b/src/plugins/find/gui/advancedsearchwidget.cpp @@ -279,14 +279,14 @@ SearchParams AdvancedSearchWidgetPrivate::searchParams() const auto &infoList = projectSrv->getAllProjectInfo(); for (const auto &info : infoList) { - params.projectFileList.append(info.sourceFiles().toList()); + params.projectFileList.append(info.sourceFiles().values()); } } break; case CurrentProject: { params.editFileList = editSrv->openedFiles(); const auto &info = projectSrv->getActiveProjectInfo(); - params.projectFileList.append(info.sourceFiles().toList()); + params.projectFileList.append(info.sourceFiles().values()); } break; case CurrentFile: { auto curFile = editSrv->currentFile(); @@ -301,9 +301,13 @@ SearchParams AdvancedSearchWidgetPrivate::searchParams() params.flags |= caseBtn->isChecked() ? SearchCaseSensitively : SearchNoFlag; params.flags |= wholeWordBtn->isChecked() ? SearchWholeWords : SearchNoFlag; params.flags |= regexBtn->isChecked() ? SearchRegularExpression : SearchNoFlag; +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + params.includeList = includeEdit->text().trimmed().split(",", Qt::SkipEmptyParts); + params.excludeList = excludeEdit->text().trimmed().split(",", Qt::SkipEmptyParts); +#else params.includeList = includeEdit->text().trimmed().split(",", QString::SkipEmptyParts); - params.excludeList = excludeEdit->text().trimmed().split(",", QString::SkipEmptyParts); - + params.excludeList = excludeEdit->text().trimmed().split(",", QString::SkipEmptyParts); +#endif return params; } diff --git a/src/plugins/find/gui/searchresultitemdelegate.cpp b/src/plugins/find/gui/searchresultitemdelegate.cpp index 473dcfa11..2a96a223e 100644 --- a/src/plugins/find/gui/searchresultitemdelegate.cpp +++ b/src/plugins/find/gui/searchresultitemdelegate.cpp @@ -203,7 +203,7 @@ QRect SearchResultItemDelegate::drawResultCount(QPainter *painter, const QStyleO QStyleOptionViewItem opt = option; painter->setFont(opt.font); auto resultCount = QString::number(index.model()->rowCount(index)); - auto countWidth = qMax(opt.fontMetrics.width(resultCount) + ItemMargin, CountNumberSize); + auto countWidth = qMax(opt.fontMetrics.horizontalAdvance(resultCount) + ItemMargin, CountNumberSize); QRect countRect = opt.rect; countRect.setSize({ countWidth, CountNumberSize }); @@ -320,7 +320,7 @@ void SearchResultItemDelegate::drawNameItem(QPainter *painter, const QStyleOptio palette.color(QPalette::Normal, DPalette::TextTips), {}); QRect pathRect = nameRect; - pathRect.setLeft(nameRect.left() + opt.fontMetrics.width(fileName) + SpacePadding); + pathRect.setLeft(nameRect.left() + opt.fontMetrics.horizontalAdvance(fileName) + SpacePadding); drawDisplay(painter, option, pathRect, filePath, { pathFormat }); } diff --git a/src/plugins/find/maincontroller/worker/searchreplaceworker.cpp b/src/plugins/find/maincontroller/worker/searchreplaceworker.cpp index 68a029d8e..ce9e4d6e0 100644 --- a/src/plugins/find/maincontroller/worker/searchreplaceworker.cpp +++ b/src/plugins/find/maincontroller/worker/searchreplaceworker.cpp @@ -38,7 +38,11 @@ void SearchReplaceWorkerPrivate::startNextJob() process.reset(new QProcess); connect(process.get(), &QProcess::readyReadStandardOutput, q, std::bind(&SearchReplaceWorker::handleReadSearchResult, q, job.keyword, job.flags)); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) connect(process.get(), qOverload(&QProcess::finished), q, &SearchReplaceWorker::processDone); +#else + connect(process.get(), &QProcess::finished, q, &SearchReplaceWorker::processDone); +#endif process->setProgram(job.program); process->setArguments(job.arguments); diff --git a/src/plugins/git/gui/gitblamewidget.cpp b/src/plugins/git/gui/gitblamewidget.cpp index 537bda613..666918e9c 100644 --- a/src/plugins/git/gui/gitblamewidget.cpp +++ b/src/plugins/git/gui/gitblamewidget.cpp @@ -139,8 +139,14 @@ void GitBlameWidget::setGitInfo(const QStringList &infos) forever { QTC_CHECK(prevPos < pos); int afterParen = prevPos + parenPos; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) result.append(info.midRef(prevPos, stripPos)); result.append(info.midRef(afterParen, pos - afterParen)); +#else + QStringView infoView(info); + result.append(infoView.mid(prevPos, stripPos)); + result.append(infoView.mid(afterParen, pos - afterParen)); +#endif prevPos = pos; QTC_CHECK(prevPos != 0); if (pos == info.size()) diff --git a/src/plugins/git/utils/gitcommand.cpp b/src/plugins/git/utils/gitcommand.cpp index a788334e1..a3896b4f4 100644 --- a/src/plugins/git/utils/gitcommand.cpp +++ b/src/plugins/git/utils/gitcommand.cpp @@ -72,7 +72,11 @@ void GitCommandPrivate::startNextJob() process.reset(new QProcess); connect(process.get(), &QProcess::readyReadStandardOutput, this, &GitCommandPrivate::readStandardOutput); connect(process.get(), &QProcess::readyReadStandardError, this, &GitCommandPrivate::readStandardError); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) connect(process.get(), qOverload(&QProcess::finished), this, &GitCommandPrivate::processDone); +#else + connect(process.get(), &QProcess::finished, this, &GitCommandPrivate::processDone); +#endif setupProcess(process.get(), jobList.at(currentJob)); process->start(); } diff --git a/src/plugins/java/CMakeLists.txt b/src/plugins/java/CMakeLists.txt index 132007865..cf59039ae 100644 --- a/src/plugins/java/CMakeLists.txt +++ b/src/plugins/java/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0.2) project(java) -find_package(Qt5 COMPONENTS Xml REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Xml REQUIRED) set(CXX_CPP maven/mavengenerator.cpp @@ -89,11 +89,10 @@ target_link_libraries(${PROJECT_NAME} duc-base duc-services duc-common - Qt5::Xml + Qt${QT_VERSION_MAJOR}::Xml ${QtUseModules} ${PkgUserModules} ) install_logo(${PROJECT_NAME}.svg) install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH}) - diff --git a/src/plugins/java/gradle/builder/parser/gradleparser.cpp b/src/plugins/java/gradle/builder/parser/gradleparser.cpp index 508589590..3e4241714 100644 --- a/src/plugins/java/gradle/builder/parser/gradleparser.cpp +++ b/src/plugins/java/gradle/builder/parser/gradleparser.cpp @@ -7,6 +7,8 @@ #include "common/type/task.h" #include "common/util/fileutils.h" +#include + const char TASK_CATEGORY_BUILDSYSTEM[] = "Task.Category.Buildsystem"; GradleParser::GradleParser() @@ -25,7 +27,7 @@ void GradleParser::stdOutput(const QString &line, OutputPane::OutputFormat forma void GradleParser::stdError(const QString &line) { QString newContent = line; - QRegExp exp("/.*:(\\d*):"); + QRegularExpression exp("/.*:(\\d*):"); int ret = newContent.indexOf(exp); QString filePath; int lineNumber = -1; diff --git a/src/plugins/java/gradle/project/gradleprojectgenerator.cpp b/src/plugins/java/gradle/project/gradleprojectgenerator.cpp index 6002f9ca2..e30e30f24 100644 --- a/src/plugins/java/gradle/project/gradleprojectgenerator.cpp +++ b/src/plugins/java/gradle/project/gradleprojectgenerator.cpp @@ -168,7 +168,7 @@ QStandardItem *GradleProjectGenerator::createRootItem(const dpfservice::ProjectI QObject::connect(d->projectParses[rootItem], &GradleAsynParse::itemsModified, this, [=](const QList &items){ doProjectChildsModified(items); auto prjService = dpfGetService(ProjectService); - prjService->expandItemByFile(d->toExpand.toList()); + prjService->expandItemByFile(d->toExpand.values()); }); QMetaObject::invokeMethod(d->projectParses[rootItem], "parseProject", Q_ARG(const dpfservice::ProjectInfo &, info)); diff --git a/src/plugins/java/javautil.cpp b/src/plugins/java/javautil.cpp index 505dd560c..deed13c4b 100644 --- a/src/plugins/java/javautil.cpp +++ b/src/plugins/java/javautil.cpp @@ -12,8 +12,8 @@ QString JavaUtil::getMainClassPath(const QDir &dir) { QFileInfoList entries = dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks); - //Create a QRegExp object with the given regular expression - QRegExp regExp("public\\s+static\\s+void\\s+main\\s*\\(\\s*"); + //Create a QRegularExpression object with the given regular expression + QRegularExpression regExp("public\\s+static\\s+void\\s+main\\s*\\(\\s*"); //Loop through files foreach (QFileInfo entry, entries) { @@ -43,7 +43,7 @@ QString JavaUtil::getMainClassPath(const QDir &dir) } QString output = process.readAllStandardOutput(); //Check if the given regular expression matches the file content - if (regExp.indexIn(output) >= 0) { + if (regExp.match(output).hasMatch()) { return entry.filePath(); } } diff --git a/src/plugins/java/maven/builder/parser/mavenparser.cpp b/src/plugins/java/maven/builder/parser/mavenparser.cpp index 7dec5f045..2690497d4 100644 --- a/src/plugins/java/maven/builder/parser/mavenparser.cpp +++ b/src/plugins/java/maven/builder/parser/mavenparser.cpp @@ -7,6 +7,8 @@ #include "common/type/task.h" #include "common/util/fileutils.h" +#include + const char TASK_CATEGORY_BUILDSYSTEM[] = "Task.Category.Buildsystem"; MavenParser::MavenParser() @@ -17,7 +19,7 @@ MavenParser::MavenParser() void MavenParser::stdOutput(const QString &line, OutputPane::OutputFormat format) { QString newContent = line; - QRegExp exp("\\033\\[(\\d*;*\\d*)m"); + QRegularExpression exp("\\033\\[(\\d*;*\\d*)m"); newContent.replace(exp, ""); if (newContent.indexOf("[ERROR]") != -1) { @@ -33,7 +35,7 @@ void MavenParser::stdOutput(const QString &line, OutputPane::OutputFormat format void MavenParser::stdError(const QString &line) { QString newContent = line; - QRegExp exp("/.*:\\[(\\d*),(\\d*)\\]"); + QRegularExpression exp("/.*:\\[(\\d*),(\\d*)\\]"); int pos = newContent.indexOf(exp); QString filePath; int lineNumber = -1; @@ -48,7 +50,7 @@ void MavenParser::stdError(const QString &line) } } } else { - QRegExp pomExp("Non-parseable POM /.*:"); + QRegularExpression pomExp("Non-parseable POM /.*:"); QString header = "Non-parseable POM "; pos = newContent.indexOf(pomExp); if (pos != -1) { diff --git a/src/plugins/java/maven/mavengenerator.cpp b/src/plugins/java/maven/mavengenerator.cpp index 684bf66af..6042776e9 100644 --- a/src/plugins/java/maven/mavengenerator.cpp +++ b/src/plugins/java/maven/mavengenerator.cpp @@ -7,7 +7,7 @@ #include "maven/mavenbuild.h" #include "javautil.h" -#include +#include using namespace dpfservice; diff --git a/src/plugins/javascript/CMakeLists.txt b/src/plugins/javascript/CMakeLists.txt index ae4729b7a..aa690befc 100644 --- a/src/plugins/javascript/CMakeLists.txt +++ b/src/plugins/javascript/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0.2) project(javascript) -find_package(Qt5 COMPONENTS Xml Script ScriptTools REQUIRED) +find_package(Qt${QT_DESIRED_VERSION} COMPONENTS Xml REQUIRED) set(javascript_CPP javascriptplugin.cpp @@ -37,13 +37,10 @@ target_link_libraries(${PROJECT_NAME} duc-base duc-services duc-common - Qt5::Xml - Qt5::Script - Qt5::ScriptTools + Qt${QT_DESIRED_VERSION}::Xml ${QtUseModules} ${PkgUserModules} ) install_logo(${PROJECT_NAME}.svg) install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH}) - diff --git a/src/plugins/linglong/builder/parser/llparser.cpp b/src/plugins/linglong/builder/parser/llparser.cpp index e8d6618f3..be4dae3fc 100644 --- a/src/plugins/linglong/builder/parser/llparser.cpp +++ b/src/plugins/linglong/builder/parser/llparser.cpp @@ -7,6 +7,8 @@ #include "common/type/task.h" #include "common/util/fileutils.h" +#include + const char TASK_CATEGORY_BUILDSYSTEM[] = "Task.Category.Buildsystem"; LLParser::LLParser() @@ -25,7 +27,7 @@ void LLParser::stdOutput(const QString &line, OutputPane::OutputFormat format) void LLParser::stdError(const QString &line) { QString newContent = line; - QRegExp exp("/.*:(\\d*):"); + QRegularExpression exp("/.*:(\\d*):"); int ret = newContent.indexOf(exp); QString filePath; int lineNumber = -1; diff --git a/src/plugins/option/optioncore/CMakeLists.txt b/src/plugins/option/optioncore/CMakeLists.txt index 93a65d083..e71c95191 100644 --- a/src/plugins/option/optioncore/CMakeLists.txt +++ b/src/plugins/option/optioncore/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0.2) project(optioncore) -find_package(Qt5 COMPONENTS Xml REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Xml REQUIRED) FILE(GLOB_RECURSE PROJECT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.h" @@ -25,7 +25,7 @@ target_link_libraries(${PROJECT_NAME} duc-common ${QtUseModules} ${PkgUserModules} - Qt5::Xml + Qt${QT_VERSION_MAJOR}::Xml ) -install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH}) +install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH}) \ No newline at end of file diff --git a/src/plugins/option/optioncore/mainframe/persistentsettings.cpp b/src/plugins/option/optioncore/mainframe/persistentsettings.cpp index f712f0e0f..af5a7b2fd 100644 --- a/src/plugins/option/optioncore/mainframe/persistentsettings.cpp +++ b/src/plugins/option/optioncore/mainframe/persistentsettings.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -97,13 +97,13 @@ class ParseContext : public Context enum Element { QtCreatorElement, DataElement, VariableElement, SimpleValueElement, ListValueElement, MapValueElement, UnknownElement }; - Element element(const QStringRef &r) const; + Element element(const QStringView &r) const; static inline bool isValueElement(Element e) { return e == SimpleValueElement || e == ListValueElement || e == MapValueElement; } QVariant readSimpleValue(QXmlStreamReader &r, const QXmlStreamAttributes &attributes) const; bool handleStartElement(QXmlStreamReader &r); - bool handleEndElement(const QStringRef &name); + bool handleEndElement(const QStringView &name); static QString formatWarning(const QXmlStreamReader &r, const QString &message); @@ -142,7 +142,7 @@ QVariantMap ParseContext::parse(QFile &file) bool ParseContext::handleStartElement(QXmlStreamReader &r) { - const QStringRef name = r.name(); + const QStringView name = r.name(); const Element e = element(name); if (e == VariableElement) { m_currentVariableName = r.readElementText(); @@ -177,7 +177,7 @@ bool ParseContext::handleStartElement(QXmlStreamReader &r) return false; } -bool ParseContext::handleEndElement(const QStringRef &name) +bool ParseContext::handleEndElement(const QStringView &name) { const Element e = element(name); if (ParseContext::isValueElement(e)) { @@ -206,7 +206,7 @@ QString ParseContext::formatWarning(const QXmlStreamReader &r, const QString &me return result; } -ParseContext::Element ParseContext::element(const QStringRef &r) const +ParseContext::Element ParseContext::element(const QStringView &r) const { if (r == valueElement) return SimpleValueElement; @@ -226,7 +226,7 @@ ParseContext::Element ParseContext::element(const QStringRef &r) const QVariant ParseContext::readSimpleValue(QXmlStreamReader &r, const QXmlStreamAttributes &attributes) const { // Simple value - const QStringRef type = attributes.value(typeAttribute); + const QStringView type = attributes.value(typeAttribute); const QString text = r.readElementText(); if (type == QLatin1String("QChar")) { QTC_ASSERT(text.size() == 1, return QVariant()); diff --git a/src/plugins/option/optioncore/mainframe/profilesettingwidget.cpp b/src/plugins/option/optioncore/mainframe/profilesettingwidget.cpp index ef3f66dbf..02201d7fd 100644 --- a/src/plugins/option/optioncore/mainframe/profilesettingwidget.cpp +++ b/src/plugins/option/optioncore/mainframe/profilesettingwidget.cpp @@ -136,7 +136,7 @@ void ProfileSettingWidget::setupUi() d->cbChooseLanguage->addItem(iter.key(), iter.value()); } - d->hlayout->setMargin(10); + d->hlayout->setContentsMargins(10, 10, 10, 10); d->hlayout->setSpacing(10); d->hlayout->addWidget(d->languageEdit); d->hlayout->addWidget(d->cbChooseLanguage, 5, Qt::AlignmentFlag::AlignRight); diff --git a/src/plugins/performance/mainframe/mainwindow.cpp b/src/plugins/performance/mainframe/mainwindow.cpp index 69badd04e..72cec286f 100644 --- a/src/plugins/performance/mainframe/mainwindow.cpp +++ b/src/plugins/performance/mainframe/mainwindow.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include DWIDGET_USE_NAMESPACE class MainWindowPrivate diff --git a/src/plugins/project/locator/allprojectfilelocator.cpp b/src/plugins/project/locator/allprojectfilelocator.cpp index f23af4696..f57ed20a9 100644 --- a/src/plugins/project/locator/allprojectfilelocator.cpp +++ b/src/plugins/project/locator/allprojectfilelocator.cpp @@ -28,7 +28,7 @@ void AllProjectFileLocator::prepareSearch(const QString &searchText) auto allProject = projectService->getAllProjectInfo(); foreach (auto project, allProject) { auto sourceFile = project.sourceFiles(); - fileList += sourceFile.toList(); + fileList += sourceFile.values(); } } setFileList(fileList); diff --git a/src/plugins/project/locator/currentprojectlocator.cpp b/src/plugins/project/locator/currentprojectlocator.cpp index a18eb758b..6a13942e1 100644 --- a/src/plugins/project/locator/currentprojectlocator.cpp +++ b/src/plugins/project/locator/currentprojectlocator.cpp @@ -28,7 +28,7 @@ void CurrentProjectLocator::prepareSearch(const QString &searchText) if (projectService->getActiveProjectInfo) { auto project = projectService->getActiveProjectInfo(); auto sourceFile = project.sourceFiles(); - fileList = sourceFile.toList(); + fileList = sourceFile.values(); } setFileList(fileList); diff --git a/src/plugins/python/CMakeLists.txt b/src/plugins/python/CMakeLists.txt index df589537b..9b3195e3b 100644 --- a/src/plugins/python/CMakeLists.txt +++ b/src/plugins/python/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0.2) project(python) -find_package(Qt5 COMPONENTS Xml REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Xml REQUIRED) set(CPPDAP_DIR ${CMAKE_SOURCE_DIR}/3rdparty/cppdap) include_directories(${CPPDAP_DIR}/include) @@ -29,11 +29,10 @@ target_link_libraries(${PROJECT_NAME} duc-services duc-common cppdap - Qt5::Xml + Qt${QT_VERSION_MAJOR}::Xml ${QtUseModules} ${PkgUserModules} ) install_logo(${PROJECT_NAME}.svg) install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH}) - diff --git a/src/plugins/python/python/option/interpreterwidget.cpp b/src/plugins/python/python/option/interpreterwidget.cpp index 357c691a5..0b720a649 100644 --- a/src/plugins/python/python/option/interpreterwidget.cpp +++ b/src/plugins/python/python/option/interpreterwidget.cpp @@ -236,7 +236,7 @@ void InterpreterWidget::setupUi() int code = dialog.exec(); if (code == 0) { auto param = qvariant_cast(d->interpreterComboBox->currentData(Qt::UserRole + 1)); - if (!d->customInterpreters.contains(param)) { + if (!d->customInterpreters.contains(std::move(const_cast(param)))) { DDialog dialog; dialog.setMessage(tr("Default Interpreter can`t be removed")); dialog.setWindowTitle(tr("Warning")); @@ -269,7 +269,9 @@ void InterpreterWidget::updatePackageData() auto param = qvariant_cast(d->interpreterComboBox->currentData(Qt::UserRole + 1)); QString cmd = param.path + " -m pip list"; - QtConcurrent::run(this, &InterpreterWidget::queryPackages, cmd); + QtConcurrent::run([this, cmd](){ + this->queryPackages(cmd); + }); } void InterpreterWidget::queryPackages(const QString &cmd) @@ -283,7 +285,7 @@ void InterpreterWidget::queryPackages(const QString &cmd) QStringList list = output.split("\n"); foreach (QString value, list) { value = value.trimmed(); - value = value.replace(QRegExp("[\\s]+"), ","); + value = value.replace(QRegularExpression("[\\s]+"), ","); QStringList sublist = value.split(","); if (sublist.count() > 1) { if (sublist.at(0).indexOf("Package") > -1 diff --git a/src/plugins/python/python/project/properties/configpropertywidget.cpp b/src/plugins/python/python/project/properties/configpropertywidget.cpp index e61e3fbf2..89845552c 100644 --- a/src/plugins/python/python/project/properties/configpropertywidget.cpp +++ b/src/plugins/python/python/project/properties/configpropertywidget.cpp @@ -81,16 +81,12 @@ void DetailPropertyWidget::setupUI() */ QList findAll(QString pattern, QString str, bool Greedy) { - QRegExp rxlen(pattern); - rxlen.setMinimal(Greedy); - int position = 0; - QList strList; - while (position >= 0) { - position = rxlen.indexIn(str, position); - if (position < 0) - break; - strList << rxlen.cap(1); - position += rxlen.matchedLength(); + QRegularExpression re(pattern); + QRegularExpressionMatchIterator i = re.globalMatch(str); + QStringList strList; + while (i.hasNext()) { + QRegularExpressionMatch match = i.next(); + strList << match.captured(1); } return strList; } diff --git a/src/plugins/python/python/pythongenerator.cpp b/src/plugins/python/python/pythongenerator.cpp index 40afb0c6d..ea6e5ea6d 100644 --- a/src/plugins/python/python/pythongenerator.cpp +++ b/src/plugins/python/python/pythongenerator.cpp @@ -87,8 +87,8 @@ QMap PythonGenerator::getDebugArguments(const dpfservice::Pro static QString getEntryFilePath(const QDir &dir) { QFileInfoList entries = dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks); - //Create a QRegExp object with the given regular expression - QRegExp regExp("if\\s*__name__\\s*==\\s*['|\"]__main__['|\"]"); + //Create a QRegularExpression object with the given regular expression + QRegularExpression regExp("if\\s*__name__\\s*==\\s*['|\"]__main__['|\"]"); //Loop through files foreach (QFileInfo entry, entries) { @@ -105,7 +105,7 @@ static QString getEntryFilePath(const QDir &dir) QString fileContent = file.readAll(); file.close(); //Check if the given regular expression matches the file content - if (regExp.indexIn(fileContent) >= 0) { + if (regExp.match(fileContent).hasMatch()) { return entry.filePath(); } } diff --git a/src/plugins/recent/mainframe/sessionitemwidget.cpp b/src/plugins/recent/mainframe/sessionitemwidget.cpp index e1fc33f41..2896fd062 100644 --- a/src/plugins/recent/mainframe/sessionitemwidget.cpp +++ b/src/plugins/recent/mainframe/sessionitemwidget.cpp @@ -187,7 +187,7 @@ void SessionItemWidgetPrivate::initUI() contentLayout->addWidget(createContent()); QVBoxLayout *loaderLayout = new QVBoxLayout(contentLoader); - loaderLayout->setMargin(0); + loaderLayout->setContentsMargins(0, 0, 0, 0); loaderLayout->setSpacing(0); loaderLayout->addWidget(boxWidget); loaderLayout->addStretch(); @@ -322,7 +322,7 @@ void SessionItemWidgetPrivate::runInputDialog(const QString &title, const QStrin dlg.setTitle(title); dlg.setIcon(QIcon::fromTheme("ide")); DLineEdit *lineEdit = new DLineEdit(&dlg); - QRegExpValidator *validator = new QRegExpValidator(QRegExp("[^/\?:\\\\*]*"), lineEdit); + QRegularExpressionValidator *validator = new QRegularExpressionValidator(QRegularExpression("[^/\?:\\\\*]*"), lineEdit); lineEdit->lineEdit()->setValidator(validator); lineEdit->setPlaceholderText(SessionItemWidget::tr("Please input session name")); lineEdit->setText(editText); diff --git a/src/plugins/reversedebug/loadcoredialog.cpp b/src/plugins/reversedebug/loadcoredialog.cpp index 514af8207..af620e05e 100644 --- a/src/plugins/reversedebug/loadcoredialog.cpp +++ b/src/plugins/reversedebug/loadcoredialog.cpp @@ -95,12 +95,10 @@ void LoadCoreDialog::setupUi() formLayout->addRow(tr("process ID:"), d->pidInput); formLayout->addRow(tr("recent:"), d->historyComboBox); formLayout->setSpacing(10); - formLayout->setMargin(0); formLayout->setContentsMargins(10, 0, 0, 0); centerLayout->addLayout(formLayout); centerLayout->addStretch(); - centerLayout->setMargin(0); centerLayout->setContentsMargins(0, 0, 0, 5); connect(d->traceDir, &DLineEdit::editingFinished, diff --git a/src/plugins/reversedebug/reversedebuggermgr.cpp b/src/plugins/reversedebug/reversedebuggermgr.cpp index 18dafccce..2c90dc060 100644 --- a/src/plugins/reversedebug/reversedebuggermgr.cpp +++ b/src/plugins/reversedebug/reversedebuggermgr.cpp @@ -109,7 +109,7 @@ QWidget *ReverseDebuggerMgr::getWidget() const // verhicle QVBoxLayout *vLayout = new QVBoxLayout(); - vLayout->setMargin(0); + vLayout->setContentsMargins(0, 0, 0, 0); vLayout->setSpacing(0); widget->setLayout(vLayout); QHBoxLayout *hLayout = new QHBoxLayout(); diff --git a/src/plugins/reversedebug/taskwindow.cpp b/src/plugins/reversedebug/taskwindow.cpp index bb2b19fd2..14238ce25 100644 --- a/src/plugins/reversedebug/taskwindow.cpp +++ b/src/plugins/reversedebug/taskwindow.cpp @@ -57,7 +57,7 @@ class TaskWidget : public DWidget void setup(TimelineWidget *timeline, TaskView *listview) { QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); setLayout(layout); layout->addWidget(timeline); diff --git a/src/plugins/smartut/common/projectitemdelegate.cpp b/src/plugins/smartut/common/projectitemdelegate.cpp index c0f0347d1..1bc1cc007 100644 --- a/src/plugins/smartut/common/projectitemdelegate.cpp +++ b/src/plugins/smartut/common/projectitemdelegate.cpp @@ -191,7 +191,7 @@ void ProjectItemDelegate::drawCheckBox(int depth, bool isSelected = (option.state & QStyle::State_Selected) && option.showDecorationSelected; if (isSelected) { - opt.palette.setColor(QPalette::Foreground, option.palette.color(QPalette::HighlightedText)); + opt.palette.setColor(QPalette::WindowText, option.palette.color(QPalette::HighlightedText)); opt.palette.setColor(QPalette::Highlight, option.palette.color(QPalette::HighlightedText)); } diff --git a/src/plugins/smartut/gui/projecttreeview.cpp b/src/plugins/smartut/gui/projecttreeview.cpp index 6c7b6aa02..a008d37c3 100644 --- a/src/plugins/smartut/gui/projecttreeview.cpp +++ b/src/plugins/smartut/gui/projecttreeview.cpp @@ -16,6 +16,7 @@ #include DWIDGET_USE_NAMESPACE +DGUI_USE_NAMESPACE class ProjectTreeViewPrivate : public QObject { diff --git a/src/plugins/smartut/gui/widget/promptsettingwidget.cpp b/src/plugins/smartut/gui/widget/promptsettingwidget.cpp index 20e6aef65..6b3b48dec 100644 --- a/src/plugins/smartut/gui/widget/promptsettingwidget.cpp +++ b/src/plugins/smartut/gui/widget/promptsettingwidget.cpp @@ -11,6 +11,7 @@ #include #include +#include DWIDGET_USE_NAMESPACE diff --git a/src/plugins/smartut/gui/widget/resourcesettingwidget.cpp b/src/plugins/smartut/gui/widget/resourcesettingwidget.cpp index 5b1b9803a..fd371f343 100644 --- a/src/plugins/smartut/gui/widget/resourcesettingwidget.cpp +++ b/src/plugins/smartut/gui/widget/resourcesettingwidget.cpp @@ -13,6 +13,7 @@ #include #include #include +#include DWIDGET_USE_NAMESPACE @@ -74,7 +75,7 @@ void ResourceSettingWidget::updateSettings() for (const auto &info : infoList) { const auto &itemText = QFileInfo(info.workspaceFolder()).baseName(); if (projectCB->findText(itemText) == -1) - projectCB->addItem(itemText, qVariantFromValue(info)); + projectCB->addItem(itemText, QVariant::fromValue(info)); } } diff --git a/src/plugins/smartut/utils/utils.cpp b/src/plugins/smartut/utils/utils.cpp index a2041ce9c..f4f83504c 100644 --- a/src/plugins/smartut/utils/utils.cpp +++ b/src/plugins/smartut/utils/utils.cpp @@ -58,7 +58,11 @@ FolderNode *Utils::recursiveFindOrCreateFolderNode(FolderNode *folder, } } } - QStringList parts = directoryWithoutPrefix.split('/', QString::SkipEmptyParts); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + QStringList parts = directoryWithoutPrefix.split('/', Qt::SkipEmptyParts); +#else + QStringList parts = directoryWithoutPrefix.split('/', QString ::SkipEmptyParts); +#endif if (!isRelative && !parts.isEmpty()) parts[0].prepend('/'); diff --git a/src/plugins/symbol/mainframe/symbolparser.cpp b/src/plugins/symbol/mainframe/symbolparser.cpp index 16306376e..ef341f788 100644 --- a/src/plugins/symbol/mainframe/symbolparser.cpp +++ b/src/plugins/symbol/mainframe/symbolparser.cpp @@ -142,16 +142,12 @@ void SymbolParser::redirectErr() QList findAll(const QString &pattern, const QString &str, bool greedy) { - QRegExp rxlen(pattern); - rxlen.setMinimal(greedy); - int position = 0; - QList strList; - while (position >= 0) { - position = rxlen.indexIn(str, position); - if (position < 0) - break; - strList << rxlen.cap(1); - position += rxlen.matchedLength(); + QRegularExpression re(pattern); + QRegularExpressionMatchIterator i = re.globalMatch(str); + QStringList strList; + while (i.hasNext()) { + QRegularExpressionMatch match = i.next(); + strList << match.captured(1); } return strList; } diff --git a/src/plugins/template/wizard/maindialog.cpp b/src/plugins/template/wizard/maindialog.cpp index 21e86ac5f..56b26d6d2 100644 --- a/src/plugins/template/wizard/maindialog.cpp +++ b/src/plugins/template/wizard/maindialog.cpp @@ -232,7 +232,7 @@ void MainDialog::setupUI(TemplateVector &templateVec) QVBoxLayout *rightLayout = new QVBoxLayout(); rightLayout->addWidget(detailFrame); - rightLayout->setMargin(10); + rightLayout->setContentsMargins(10, 10, 10, 10); QHBoxLayout *hLayout = new QHBoxLayout(); hLayout->addLayout(leftLayout); diff --git a/src/plugins/valgrind/mainframe/valgrindbar.cpp b/src/plugins/valgrind/mainframe/valgrindbar.cpp index 6745bd636..87e98ce94 100644 --- a/src/plugins/valgrind/mainframe/valgrindbar.cpp +++ b/src/plugins/valgrind/mainframe/valgrindbar.cpp @@ -93,20 +93,18 @@ void ValgrindBar::initValgrindbar() QHBoxLayout *hLayout = new QHBoxLayout(); hLayout->addWidget(d->btnBox); hLayout->setAlignment(Qt::AlignLeft); - hLayout->setMargin(0); + hLayout->setContentsMargins(0, 0, 0, 0); QVBoxLayout *vLayout = new QVBoxLayout(); vLayout->addLayout(hLayout); vLayout->addWidget(d->stackedWidget); vLayout->setContentsMargins(0, 0, 0, 0); - vLayout->setMargin(0); d->mainFrame->setLayout(vLayout); d->mainFrame->setLineWidth(0); vLayout->setAlignment(Qt::AlignLeft | Qt::AlignTop); QVBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->addWidget(d->mainFrame); - mainLayout->setMargin(0); mainLayout->setContentsMargins(0, 0, 0, 0); DStyle::setFrameRadius(d->mainFrame, 0); this->setLayout(mainLayout); diff --git a/src/services/option/toolchaindata.h b/src/services/option/toolchaindata.h index 44a472cfc..194a50f9f 100644 --- a/src/services/option/toolchaindata.h +++ b/src/services/option/toolchaindata.h @@ -34,7 +34,7 @@ class SERVICE_EXPORT ToolChainData { QString name; QString path; - bool operator ==(const ToolChainParam ¶m) { + bool operator ==(const ToolChainParam ¶m) const { return (this->name == param.name && this->path == param.path); } }; diff --git a/src/services/project/directoryasynparse.cpp b/src/services/project/directoryasynparse.cpp index e1b69e444..7655b2202 100644 --- a/src/services/project/directoryasynparse.cpp +++ b/src/services/project/directoryasynparse.cpp @@ -165,7 +165,7 @@ void DirectoryAsynParse::updateItem(QStandardItem *item) if (!dir.exists()) return; - QStringList tempFileList = d->fileList.toList(); + QStringList tempFileList = d->fileList.values(); QStringList existingPaths; // Remove non-existent items for (int i = item->rowCount() - 1; i >= 0; --i) { @@ -188,7 +188,8 @@ void DirectoryAsynParse::updateItem(QStandardItem *item) } } - d->fileList = tempFileList.toSet(); + for (auto tempFile : tempFileList) + d->fileList.insert(tempFile); bool hasAdded = false; // Process directory entries const QFileInfoList entries = dir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot); diff --git a/src/services/project/directorygenerator.cpp b/src/services/project/directorygenerator.cpp index 56f70bdb1..fe1cb9bc4 100644 --- a/src/services/project/directorygenerator.cpp +++ b/src/services/project/directorygenerator.cpp @@ -100,7 +100,7 @@ QStandardItem *DirectoryGenerator::createRootItem(const dpfservice::ProjectInfo &DirectoryAsynParse::reqUpdateItem, this, &DirectoryGenerator::handleItemUpdated, Qt::UniqueConnection); - QtConcurrent::run(ginfo.parser, &DirectoryAsynParse::parseProject, info); + QtConcurrent::run([ginfo, &info](){ ginfo.parser->parseProject(info); }); return rootItem; } diff --git a/src/services/project/projectgenerator.cpp b/src/services/project/projectgenerator.cpp index c1ae3f808..aa627a89e 100644 --- a/src/services/project/projectgenerator.cpp +++ b/src/services/project/projectgenerator.cpp @@ -157,7 +157,7 @@ bool dpfservice::ProjectGenerator::configure(const dpfservice::ProjectInfo &proj */ QStandardItem *dpfservice::ProjectGenerator::createRootItem(const dpfservice::ProjectInfo &info) { - QIcon icon = CustomIcons::icon(info.workspaceFolder()); + QIcon icon = CustomIcons::icon(QFileInfo(info.workspaceFolder())); QString displyName = QFileInfo(info.workspaceFolder()).fileName(); QString tooltip = info.workspaceFolder(); auto rootItem = new QStandardItem(icon, displyName); diff --git a/src/tools/debugadapter/CMakeLists.txt b/src/tools/debugadapter/CMakeLists.txt index 05c94c79b..1d68d9879 100644 --- a/src/tools/debugadapter/CMakeLists.txt +++ b/src/tools/debugadapter/CMakeLists.txt @@ -47,7 +47,7 @@ add_executable(${PROJECT_NAME} main.cpp ${${PROJECT_NAME}_SOURCES}) target_link_libraries(${PROJECT_NAME} - Qt5::DBus + Qt${QT_VERSION_MAJOR}::DBus duc-common ) diff --git a/src/tools/debugadapter/dapsession.cpp b/src/tools/debugadapter/dapsession.cpp index f0f080105..cff414510 100644 --- a/src/tools/debugadapter/dapsession.cpp +++ b/src/tools/debugadapter/dapsession.cpp @@ -99,7 +99,7 @@ void DapSession::slotReceiveClientInfo(const QString &ppid, const QString &kit, param.insert("targetPath", targetPath); param.insert("arguments", arguments); - if(ppid == getppid()) + if(ppid == QString::number(getppid())) emit sigSendToClient(ppid, d->serverInfo.port(), kit, param); } @@ -118,8 +118,9 @@ bool DapSession::start() auto checkPortFree = [](int port) { QProcess process; - QString cmd = QString("fuser %1/tcp").arg(port); - process.start(cmd); + QString program = "fuser"; + QStringList param = { QString("%1/tcp").arg(port) }; + process.start(program, param); process.waitForFinished(); QString ret = process.readAll(); if (ret.isEmpty()) @@ -312,24 +313,23 @@ void DapSession::registerHanlder() // execute debugger and debuggee after configurate done response d->session->registerSentHandler([&](const dap::ResponseOrError &response) { Q_UNUSED(response) - connect(d->debugger, &DebugManager::asyncRunning, DapProxy::instance(), - [this](const QString& processName, const QString& theadId) mutable { - // TODO(Any):multi-thread condition should be done. - Q_UNUSED(theadId) - dap::integer pointerSize; - dap::ProcessEvent processEvent; - processEvent.name = processName.toStdString(); - processEvent.startMethod = "launch"; - processEvent.systemProcessId = d->debugger->getProcessId(); - processEvent.pointerSize = pointerSize; - d->session->send(processEvent); - Log("--> Server sent process Event to client\n") - - configured.fire(); - }, Qt::UniqueConnection); - emit DapProxy::instance()->sigLaunchLocal(); }); + connect(d->debugger, &DebugManager::asyncRunning, DapProxy::instance(), + [this](const QString& processName, const QString& theadId) mutable { + // TODO(Any):multi-thread condition should be done. + Q_UNUSED(theadId) + dap::integer pointerSize; + dap::ProcessEvent processEvent; + processEvent.name = processName.toStdString(); + processEvent.startMethod = "launch"; + processEvent.systemProcessId = d->debugger->getProcessId(); + processEvent.pointerSize = pointerSize; + d->session->send(processEvent); + Log("--> Server sent process Event to client\n") + + configured.fire(); + }); // The Launch request is made when the client instructs the debugger adapter // to start the debuggee. This request contains the launch arguments. diff --git a/src/tools/debugadapter/debugger/gdbmi/gdbdebugger.cpp b/src/tools/debugadapter/debugger/gdbmi/gdbdebugger.cpp index cc7bbcf81..96cc68578 100644 --- a/src/tools/debugadapter/debugger/gdbmi/gdbdebugger.cpp +++ b/src/tools/debugadapter/debugger/gdbmi/gdbdebugger.cpp @@ -68,8 +68,8 @@ GDBDebugger::~GDBDebugger() void GDBDebugger::init() { //use to debugging adapter -// DebugManager::instance()->command("set logging file /tmp/log.txt"); -// DebugManager::instance()->command("set logging on"); + DebugManager::instance()->command("set logging file /tmp/log.txt"); + DebugManager::instance()->command("set logging on"); QString prettyPrintersPath = CustomPaths::CustomPaths::global(CustomPaths::Scripts) + "/prettyprinters"; DebugManager::instance()->command(QString("python sys.path.insert(0, \"%1\")").arg(prettyPrintersPath)); @@ -630,11 +630,16 @@ void GDBDebugger::parseResultData(gdbmi::Record &record) // -stack-list-frames => StackTrace Reqeust if (!d->inferiorRunning) { QList stackFrames; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) auto stackTrace = record.payload.toMap().value("stack").toList().first().toMap().values("frame"); - for (const auto& e: stackTrace) { +#else + auto stacks = record.payload.toMap().value("stack").toList(); + auto stackTrace = stacks.first().toMap().value("frame").toList(); +#endif + for (const auto& e : stackTrace) { auto frame = gdbmi::Frame::parseMap(e.toMap()); stackFrames.prepend(frame); - } + } d->stackFrames = stackFrames; emit updateStackFrame(stackFrames); } @@ -644,7 +649,7 @@ void GDBDebugger::parseResultData(gdbmi::Record &record) auto data = record.payload.toMap(); auto bp = gdbmi::Breakpoint::parseMap(data.value("bkpt").toMap()); d->breakpoints.insert(bp.number, bp); - emit breakpointInserted(bp); + // emit breakpointInserted(bp); //unused } } emit updateExceptResponse(record.token, record.payload); diff --git a/src/tools/debugadapter/debugger/gdbmi/gdbmi.cpp b/src/tools/debugadapter/debugger/gdbmi/gdbmi.cpp index efe0d6424..a686b578b 100644 --- a/src/tools/debugadapter/debugger/gdbmi/gdbmi.cpp +++ b/src/tools/debugadapter/debugger/gdbmi/gdbmi.cpp @@ -141,8 +141,17 @@ QVariantMap parseKeyVal(const QString& str, QString::const_iterator& it, QChar t auto v = parseValue(str, skipspaces(++it), terminator); // qInfo() << "Key => " << k; // qInfo() << "Value => " << k; - m.insertMulti(k,v); - //m.insert(k, v); //insertMulti?? +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + m.insertMulti(k, v); +#else + if (k == "frame") { + QVariantList values = m[k].toList(); + values.prepend(v); // append stack frame from head + m[k] = values; + } else { + m.insert(k, v); + } +#endif if (it >= str.cend()) break; if (*it == terminator) { diff --git a/src/tools/debugadapter/debugger/python/pythondebugger.cpp b/src/tools/debugadapter/debugger/python/pythondebugger.cpp index d3ee35efb..b27d2f45e 100644 --- a/src/tools/debugadapter/debugger/python/pythondebugger.cpp +++ b/src/tools/debugadapter/debugger/python/pythondebugger.cpp @@ -154,7 +154,7 @@ void PythonDebugger::slotReceiveClientInfo(const QString &ppid, const QString &projectPath, const QString &projectCachePath) { - if (ppid != getppid()) + if (ppid != QString::number(getppid())) return; d->port = 0; d->process.close(); diff --git a/src/tools/debugadapter/debugmanager.cpp b/src/tools/debugadapter/debugmanager.cpp index b62948693..f438b1a33 100644 --- a/src/tools/debugadapter/debugmanager.cpp +++ b/src/tools/debugadapter/debugmanager.cpp @@ -249,7 +249,7 @@ void DebugManager::breakInsert(const QString &path, const QString &condition, bo void DebugManager::updateExceptResponse(const int token, const QVariant& payload) { if (d->resposeExpected.contains(token)) { - auto& expect = d->resposeExpected.value(token); + const auto& expect = d->resposeExpected.value(token); if(expect.handler) expect.handler(payload); if (expect.action == ResponseEntry::ResponseEntry::ResponseAction_t::Temporal) diff --git a/src/tools/languageadapter/CMakeLists.txt b/src/tools/languageadapter/CMakeLists.txt index 1868abca2..0969ab627 100644 --- a/src/tools/languageadapter/CMakeLists.txt +++ b/src/tools/languageadapter/CMakeLists.txt @@ -30,7 +30,7 @@ if ((NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "sw_64") # set(CMAKE_L_FLAGS "-fsanitize=thread") endif() -find_package(Qt5 CONFIG REQUIRED Core Gui Widgets Network Concurrent) +find_package(Qt${QT_VERSION_MAJOR} CONFIG REQUIRED Core Gui Widgets Network Concurrent) set(HEADERS remotechecker.h @@ -54,4 +54,4 @@ target_link_libraries(${PROJECT_NAME} duc-framework ) -install(TARGETS ${PROJECT_NAME} DESTINATION "${LIBRARY_INSTALL_PREFIX}/tools") +install(TARGETS ${PROJECT_NAME} DESTINATION "${LIBRARY_INSTALL_PREFIX}/tools") \ No newline at end of file diff --git a/src/tools/performancedapter/CMakeLists.txt b/src/tools/performancedapter/CMakeLists.txt index 7a9c78e0c..1949c3a68 100644 --- a/src/tools/performancedapter/CMakeLists.txt +++ b/src/tools/performancedapter/CMakeLists.txt @@ -19,7 +19,7 @@ if ((NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "sw_64") # set(CMAKE_L_FLAGS "-fsanitize=thread") endif() -find_package(Qt5 CONFIG REQUIRED Core Gui Widgets Network Concurrent) +find_package(Qt${QT_VERSION_MAJOR} CONFIG REQUIRED Core Gui Widgets Network Concurrent) set(HEADERS serverhandler.h @@ -41,4 +41,4 @@ target_link_libraries(${PROJECT_NAME} unioncode-jsonrpccpp-common ) -install(TARGETS ${PROJECT_NAME} DESTINATION "${LIBRARY_INSTALL_PREFIX}/tools") +install(TARGETS ${PROJECT_NAME} DESTINATION "${LIBRARY_INSTALL_PREFIX}/tools") \ No newline at end of file diff --git a/src/tools/performancedapter/tools.cpp b/src/tools/performancedapter/tools.cpp index ad9854b33..da581b5ee 100644 --- a/src/tools/performancedapter/tools.cpp +++ b/src/tools/performancedapter/tools.cpp @@ -130,7 +130,7 @@ struct Add : QString, std::string QString format(const QString &src) { QString temp = src; - temp.replace(QRegExp("[\\s]+"), " "); + temp.replace(QRegularExpression("[\\s]+"), " "); while (temp.startsWith(" ")) { temp.remove(0 , sizeof(" ")); } @@ -424,7 +424,7 @@ void Tools::startAll() for (auto ins : d->toolsIns) { ins->start(); qInfo() << "start" << ins->program() << ins->arguments() - << "pid :" << ins->pid(); + << "pid :" << ins->processId(); } } From ce33cbb388fa137af4645ea22a57416ca95b73a8 Mon Sep 17 00:00:00 2001 From: ZhangTingAn Date: Thu, 23 Jan 2025 14:11:47 +0800 Subject: [PATCH 2/3] feat: adapt qtermwidget for Qt6.8 log: as title --- 3rdparty/CMakeLists.txt | 2 +- .../CMakeLists.txt | 26 ++++-- .../lib/Character.h | 8 +- .../lib/ColorScheme.cpp | 20 ++-- .../lib/HistorySearch.cpp | 7 +- .../lib/HistorySearch.h | 5 +- .../lib/KeyboardTranslator.cpp | 27 +++--- .../unioncode-qtermwidget-0.14.1/lib/Pty.cpp | 9 +- .../unioncode-qtermwidget-0.14.1/lib/Pty.h | 6 +- .../lib/Session.cpp | 6 +- .../lib/TerminalDisplay.cpp | 91 +++++++++++++------ .../lib/Vt102Emulation.cpp | 17 ++-- .../lib/kprocess.cpp | 4 +- .../lib/kprocess.h | 2 + .../unioncode-qtermwidget-0.14.1/lib/kpty.cpp | 26 +++--- .../lib/kptyprocess.cpp | 21 +++++ .../lib/kptyprocess.h | 5 +- .../lib/qtermwidget.cpp | 10 +- CMakeLists.txt | 3 +- src/plugins/CMakeLists.txt | 2 +- 20 files changed, 195 insertions(+), 102 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index b62e64d0d..3066c8dcf 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -2,6 +2,6 @@ add_subdirectory(cppdap) add_subdirectory(unioncode-qscintilla214) if (QT_VERSION_MAJOR MATCHES 5) add_subdirectory(unioncode-GitQlient) -add_subdirectory(unioncode-qtermwidget-0.14.1) endif() +add_subdirectory(unioncode-qtermwidget-0.14.1) add_subdirectory(unioncode-jsonrpccpp) diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/CMakeLists.txt b/3rdparty/unioncode-qtermwidget-0.14.1/CMakeLists.txt index 4f5043ecb..c8e298854 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/CMakeLists.txt +++ b/3rdparty/unioncode-qtermwidget-0.14.1/CMakeLists.txt @@ -28,8 +28,13 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(QT_MINIMUM_VERSION "5.7.1") set(LXQTBT_MINIMUM_VERSION "0.6.0") -find_package(Qt5Widgets "${QT_MINIMUM_VERSION}" REQUIRED) -find_package(Qt5LinguistTools "${QT_MINIMUM_VERSION}" REQUIRED) +#find_package(Qt5Widgets "${QT_MINIMUM_VERSION}" REQUIRED) +#find_package(Qt5LinguistTools "${QT_MINIMUM_VERSION}" REQUIRED) +find_package(Qt${QT_VERSION_MAJOR}Widgets REQUIRED) +find_package(Qt${QT_VERSION_MAJOR}LinguistTools REQUIRED) +if (${QT_VERSION_MAJOR} MATCHES 6) + find_package(Qt6Core5Compat REQUIRED) +endif() find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED) if(USE_UTF8PROC) @@ -110,9 +115,15 @@ message(STATUS "Translations will be installed in: ${TRANSLATIONS_DIR}") CHECK_FUNCTION_EXISTS(updwtmpx HAVE_UPDWTMPX) -qt5_wrap_cpp(MOCS ${HDRS}) -qt5_wrap_ui(UI_SRCS ${UI}) -set(PKG_CONFIG_REQ "Qt5Widgets") +if (${QT_VERSION_MAJOR} MATCHES 6) + qt6_wrap_cpp(MOCS ${HDRS}) + qt6_wrap_ui(UI_SRCS ${UI}) +else() + qt5_wrap_cpp(MOCS ${HDRS}) + qt5_wrap_ui(UI_SRCS ${UI}) +endif() + +set(PKG_CONFIG_REQ "Qt${QT_VERSION_MAJOR}Widgets") lxqt_translate_ts(QTERMWIDGET_QM TRANSLATION_DIR "lib/translations" @@ -127,7 +138,10 @@ lxqt_translate_ts(QTERMWIDGET_QM ) add_library(${QTERMWIDGET_LIBRARY_NAME} SHARED ${SRCS} ${MOCS} ${UI_SRCS} ${QTERMWIDGET_QM}) -target_link_libraries(${QTERMWIDGET_LIBRARY_NAME} Qt5::Widgets) +target_link_libraries(${QTERMWIDGET_LIBRARY_NAME} Qt${QT_VERSION_MAJOR}::Widgets) +if (${QT_VERSION_MAJOR} MATCHES 6) + target_link_libraries(${QTERMWIDGET_LIBRARY_NAME} Qt6::Core5Compat) +endif() if(APPLE) target_compile_definitions(${QTERMWIDGET_LIBRARY_NAME} diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/Character.h b/3rdparty/unioncode-qtermwidget-0.14.1/lib/Character.h index 9c9fae293..eb588d139 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/Character.h +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/Character.h @@ -78,8 +78,12 @@ class Character union { /** The unicode character value for this character. */ - wchar_t character; - /** +#if QT_VERSION >= 0x060000 + char16_t character; +#else + wchar_t character; +#endif + /** * Experimental addition which allows a single Character instance to contain more than * one unicode character. * diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/ColorScheme.cpp b/3rdparty/unioncode-qtermwidget-0.14.1/lib/ColorScheme.cpp index c9cc851d3..75a8fdee5 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/ColorScheme.cpp +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/ColorScheme.cpp @@ -31,7 +31,7 @@ #include #include #include - +#include // KDE //#include @@ -177,11 +177,9 @@ void ColorScheme::setColorTableEntry(int index , const ColorEntry& entry) } ColorEntry ColorScheme::colorEntry(int index , uint randomSeed) const { + Q_UNUSED(randomSeed); Q_ASSERT( index >= 0 && index < TABLE_COLORS ); - if ( randomSeed != 0 ) - qsrand(randomSeed); - ColorEntry entry = colorTable()[index]; if ( randomSeed != 0 && @@ -191,9 +189,9 @@ ColorEntry ColorScheme::colorEntry(int index , uint randomSeed) const const RandomizationRange& range = _randomTable[index]; - int hueDifference = range.hue ? (qrand() % range.hue) - range.hue/2 : 0; - int saturationDifference = range.saturation ? (qrand() % range.saturation) - range.saturation/2 : 0; - int valueDifference = range.value ? (qrand() % range.value) - range.value/2 : 0; + int hueDifference = range.hue ? (QRandomGenerator::global()->bounded(range.hue)) - range.hue/2 : 0; + int saturationDifference = range.saturation ? (QRandomGenerator::global()->bounded(range.saturation)) - range.saturation/2 : 0; + int valueDifference = range.value ? (QRandomGenerator::global()->bounded(range.value)) - range.value/2 : 0; QColor& color = entry.color; @@ -367,9 +365,9 @@ void ColorScheme::readColorEntry(QSettings * s , int index) if (hexColorPattern.match(colorStr).hasMatch()) { // Parsing is always ok as already matched by the regexp - r = colorStr.midRef(1, 2).toInt(nullptr, 16); - g = colorStr.midRef(3, 2).toInt(nullptr, 16); - b = colorStr.midRef(5, 2).toInt(nullptr, 16); + r = colorStr.mid(1, 2).toInt(nullptr, 16); + g = colorStr.mid(3, 2).toInt(nullptr, 16); + b = colorStr.mid(5, 2).toInt(nullptr, 16); ok = true; } } @@ -502,7 +500,7 @@ ColorScheme* KDE3ColorSchemeReader::read() ColorScheme* scheme = new ColorScheme(); - QRegExp comment(QLatin1String("#.*$")); + QRegularExpression comment(QLatin1String("#.*$")); while ( !_device->atEnd() ) { QString line(QString::fromUtf8(_device->readLine())); diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/HistorySearch.cpp b/3rdparty/unioncode-qtermwidget-0.14.1/lib/HistorySearch.cpp index 41c514f7b..74e8de187 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/HistorySearch.cpp +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/HistorySearch.cpp @@ -24,7 +24,7 @@ #include "Emulation.h" #include "HistorySearch.h" -HistorySearch::HistorySearch(EmulationPtr emulation, QRegExp regExp, +HistorySearch::HistorySearch(EmulationPtr emulation, QRegularExpression regExp, bool forwards, int startColumn, int startLine, QObject* parent) : QObject(parent), @@ -41,7 +41,7 @@ HistorySearch::~HistorySearch() { void HistorySearch::search() { bool found = false; - if (! m_regExp.isEmpty()) + if( ! m_regExp.isValid()) { if (m_forwards) { found = search(m_startColumn, m_startLine, -1, m_emulation->lineCount()) || search(0, 0, m_startColumn, m_startLine); @@ -119,7 +119,8 @@ bool HistorySearch::search(int startColumn, int startLine, int endColumn, int en if (matchStart > -1) { - int matchEnd = matchStart + m_regExp.matchedLength() - 1; + auto match = m_regExp.match(string); + int matchEnd = matchStart + match.capturedLength() - 1; qDebug() << "Found in string from" << matchStart << "to" << matchEnd; // Translate startPos and endPos to startColum, startLine, endColumn and endLine in history. diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/HistorySearch.h b/3rdparty/unioncode-qtermwidget-0.14.1/lib/HistorySearch.h index e019650c6..fc2dee55d 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/HistorySearch.h +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/HistorySearch.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -38,7 +39,7 @@ class HistorySearch : public QObject Q_OBJECT public: - explicit HistorySearch(EmulationPtr emulation, QRegExp regExp, bool forwards, + explicit HistorySearch(EmulationPtr emulation, QRegularExpression regExp, bool forwards, int startColumn, int startLine, QObject* parent); ~HistorySearch(); @@ -55,7 +56,7 @@ class HistorySearch : public QObject EmulationPtr m_emulation; - QRegExp m_regExp; + QRegularExpression m_regExp; bool m_forwards; int m_startColumn; int m_startLine; diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/KeyboardTranslator.cpp b/3rdparty/unioncode-qtermwidget-0.14.1/lib/KeyboardTranslator.cpp index 7382e158a..d81b088bc 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/KeyboardTranslator.cpp +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/KeyboardTranslator.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include "tools.h" @@ -532,10 +533,10 @@ QList KeyboardTranslatorReader::tokenize(const text = text.simplified(); // title line: keyboard "title" - static QRegExp title(QLatin1String("keyboard\\s+\"(.*)\"")); + QRegularExpression title(QLatin1String("keyboard\\s+\"(.*)\"")); // key line: key KeySequence : "output" // key line: key KeySequence : command - static QRegExp key(QLatin1String("key\\s+([\\w\\+\\s\\-\\*\\.]+)\\s*:\\s*(\"(.*)\"|\\w+)")); + QRegularExpression key(QLatin1String("key\\s+([\\w\\+\\s\\-\\*\\.]+)\\s*:\\s*(\"(.*)\"|\\w+)")); QList list; if ( text.isEmpty() ) @@ -543,30 +544,31 @@ QList KeyboardTranslatorReader::tokenize(const return list; } - if ( title.exactMatch(text) ) + if ( title.match(text).hasMatch() ) { + auto match = title.match(text); Token titleToken = { Token::TitleKeyword , QString() }; - Token textToken = { Token::TitleText , title.capturedTexts().at(1) }; - + Token textToken = { Token::TitleText , match.capturedTexts().at(1) }; list << titleToken << textToken; } - else if ( key.exactMatch(text) ) + else if ( key.match(text).hasMatch() ) { + auto match = key.match(text); Token keyToken = { Token::KeyKeyword , QString() }; - Token sequenceToken = { Token::KeySequence , key.capturedTexts().value(1).remove(QLatin1Char(' ')) }; + Token sequenceToken = { Token::KeySequence , match.capturedTexts().value(1).remove(QLatin1Char(' ')) }; list << keyToken << sequenceToken; - if ( key.capturedTexts().at(3).isEmpty() ) + if ( match.capturedTexts().size() < 4 || match.capturedTexts().at(3).isEmpty() ) { // capturedTexts()[2] is a command - Token commandToken = { Token::Command , key.capturedTexts().at(2) }; + Token commandToken = { Token::Command , match.capturedTexts().at(2) }; list << commandToken; } else { // capturedTexts()[3] is the output string - Token outputToken = { Token::OutputText , key.capturedTexts().at(3) }; + Token outputToken = { Token::OutputText , match.capturedTexts().at(3) }; list << outputToken; } } @@ -664,7 +666,8 @@ QByteArray KeyboardTranslator::Entry::escapedText(bool expandWildCards,Qt::Keybo if ( replacement == 'x' ) { - result.replace(i,1,"\\x"+QByteArray(1,ch).toHex()); + QByteArray data = "\\x"+QByteArray(1,ch).toHex(); + result.replace(i,1,data); } else if ( replacement != 0 ) { result.remove(i,1); @@ -682,7 +685,7 @@ QByteArray KeyboardTranslator::Entry::unescape(const QByteArray& input) const for ( int i = 0 ; i < result.count()-1 ; i++ ) { - QByteRef ch = result[i]; + auto ch = result[i]; if ( ch == '\\' ) { char replacement[2] = {0,0}; diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/Pty.cpp b/3rdparty/unioncode-qtermwidget-0.14.1/lib/Pty.cpp index 87484be2d..ee7c429f0 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/Pty.cpp +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/Pty.cpp @@ -317,10 +317,11 @@ int Pty::foregroundProcessGroup() const return 0; } +// TODO: we need to handle this +#if QT_VERSION < 0x060000 void Pty::setupChildProcess() { KPtyProcess::setupChildProcess(); - // reset all signal handlers // this ensures that terminal applications respond to // signals generated via key sequences such as Ctrl+C @@ -328,11 +329,13 @@ void Pty::setupChildProcess() struct sigaction action; sigset_t sigset; sigemptyset(&action.sa_mask); + sigemptyset(&sigset); action.sa_handler = SIG_DFL; action.sa_flags = 0; for (int signal=1;signal < NSIG; signal++) { - sigaction(signal,&action,0L); + sigaction(signal,&action,nullptr); sigaddset(&sigset, signal); } - sigprocmask(SIG_UNBLOCK, &sigset, NULL); + sigprocmask(SIG_UNBLOCK, &sigset, nullptr); } +#endif diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/Pty.h b/3rdparty/unioncode-qtermwidget-0.14.1/lib/Pty.h index e5f6cebf9..d1e14cee0 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/Pty.h +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/Pty.h @@ -188,8 +188,10 @@ Q_OBJECT */ void receivedData(const char* buffer, int length); - protected: - void setupChildProcess(); +#if QT_VERSION < 0x060000 +protected: + void setupChildProcess() override; +#endif private slots: // called when data is received from the terminal process diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/Session.cpp b/3rdparty/unioncode-qtermwidget-0.14.1/lib/Session.cpp index c92069f56..e28768805 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/Session.cpp +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/Session.cpp @@ -30,13 +30,13 @@ // Qt #include -#include #include #include #include #include #include #include +#include #include "Pty.h" //#include "kptyprocess.h" @@ -381,7 +381,11 @@ void Session::setUserTitle( int what, const QString & caption ) if (what == 31) { QString cwd=caption; +#if QT_VERSION >= 0x060000 + cwd=cwd.replace( QRegularExpression(QLatin1String("^~")), QDir::homePath() ); +#else cwd=cwd.replace( QRegExp(QLatin1String("^~")), QDir::homePath() ); +#endif emit openUrlRequest(cwd); } diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/TerminalDisplay.cpp b/3rdparty/unioncode-qtermwidget-0.14.1/lib/TerminalDisplay.cpp index ef0f87c1c..4d35bf435 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/TerminalDisplay.cpp +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/TerminalDisplay.cpp @@ -252,19 +252,19 @@ void TerminalDisplay::fontChange(const QFont&) void TerminalDisplay::calDrawTextAdditionHeight(QPainter& painter) { QRect test_rect, feedback_rect; - test_rect.setRect(1, 1, _fontWidth * 4, _fontHeight); + test_rect.setRect(1, 1, _fontWidth * 4, _fontHeight); painter.drawText(test_rect, Qt::AlignBottom, LTR_OVERRIDE_CHAR + QLatin1String("Mq"), &feedback_rect); - //qDebug() << "test_rect:" << test_rect << "feeback_rect:" << feedback_rect; + //qDebug() << "test_rect:" << test_rect << "feeback_rect:" << feedback_rect; - _drawTextAdditionHeight = (feedback_rect.height() - _fontHeight) / 2; - if(_drawTextAdditionHeight < 0) { - _drawTextAdditionHeight = 0; - } + _drawTextAdditionHeight = (feedback_rect.height() - _fontHeight) / 2; + if(_drawTextAdditionHeight < 0) { + _drawTextAdditionHeight = 0; + } - // update the original content + // update the original content _drawTextTestFlag = false; - update(); + update(); } void TerminalDisplay::setVTFont(const QFont& f) @@ -276,8 +276,9 @@ void TerminalDisplay::setVTFont(const QFont& f) // this ensures the same handling for all platforms // but then there was revealed that various Linux distros // have this problem too... - font.setStyleStrategy(QFont::ForceIntegerMetrics); - +#if QT_VERSION < 0x060000 + font.setStyleStrategy(QFont::ForceIntegerMetrics); +#endif QFontMetrics metrics(font); if ( !QFontInfo(font).fixedPitch() ) @@ -1946,7 +1947,13 @@ void TerminalDisplay::mousePressEvent(QMouseEvent* ev) spot->activate(QLatin1String("click-action")); } } - else if ( ev->button() == Qt::MidButton ) + else if ( ev->button() == +#if QT_VERSION >= 0x060000 + Qt::MiddleButton +#else + Qt::MidButton +#endif + ) { if ( _mouseMarks || (ev->modifiers() & Qt::ShiftModifier) ) emitSelection(true,ev->modifiers() & Qt::ControlModifier); @@ -2037,7 +2044,13 @@ void TerminalDisplay::mouseMoveEvent(QMouseEvent* ev) int button = 3; if (ev->buttons() & Qt::LeftButton) button = 0; - if (ev->buttons() & Qt::MidButton) + if (ev->buttons() & +#if QT_VERSION >= 0x060000 + Qt::MiddleButton +#else + Qt::MidButton +#endif + ) button = 1; if (ev->buttons() & Qt::RightButton) button = 2; @@ -2079,7 +2092,14 @@ void TerminalDisplay::mouseMoveEvent(QMouseEvent* ev) if (_actSel == 0) return; // don't extend selection while pasting - if (ev->buttons() & Qt::MidButton) return; + if (ev->buttons() & +#if QT_VERSION >= 0x060000 + Qt::MiddleButton +#else + Qt::MidButton +#endif + ) + return; extendSelection( ev->pos() ); } @@ -2334,9 +2354,21 @@ void TerminalDisplay::mouseReleaseEvent(QMouseEvent* ev) if ( !_mouseMarks && ((ev->button() == Qt::RightButton && !(ev->modifiers() & Qt::ShiftModifier)) - || ev->button() == Qt::MidButton) ) + || ev->button() == +#if QT_VERSION >= 0x060000 + Qt::MiddleButton +#else + Qt::MidButton +#endif +)) { - emit mouseSignal( ev->button() == Qt::MidButton ? 1 : 2, + emit mouseSignal( ev->button() == +#if QT_VERSION >= 0x060000 + Qt::MiddleButton +#else + Qt::MidButton +#endif + ? 1 : 2, charColumn + 1, charLine + 1 +_scrollBar->value() -_scrollBar->maximum() , 2); @@ -2483,8 +2515,8 @@ void TerminalDisplay::mouseDoubleClickEvent(QMouseEvent* ev) void TerminalDisplay::wheelEvent( QWheelEvent* ev ) { - if (ev->orientation() != Qt::Vertical) - return; + if (ev->angleDelta().y() == 0) + return; // if the terminal program is not interested mouse events // then send the event to the scrollbar if the slider has room to move @@ -2503,10 +2535,10 @@ void TerminalDisplay::wheelEvent( QWheelEvent* ev ) // to get a reasonable scrolling speed, scroll by one line for every 5 degrees // of mouse wheel rotation. Mouse wheels typically move in steps of 15 degrees, // giving a scroll of 3 lines - int key = ev->delta() > 0 ? Qt::Key_Up : Qt::Key_Down; + int key = ev->angleDelta().y() > 0 ? Qt::Key_Up : Qt::Key_Down; - // QWheelEvent::delta() gives rotation in eighths of a degree - int wheelDegrees = ev->delta() / 8; + // QWheelEvent::angleDelta().y() gives rotation in eighths of a degree + int wheelDegrees = ev->angleDelta().y() / 8; int linesToScroll = abs(wheelDegrees) / 5; QKeyEvent keyScrollEvent(QEvent::KeyPress,key,Qt::NoModifier); @@ -2519,14 +2551,17 @@ void TerminalDisplay::wheelEvent( QWheelEvent* ev ) { // terminal program wants notification of mouse activity - int charLine; - int charColumn; - getCharacterPosition( ev->pos() , charLine , charColumn ); - - emit mouseSignal( ev->delta() > 0 ? 4 : 5, - charColumn + 1, - charLine + 1 +_scrollBar->value() -_scrollBar->maximum() , - 0); + int charLine; + int charColumn; +#if QT_VERSION <= 0x060000 + getCharacterPosition( ev->pos() , charLine , charColumn ); +#else + getCharacterPosition( ev->position().toPoint() , charLine , charColumn ); +#endif + emit mouseSignal( ev->angleDelta().y() > 0 ? 4 : 5, + charColumn + 1, + charLine + 1 +_scrollBar->value() -_scrollBar->maximum() , + 0); } } diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/Vt102Emulation.cpp b/3rdparty/unioncode-qtermwidget-0.14.1/lib/Vt102Emulation.cpp index 64726598a..3f54f90c7 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/Vt102Emulation.cpp +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/Vt102Emulation.cpp @@ -44,7 +44,6 @@ // Qt #include #include -#include // KDE //#include @@ -413,10 +412,10 @@ void Vt102Emulation::processWindowAttributeChange() return; } - QString newValue; - newValue.reserve(tokenBufferPos-i-2); - for (int j = 0; j < tokenBufferPos-i-2; j++) - newValue[j] = tokenBuffer[i+1+j]; + // copy from the first char after ';', and skipping the ending delimiter + // 0x07 or 0x92. Note that as control characters in OSC text parts are + // ignored, only the second char in ST ("\e\\") is appended to tokenBuffer. + QString newValue = QString::fromWCharArray(tokenBuffer + i + 1, tokenBufferPos-i-2); _pendingTitleUpdates[attributeToChange] = newValue; _titleUpdateTimer->start(20); @@ -961,8 +960,8 @@ void Vt102Emulation::sendMouseEvent( int cb, int cx, int cy , int eventType ) // coordinate+32, no matter what the locale is. We could easily // convert manually, but QString can also do it for us. QChar coords[2]; - coords[0] = cx + 0x20; - coords[1] = cy + 0x20; + coords[0] = QChar(cx + 0x20); + coords[1] = QChar(cy + 0x20); QString coordsStr = QString(coords, 2); QByteArray utf8 = coordsStr.toUtf8(); snprintf(command, sizeof(command), "\033[M%c%s", cb + 0x20, utf8.constData()); @@ -1341,8 +1340,8 @@ char Vt102Emulation::eraseChar() const { KeyboardTranslator::Entry entry = _keyTranslator->findEntry( Qt::Key_Backspace, - 0, - 0); + Qt::NoModifier, + KeyboardTranslator::NoState); if ( entry.text().count() > 0 ) return entry.text().at(0); else diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/kprocess.cpp b/3rdparty/unioncode-qtermwidget-0.14.1/lib/kprocess.cpp index 73264a611..d4ca8fbad 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/kprocess.cpp +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/kprocess.cpp @@ -404,9 +404,9 @@ int KProcess::startDetached(const QStringList &argv) int KProcess::pid() const { #ifdef Q_OS_UNIX - return (int) QProcess::pid(); + return (int) QProcess::processId(); #else - return QProcess::pid() ? QProcess::pid()->dwProcessId : 0; + return QProcess::processId() ? QProcess::processId()->dwProcessId : 0; #endif } diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/kprocess.h b/3rdparty/unioncode-qtermwidget-0.14.1/lib/kprocess.h index ec90721d1..3a9446144 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/kprocess.h +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/kprocess.h @@ -336,8 +336,10 @@ class KProcess : public QProcess private: // hide those +#if QT_VERSION < 0x060000 using QProcess::setReadChannelMode; using QProcess::readChannelMode; +#endif using QProcess::setProcessChannelMode; using QProcess::processChannelMode; diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/kpty.cpp b/3rdparty/unioncode-qtermwidget-0.14.1/lib/kpty.cpp index 97416d828..fcd820e20 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/kpty.cpp +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/kpty.cpp @@ -332,24 +332,28 @@ bool KPty::open() (st.st_mode & (S_IRGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH))) && !d->chownpty(true)) { qWarning() - << "chownpty failed for device " << ptyName << "::" << d->ttyName - << "\nThis means the communication can be eavesdropped." << endl; + << "chownpty failed for device " << ptyName << "::" << d->ttyName +#if QT_VERSION >= 0x060000 + << "\nThis means the communication can be eavesdropped." << Qt::endl; +#else + << "\nThis means the communication can be eavesdropped." << endl; +#endif } -#if defined (HAVE__GETPTY) || defined (HAVE_GRANTPT) +# if defined(HAVE__GETPTY) || defined(HAVE_GRANTPT) grantedpt: -#endif +# endif -#ifdef HAVE_REVOKE +# ifdef HAVE_REVOKE revoke(d->ttyName.data()); -#endif +# endif -#ifdef HAVE_UNLOCKPT +# ifdef HAVE_UNLOCKPT unlockpt(d->masterFd); -#elif defined(TIOCSPTLCK) +# elif defined(TIOCSPTLCK) int flag = 0; ioctl(d->masterFd, TIOCSPTLCK, &flag); -#endif +# endif d->slaveFd = ::open(d->ttyName.data(), O_RDWR | O_NOCTTY); if (d->slaveFd < 0) { @@ -359,11 +363,11 @@ bool KPty::open() return false; } -#if (defined(__svr4__) || defined(__sgi__)) +# if (defined(__svr4__) || defined(__sgi__)) // Solaris ioctl(d->slaveFd, I_PUSH, "ptem"); ioctl(d->slaveFd, I_PUSH, "ldterm"); -#endif +# endif #endif /* HAVE_OPENPTY */ diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/kptyprocess.cpp b/3rdparty/unioncode-qtermwidget-0.14.1/lib/kptyprocess.cpp index ec8df33ed..f455f7cc4 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/kptyprocess.cpp +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/kptyprocess.cpp @@ -46,6 +46,25 @@ KPtyProcess::KPtyProcess(QObject *parent) : d->pty->open(); connect(this, SIGNAL(stateChanged(QProcess::ProcessState)), SLOT(_k_onStateChanged(QProcess::ProcessState))); +#if QT_VERSION >= 0x060000 + setChildProcessModifier([this] { + Q_D(KPtyProcess); + d->pty->setCTty(); + +#if 0 + if (d->addUtmp) + d->pty->login(KUser(KUser::UseRealUserID).loginName().toLocal8Bit().data(), qgetenv("DISPLAY")); +#endif + if (d->ptyChannels & StdinChannel) + dup2(d->pty->slaveFd(), 0); + + if (d->ptyChannels & StdoutChannel) + dup2(d->pty->slaveFd(), 1); + + if (d->ptyChannels & StderrChannel) + dup2(d->pty->slaveFd(), 2); + }); +#endif } KPtyProcess::KPtyProcess(int ptyMasterFd, QObject *parent) : @@ -119,6 +138,7 @@ KPtyDevice *KPtyProcess::pty() const return d->pty; } +#if QT_VERSION < 0x060000 void KPtyProcess::setupChildProcess() { Q_D(KPtyProcess); @@ -140,5 +160,6 @@ void KPtyProcess::setupChildProcess() KProcess::setupChildProcess(); } +#endif //#include "kptyprocess.moc" diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/kptyprocess.h b/3rdparty/unioncode-qtermwidget-0.14.1/lib/kptyprocess.h index 1270c475b..8816b2b5d 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/kptyprocess.h +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/kptyprocess.h @@ -144,8 +144,9 @@ class KPtyProcess : public KProcess /** * @reimp */ - virtual void setupChildProcess(); - +#if QT_VERSION < 0x060000 // move to KPtyProcess() + void setupChildProcess() override; +#endif private: Q_PRIVATE_SLOT(d_func(), void _k_onStateChanged(QProcess::ProcessState)) }; diff --git a/3rdparty/unioncode-qtermwidget-0.14.1/lib/qtermwidget.cpp b/3rdparty/unioncode-qtermwidget-0.14.1/lib/qtermwidget.cpp index 2d92a8b59..1ec007189 100644 --- a/3rdparty/unioncode-qtermwidget-0.14.1/lib/qtermwidget.cpp +++ b/3rdparty/unioncode-qtermwidget-0.14.1/lib/qtermwidget.cpp @@ -159,10 +159,10 @@ void QTermWidget::search(bool forwards, bool next) qDebug() << "current selection starts at: " << startColumn << startLine; qDebug() << "current cursor position: " << m_impl->m_terminalDisplay->screenWindow()->cursorPosition(); - QRegExp regExp(m_searchBar->searchText()); - regExp.setPatternSyntax(m_searchBar->useRegularExpression() ? QRegExp::RegExp : QRegExp::FixedString); - regExp.setCaseSensitivity(m_searchBar->matchCase() ? Qt::CaseSensitive : Qt::CaseInsensitive); - + QRegularExpression regExp(m_searchBar->searchText(), + m_searchBar->matchCase() ? QRegularExpression::CaseInsensitiveOption| + QRegularExpression::UseUnicodePropertiesOption + : QRegularExpression::UseUnicodePropertiesOption); HistorySearch *historySearch = new HistorySearch(m_impl->m_session->emulation(), regExp, forwards, startColumn, startLine, this); connect(historySearch, SIGNAL(matchFound(int, int, int, int)), this, SLOT(matchFound(int, int, int, int))); @@ -253,7 +253,7 @@ void QTermWidget::startTerminalTeletype() void QTermWidget::init(int startnow) { m_layout = new QVBoxLayout(); - m_layout->setMargin(0); + m_layout->setContentsMargins(0, 0, 0, 0); setLayout(m_layout); // translations diff --git a/CMakeLists.txt b/CMakeLists.txt index 947922ae3..d156a6ef0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,8 @@ endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wl,--as-need -fPIE") -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) +# find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) +set(QT_VERSION_MAJOR 6) message(" >>> Found Qt version: ${QT_VERSION_MAJOR}") if (QT_VERSION_MAJOR MATCHES 6) set(DTK_VERSION_MAJOR 6) diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index db9294701..d33244a55 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -12,9 +12,9 @@ add_subdirectory(codeeditor) add_subdirectory(filebrowser) if (QT_VERSION_MAJOR MATCHES 5) #add_subdirectory(collaborators) -#add_subdirectory(console) # add_subdirectory(javascript) endif() +add_subdirectory(console) add_subdirectory(builder) #remove it until system lock issue resolved. #add_subdirectory(container) From 5f2cc1b986d61b9c89194a6472829eb84a4373be Mon Sep 17 00:00:00 2001 From: ZhangTingAn Date: Thu, 23 Jan 2025 16:59:25 +0800 Subject: [PATCH 3/3] feat: adapt Javascript plugin to qt6.8 log: as title --- src/plugins/CMakeLists.txt | 4 +-- src/plugins/javascript/CMakeLists.txt | 35 +++++++++++++++++-- .../javascript/debugger/jsdebugger.cpp | 3 ++ src/plugins/javascript/debugger/jsdebugger.h | 4 +-- src/plugins/javascript/javascriptplugin.cpp | 10 ++++-- src/plugins/javascript/jsgenerator.cpp | 5 +++ 6 files changed, 53 insertions(+), 8 deletions(-) diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index d33244a55..b18a92f50 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -11,9 +11,9 @@ add_subdirectory(debugger) add_subdirectory(codeeditor) add_subdirectory(filebrowser) if (QT_VERSION_MAJOR MATCHES 5) -#add_subdirectory(collaborators) -# add_subdirectory(javascript) +add_subdirectory(collaborators) endif() +add_subdirectory(javascript) add_subdirectory(console) add_subdirectory(builder) #remove it until system lock issue resolved. diff --git a/src/plugins/javascript/CMakeLists.txt b/src/plugins/javascript/CMakeLists.txt index aa690befc..c1f024c9c 100644 --- a/src/plugins/javascript/CMakeLists.txt +++ b/src/plugins/javascript/CMakeLists.txt @@ -2,7 +2,13 @@ cmake_minimum_required(VERSION 3.0.2) project(javascript) -find_package(Qt${QT_DESIRED_VERSION} COMPONENTS Xml REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Xml REQUIRED) + +if (${QT_VERSION_MAJOR} MATCHES 6) + find_package(Qt6 REQUIRED COMPONENTS Qml) +else() + find_package(Qt5 REQUIRED COMPONENTS Script ScriptTools Qml) +endif() set(javascript_CPP javascriptplugin.cpp @@ -37,10 +43,35 @@ target_link_libraries(${PROJECT_NAME} duc-base duc-services duc-common - Qt${QT_DESIRED_VERSION}::Xml + Qt${QT_VERSION_MAJOR}::Xml ${QtUseModules} ${PkgUserModules} ) +if (${QT_VERSION_MAJOR} MATCHES 6) + target_link_libraries(${PROJECT_NAME} + duc-framework + duc-base + duc-services + duc-common + Qt6::Xml + Qt6::Qml + ${QtUseModules} + ${PkgUserModules} + ) +else() + target_link_libraries(${PROJECT_NAME} + duc-framework + duc-base + duc-services + duc-common + Qt5::Xml + Qt5::Script + Qt5::ScriptTools + ${QtUseModules} + ${PkgUserModules} + ) +endif() + install_logo(${PROJECT_NAME}.svg) install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH}) diff --git a/src/plugins/javascript/debugger/jsdebugger.cpp b/src/plugins/javascript/debugger/jsdebugger.cpp index 0931ccb53..83aceac02 100644 --- a/src/plugins/javascript/debugger/jsdebugger.cpp +++ b/src/plugins/javascript/debugger/jsdebugger.cpp @@ -12,6 +12,7 @@ #include #include #include +#if QT_VERSION <= 0x060000 #define SAFE_DELETE(p) \ if (p) { \ @@ -251,3 +252,5 @@ void JSDebugger::setupDebugEnv() runState = kNoRun; emit runStateChanged(kNoRun); } + +#endif diff --git a/src/plugins/javascript/debugger/jsdebugger.h b/src/plugins/javascript/debugger/jsdebugger.h index 1cb9ccba2..8f698c62e 100644 --- a/src/plugins/javascript/debugger/jsdebugger.h +++ b/src/plugins/javascript/debugger/jsdebugger.h @@ -1,12 +1,11 @@ // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later - #ifndef JSDebugger_H #define JSDebugger_H #include "base/abstractdebugger.h" - +#if QT_VERSION <= 0x060000 #include #include #include @@ -72,4 +71,5 @@ public slots: AbstractWidget *codeEditor = nullptr; }; +#endif #endif // JSDebugger_H diff --git a/src/plugins/javascript/javascriptplugin.cpp b/src/plugins/javascript/javascriptplugin.cpp index f0d62215b..045d0ec29 100644 --- a/src/plugins/javascript/javascriptplugin.cpp +++ b/src/plugins/javascript/javascriptplugin.cpp @@ -11,13 +11,18 @@ #include "services/window/windowservice.h" #include "services/debugger/debuggerservice.h" #include "base/abstractwidget.h" + +#if QT_VERSION <= 0x060000 #include "debugger/jsdebugger.h" #include #include + #ifndef QT_NO_SCRIPTTOOLS #include #endif +#endif + #include #include @@ -53,13 +58,14 @@ bool JavascriptPlugin::start() projectService->implGenerator(JSProjectGenerator::toolKitName(), &errorString); } - // debugger register. +#if QT_VERSION <= 0x060000 + // debugger register. Qt6 dose not supprt auto jsDebugger = new JSDebugger(qApp); auto debuggerService = dpfGetService(DebuggerService); if (debuggerService && debuggerService->registerDebugger) { debuggerService->registerDebugger("local", jsDebugger); } - +#endif return true; } diff --git a/src/plugins/javascript/jsgenerator.cpp b/src/plugins/javascript/jsgenerator.cpp index 483d14ff2..b7d7d5426 100644 --- a/src/plugins/javascript/jsgenerator.cpp +++ b/src/plugins/javascript/jsgenerator.cpp @@ -38,7 +38,12 @@ bool JSGenerator::prepareDebug(const QMap ¶m, QString &re { Q_UNUSED(param) Q_UNUSED(retMsg) +#if QT_VERSION <= 0x060000 return true; +#else + retMsg = tr("JavaScript cannot be debugged in the current version of the IDE."); + return false; +#endif } bool JSGenerator::requestDAPPort(const QString &ppid, const QMap ¶m, QString &retMsg)