Skip to content

WIP: refactor: migrate taskmanager model to the new DockItemModel #1201

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BLumia
Copy link
Member

@BLumia BLumia commented Jul 23, 2025

PR 当前状态说明:

  1. 相比 WIP: refactor: migrate taskmanager model to the new DockItemModel #1148 ,此 PR 状态仅负责 model 切换以及切换后基础功能的相应变更/重新实现
  2. 原有代码关于“终端启动的应用的子进程”识别问题可以通过移除通过 AM 进行 cgroup 识别的调用来解决,但观察到有 360zip 这种不太对劲的 app 会在特定操作步骤后导致任务栏显示成齿轮。重构分支无此问题,在旧分支解决的意义可能不大。
  3. 原有代码关于非子进程识别问题的图标错误合并情况大概率是应用列表刷新时机的问题,旧的结构上只能绕过,不太方便根治。
  4. 此 PR 【目前】状态有一些功能未补全,包括关闭窗口、任务栏驻留等。这也是当前标记为 draft 的原因,挂一个 PR 旨在方便看 diff,不用在 worktree 之间切来切去。

切换 taskmanager 区域的 model 为新的 DockItemModel,以解决一系列问题:

  1. 部分场景下企业微信和微信图标合并/钉钉和微信合并等问题
  2. 终端执行 gitk/dde-dconfig-editor 时不会单独显示任务栏图标
  3. 没有 desktop-id 的带界面的可执行程序不会单独显示任务栏图标

Summary by Sourcery

Migrate the TaskManager from the old AppItem/ItemModel architecture to the new DockItemModel, refactor preview and activation APIs, and update QML bindings and tests accordingly.

New Features:

  • Replace AppItemWindowModel with DockItemWindowModel that drives window previews from QModelIndexList.
  • Implement AbstractTaskManagerInterface methods (requestActivate, requestClose, requestPreview, etc.) in window monitors.
  • Add fetchWindowPreview using KWin ScreenShot2 D-Bus interface for accurate window preview snapshots.

Bug Fixes:

  • Eliminate icon-merging problems (e.g. WeChat, Enterprise WeChat) by switching to the new dock model.

Enhancements:

  • Simplify QML by replacing legacy clickItem/drop signals with TaskManager.requestActivate and requestNewInstance using modelIndex.
  • Remove outdated docking drop-area hacks and delay window monitor startup for proper initialization.

Tests:

  • Include QAbstractItemModelTester in combine/group model tests to strengthen model validation.

切换 taskmanager 区域的 model 为新的 DockItemModel,以解决一系列问题:

1. 部分场景下企业微信和微信图标合并/钉钉和微信合并等问题
2. 终端执行 gitk/dde-dconfig-editor 时不会单独显示任务栏图标
3. 没有 desktop-id 的带界面的可执行程序不会单独显示任务栏图标

Log:
@deepin-ci-robot
Copy link

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia

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

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

Copy link

sourcery-ai bot commented Jul 23, 2025

Reviewer's Guide

This PR migrates the TaskManager area to the new DockItemModel, refactoring window previews, monitors, TaskManager APIs, and QML delegates to operate on QModelIndexList and the AbstractTaskManagerInterface, while removing legacy AppItem/ItemModel code and updating tests.

Sequence diagram for window preview request using new model

sequenceDiagram
    participant User as actor User
    participant AppItem as AppItem (QML)
    participant TaskManagerQML as TaskManagerQML
    participant TaskManager as TaskManager
    participant AbstractWindowMonitor as AbstractWindowMonitor
    participant X11WindowPreviewContainer as X11WindowPreviewContainer
    User->>AppItem: Hover or click triggers preview
    AppItem->>TaskManagerQML: requestPreview([modelIndex], Panel.rootObject, xOffset, yOffset, position)
    TaskManagerQML->>TaskManager: requestPreview(...)
    TaskManager->>AbstractWindowMonitor: requestPreview(QModelIndexList, ...)
    AbstractWindowMonitor->>X11WindowPreviewContainer: showPreview(QModelIndexList, ...)
    X11WindowPreviewContainer->>DockItemWindowModel: setData(QModelIndexList)
    X11WindowPreviewContainer->>X11WindowPreviewContainer: updatePreviewIconFromBase64(...)
    X11WindowPreviewContainer->>X11WindowPreviewContainer: updatePreviewTitle(...)
    X11WindowPreviewContainer->>X11WindowPreviewContainer: updateSize(...)
Loading

Class diagram for TaskManager model migration to DockItemModel

