Skip to content

Commit

Permalink
feat: Support Qt6 base
Browse files Browse the repository at this point in the history
Enable build with Qt6.8 base which depends kf6 codecs and archive packages, it compats Qt5 build.

Log: Support Qt6 base
  • Loading branch information
re2zero authored and deepin-bot[bot] committed Jan 7, 2025
1 parent fa43158 commit bc97f00
Show file tree
Hide file tree
Showing 87 changed files with 786 additions and 316 deletions.
5 changes: 5 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ Files: debian/*
Copyright: None
License: CC0-1.0

# cmake
Files: cmake/*
Copyright: UnionTech Software Technology Co., Ltd.
License: CC0-1.0

# rpm
Files: rpm/*
Copyright: None
Expand Down
9 changes: 5 additions & 4 deletions 3rdparty/cli7zplugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ project(${LIB_NAME})

#查找依赖关系的包信息
find_package(PkgConfig REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(KF5Codecs REQUIRED)
find_package(Qt${QT_DESIRED_VERSION} REQUIRED COMPONENTS Widgets)
find_package(KF${KF_VERSION_MAJOR}Codecs REQUIRED)

include(FindPkgConfig)

#指定头文件路径
Expand All @@ -28,7 +29,7 @@ add_library(${LIB_NAME} SHARED ${c_files} ${json_files} ${h_files})

#链接动静态库
target_link_libraries(${LIB_NAME}
Qt5::Widgets
KF5::Codecs
Qt${QT_DESIRED_VERSION}::Widgets
KF${KF_VERSION_MAJOR}::Codecs
compressor-interface
)
20 changes: 15 additions & 5 deletions 3rdparty/cli7zplugin/cli7zplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,28 @@ bool Cli7zPlugin::readListLine(const QString &line)
m_fileEntry.strFullPath = entryFilename;

// 文件名称
const QStringList pieces = entryFilename.split(QLatin1Char('/'), QString::SkipEmptyParts);
const QStringList pieces = entryFilename.split(QLatin1Char('/'),
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QString::SkipEmptyParts
#else
Qt::SkipEmptyParts
#endif
);
m_fileEntry.strFileName = pieces.isEmpty() ? QString() : pieces.last();
} else if (line.startsWith(QLatin1String("Size = "))) {
// 单文件实际大小
m_fileEntry.qSize = line.midRef(7).trimmed().toLongLong();
m_fileEntry.qSize = line.mid(7).trimmed().toLongLong();

// 压缩包内所有文件总大小
stArchiveData.qSize += m_fileEntry.qSize;
} else if (line.startsWith(QLatin1String("Modified = "))) {
// 文件最后修改时间
m_fileEntry.uLastModifiedTime = QDateTime::fromString(line.mid(11).trimmed(),
QStringLiteral("yyyy-MM-dd hh:mm:ss")).toTime_t();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QStringLiteral("yyyy-MM-dd hh:mm:ss")).toTime_t();
#else
QStringLiteral("yyyy-MM-dd hh:mm:ss")).toSecsSinceEpoch();
#endif
if (ArchiveTypeIso == m_archiveType || ArchiveTypeUdf == m_archiveType) { // 读取的压缩包是iso、udf文件,读到Modified的时候已经结束了
// QString name = m_fileEntry.strFullPath;

Expand All @@ -276,7 +286,7 @@ bool Cli7zPlugin::readListLine(const QString &line)
m_fileEntry.reset();
}
} else if (line.startsWith(QLatin1String("Attributes = "))) { // 文件权限
const QStringRef attributes = line.midRef(13).trimmed();
const QString attributes = line.mid(13).trimmed();

// D开头为文件夹
if (attributes.startsWith(QLatin1Char('D'))) {
Expand All @@ -303,7 +313,7 @@ bool Cli7zPlugin::readListLine(const QString &line)
// clear m_fileEntry
m_fileEntry.reset();
} else if (line.startsWith(QLatin1String("Folder = "))) { // 是否文件夹
const QStringRef folder = line.midRef(9, 1);
const QString folder = line.mid(9, 1);

// "+" 为文件夹
if (0 == folder.compare(QLatin1String("+"))) {
Expand Down
9 changes: 5 additions & 4 deletions 3rdparty/clirarplugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ project(${LIB_NAME})

#设置项目名称
find_package(PkgConfig REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(KF5Codecs REQUIRED)
find_package(Qt${QT_DESIRED_VERSION} REQUIRED COMPONENTS Widgets)
find_package(KF${KF_VERSION_MAJOR}Codecs REQUIRED)

include(FindPkgConfig)

#指定头文件路径
Expand All @@ -28,7 +29,7 @@ add_library(${LIB_NAME} SHARED ${c_files} ${h_files} ${json_files})

#链接动静态库
target_link_libraries(${LIB_NAME}
Qt5::Widgets
KF5::Codecs
Qt${QT_DESIRED_VERSION}::Widgets
KF${KF_VERSION_MAJOR}::Codecs
compressor-interface
)
15 changes: 13 additions & 2 deletions 3rdparty/clirarplugin/clirarplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,13 @@ bool CliRarPlugin::readListLine(const QString &line)
m_fileEntry.strFullPath = parseLineRight;

// 文件名称
const QStringList pieces = m_fileEntry.strFullPath.split(QLatin1Char('/'), QString::SkipEmptyParts);
const QStringList pieces = m_fileEntry.strFullPath.split(QLatin1Char('/'),
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QString::SkipEmptyParts
#else
Qt::SkipEmptyParts
#endif
);
m_fileEntry.strFileName = pieces.isEmpty() ? QString() : pieces.last();
} else if (parseLineLeft == QLatin1String("Type")) {
if (parseLineRight == QLatin1String("Directory")) {
Expand All @@ -241,7 +247,12 @@ bool CliRarPlugin::readListLine(const QString &line)
QString time = line.left((line.length() - 10));
// 文件最后修改时间
m_fileEntry.uLastModifiedTime = QDateTime::fromString(time.right(time.length() - 14),
QStringLiteral("yyyy-MM-dd hh:mm:ss")).toTime_t();
QStringLiteral("yyyy-MM-dd hh:mm:ss"))
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
.toTime_t();
#else
.toSecsSinceEpoch();
#endif

QString name = m_fileEntry.strFullPath;

Expand Down
8 changes: 4 additions & 4 deletions 3rdparty/cliunarchiverplugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ project(${LIB_NAME})

#查找依赖关系的包信息
find_package(PkgConfig REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(KF5Codecs REQUIRED)
find_package(Qt${QT_DESIRED_VERSION} REQUIRED COMPONENTS Widgets)
find_package(KF${KF_VERSION_MAJOR}Codecs REQUIRED)
include(FindPkgConfig)


Expand All @@ -29,7 +29,7 @@ add_library(${LIB_NAME} SHARED ${c_files} ${h_files} ${json_files})

#链接动静态库
target_link_libraries(${LIB_NAME}
Qt5::Widgets
KF5::Codecs
Qt${QT_DESIRED_VERSION}::Widgets
KF${KF_VERSION_MAJOR}::Codecs
compressor-interface
)
30 changes: 9 additions & 21 deletions 3rdparty/clizipplugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,12 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

find_package(PkgConfig REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5DBus REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5 REQUIRED Widgets)
find_package(Qt5Concurrent)
find_package(Qt5Xml)
find_package(Qt5Svg REQUIRED SvgWidgets)
find_package(KF5Codecs REQUIRED)
include(FindPkgConfig)

pkg_search_module(DtkWidget REQUIRED dtkwidget)
include_directories(${DtkWidget_INCLUDE_DIRS})
find_package(Qt${QT_DESIRED_VERSION} REQUIRED COMPONENTS Widgets)
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Core Widget)

pkg_search_module(DtkCore REQUIRED dtkcore)
include_directories(${DtkCore_INCLUDE_DIRS})
include(FindPkgConfig)

set(LIBS_INCLUDE_DIRS
${DtkWidget_LIBRARIES}
${DtkCore_LIBRARIES}
)


include_directories(${PROJECT_SOURCE_DIR}/../ChardetDetector)
Expand All @@ -47,6 +31,10 @@ file(GLOB_RECURSE json_files *.json)
include_directories(${PROJECT_SOURCE_DIR})

add_library(${LIB_NAME} SHARED ${c_files} ${h_files} ${json_files})
target_link_libraries(${LIB_NAME} Qt5::Widgets)
target_link_libraries(${LIB_NAME} ${LIBS_INCLUDE_DIRS})
target_link_libraries(${LIB_NAME}
Qt${QT_DESIRED_VERSION}::Widgets
Dtk${DTK_VERSION_MAJOR}::Widget
Dtk${DTK_VERSION_MAJOR}::Core
)

target_link_libraries( ${LIB_NAME} compressor-interface)
26 changes: 17 additions & 9 deletions 3rdparty/interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ project(interface)

#查找依赖关系的包信息
find_package(PkgConfig REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(KF5Codecs REQUIRED)

find_package(Qt${QT_DESIRED_VERSION} REQUIRED COMPONENTS Widgets)
find_package(KF${KF_VERSION_MAJOR}Codecs REQUIRED)
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Core Widget)

if (QT_DESIRED_VERSION MATCHES 6)
find_package(Qt${QT_DESIRED_VERSION} REQUIRED COMPONENTS Core5Compat)
endif()

include(FindPkgConfig)

pkg_search_module(DtkWidget REQUIRED dtkwidget)
pkg_search_module(GOBJECT REQUIRED gobject-2.0)
pkg_search_module(MOUNT REQUIRED mount)

Expand All @@ -20,10 +26,7 @@ file(GLOB_RECURSE c_files RELATIVE ${PROJECT_SOURCE_DIR} *.cpp)
file(GLOB_RECURSE h_files RELATIVE ${PROJECT_SOURCE_DIR} *.h)

#指定头文件路径
include_directories(${DtkWidget_INCLUDE_DIRS})
include_directories(${MOUNT_INCLUDE_DIRS})
include_directories(${Qt5Widgets_INCLUDE_DIRS})
include_directories(${KF5Codecs_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/archiveinterface)
include_directories(${PROJECT_SOURCE_DIR}/plugin)
Expand Down Expand Up @@ -59,10 +62,15 @@ add_library(${LIB_NAME} SHARED ${h_files} ${c_files})

#链接动静态库
target_link_libraries(${LIB_NAME}
Qt5::Widgets
KF5::Codecs
${DtkWidget_LIBRARIES}
Qt${QT_DESIRED_VERSION}::Widgets
Dtk${DTK_VERSION_MAJOR}::Widget
KF${KF_VERSION_MAJOR}::Codecs
${MOUNT_LIBRARIES}
compressor-ChardetDetector
)

if (QT_DESIRED_VERSION MATCHES 6)
target_link_libraries(${LIB_NAME}
Qt${QT_DESIRED_VERSION}::Core5Compat
)
endif()
41 changes: 26 additions & 15 deletions 3rdparty/interface/archiveinterface/cliinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ CliInterface::CliInterface(QObject *parent, const QVariantList &args)
{
// m_bHandleCurEntry = true;
setWaitForFinishedSignal(true);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (QMetaType::type("QProcess::ExitStatus") == 0) {
#else
if (!QMetaType::fromName("QProcess::ExitStatus").isValid()) {
#endif
qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
}

Expand Down Expand Up @@ -342,7 +346,13 @@ PluginFinishType CliInterface::addFiles(const QList<FileEntry> &files, const Com
QDir::setCurrent(m_extractTempDir->path());

// 添加临时路径中的第一层文件(夹)
fileList.append(destinationPath.split(QLatin1Char('/'), QString::SkipEmptyParts).at(0));
fileList.append(destinationPath.split(QLatin1Char('/'),
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QString::SkipEmptyParts
#else
Qt::SkipEmptyParts
#endif
).at(0));
} else { // 压缩、向压缩包第一层文件追加压缩
QList<FileEntry> tempfiles = files;
// 获取待压缩的文件
Expand Down Expand Up @@ -768,7 +778,7 @@ void CliInterface::handleProgress(const QString &line)
if (m_process && m_process->program().at(0).contains("7z")) { // 解析7z相关进度、文件名
int pos = line.indexOf(QLatin1Char('%'));
if (pos > 1) {
int percentage = line.midRef(pos - 3, 3).toInt();
int percentage = line.mid(pos - 3, 3).toInt();
if (percentage > 0) {
if (line.contains("\b\b\b\b") == true) {
QString strfilename;
Expand All @@ -786,7 +796,7 @@ void CliInterface::handleProgress(const QString &line)
}

if (count > 0) {
strfilename = line.midRef(count + 2).toString(); // 文件名
strfilename = line.mid(count + 2); // 文件名
// 右键 解压到当前文件夹
if (m_workStatus == WT_Extract && !m_extractOptions.bExistList && m_indexOfListRootEntry == 0) {
m_indexOfListRootEntry++;
Expand Down Expand Up @@ -819,18 +829,18 @@ void CliInterface::handleProgress(const QString &line)
} else if (m_process && m_process->program().at(0).contains("unrar")) { // 解析rar相关进度、文件名
int pos = line.indexOf(QLatin1Char('%'));
if (pos > 1) {
int percentage = line.midRef(pos - 3, 3).toInt();
int percentage = line.mid(pos - 3, 3).toInt();
emit signalprogress(percentage);
}

QStringRef strfilename;
// QStringRef strfilename;
QString fileName;
if (line.startsWith("Extracting")) { // 普通文件
strfilename = line.midRef(12, pos - 24);
fileName = strfilename.toString();
fileName = line.mid(12, pos - 24);
// fileName = strfilename.toString();
} else if (line.startsWith("Creating")) { // 文件夹
strfilename = line.midRef(10, pos - 22);
fileName = strfilename.toString();
fileName = line.mid(10, pos - 22);
// fileName = strfilename.toString();
}

if (!fileName.isEmpty()) {
Expand Down Expand Up @@ -1240,7 +1250,7 @@ void CliInterface::readStdout(bool handleAll)
}

// 处理命令行输出
for (const QByteArray &line : qAsConst(lines)) {
for (const QByteArray &line : lines) {
// 第二个判断条件是处理rar的list,当rar文件含有comment信息的时候需要根据空行解析
if (!line.isEmpty() || (m_listEmptyLines && m_workStatus == WT_List)) {
if (!handleLine(QString::fromLocal8Bit(line), m_workStatus)) {
Expand Down Expand Up @@ -1343,17 +1353,18 @@ void CliInterface::getChildProcessId(qint64 processId, const QStringList &listKe
QList<QByteArray> lines = dd.split('\n');

if (lines[0].contains(strProcessId.toUtf8())) { // 从包含有processId这一行开始处理
for (const QByteArray &line : qAsConst(lines)) {
for (const QByteArray &line : lines) {

for (const QString &strKey : qAsConst(listKey)) {
for (const QString &strKey : listKey) {
QString str = QString("-%1(").arg(strKey);
int iCount = line.count(str.toStdString().c_str()); // 多个子进程都需要获取到
QByteArray strUtf8 = str.toUtf8(); // 将QString转换为QByteArray
int iCount = line.count(strUtf8.constData()); // 多个子进程都需要获取到
int iIndex = 0;
for (int i = 0; i < iCount; ++i) {
int iStartIndex = line.indexOf(str, iIndex);
int iStartIndex = line.indexOf(strUtf8, iIndex); // 使用QByteArray类型的参数
int iEndIndex = line.indexOf(")", iStartIndex);
if (0 < iStartIndex && 0 < iEndIndex) {
childprocessid.append(line.mid(iStartIndex + str.length(), iEndIndex - iStartIndex - str.length()).toInt()); // 取-7z(3971)中间的进程号
childprocessid.append(line.mid(iStartIndex + strUtf8.length(), iEndIndex - iStartIndex - strUtf8.length()).toInt()); // 取-7z(3971)中间的进程号
}
iIndex = iStartIndex + 1;
}
Expand Down
Loading

0 comments on commit bc97f00

Please sign in to comment.