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

chore: support Qt6 #178

Merged
merged 17 commits into from
Jan 20, 2025
Merged
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
1 change: 1 addition & 0 deletions 3rdparty/fsearch/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <string.h>
#include <sys/param.h>
#include <assert.h>
#include <stdlib.h>
#include "array.h"
#include "btree.h"

Expand Down
4 changes: 2 additions & 2 deletions 3rdparty/fsearch/fsearch_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include "fsearch_utils.h"
#include "utils/chineseletterhelper.h"

#include <QRegExp>
#include <QRegularExpression>

#include <stdio.h>

bool convert_chinese_2_pinyin(const char *in_str, char *out_first_py, char *out_full_py)
{
QRegExp reg("[\u4e00-\u9fa5]");
QRegularExpression reg("[\u4e00-\u9fa5]");
QString str(in_str);
if (!str.contains(reg))
return false;
Expand Down
1 change: 0 additions & 1 deletion 3rdparty/services/grandsearchserviceadaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class QByteArray;
template<class T> class QList;
template<class Key, class Value> class QMap;
class QString;
class QStringList;
class QVariant;
QT_END_NAMESPACE

Expand Down
23 changes: 13 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@ if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -z noexecstack -z relro")
endif()

#Indentify the version
find_package(DtkCMake REQUIRED)

if (1 OR ${DEEPIN_OS_VERSION} MATCHES "^(23|25)$")
add_definitions(-DCOMPILE_ON_V23)
set(COMPLIE_ON_V23 TRUE)
message("COMPILE ON v2x")
# Find Qt version
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
if (NOT DEFINED QT_VERSION_MAJOR)
set(QT_VERSION_MAJOR 6)
endif()
if (QT_VERSION_MAJOR MATCHES 6)
set(DTK_VERSION_MAJOR 6)
else()
add_definitions(-DCOMPILE_ON_V20)
set(COMPLIE_ON_V20 TRUE)
message("COMPILE ON v20")
set(DTK_VERSION_MAJOR "")
endif()
message(" >>> Found Qt version: ${QT_VERSION_MAJOR}")
message(" >>> Build with DTK: ${DTK_VERSION_MAJOR}")

set(QT_NS Qt${QT_VERSION_MAJOR})
set(DTK_NS Dtk${DTK_VERSION_MAJOR})

#tar -czvf antlr4.tar.gz ./antlr4
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/antlr4")
Expand Down
20 changes: 20 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
dde-grand-search (5.5.14) unstable; urgency=medium

* update version

-- Liu zheng <[email protected]> Fri, 17 Jan 2025 21:36:12 +0800

dde-grand-search (5.5.13) unstable; urgency=medium

* update dde-grand-search V25 5.5.13 baseline version
* fix issue about launch app and CI build.

-- re2zero <[email protected]> Fri, 17 Jan 2025 14:45:45 +0800

dde-grand-search (5.5.12) unstable; urgency=medium

* update dde-grand-search V25 5.5.12 baseline version
* fix issue about launch app and CI build.

-- re2zero <[email protected]> Fri, 17 Jan 2025 14:15:36 +0800

dde-grand-search (5.5.11) unstable; urgency=medium

* update dde-grand-search V25 5.5.11 baseline version
Expand Down
14 changes: 10 additions & 4 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,25 @@ Build-Depends: debhelper (>= 9),
libdtkcore-dev,
libdtkgui-dev,
libdtkcore5-bin,
libdframeworkdbus-dev (>=5.4.6),
qttools5-dev-tools,
qt6-base-dev,
libqt6core5compat6-dev,
libdtk6widget-dev,
libdtk6core-dev,
libdtk6gui-dev,
libdtk6core-bin,
libdframeworkdbus-dev (>=5.4.6),
qt6-tools-dev-tools,
cmake,
dde-dock-dev,
dde-tray-loader-dev | dde-dock-dev,
libglib2.0-dev,
libffmpegthumbnailer-dev,
libavformat-dev,
libavcodec-dev,
libtag1-dev,
libicu-dev,
libgsettings-qt-dev,
libpcre3-dev,
libdeepin-pdfium-dev,
libdeepin-pdfium-dev (>=1.5.1),
libjpeg62-turbo-dev,
liblucene++-dev,
libboost-dev,
Expand Down
22 changes: 20 additions & 2 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,30 @@ include /usr/share/dpkg/default.mk

export QT_SELECT = 5

# 检测当前安装的Qt版本,优先使用Qt6,否则使用Qt5
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

# 调用检测Qt版本的命令
$(eval $(call detect_qt_version))

# hardcode this if want to force build with sepecific Qt version
# QT_DIR="/usr/lib/$(DEB_HOST_MULTIARCH)/cmake/Qt5"

%:
dh $@ --parallel

override_dh_shlibdeps:
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info

override_dh_auto_configure:
dh_auto_configure -- VERSION=$(VERSION) "-DVERSION=$(DEB_VERSION_UPSTREAM)"

dh_auto_configure -- \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DVERSION=$(DEB_VERSION_UPSTREAM) -DVERSION=$(VERSION) \
-DQT_DIR=$(QT_DIR)
33 changes: 21 additions & 12 deletions src/dde-grand-search-daemon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# 定义需要的cmake版本
cmake_minimum_required(VERSION 3.10)

set(QT_NS Qt5)
set(DTK_NS Dtk)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
Expand All @@ -12,9 +15,11 @@ set(BIN_NAME ${DAEMON_BIN_NAME})

# 依赖包
find_package(PkgConfig REQUIRED)
find_package(DtkCore REQUIRED)
find_package(DtkWidget REQUIRED)
find_package(Qt5 COMPONENTS
find_package(${DTK_NS} COMPONENTS
Gui
Widget
REQUIRED)
find_package(${QT_NS} COMPONENTS
Core
Gui
Widgets
Expand All @@ -26,18 +31,22 @@ find_package(deepin-qdbus-service REQUIRED)
add_definitions(-DSERVICE_CONFIG_DIR="${CMAKE_INSTALL_PREFIX}/share/deepin-service-manager/")

set(Qt_LIBS
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::DBus
Qt5::Concurrent
${QT_NS}::Core
${QT_NS}::Gui
${QT_NS}::Widgets
${QT_NS}::DBus
${QT_NS}::Concurrent
)

set(DTK_LIBS
${DTK_NS}::Gui
${DTK_NS}::Widget
)

# 依赖库
set(LINK_LIBS
${Qt_LIBS}
${DtkCore_LIBRARIES}
${DtkWidget_LIBRARIES}
${DTK_LIBS}
${deepin-qdbus-service_LIBRARIES}
)

Expand Down Expand Up @@ -207,17 +216,17 @@ set(SRCS
${GDCONFIGURATION}
)

# 资源文件

qt5_add_resources(QRC_FILES utils/dict.qrc)


# 执行程序
add_executable(${BIN_NAME}
${SRCS} ${QRC_FILES}
)

target_include_directories(${BIN_NAME} PUBLIC
${CMAKE_SOURCE_DIR}/include
${DtkWidget_INCLUDE_DIRS}
${PROJECT_3RDPARTY_PATH}/fsearch
${GLIB_INCLUDE_DIRS}
${PCRE_INCLUDE_DIRS}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ DesktopAppSearcherPrivate::~DesktopAppSearcherPrivate()

void DesktopAppSearcherPrivate::createIndex(DesktopAppSearcherPrivate *d)
{
QTime time;
QElapsedTimer time;
time.start();

QHash<QString, QList<DesktopAppPointer>> indexTable;
Expand Down Expand Up @@ -161,7 +161,11 @@ bool DesktopAppSearcherPrivate::isHidden(DesktopEntryPointer pointer)
if (!desktop.isEmpty()) {
// NotShowIn
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QStringList notShows = pointer->stringValue("NotShowIn").split(';', QString::SkipEmptyParts);
#else
QStringList notShows = pointer->stringValue("NotShowIn").split(';', Qt::SkipEmptyParts);
#endif
if (notShows.contains(desktop, Qt::CaseInsensitive))
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/dde-grand-search-daemon/searcher/app/desktopappworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool DesktopAppWorker::working(void *context)
}

//计时
QTime time;
QElapsedTimer time;
time.start();
int lastEmit = 0;

Expand All @@ -52,7 +52,7 @@ bool DesktopAppWorker::working(void *context)
return false;

//匹配
QRegExp regExp(m_context, Qt::CaseInsensitive);
QRegularExpression regExp(m_context, QRegularExpression::CaseInsensitiveOption);
if (iter.key().contains(regExp)) {
//遍历该关键词匹配的项目检查是否已经被添加
for (const QSharedPointer<MatchedItem> &item : iter.value()) {
Expand Down
6 changes: 3 additions & 3 deletions src/dde-grand-search-daemon/searcher/file/filenameworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ QFileInfoList FileNameWorkerPrivate::traverseDirAndFile(const QString &path)
dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
auto result = dir.entryInfoList();
// 排序
qSort(result.begin(), result.end(), [](const QFileInfo &info1, const QFileInfo &info2) {
std::sort(result.begin(), result.end(), [](const QFileInfo &info1, const QFileInfo &info2) {
static QStringList sortList{"Desktop", "Music", "Downloads", "Documents", "Pictures", "Videos"};
int index1 = sortList.indexOf(info1.fileName());
int index2 = sortList.indexOf(info2.fileName());
Expand Down Expand Up @@ -154,7 +154,7 @@ bool FileNameWorkerPrivate::searchUserPath()
if (info.isDir())
m_searchDirList << info.absoluteFilePath();

QRegExp reg(m_searchInfo.keyword, Qt::CaseInsensitive);
QRegularExpression reg(m_searchInfo.keyword, QRegularExpression::CaseInsensitiveOption);
if (info.fileName().contains(reg)) {
auto absoluteFilePath = info.absoluteFilePath();

Expand Down Expand Up @@ -190,7 +190,7 @@ bool FileNameWorkerPrivate::searchByAnything()
quint32 searchStartOffset = 0;
quint32 searchEndOffset = 0;
// 过滤系统隐藏文件
QRegExp hiddenFileFilter("^(?!.*/\\..*).+$");
QRegularExpression hiddenFileFilter("^(?!.*/\\..*).+$");
while (!isResultLimit() && !m_searchDirList.isEmpty()) {
//中断
if (m_status.loadAcquire() != ProxyWorker::Runing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class FileNameWorkerPrivate
QHash<QString, QSet<QString>> m_hiddenFilters;

//计时
QTime m_time;
QElapsedTimer m_time;
int m_lastEmit = 0;

// anything新特性
Expand Down
2 changes: 1 addition & 1 deletion src/dde-grand-search-daemon/searcher/file/fssearcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void FsSearcher::loadDataBase(FsSearcher *fs)

void FsSearcher::updateDataBase(FsSearcher *fs)
{
QTime time;
QElapsedTimer time;
time.start();

fs->m_isUpdating = true;
Expand Down
6 changes: 3 additions & 3 deletions src/dde-grand-search-daemon/searcher/file/fssearcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "fsearch.h"
}

#include <QFuture>

Check warning on line 14 in src/dde-grand-search-daemon/searcher/file/fssearcher.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 15 in src/dde-grand-search-daemon/searcher/file/fssearcher.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

namespace GrandSearch {

Expand All @@ -39,11 +39,11 @@

FsearchApplication *m_app = nullptr;
mutable Database *m_databaseForUpdate = nullptr;
mutable QTime m_updateTime;
mutable QElapsedTimer m_updateTime;
mutable bool m_isUpdating = false;
mutable QFuture<void> m_updateFuture;

QTime m_databaseSaveTime; // 索引保存计时
QElapsedTimer m_databaseSaveTime; // 索引保存计时
int m_lastSaveTime = 0;
};

Expand Down
2 changes: 1 addition & 1 deletion src/dde-grand-search-daemon/searcher/file/fsworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class FsWorker : public ProxyWorker
QSet<QString> m_tmpSearchResults; // 存储所有的搜索结果,用于去重
QHash<QString, QSet<QString>> m_hiddenFilters;

QTime m_time; //搜索计时
QElapsedTimer m_time; //搜索计时
int m_lastEmit = 0;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool AnythingQueryPrivate::searchUserPath(PushItemCallBack callBack, void *pdata

// 先对user目录下进行搜索
for (const SemanticEntity &entity : m_entity) {
QRegExp reg(getRegExp(entity), Qt::CaseInsensitive);
QRegularExpression reg(getRegExp(entity), QRegularExpression::CaseInsensitiveOption);
for (const auto &info : fileInfoList) {
// 检查是否需要推送数据与中断
if (timeToPush()) {
Expand Down Expand Up @@ -265,7 +265,7 @@ QFileInfoList AnythingQueryPrivate::traverseDirAndFile(const QString &path)
dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
auto result = dir.entryInfoList();
// 排序
qSort(result.begin(), result.end(), [](const QFileInfo &info1, const QFileInfo &info2) {
std::sort(result.begin(), result.end(), [](const QFileInfo &info1, const QFileInfo &info2) {
static QStringList sortList{"Desktop", "Music", "Downloads", "Documents", "Pictures", "Videos"};
int index1 = sortList.indexOf(info1.fileName());
int index2 = sortList.indexOf(info2.fileName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AnythingQueryPrivate

QStringList m_searchDirList;
FileResultsHandler *m_handler = nullptr;
QTime m_time;
QElapsedTimer m_time;
int m_lastPush = 0;
int m_count = 0;
private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FeatureQueryPrivate
public:
QList<SemanticEntity> m_entity;
FileResultsHandler *m_handler = nullptr;
QTime m_time;
QElapsedTimer m_time;
int m_lastPush = 0;
MatchedItemMap m_results;
int m_count = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class FullTextQueryPrivate
public:
QList<SemanticEntity> m_entity;
FileResultsHandler *m_handler = nullptr;
QTime m_time;
QElapsedTimer m_time;
int m_lastPush = 0;
MatchedItemMap m_results;
int m_count = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class VectorQueryPrivate
SemanticParser *m_parser = nullptr;
QString m_query;
int m_count = 0;
QTime m_time;
QElapsedTimer m_time;
int m_lastPush = 0;
private:
VectorQuery *q;
Expand Down
Loading
Loading