Skip to content

Commit edbd9f4

Browse files
itsXuStdeepin-bot[bot]
authored andcommitted
fix: add Qt5 build compatibility
- Update debian/control to support both Qt5 and Qt6 dependencies - Add Qt version auto-detection in debian/rules - Fix DConfig installation check using dtk_add_config_meta_files command - Add missing includes for DApplicationHelper, DGuiApplicationHelper, QtMath - Fix QString::split API for Qt5 (use QString::SkipEmptyParts) - Fix QSet construction for Qt < 5.14 - Add mount_attr struct definition for older kernels Log: Add build compatibility for Qt5 environment while maintaining Qt6 support
1 parent e7ead1f commit edbd9f4

File tree

11 files changed

+76
-24
lines changed

11 files changed

+76
-24
lines changed

CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,24 @@ set(system_monitor_plugin assets/configs/org.deepin.system-monitor.plugin.json)
8787
set(system_monitor_plugin_popup assets/configs/org.deepin.system-monitor.plugin.popup.json)
8888
set(system_monitor_plugin_server assets/configs/org.deepin.system-monitor.server.json)
8989

90-
if (DEFINED DSG_DATA_DIR)
90+
# DTK6 提供 dtk_add_config_meta_files 命令,DTK5 需要手动安装
91+
# 需要显式引入 DConfig 模块以确保 DSG_DATA_DIR 在当前作用域可用
92+
if (DTK_VERSION_MAJOR EQUAL 6)
93+
find_package(Dtk6DConfig QUIET)
94+
endif()
95+
96+
if (COMMAND dtk_add_config_meta_files)
9197
dtk_add_config_meta_files(APPID ${APPID} FILES ${system_monitor_main})
9298
dtk_add_config_meta_files(APPID ${APPID} FILES ${system_monitor_daemon})
9399
dtk_add_config_meta_files(APPID ${APPID} FILES ${system_monitor_plugin})
94100
dtk_add_config_meta_files(APPID ${APPID} FILES ${system_monitor_plugin_popup})
95101
dtk_add_config_meta_files(APPID ${APPID} FILES ${system_monitor_plugin_server})
96-
message("-- DConfig is supported by DTK")
102+
message("-- DConfig is supported by DTK (using dtk_add_config_meta_files)")
97103
else()
98104
install(FILES ${system_monitor_main} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dsg/configs/${APPID}/)
99105
install(FILES ${system_monitor_daemon} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dsg/configs/${APPID}/)
100106
install(FILES ${system_monitor_plugin} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dsg/configs/${APPID}/)
101107
install(FILES ${system_monitor_plugin_popup} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dsg/configs/${APPID}/)
102108
install(FILES ${system_monitor_plugin_server} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dsg/configs/${APPID}/)
103-
104-
message("-- DConfig is not supported by DTK")
109+
message("-- DConfig fallback: installing config files directly")
105110
endif()

debian/control

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ Source: deepin-system-monitor
22
Section: utils
33
Priority: optional
44
Maintainer: Deepin Packages Builder <packages@deepin.com>
5-
Build-Depends:
5+
Build-Depends:
66
debhelper-compat (= 11),
77
cmake,
88
pkg-config,
9-
qt6-base-dev,
10-
qt6-svg-dev,
11-
qt6-tools-dev,
12-
libdtk6core-dev,
13-
libdtk6gui-dev,
14-
libdtk6widget-dev,
9+
qt6-base-dev | qtbase5-dev,
10+
qt6-svg-dev | libqt5svg5-dev,
11+
qt6-tools-dev | qttools5-dev,
12+
qt6-tools-dev-tools | qttools5-dev-tools,
13+
libdtk6core-dev | libdtkcore-dev,
14+
libdtk6gui-dev | libdtkgui-dev,
15+
libdtk6widget-dev | libdtkwidget-dev,
1516
libxcb1-dev,
1617
libxext-dev,
1718
libpcap-dev,
18-
qt6-tools-dev-tools,
1919
libicu-dev,
2020
deepin-gettext-tools,
2121
libxcb-util0-dev,

