Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adapt for Qt6.8 #1073

Open
wants to merge 3 commits into
base: develop/Qt6.8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
endif()
add_subdirectory(unioncode-qtermwidget-0.14.1)
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})
26 changes: 20 additions & 6 deletions 3rdparty/unioncode-qtermwidget-0.14.1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand All @@ -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}
Expand Down
8 changes: 6 additions & 2 deletions 3rdparty/unioncode-qtermwidget-0.14.1/lib/Character.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
20 changes: 9 additions & 11 deletions 3rdparty/unioncode-qtermwidget-0.14.1/lib/ColorScheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <QSettings>
#include <QDir>
#include <QRegularExpression>

#include <QRandomGenerator>

// KDE
//#include <KColorScheme>
Expand Down Expand Up @@ -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 &&
Expand All @@ -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;

Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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()));
Expand Down
7 changes: 4 additions & 3 deletions 3rdparty/unioncode-qtermwidget-0.14.1/lib/HistorySearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions 3rdparty/unioncode-qtermwidget-0.14.1/lib/HistorySearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <QObject>
#include <QPointer>
#include <QMap>
#include <QRegularExpression>

#include <Session.h>
#include <ScreenWindow.h>
Expand All @@ -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();
Expand All @@ -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;
Expand Down
Loading
Loading