Skip to content

chore: extend flmx mode of device#557

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
add-uos:master
Nov 28, 2025
Merged

chore: extend flmx mode of device#557
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
add-uos:master

Conversation

@add-uos
Copy link
Contributor

@add-uos add-uos commented Nov 28, 2025

extend flmx mode of device

Log: extend flmx mode of device

Bug: https://pms.uniontech.com/task-view-368603.html

Summary by Sourcery

Adjust device information display and generator selection for special device types and clean up unused platform-specific generators.

Bug Fixes:

  • Hide multi-device tables for storage and memory views on special device types based on a global configuration flag.
  • Suppress vendor field display for memory and storage devices when a special device type is active.

Enhancements:

  • Route multiple previously platform-specific machine types to the generic hardware generator and remove the associated custom generator implementations.
  • Remove hardcoded dummy monitor device creation from the monitor generation routine.
  • Add translations for new Storage and Memory labels used in conditional UI logic.

extend flmx mode of device

Log: extend flmx mode of device

Bug: https://pms.uniontech.com/task-view-368603.html
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 28, 2025

Reviewer's Guide

Extends special device mode handling (via Common::specialComType) for storage and memory views, hides vendor info in that mode, unifies several platform-specific generators to HWGenerator, and removes obsolete monitor debugging scaffolding, with corresponding translation updates.

Sequence diagram for PageMultiInfo.updateInfo with specialComType handling

sequenceDiagram
    actor User
    participant PageMultiInfo
    participant Common
    participant QLabel
    participant DeviceTable
    participant DeviceDetail

    User->>PageMultiInfo: updateInfo(lst)
    PageMultiInfo->>PageMultiInfo: getTableListInfo(lst, m_deviceList, m_menuControlList)

    PageMultiInfo->>DeviceTable: setVisible(true)
    PageMultiInfo->>DeviceTable: setFixedHeight(TABLE_HEIGHT)
    PageMultiInfo->>DeviceTable: updateTable(m_deviceList, m_menuControlList)

    PageMultiInfo->>Common: read specialComType
    alt specialComType >= 1
        PageMultiInfo->>QLabel: text()
        alt text is Storage or Memory
            PageMultiInfo->>DeviceTable: setVisible(false)
            PageMultiInfo->>DeviceTable: setFixedHeight(0)
        end
    end

    PageMultiInfo->>DeviceDetail: showDeviceInfo(lst)
    PageMultiInfo-->>User: UI updated
Loading

Class diagram for updated DeviceFactory generator selection

classDiagram
    class DeviceFactory {
        +getDeviceGenerator() DeviceGenerator*
    }

    class DeviceGenerator {
        <<interface>>
    }

    class HWGenerator {
        +generatorMonitorDevice() void
    }

    class X86Generator {
    }

    class MipsGenerator {
    }

    class ArmGenerator {
    }

    DeviceFactory ..> DeviceGenerator : creates
    DeviceGenerator <|-- HWGenerator
    DeviceGenerator <|-- X86Generator
    DeviceGenerator <|-- MipsGenerator
    DeviceGenerator <|-- ArmGenerator

    class Common {
        +specialComType int
    }

    DeviceFactory ..> Common : reads type

    %% PGUV, PGUW, PGUX and other types now map to HWGenerator instead of
    %% platform specific generators that were removed in this PR.
Loading

Class diagram for PageMultiInfo and special mode table handling

classDiagram
    class PageMultiInfo {
        -mp_Table DeviceTable*
        -mp_Label QLabel*
        -mp_Detail DeviceDetail*
        -m_deviceList QList~DeviceBaseInfo*~
        -m_menuControlList QList~MenuControlInfo~
        +updateInfo(lst QList~DeviceBaseInfo*~) void
        +resizeEvent(e QResizeEvent*) void
    }

    class DeviceTable {
        +setVisible(visible bool) void
        +setFixedHeight(height int) void
        +updateTable(deviceList QList~DeviceBaseInfo*~, menuControlList QList~MenuControlInfo~, limitRows bool, rowCount int) void
        +updateTable(deviceList QList~DeviceBaseInfo*~, menuControlList QList~MenuControlInfo~) void
    }

    class DeviceDetail {
        +showDeviceInfo(lst QList~DeviceBaseInfo*~) void
    }

    class QLabel {
        +text() QString
    }

    class Common {
        +specialComType int
    }

    PageMultiInfo o--> DeviceTable : mp_Table
    PageMultiInfo o--> DeviceDetail : mp_Detail
    PageMultiInfo o--> QLabel : mp_Label
    PageMultiInfo ..> Common : checks specialComType

    %% In specialComType >= 1 and when label text is Storage or Memory,
    %% PageMultiInfo hides mp_Table and sets its height to 0.
Loading

Class diagram for DeviceMemory and DeviceStorage base info loading in special mode