debian/rules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ include /usr/share/dpkg/default.mk
55
DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
66
DH_AUTO_ARGS = --parallel --buildsystem=cmake
77

8+
# 自动检测 Qt 版本:优先使用 Qt6,如果没有则使用 Qt5
9+
QT_VERSION_MAJOR := $(shell pkg-config --exists Qt6Core && echo 6 || echo 5)
10+
811
# Uncomment this to turn on verbose mode.
912
export DH_VERBOSE=1
1013

@@ -15,4 +18,5 @@ override_dh_auto_configure:
1518
dh_auto_configure -- \
1619
-DCMAKE_BUILD_TYPE=Release \
1720
-DCMAKE_SAFETYTEST_ARG="CMAKE_SAFETYTEST_ARG_OFF" \
21+
-DQT_VERSION_MAJOR=$(QT_VERSION_MAJOR) \
1822
-DAPP_VERSION=$(DEB_VERSION_UPSTREAM) -DVERSION=$(DEB_VERSION_UPSTREAM) LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH)

deepin-system-monitor-main/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,9 +623,11 @@ install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/assets/deepin-system-monitor DESTINA
623623

624624
#hw机型增加DConfig配置
625625
set(APPID org.deepin.system-monitor)
626-
message("-- DConfig is supported by DTK ${PROJECT_SOURCE_DIR}")
627626
set(configFile ${PROJECT_SOURCE_DIR}/assets/org.deepin.system-monitor.main.json)
628-
if (DEFINED DSG_DATA_DIR)
629-
message("-- DConfig is supported by DTK")
627+
if (COMMAND dtk_add_config_meta_files)
628+
message("-- DConfig is supported by DTK (main app)")
630629
dtk_add_config_meta_files(APPID ${APPID} FILES ${configFile})
630+
else()
631+
message("-- DConfig fallback: installing config file directly (main app)")
632+
install(FILES ${configFile} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dsg/configs/${APPID}/)
631633
endif()

deepin-system-monitor-main/gui/base/base_detail_view_widget.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ void BaseDetailViewWidget::updateWidgetGrometry()
172172
m_switchButton->setGeometry(m_detailButton->x() - 30, 10 + titleFont.height() / 2 - m_switchButton->height() / 2, m_switchButton->width(), m_switchButton->height());
173173
}
174174

