Skip to content

Commit

Permalink
feat: adapt for Qt6.8
Browse files Browse the repository at this point in the history
Log: as title
  • Loading branch information
LiHua000 committed Jan 22, 2025
1 parent 5f32126 commit 3ca7910
Show file tree
Hide file tree
Showing 144 changed files with 536 additions and 361 deletions.
4 changes: 3 additions & 1 deletion 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
45 changes: 25 additions & 20 deletions 3rdparty/diff-match-patch/diff_match_patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("\")");
}
Expand Down Expand Up @@ -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.
Expand All @@ -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<Diff> &diffs) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -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));
Expand Down Expand Up @@ -1974,7 +1974,7 @@ void diff_match_patch::patch_splitMax(QList<Patch> &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();
Expand Down Expand Up @@ -2035,37 +2035,42 @@ QList<Patch> 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();

Expand Down
4 changes: 2 additions & 2 deletions 3rdparty/diff-match-patch/diff_match_patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 5 additions & 6 deletions 3rdparty/unioncode-qscintilla214/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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})
4 changes: 4 additions & 0 deletions 3rdparty/unioncode-qtermwidget-0.14.1/lib/qtermwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
24 changes: 19 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1.0)
cmake_minimum_required(VERSION 3.18.0)

project(deepin-unioncode)

Expand All @@ -10,6 +10,7 @@ function(print_directory arg)
endfunction()

set(VERSION $ENV{VERSION})

if (NOT VERSION)
set(VERSION "0.0.1")
endif()
Expand Down Expand Up @@ -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()

Expand Down
6 changes: 3 additions & 3 deletions assets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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")
24 changes: 13 additions & 11 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ Maintainer: Deepin Packages Builder <[email protected]>
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~),
Expand All @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,25 @@ 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

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)


4 changes: 2 additions & 2 deletions src/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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})
9 changes: 4 additions & 5 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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}
)

Expand All @@ -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})
1 change: 1 addition & 0 deletions src/common/actionmanager/actionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <QDir>

Check warning on line 11 in src/common/actionmanager/actionmanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDir> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 11 in src/common/actionmanager/actionmanager.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QDir> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDebug>

Check warning on line 12 in src/common/actionmanager/actionmanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 12 in src/common/actionmanager/actionmanager.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QApplication>

Check warning on line 13 in src/common/actionmanager/actionmanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 13 in src/common/actionmanager/actionmanager.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QWidget>

Check warning on line 14 in src/common/actionmanager/actionmanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWidget> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 14 in src/common/actionmanager/actionmanager.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QWidget> not found. Please note: Cppcheck does not need standard library headers to get proper results.

constexpr char kKeyboardShortcuts[] = "KeyboardShortcuts";
static ActionManager *m_instance = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/common/dialog/propertiesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 3ca7910

Please sign in to comment.