classDiagram
    class TaskManager {
        +DockItemModel* dataModel() const
        +void dropFilesOnItem(QString, QStringList)
        +void hideItemPreview()
        ...
    }
    class DockItemModel {
        +void setSourceModel(QAbstractItemModel*)
        +void dumpItemInfo(QModelIndex)
        ...
    }
    class AbstractWindowMonitor {
        +QPointer<AbstractWindow> getWindowByWindowId(ulong)
        +void requestActivate(QModelIndex) const
        +void requestPreview(QModelIndexList, QObject*, int32_t, int32_t, uint32_t) const
        +void requestClose(QModelIndex, bool) const
        ...
    }
    class X11WindowMonitor {
        +void requestPreview(QModelIndexList, QObject*, int32_t, int32_t, uint32_t) const
        +void hideItemPreview()
        ...
    }
    class TreeLandWindowMonitor {
        +void requestPreview(QModelIndexList, QObject*, int32_t, int32_t, uint32_t) const
        +void hideItemPreview()
        ...
    }
    class DockItemWindowModel {
        +int rowCount(QModelIndex) const
        +QVariant data(QModelIndex, int) const
        +void setData(QModelIndexList)
        +void resetPreviewPixmap()
        ...
    }
    TaskManager --> DockItemModel : uses
    TaskManager --> AbstractWindowMonitor : owns
    AbstractWindowMonitor <|-- X11WindowMonitor
    AbstractWindowMonitor <|-- TreeLandWindowMonitor
    X11WindowMonitor --> DockItemWindowModel : uses
    TreeLandWindowMonitor --> DockItemWindowModel : uses
Loading

Class diagram for QML delegate and AppItem changes

classDiagram
    class AppItem {
        +string itemId
        +string name
        +string iconName
        +string icon
        +list<string> windows
        +int visualIndex
        +var modelIndex
        +signal dropFilesOnItem(itemId, files)
        +signal dragFinished()
        ...
    }
    class TaskManagerQML {
        +void requestActivate(var modelIndex)
        +void requestNewInstance(var modelIndex, string action)
        +void requestPreview(var indexes, QObject, int32_t, int32_t, uint32_t)
        ...
    }
    AppItem --> TaskManagerQML : calls methods
Loading

File-Level Changes

Change Details Files
Refactor window preview component to use DockItemModel and QModelIndexList
  • Renamed AppItemWindowModel to DockItemWindowModel keyed on QModelIndexList
  • Updated data(), setData(), and resetPreviewPixmap() to fetch roles from QModelIndex
  • Changed showPreview and updateSize signatures to accept QModelIndexList
  • Removed direct AppItem references and legacy signal connections
x11preview.cpp
x11preview.h
Replace ItemModel with DockItemModel in TaskManager
  • Changed dataModel() to return DockItemModel* and removed loadDockedAppItems
  • Removed clickItem and showItemPreview Q_INVOKABLEs, stubbed dropFilesOnItem
  • Deferred window monitor start via QTimer instead of immediate start
  • Guarded loadDockedItems() in TaskManagerSettings to avoid repeated loads
taskmanager.cpp
taskmanager.h
taskmanagersettings.cpp
Extend AbstractWindowMonitor with AbstractTaskManagerInterface and add request methods
  • Inherited AbstractTaskManagerInterface and removed showItemPreview virtual
  • Added requestActivate, requestClose, requestPreview, requestWindowsView, and other requestX methods
  • Adjusted dataChanged signals to include combined roles
abstractwindowmonitor.h
abstractwindowmonitor.cpp
Implement requestPreview in X11 and TreeLand window monitors
  • Replaced legacy showItemPreview with requestPreview forwarding indexes to preview container/context
  • Removed direct AppItem usage and updated preview lifecycle
  • Connected preview context and hid previews via requestPreview
treelandwindowmonitor.cpp
treelandwindowmonitor.h
x11windowmonitor.cpp
x11windowmonitor.h
Update QML delegates to use modelIndex and new request APIs
  • Added modelIndex property to TaskManager and AppItem delegates
  • Replaced clickItem with TaskManager.requestActivate and requestNewInstance
  • Rewired preview trigger to call requestPreview with indexes
  • Removed legacy DropArea drag handlers and simplified bindings
TaskManager.qml
AppItem.qml
Clean up combine models and tests
  • Enhanced DockCombineModel debug output and role handling
  • Invoked requestClose for CloseAll action in DockGlobalElementModel
  • Added QAbstractItemModelTester include to role model tests
  • Removed excess whitespace and formatting fixes
dockcombinemodel.cpp
dockglobalelementmodel.cpp
rolecombinemodeltests.cpp
rolegroupmodeltests.cpp

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

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.

2 participants