175+
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
176+
void BaseDetailViewWidget::onThemeTypeChanged(DApplicationHelper::ColorType themeType)
177+
#else
175178
void BaseDetailViewWidget::onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType)
179+
#endif
176180
{
177181
qCDebug(app) << "onThemeTypeChanged, themeType:" << themeType;
178182
if (themeType == DGuiApplicationHelper::DarkType) {

deepin-system-monitor-main/gui/base/base_detail_view_widget.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@
1212
#include <QVBoxLayout>
1313
#include <QPushButton>
1414

15-
class BaseCommandLinkButton;
15+
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
16+
#include <DApplicationHelper>
17+
DWIDGET_USE_NAMESPACE
18+
#else
19+
#include <DGuiApplicationHelper>
1620
DWIDGET_USE_NAMESPACE
21+
DGUI_USE_NAMESPACE
22+
#endif
23+
24+
class BaseCommandLinkButton;
1725
class BaseDetailViewWidget : public QWidget
1826
{
1927
Q_OBJECT
@@ -48,7 +56,11 @@ public slots:
4856
//!
4957
//! \brief onThemeTypeChanged 主题背景切换
5058
//!
59+
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
60+
void onThemeTypeChanged(DApplicationHelper::ColorType themeType);
61+
#else
5162
void onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType);
63+
#endif
5264

5365
protected:
5466
void resizeEvent(QResizeEvent *event);

deepin-system-monitor-main/service/service_manager_worker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ QString ServiceManagerWorker::readUnitDescriptionFromUnitFile(const QString &pat
294294
while ((fgets(buf.data(), BLEN, fp))) {
295295
descStr = QString("Description=%1").arg(buf.data());
296296
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
297-
QStringList descStrList = descStr.split(QRegularExpression("[\n]"), Qt::SkipEmptyParts);
297+
QStringList descStrList = descStr.split(QRegularExpression("[\n]"), QString::SkipEmptyParts);
298298
#else
299299
QStringList descStrList = descStr.split(QRegularExpression("[\n]"), Qt::SkipEmptyParts);
300300
#endif

deepin-system-monitor-plugin/gui/commoniconbutton.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <QMouseEvent>
77
#include <QPainter>
88
#include <QTimer>
9+
#include <QtMath>
910

1011
#include <DGuiApplicationHelper>
1112

deepin-system-monitor-system-server/misc/org.deepin.deepin-system-monitor-system-server.policy

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
<message xml:lang="ar">المصادقة مطلوبة لتعيين نوع بدء تشغيل الخدمة</message>
1919
<description xml:lang="az">Xidmətin başladılma növünü təyin edin</description>
2020
<message xml:lang="az">Xidmətin başladılma növünü təyin etmək üçün doğrulama tələb olunur</message>
21+
<description xml:lang="bn">সেবা শুরুর ধরন নির্ধারণ করুন</description>
22+
<message xml:lang="bn">সেবা শুরুর ধরন নির্ধারণে পরিচালনা করতে জারিফিকেশন প্রয়োজন</message>
2123
<description xml:lang="bo">ཞབས་ཞུའི་འགོ་སློང་བྱེད་ཐབས་སྒྲིག་འགོད་བྱེད་པ།</description>
2224
<message xml:lang="bo">ཞབས་ཞུའི་འགོ་སློང་ཐབས་སྒྲིག་འགོད་བྱེད་པར་དཔང་དཔྱད་བྱ་དགོས།</message>
2325
<description xml:lang="br">Termeniñ doare loc'hañ ar servij</description>
@@ -32,12 +34,16 @@
3234
<message xml:lang="de">Authentifizierung ist erforderlich, um den Starttyp des Dienstes einzustellen</message>
3335
<description xml:lang="es">Establecer tipo de inicio del servicio</description>
3436
<message xml:lang="es">Se requiere autenticación para establecer el tipo de servicio de inicio</message>
37+
<description xml:lang="et">Määrake süsteemi käivitusrakendus</description>
38+
<message xml:lang="et">Süsteemi käivitusrakenduse määramiseks on vajalik autentimine</message>
3539
<description xml:lang="fi">Palvelun käynnistystyypin vaihto</description>
3640
<message xml:lang="fi">Palvelun käynnistystyypin vaihtamiseen vaaditaan todennus</message>
3741
<description xml:lang="fr">Définir le type de démarrage du service</description>
3842
<message xml:lang="fr">L'authentification est requise pour définir le type de démarrage du service</message>
3943
<description xml:lang="gl_ES">Estableza o tipo de inicio de servizo</description>
4044
<message xml:lang="gl_ES">A autenticación é necesaria para configurar o tipo de inicio de servizo</message>
45+
<description xml:lang="he">הגדרת סוג הפעלת שירות</description>
46+
<message xml:lang="he">נדרש אימות כדי להגדיר את סוג הפעלת השירות</message>
4147
<description xml:lang="hu">Állítsa be a szolgáltatás indítási típusát</description>
4248
<message xml:lang="hu">Hitelesítés szükséges a szolgáltatás indítási típusának beállításához</message>
4349
<description xml:lang="id">Setel tipe layanan startup</description>
@@ -46,6 +52,10 @@
4652
<message xml:lang="it">Autenticazione richiesta per variare il tipo di avvio automatico</message>
4753
<description xml:lang="ko">서비스 시작 유형 설정</description>
4854
<message xml:lang="ko">서비스 시작 유형을 설정하려면 인증이 필요합니다.</message>
55+
<description xml:lang="lo">ຕັ້ງປະເພດການເລີ່ມຕົ້ນຂອງບໍລິການ</description>
56+
<message xml:lang="lo">ການຢືນຢັນຕ້ອງການເພື່ອຕັ້ງປະເພດການເລີ່ມຕົ້ນຂອງບໍລິການ</message>
57+
<description xml:lang="lt">Nustatyti paslaugos paleidimo tipą</description>
58+
<message xml:lang="lt">Tėkite autentifikacijos norint nustatyti paslaugos paleidimo tipą</message>
4959
<description xml:lang="ms">Tetapkan jenis permulaan perkhidmatan</description>
5060
<message xml:lang="ms">Pengesahihan diperlukan untuk menetapkan jenis permulaan perkhidmatan</message>
5161
<description xml:lang="nl">Soort opstart instellen</description>
@@ -58,6 +68,8 @@
5868
<message xml:lang="pt_BR">A autenticação é necessária para definir o tipo de inicialização do serviço</message>
5969
<description xml:lang="ru">Задать тип запуска службы</description>
6070
<message xml:lang="ru">Требуется аутентификация для установки типа запуска службы </message>
71+
<description xml:lang="sl">Nastavi vrsto zacetnega vrata storitve</description>
72+
<message xml:lang="sl">Zaustavljanje zacetnega vrata storitve je zahtevano prijavljenost</message>
6173
<description xml:lang="sq">Caktoni lloj nisjeje shërbimi</description>
6274
<message xml:lang="sq">Që të caktohet lloj nisjeje shërbimi, lyspet mirëfilltësim</message>
6375
<description xml:lang="sr">Постави режим покретања услуге</description>
@@ -68,12 +80,12 @@
6880
<message xml:lang="ug">مۇلازىمەت باشلاش تىپىنى تەڭشەش ئۈچۈن دەلىللەش تەلەپ قىلىنىدۇ</message>
6981
<description xml:lang="uk">Встановлення типу запуску служби</description>
7082
<message xml:lang="uk">Для встановлення типу запуску служби слід пройти розпізнавання</message>
83+
<description xml:lang="vi">Thiết lập loại khởi động dịch vụ</description>
84+
<message xml:lang="vi">Bạn cần xác thực để thiết lập loại khởi động dịch vụ</message>
7185
<description xml:lang="zh_CN">设置服务的启动方式</description>
7286
<message xml:lang="zh_CN">设置服务的启动方式需要认证</message>
7387
<description xml:lang="zh_HK">設置服務的啟動方式</description>
7488
<message xml:lang="zh_HK">設置服務的啟動方式需要認證</message>
75-
<description xml:lang="lo">ຕັ້ງປະເພດການເລີ່ມຕົ້ນຂອງບໍລິການ</description>
76-
<message xml:lang="lo">ຕ້ອງການການຢັ້ງຢືນເພື່ອຕັ້ງປະເພດການເລີ່ມຕົ້ນຂອງບໍລິການ</message>
7789
<description xml:lang="zh_TW">設定服務的啟動方式</description>
7890
<message xml:lang="zh_TW">設定服務的啟動方式需要認證</message>
7991
</action>

deepin-system-monitor-system-server/src/dkapture.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,20 @@
1515
#include <unistd.h>
1616
#include <sys/stat.h>
1717
#include <sys/types.h>
18+
#include <sys/mount.h>
1819
#include <netinet/in.h>
1920

21+
// mount_attr 结构体在 Linux 5.12+ 内核中定义,旧内核需要手动定义
22+
#ifndef MOUNT_ATTR_SIZE_VER0
23+
struct mount_attr {
24+
uint64_t attr_set;
25+
uint64_t attr_clr;
26+
uint64_t propagation;
27+
uint64_t userns_fd;
28+
};
29+
#define MOUNT_ATTR_SIZE_VER0 32
30+
#endif
31+
2032
#define TASK_COMM_LEN 16
2133
struct FileLog;
2234

@@ -761,10 +773,6 @@ struct SeekLog : public FileLog
761773
#define DATA_LEN 512
762774
#define PATH_MAX 4096
763775

764-
#ifndef __VMLINUX_H__
765-
#include <sys/mount.h>
766-
#endif
767-
768776
struct mount_args
769777
{
770778
pid_t pid;

0 commit comments

Comments
 (0)