classDiagram
    class DeviceInfo {
        +addBaseDeviceInfo(key QString, value QString) void
    }

    class DeviceMemory {
        -m_Name QString
        -m_Vendor QString
        -m_Size QString
        -m_Type QString
        -m_Speed QString
        +loadBaseDeviceInfo() void
    }

    class DeviceStorage {
        -m_Name QString
        -m_Vendor QString
        -m_MediaType QString
        -m_Size QString
        -m_Version QString
        +loadBaseDeviceInfo() void
        +translateStr(value QString) QString
    }

    class Common {
        +specialComType int
    }

    DeviceInfo <|-- DeviceMemory
    DeviceInfo <|-- DeviceStorage

    DeviceMemory ..> Common : guards Vendor field
    DeviceStorage ..> Common : guards Vendor field

    %% loadBaseDeviceInfo now only adds Vendor when specialComType <= 0.
Loading

File-Level Changes

Change Details Files
Conditionally hide the multi-device table for Storage/Memory when running on specialComType devices and guard resize-time table updates with the same logic.
  • Include commonfunction.h to access Common::specialComType.
  • In updateInfo, always show and size the table first, then hide it and collapse height when specialComType >= 1 and the current label is Storage or Memory.
  • In resizeEvent, only call updateTable when either specialComType <= 0 or the label is not Storage/Memory, for both small-height and normal-height branches.
deepin-devicemanager/src/Page/PageMultiInfo.cpp
Add translations for the new Storage/Memory text usage locations and update source line references.
  • Declare new translation entries for Storage and Memory in PageMultiInfo, mapping to 存储设备 and 内存, and reference all code locations where these strings are used.
  • Adjust the location for the existing 'Failed to enable the device' message to the new line number.
deepin-devicemanager/translations/deepin-devicemanager_zh_CN.ts
Simplify hardware generator selection by routing multiple Pangu-related board types to HWGenerator and remove now-unused dedicated generator implementations.
  • Remove includes for PanguGenerator, PanguVGenerator, and PanguxGenerator from DeviceFactory.
  • For PGUV/PGUW and PGUX types, return a new HWGenerator instead of the respective Pangu* generators, keeping debug logs but changing the instantiated class.
  • Delete PanguGenerator, PanguVGenerator, and PanguxGenerator source and header files from the project.
deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp
deepin-devicemanager/src/GenerateDevice/PanguGenerator.cpp
deepin-devicemanager/src/GenerateDevice/PanguGenerator.h
deepin-devicemanager/src/GenerateDevice/PanguVGenerator.cpp
deepin-devicemanager/src/GenerateDevice/PanguVGenerator.h
deepin-devicemanager/src/GenerateDevice/PanguxGenerator.cpp
deepin-devicemanager/src/GenerateDevice/PanguxGenerator.h
Remove hardcoded dummy monitor device creation from the monitor generator.
  • Delete the temporary LCD monitor map setup and DeviceMonitor creation that previously ran at the start of generatorMonitorDevice, so it now only scans /sys/class/drm and real data sources.
deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp
Hide Vendor field for memory and storage devices on specialComType platforms.
  • Include commonfunction.h within DeviceStorage to access Common::specialComType.
  • In DeviceMemory::loadBaseDeviceInfo, guard adding the Vendor base field so it is only added when specialComType <= 0.
  • Apply the same conditional around adding the Vendor base field in DeviceStorage::loadBaseDeviceInfo.
deepin-devicemanager/src/DeviceManager/DeviceMemory.cpp
deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp
deepin-devicemanager/src/DeviceManager/DeviceStorage.h

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link

deepin pr auto review

我来对这次代码变更进行详细审查:

  1. 语法逻辑:
  • 代码修改符合C++语法规范,没有发现语法错误
  • 条件判断语句结构清晰,逻辑分支完整
  • 代码格式保持一致,缩进规范
  1. 代码质量:
  • 删除了冗余的特定设备生成器(PanguGenerator、PanguVGenerator、PanguxGenerator),统一使用HWGenerator,提高了代码复用性
  • 添加了新的特殊机器类型(FLMX),扩展性良好
  • 在DeviceMemory和DeviceStorage中添加了条件判断,避免在特殊机器上显示供应商信息,逻辑合理
  • PageMultiInfo中的界面显示逻辑根据机器类型进行了优化
  1. 代码性能:
  • 删除了特定设备的生成器类,减少了代码量和内存占用
  • 使用条件判断替代了多个生成器的创建,减少了运行时开销
  • 界面显示逻辑的优化可以减少不必要的UI更新
  1. 代码安全:
  • 删除了特定设备的硬编码信息,提高了代码安全性
  • 条件判断中使用了<=0作为默认情况,避免了意外情况
  • 界面显示逻辑的修改不会影响其他功能

