-
Notifications
You must be signed in to change notification settings - Fork 55
refactor: migrated docked items config to TASKMANAGER_DOCKEDELEMENTS_KEY #1213
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
Conversation
Reviewer's GuideThis PR refactors the docked-items persistence in TaskManagerSettings to use a new TASKMANAGER_DOCKEDELEMENTS_KEY, removes legacy JSON-based APIs, introduces string-based helpers and migration logic, updates Desktopfile parsing, eliminates the old ItemModel moveTo method, and adapts TaskManager and its QML UI to handle ordering and saving via the new API. Sequence diagram for saving docked elements order from QML drag-and-dropsequenceDiagram
participant User as actor User
participant QML as TaskManager.qml
participant TaskManager as TaskManager
participant TaskManagerSettings as TaskManagerSettings
User->>QML: Drag and drop docked app icon
QML->>QML: visualModel.items.move(currentIndex, targetIndex)
QML->>QML: Collect new appIds order
QML->>TaskManager: saveDockElementsOrder(appIds)
TaskManager->>TaskManagerSettings: setDockedElements(newDockedElements)
TaskManagerSettings->>TaskManagerSettings: saveDockedElements()
TaskManagerSettings-->>TaskManager: (order persisted)
TaskManager-->>QML: (optional: update UI)
Class diagram for TaskManagerSettings refactor to TASKMANAGER_DOCKEDELEMENTS_KEYclassDiagram
class TaskManagerSettings {
+setDockedElements(elements: QStringList)
+appendDockedElements(element: QString)
+removeDockedElements(element: QString)
+dockedElements() const: QStringList
+isDocked(elementId: QString) const: bool
-migrateFromDockedItems()
-toDockedElementsStrings(items: QJsonArray) const: QStringList
-toDockedElementsString(item: QJsonObject) const: QString
-saveDockedElements()
}
class DesktopfileAbstractParser {
+isDocked(): bool
+setDocked(docked: bool)
}
TaskManagerSettings <.. DesktopfileAbstractParser : uses
class TaskManager {
+saveDockElementsOrder(appIds: QStringList)
+loadDockedAppItems()
}
TaskManager --> TaskManagerSettings : uses
class ItemModel {
+dumpDockedItems() const: QJsonArray
}
Class diagram for removed legacy docked items APIclassDiagram
class TaskManagerSettings {
-setDockedDesktopFiles(desktopfiles: QJsonArray)
-appnedDockedDesktopfiles(desktopfile: QJsonObject)
-removeDockedDesktopfile(desktopfile: QJsonObject)
-dockedDesktopFiles(): QJsonArray
-dockedItemsPersisted()
-loadDockedItems()
}
%% These methods and members have been removed in favor of the new string-based API.
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @BLumia - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `panels/dock/taskmanager/taskmanagersettings.cpp:162` </location>
<code_context>
+
+void TaskManagerSettings::appendDockedElements(const QString &element)
+{
+ m_dockedElements.append(element);
+ Q_EMIT dockedElementsChanged();
+ saveDockedElements();
}
</code_context>
<issue_to_address>
Appending elements without duplicate check may cause repeated entries.
This could lead to UI or logic errors if unique docked elements are expected.
</issue_to_address>
### Comment 2
<location> `panels/dock/taskmanager/package/TaskManager.qml:192` </location>
<code_context>
let appId = taskmanager.Applet.desktopIdToAppId(launcherDndDesktopId)
- taskmanager.Applet.dataModel.moveTo(appId, targetIndex)
+ let currentIndex = taskmanager.findAppIndex(appId)
+ if (currentIndex !== -1 && currentIndex !== targetIndex && targetIndex < visualModel.items.count) {
+ visualModel.items.move(currentIndex, targetIndex)
+ }
}
</code_context>
<issue_to_address>
No handling for out-of-bounds or negative targetIndex.
Also check that targetIndex is not negative to avoid errors.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
let currentIndex = taskmanager.findAppIndex(appId)
if (currentIndex !== -1 && currentIndex !== targetIndex && targetIndex < visualModel.items.count) {
visualModel.items.move(currentIndex, targetIndex)
}
=======
let currentIndex = taskmanager.findAppIndex(appId)
if (
currentIndex !== -1 &&
currentIndex !== targetIndex &&
targetIndex >= 0 &&
targetIndex < visualModel.items.count
) {
visualModel.items.move(currentIndex, targetIndex)
}
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| Q_EMIT dockedElementsChanged(); | ||
| qDebug() << "TASKMANAGER_DOCKEDITEMS_KEY is deprecated, please use TASKMANAGER_DOCKEDELEMENTS_KEY instead"; | ||
| } else if (TASKMANAGER_DOCKEDELEMENTS_KEY == key) { | ||
| m_dockedElements = m_taskManagerDconfig->value(TASKMANAGER_DOCKEDELEMENTS_KEY, {}).toStringList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Appending elements without duplicate check may cause repeated entries.
This could lead to UI or logic errors if unique docked elements are expected.
d19a40d to
2e66369
Compare
2e66369 to
5a3823e
Compare
使 ItemModel 使用新的任务栏驻留配置,并确保任务栏驻留顺序的保存位置也使用 新的任务栏驻留配置. 此提交旨在进一步与 ItemModel 解耦,便于后续模型切换重构分支的合入. Log:
5a3823e to
971ef6f
Compare
deepin pr auto review代码审查意见:
以上是针对代码提交的详细审查意见,旨在提高代码质量、可读性和可维护性。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
使 ItemModel 使用新的任务栏驻留配置,并确保任务栏驻留顺序的保存位置也使用
新的任务栏驻留配置.
此提交旨在进一步与 ItemModel 解耦,便于后续模型切换重构分支的合入.
Summary by Sourcery
Refactor TaskManager to migrate docked items configuration from the deprecated TASKMANAGER_DOCKEDITEMS_KEY to the new TASKMANAGER_DOCKEDELEMENTS_KEY, unify docking APIs around element ID strings, and update drag-and-drop reordering logic accordingly.
New Features:
Enhancements: