SuperAPI AI Directory

deepin-dde-expert

Coding & development

View repository

Updated 10-16 07:26

About this skill

Deepin/UOS DDE Desktop Application Development Expert

Overview

Deepin/UOS system-level development expert, proficient in DTK, GVfs, DBus, and Polkit, developing applications that conform to DDE specifications.

Core Principles:

  • DTK takes priority over native Qt
  • GIO takes priority over QFile (network protocols)
  • DBus event-driven takes priority over polling
  • Polkit authentication takes priority over sudo
  • Qt6 takes priority, V20 falls back to Qt5

When to Use

Use when:

  • DTK widgets (DMainWindow, DDialog, DMessageBox)
  • GVfs network protocols (smb://, mtp://, dav://)
  • DDE DBus service integration
  • Polkit permission control
  • DDE theme adaptation

Do not use: general Qt applications, command-line tools, server-side development

Decision Table

Scenario Decision Reference Documentation
Display main window DMainWindow instead of QMainWindow DTK Widgets
Access smb:// path GIO GFile instead of QFile GVfs/GIO
Get battery/network status DBus signal listening instead of polling DBus
Modify /etc configuration Polkit + Helper instead of sudo Polkit
Dark/light theme adaptation applicationPalette() instead of hardcoding DTK Widgets
Large file I/O QtConcurrent background thread GVfs/GIO

Core Rules

Rule 1: DTK Widgets (MANDATORY)

Use Forbidden
DMainWindow QMainWindow
DDialog QDialog
DMessageBox QMessageBox
DWidget QWidget
// ✅ CORRECT
#include <DMainWindow>
#include <DMessageBox>
DWIDGET_USE_NAMESPACE

DMainWindow *window = new DMainWindow();
DMessageBox::information(this, "Title", "Message");

// ❌ FORBIDDEN
QMainWindow *window = new QMainWindow();

Theme: Use DGuiApplicationHelper::instance()->applicationPalette(), never hardcode colors.

📖 Details: reference/dtk-widgets-guide.md

Rule 2: GVfs/GIO for Network Protocols

// ✅ CORRECT: smb://, mtp://, dav://
#include <gio/gio.h>
GFile *file = g_file_new_for_uri("smb://server/share/file.pdf");
GFileInputStream *input = g_file_read(file, nullptr, &error);

// ❌ FORBIDDEN
QFile file("smb://server/share/file.pdf"); // Fails

Async I/O: Always use QtConcurrent::run() for file operations.

📖 Details: reference/gvfs-gio-integration.md

Rule 3: DBus Event-Driven

// ✅ CORRECT: Listen to signals
QDBusConnection::systemBus().connect(
    "org.freedesktop.UPower",
    "/org/freedesktop/UPower",
    "org.freedesktop.DBus.Properties",
    "PropertiesChanged",
    this, SLOT(handleEvent(QString, QVariantMap)));

// ❌ FORBIDDEN: Polling
QTimer *timer = new QTimer();
connect(timer, &QTimer::timeout, this, [](){
    QFile::read("/sys/class/power_supply/BAT0/capacity");
});

📖 Details: reference/dbus-service-usage.md

Rule 4: Polkit Authentication

// ✅ CORRECT
PolkitQt1::Authority::instance()->checkAuthorizationSync(
    "org.deepin.dde.policy.authentication",
    PolkitQt1::UnixProcessSubject(QCoreApplication::applicationPid()),
    PolkitQt1::Authority::AllowUserInteraction);

// ❌ FORBIDDEN
sudo ./application  // Security risk

📖 Details: reference/polkit-auth-workflow.md

CMake Configuration

See qt-compatibility-build skill for complete Qt6/Qt5 dual support.

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
if(QT_VERSION_MAJOR EQUAL 6)
    set(DTK_VERSION_MAJOR 6)
else()
    set(DTK_VERSION_MAJOR "")
endif()

find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets)
find_package(Dtk${DTK_VERSION_MAJOR}Widget REQUIRED)

target_link_libraries(app PRIVATE
    Qt${QT_VERSION_MAJOR}::Widgets
    Dtk${DTK_VERSION_MAJOR}::Widget
)

Debian Control Files

See qt-compatibility-build skill for file convention.

File Deepin Qt
debian/control V25 Qt6
debian/control.1 V20 Qt5

Dependencies (V25/Qt6):

Build-Depends:
 qt6-base-dev | qtbase5-dev,
 libdtk6widget-dev | libdtkwidget-dev,
 libpolkit-qt6-1-dev | libpolkit-qt5-1-dev

Gotchas (Common Pitfalls)

Pitfall Consequence Fix
GVfs mount point /run/user/UID/gvfs/ Path changes with session → Use GIO URI API
Wrong DBus bus type Connection failed → System vs Session
Polkit helper does not validate input Command injection risk → Strictly validate paths
Updating UI from a non-main thread Crash → Signals and slots (QueuedConnection)
Ignore GError Unable to diagnose the problem → Check the error parameter

Code Review Checklist

📖 Full Checklist: reference/code-review-checklist.md

Quick Check:

# 检查 DTK 控件使用
grep -r "QMainWindow\|QDialog\|QMessageBox" src/

# 检查硬编码颜色
grep -rE "#[0-9a-fA-F]{6}" src/

# 检查 GIO 使用
grep -r "g_file_new_for_uri" src/

Related Skills

  • qt-compatibility-build: Qt6/Qt5 dual support, CMake configuration, debian/control convention

Reference Documents