改进建议:

  1. 建议将特殊机器类型定义移到一个单独的配置文件中,便于维护
  2. 建议在Common::specialComType的判断处添加注释,说明不同值的含义
  3. PageMultiInfo中的特殊处理逻辑可以考虑使用策略模式重构,提高代码可维护性
  4. 建议添加单元测试,确保特殊机器类型下的功能正确性

总的来说,这次代码修改质量较高,提高了代码的复用性和可维护性,同时保持了良好的性能和安全性。

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • The repeated checks if (Common::specialComType ... && mp_Label->text() == tr("Storage")/tr("Memory")) in PageMultiInfo make the logic fragile and translation-dependent; consider introducing a dedicated enum or type flag on the page/device instead of comparing translated label text in multiple places.
  • In DeviceFactory::getDeviceGenerator, the log messages still mention PanguVGenerator/PanguXGenerator even though HWGenerator is now created; update the debug output to reflect the actual generator being instantiated to avoid confusion during debugging.
  • The conditional hiding of memory/storage vendor information via Common::specialComType is scattered across multiple classes; consider encapsulating this policy in a single helper (e.g., a function on Common or a utility) to avoid repeating the same condition and to keep behavior consistent.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The repeated checks `if (Common::specialComType ... && mp_Label->text() == tr("Storage")/tr("Memory"))` in `PageMultiInfo` make the logic fragile and translation-dependent; consider introducing a dedicated enum or type flag on the page/device instead of comparing translated label text in multiple places.
- In `DeviceFactory::getDeviceGenerator`, the log messages still mention `PanguVGenerator`/`PanguXGenerator` even though `HWGenerator` is now created; update the debug output to reflect the actual generator being instantiated to avoid confusion during debugging.
- The conditional hiding of memory/storage vendor information via `Common::specialComType` is scattered across multiple classes; consider encapsulating this policy in a single helper (e.g., a function on `Common` or a utility) to avoid repeating the same condition and to keep behavior consistent.

## Individual Comments

### Comment 1
<location> `deepin-devicemanager/src/Page/PageMultiInfo.cpp:102-103` </location>
<code_context>
+    mp_Table->setVisible(true);
+    mp_Table->setFixedHeight(TABLE_HEIGHT);
     mp_Table->updateTable(m_deviceList, m_menuControlList);
