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: 5 additions & 0 deletions panels/dock/taskmanager/itemmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@
return QVariant();
}

void ItemModel::moveTo(const QString &id, int dIndex)

Check warning on line 75 in panels/dock/taskmanager/itemmodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'moveTo' is never used.
{
// simply do nothing if dIndex is invalid
if (dIndex >= m_items.size() || dIndex < 0) {
return;
}

auto sItem = getItemById(id);
auto dItem = m_items.at(dIndex);

Expand Down
4 changes: 2 additions & 2 deletions panels/dock/taskmanager/package/AppItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Item {
Drag.hotSpot.x: icon.width / 2
Drag.hotSpot.y: icon.height / 2
Drag.dragType: Drag.Automatic
Drag.mimeData: { "text/x-dde-dock-dnd-appid": itemId }
Drag.mimeData: { "text/x-dde-dock-dnd-appid": itemId, "text/x-dde-dock-dnd-source": "taskbar" }

property bool useColumnLayout: Panel.position % 2
property int statusIndicatorSize: useColumnLayout ? root.width * 0.72 : root.height * 0.72
Expand Down Expand Up @@ -72,7 +72,7 @@ Item {

WindowIndicator {
id: windowIndicator
dotWidth: root.useColumnLayout ? Math.max(Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE * iconScale / 16, 2) : Math.max(Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE * iconScale / 3, 2)
dotWidth: root.useColumnLayout ? Math.max(Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE * iconScale / 16, 2) : Math.max(Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE * iconScale / 3, 2)
dotHeight: root.useColumnLayout ? Math.max(Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE * iconScale / 3, 2) : Math.max(Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE * iconScale / 16, 2)
windows: root.windows
displayMode: root.displayMode
Expand Down
34 changes: 22 additions & 12 deletions panels/dock/taskmanager/package/TaskManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ContainmentItem {
required property list<string> windows
keys: ["text/x-dde-dock-dnd-appid"]
z: attention ? -1 : 0
property bool visibility: itemId !== launcherDndDropArea.launcherDndDesktopId
property bool visibility: itemId !== taskmanager.Applet.desktopIdToAppId(launcherDndDropArea.launcherDndDesktopId)

states: [
State {
Expand Down Expand Up @@ -100,13 +100,12 @@ ContainmentItem {
menus: delegateRoot.menus
windows: delegateRoot.windows
visualIndex: delegateRoot.visualIndex
ListView.delayRemove: Drag.active
Component.onCompleted: {
clickItem.connect(taskmanager.Applet.clickItem)
}

onDragFinished: function() {
// 就算在非法区域松开也更新 Model
taskmanager.Applet.dataModel.moveTo(itemId, visualIndex)
launcherDndDropArea.resetDndState()
}
anchors.fill: parent // This is mandatory for draggable item center in drop area
}
Expand All @@ -118,11 +117,19 @@ ContainmentItem {
anchors.fill: parent
keys: ["text/x-dde-dock-dnd-appid"]
property string launcherDndDesktopId: ""
property string launcherDndDragSource: ""

function resetDndState() {
launcherDndDesktopId = ""
launcherDndDragSource = ""
}

onEntered: function(drag) {
let desktopId = drag.getDataAsString("text/x-dde-dock-dnd-appid")
launcherDndDesktopId = taskmanager.Applet.desktopIdToAppId(desktopId)
launcherDndDragSource = drag.getDataAsString("text/x-dde-dock-dnd-source")
launcherDndDesktopId = desktopId
if (taskmanager.Applet.requestDockByDesktopId(desktopId) === false) {
launcherDndDesktopId = ""
resetDndState()
}
}

Expand All @@ -132,8 +139,8 @@ ContainmentItem {
curX *= Screen.devicePixelRatio
let cellWidth = Panel.rootObject.dockItemMaxSize
let curCell = curX / cellWidth
let left = (curX % cellWidth) < (cellWidth / 2)
taskmanager.Applet.dataModel.moveTo(launcherDndDesktopId, curCell)
let appId = taskmanager.Applet.desktopIdToAppId(launcherDndDesktopId)
taskmanager.Applet.dataModel.moveTo(appId, curCell)
}

onDropped: function(drop) {
Expand All @@ -142,13 +149,16 @@ ContainmentItem {
curX *= Screen.devicePixelRatio
let cellWidth = Panel.rootObject.dockItemMaxSize
let curCell = curX / cellWidth
let left = (curX % cellWidth) < (cellWidth / 2)
taskmanager.Applet.dataModel.moveTo(launcherDndDesktopId, curCell)
launcherDndDesktopId = ""
let appId = taskmanager.Applet.desktopIdToAppId(launcherDndDesktopId)
taskmanager.Applet.dataModel.moveTo(appId, curCell)
resetDndState()
}

onExited: function() {
launcherDndDesktopId = ""
if (launcherDndDesktopId !== "" && launcherDndDragSource !== "taskbar") {
taskmanager.Applet.requestUndockByDesktopId(launcherDndDesktopId)
}
resetDndState()
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions panels/dock/taskmanager/taskmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,16 @@ QString TaskManager::desktopIdToAppId(const QString& desktopId)
return Q_LIKELY(desktopId.endsWith(".desktop")) ? desktopId.chopped(8) : desktopId;
}

bool TaskManager::requestDockByDesktopId(const QString& appID)
bool TaskManager::requestDockByDesktopId(const QString& desktopID)
{
if (appID.startsWith("internal/")) return false;
return RequestDock(desktopIdToAppId(appID));
if (desktopID.startsWith("internal/")) return false;
return RequestDock(desktopIdToAppId(desktopID));
}

bool TaskManager::requestUndockByDesktopId(const QString& desktopID)
{
if (desktopID.startsWith("internal/")) return false;
return RequestUndock(desktopIdToAppId(desktopID));
}

bool TaskManager::RequestDock(QString appID)
Expand Down
3 changes: 2 additions & 1 deletion panels/dock/taskmanager/taskmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class TaskManager : public DS_NAMESPACE::DContainment
bool allowForceQuit();

Q_INVOKABLE QString desktopIdToAppId(const QString& desktopId);
Q_INVOKABLE bool requestDockByDesktopId(const QString& appID);
Q_INVOKABLE bool requestDockByDesktopId(const QString& desktopID);
Q_INVOKABLE bool requestUndockByDesktopId(const QString& desktopID);
Q_INVOKABLE bool RequestDock(QString appID);
Q_INVOKABLE bool IsDocked(QString appID);
Q_INVOKABLE bool RequestUndock(QString appID);
Expand Down
Loading