Skip to content
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
5 changes: 4 additions & 1 deletion service/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ set(APP_DCONFIG_SCHEMA "${APP_DCONFIG_DIR}/com.deepin.diskmanager.storage.json")

# Find the library
find_package(PkgConfig REQUIRED)
find_package(DtkCore REQUIRED)
find_package(DtkCore)
if(DtkCore_FOUND)
add_definitions(-DHAVE_DCONFIG)
endif()
find_package(DtkGui REQUIRED)
find_package(Qt5 COMPONENTS
Core
Expand Down
5 changes: 5 additions & 0 deletions service/diskoperation/DeviceStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
#include "DeviceStorage.h"
#include <QDebug>
#include <QFile>
#include <QRegularExpression>

Check warning on line 8 in service/diskoperation/DeviceStorage.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 9 in service/diskoperation/DeviceStorage.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 10 in service/diskoperation/DeviceStorage.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QVariant> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#ifdef HAVE_DCONFIG
#include <DConfig>

Check warning on line 12 in service/diskoperation/DeviceStorage.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DConfig> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#endif
#include "utils.h"

Check warning on line 14 in service/diskoperation/DeviceStorage.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "utils.h" not found.

namespace DiskManager {

Expand Down Expand Up @@ -588,16 +590,19 @@

// 从 DConfig 读取需要识别为 UFS 接口的 spec_version 子串列表,新增 UFS 版本时
// 只需在 com.deepin.diskmanager.storage 配置中追加,无需修改源码。
// 当构建环境不支持 DConfig(如 102X 等低版本)时,回退到硬编码列表。
static QStringList ufsSpecVersions()
{
const QStringList fallback{"300", "310", "400", "410"};
#ifdef HAVE_DCONFIG
QScopedPointer<Dtk::Core::DConfig> cfg(
Dtk::Core::DConfig::create("com.deepin.diskmanager", "com.deepin.diskmanager.storage"));
if (cfg && cfg->isValid()) {
QStringList versions = cfg->value("ufsSpecVersions", QVariant::fromValue(fallback)).toStringList();
if (!versions.isEmpty())
return versions;
}
#endif
return fallback;
}

Expand Down
5 changes: 4 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ LIST(APPEND SRC_LIST ${UT_DISKOPERATION})
file(GLOB ALL_HEADERS "../service/diskoperation/*.h" "../service/diskoperation/filesystems/*.h")
file(GLOB ALL_SOURCES "../service/diskoperation/*.cpp" "../service/diskoperation/filesystems/*.cpp")

find_package(DtkCore REQUIRED)
find_package(DtkCore)
if(DtkCore_FOUND)
add_definitions(-DHAVE_DCONFIG)
endif()

add_executable(${PROJECT_NAME_TEST} ${SRC_LIST} ${ALL_HEADERS} ${ALL_SOURCES})

Expand Down
Loading