+    if (Common::specialComType >= 1) {
+        if (mp_Label->text() == tr("Storage") || mp_Label->text() == tr("Memory")) {
+            mp_Table->setVisible(false);
+            mp_Table->setFixedHeight(0);
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Avoid using translated label text to drive logic; consider a more robust device-type check.

This logic depends on `mp_Label->text() == tr("Storage")/tr("Memory")` to control table visibility. Using UI text for behavior is brittle and can break with translation or wording changes. Prefer an explicit device type signal (e.g., enum or internal ID on the page) so you’re not relying on localized strings or duplicating these comparisons elsewhere.

Suggested implementation:

```cpp
    // 更新表格
    mp_Table->setVisible(true);
    mp_Table->setFixedHeight(TABLE_HEIGHT);
    mp_Table->updateTable(m_deviceList, m_menuControlList);
    if (Common::specialComType >= 1) {
        // 使用设备类型判断是否隐藏表格,避免依赖翻译文本
        if (shouldHideTableForDeviceType()) {
            mp_Table->setVisible(false);
            mp_Table->setFixedHeight(0);
        }
    }

```

To fully remove the dependency on localized label text, you’ll need to:

1. **Add an explicit device type to the page (if not present already)**  
   - In the corresponding header file (likely `PageMultiInfo.h`), introduce an enum describing device types, for example:
     ```cpp
     enum class DeviceType {
         Unknown,
         Storage,
         Memory,
         // ... other types
     };
     ```
   - Add a member to `PageMultiInfo`:
     ```cpp
     DeviceType m_deviceType = DeviceType::Unknown;
     ```

2. **Provide a helper method used above**  
   - In `PageMultiInfo.h` declare:
     ```cpp
     bool shouldHideTableForDeviceType() const;
     ```
   - In `PageMultiInfo.cpp` implement:
     ```cpp
     bool PageMultiInfo::shouldHideTableForDeviceType() const
     {
         switch (m_deviceType) {
         case DeviceType::Storage:
         case DeviceType::Memory:
             return true;
         default:
             return false;
         }
     }
     ```

3. **Initialize `m_deviceType` based on non-UI data**  
   - Wherever this page is constructed or updated (likely in the constructor or a `setDeviceInfo`/`updatePage`-style method that receives `lst` or device metadata), set `m_deviceType` from a stable identifier (e.g., a field in `lst`, `m_deviceList`, or `m_menuControlList`, or a higher-level page ID), *not* from `mp_Label->text()` or any translated string:
     ```cpp
     // Example sketch – adapt to your real model:
     if (deviceCategoryFromModel == DeviceCategory::Storage)
         m_deviceType = DeviceType::Storage;
     else if (deviceCategoryFromModel == DeviceCategory::Memory)
         m_deviceType = DeviceType::Memory;
     else
         m_deviceType = DeviceType::Unknown;
     ```

4. **(Optional) Remove any remaining logic that uses `mp_Label->text()` as a behavior driver**  
   - Search the codebase for usages like `mp_Label->text() == tr("Storage")` or `tr("Memory")` checks and replace them with `m_deviceType` / `DeviceType`-based checks, so behavior is no longer coupled to UI strings.
</issue_to_address>

### Comment 2
<location> `deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp:45` </location>
<code_context>
                 generator = new HWGenerator();
             } else if (type == "PGUV" || type == "PGUW") {
                 qCDebug(appLog) << "DeviceFactory::getDeviceGenerator create PanguVGenerator";
</code_context>

<issue_to_address>
**issue:** Debug log messages no longer match the actual generator type being instantiated.

For `type == "PGUV" || type == "PGUW"` (and `PGUX`), the log still says `create PanguVGenerator` / `create PanguXGenerator` while the code now instantiates `HWGenerator`. This mismatch can confuse field debugging; please update the messages (or centralize logging in a helper) so they reflect the actual generator class being created.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +102 to +103

// 更新详细信息
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Avoid using translated label text to drive logic; consider a more robust device-type check.

This logic depends on mp_Label->text() == tr("Storage")/tr("Memory") to control table visibility. Using UI text for behavior is brittle and can break with translation or wording changes. Prefer an explicit device type signal (e.g., enum or internal ID on the page) so you’re not relying on localized strings or duplicating these comparisons elsewhere.

Suggested implementation:

    // 更新表格
    mp_Table->setVisible(true);
    mp_Table->setFixedHeight(TABLE_HEIGHT);
    mp_Table->updateTable(m_deviceList, m_menuControlList);
    if (Common::specialComType >= 1) {
        // 使用设备类型判断是否隐藏表格,避免依赖翻译文本
        if (shouldHideTableForDeviceType()) {
            mp_Table->setVisible(false);
            mp_Table->setFixedHeight(0);
        }
    }

To fully remove the dependency on localized label text, you’ll need to:

  1. Add an explicit device type to the page (if not present already)

    • In the corresponding header file (likely PageMultiInfo.h), introduce an enum describing device types, for example:
      enum class DeviceType {
          Unknown,
          Storage,
          Memory,
          // ... other types
      };
    • Add a member to PageMultiInfo:
      DeviceType m_deviceType = DeviceType::Unknown;
  2. Provide a helper method used above

    • In PageMultiInfo.h declare:
      bool shouldHideTableForDeviceType() const;
    • In PageMultiInfo.cpp implement:
      bool PageMultiInfo::shouldHideTableForDeviceType() const
      {
          switch (m_deviceType) {
          case DeviceType::Storage:
          case DeviceType::Memory:
              return true;
          default:
              return false;
          }
      }
  3. Initialize m_deviceType based on non-UI data

    • Wherever this page is constructed or updated (likely in the constructor or a setDeviceInfo/updatePage-style method that receives lst or device metadata), set m_deviceType from a stable identifier (e.g., a field in lst, m_deviceList, or m_menuControlList, or a higher-level page ID), not from mp_Label->text() or any translated string:
      // Example sketch – adapt to your real model:
      if (deviceCategoryFromModel == DeviceCategory::Storage)
          m_deviceType = DeviceType::Storage;
      else if (deviceCategoryFromModel == DeviceCategory::Memory)
          m_deviceType = DeviceType::Memory;
      else
          m_deviceType = DeviceType::Unknown;
  4. (Optional) Remove any remaining logic that uses mp_Label->text() as a behavior driver

    • Search the codebase for usages like mp_Label->text() == tr("Storage") or tr("Memory") checks and replace them with m_deviceType / DeviceType-based checks, so behavior is no longer coupled to UI strings.

@@ -48,13 +45,13 @@ DeviceGenerator *DeviceFactory::getDeviceGenerator()
generator = new HWGenerator();
} else if (type == "PGUV" || type == "PGUW") {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Debug log messages no longer match the actual generator type being instantiated.

For type == "PGUV" || type == "PGUW" (and PGUX), the log still says create PanguVGenerator / create PanguXGenerator while the code now instantiates HWGenerator. This mismatch can confuse field debugging; please update the messages (or centralize logging in a helper) so they reflect the actual generator class being created.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@add-uos
Copy link
Contributor Author

add-uos commented Nov 28, 2025

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Nov 28, 2025

This pr cannot be merged! (status: unstable)

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Nov 28, 2025

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit 6faae86 into linuxdeepin:master Nov 28, 2025
16 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants