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
2 changes: 1 addition & 1 deletion docs/launcher-folder-residence.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ FolderIcon 固定保留四个 2×2 预览位置。FolderPopup 接收名称和 co

DockPanelPositioner 暴露当前屏幕 availableGeometry,使模板在任务栏四个方向、多屏和工作区偏移下限制尺寸与位置。不能使用 QML Screen.desktopAvailableWidth/Height 代替单屏工作区。

拖拽使用既有 text/x-dde-dock-dnd-appid/source MIME。进入任务栏时只对新驻留项做预览,离开时回滚预览,不移除本来已驻留的同源项。任务栏内部排序落地后保存混合应用/文件夹顺序。从任务栏拖出不会取消驻留,取消驻留只通过驻留项右键菜单的「移除驻留」完成。
拖拽使用既有 text/x-dde-dock-dnd-appid/source MIME。进入任务栏时只对新驻留项做预览,离开时回滚预览,不移除本来已驻留的同源项。任务栏内部排序落地后保存混合应用/文件夹顺序。从任务栏或溢出区域拖出不会取消驻留,取消驻留只通过驻留项右键菜单的「移除驻留」完成。

## 驻留项右键菜单:固定项 + 插件扩展

Expand Down
15 changes: 7 additions & 8 deletions panels/dock/taskmanager/package/TaskManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ ContainmentItem {
id: overflowButton
taskManagerItem: taskmanager
overflow: taskOverflow
onDragFinished: function(dropAction, itemId, canUndock) {
launcherDndDropArea.finishDrag(dropAction, itemId, canUndock)
onDragFinished: function(dropAction) {
launcherDndDropArea.finishDrag(dropAction)
}
}

Expand Down Expand Up @@ -360,20 +360,19 @@ ContainmentItem {
return true
}

function finishDrag(dropAction, itemId, canUndock) {
function finishDrag(dropAction) {
const pending = pendingOverflowDrop
pendingOverflowDrop = null
const shouldUndock = taskOverflow.finishDrag(dropAction)
taskOverflow.finishDrag()
resetDndState()
// Both moves and unpinning can destroy the source. Commit them
// only after QDrag and the initiating MouseArea event return.
// Dropping outside the dock preserves residence. Only commit
// accepted moves after QDrag and the MouseArea event return,
// since moving into the taskbar can destroy the source.
Qt.callLater(function() {
if (pending && dropAction === Qt.MoveAction) {
const targetIndex = Math.min(pending.targetIndex, taskOverflow.visibleItemCount - 1)
if (moveApp(pending.appId, pending.winId, targetIndex))
saveOrder()
} else if (canUndock && shouldUndock) {
taskmanager.Applet.requestUndockByDesktopId(itemId)
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions panels/dock/taskmanager/package/TaskOverflowButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Item {
required property var taskManagerItem
required property var overflow

signal dragFinished(int dropAction, string itemId, bool canUndock)
signal dragFinished(int dropAction)

readonly property int overflowCount: overflow.popupCount
readonly property var primaryOverflowItem: overflow.popupCount > 0 ? overflow.primaryItem : null
Expand Down Expand Up @@ -324,7 +324,7 @@ Item {
root.taskManagerItem.Applet.dropFilesOnItem(itemId, files)
}
onDragFinished: function(dropAction) {
root.dragFinished(dropAction, itemId, dragEnabled)
root.dragFinished(dropAction)
}
}
}
Expand Down
24 changes: 2 additions & 22 deletions panels/dock/taskmanager/taskoverflowcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

#include "globals.h"

#include <QTimer>

Check warning on line 9 in panels/dock/taskmanager/taskoverflowcontroller.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QTimer> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QGuiApplication>
#include <QKeyEvent>
#include <QVariantMap>

Check warning on line 10 in panels/dock/taskmanager/taskoverflowcontroller.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QVariantMap> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <algorithm>

Check warning on line 12 in panels/dock/taskmanager/taskoverflowcontroller.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <algorithm> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <cmath>
#include <utility>

Expand Down Expand Up @@ -177,36 +175,18 @@
return;
m_dragInProgress = true;
emit dragInProgressChanged();
m_dragCancelled = false;
// Install after QDrag starts its event loop so that Escape is observed
// before the native drag filter consumes it and clears the mouse state.
QTimer::singleShot(0, this, [this] {
if (m_dragInProgress)
QCoreApplication::instance()->installEventFilter(this);
});
}

bool TaskOverflowController::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::KeyPress && static_cast<QKeyEvent *>(event)->key() == Qt::Key_Escape)
m_dragCancelled = true;
return QObject::eventFilter(watched, event);
}

bool TaskOverflowController::finishDrag(int dropAction)
void TaskOverflowController::finishDrag()
{
if (!m_dragInProgress)
return false;
return;
m_dragInProgress = false;
QCoreApplication::instance()->removeEventFilter(this);
emit dragInProgressChanged();
if (m_syncDeferred) {
m_syncDeferred = false;
scheduleSync();
}
// IgnoreAction represents both dropping outside and cancelling with Escape.
return dropAction == Qt::IgnoreAction && !m_dragCancelled
&& !(QGuiApplication::mouseButtons() & Qt::LeftButton);
}

void TaskOverflowController::setLayout(bool showRecent, qreal trailingExtent, qreal buttonOffset,
Expand Down
4 changes: 1 addition & 3 deletions panels/dock/taskmanager/taskoverflowcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class TaskOverflowController : public QObject

Q_INVOKABLE void scheduleSync();
Q_INVOKABLE void beginDrag();
Q_INVOKABLE bool finishDrag(int dropAction);
Q_INVOKABLE void finishDrag();

Q_SIGNALS:
void enabledChanged();
Expand All @@ -134,7 +134,6 @@ private Q_SLOTS:
void onDataModelDestroyed();

private:
bool eventFilter(QObject *watched, QEvent *event) override;
void sync();
int modelCount() const;
QModelIndex modelIndexAt(int visualIndex) const;
Expand Down Expand Up @@ -180,7 +179,6 @@ private Q_SLOTS:
QSet<QString> m_runningItems;
bool m_syncPending = false;
bool m_dragInProgress = false;
bool m_dragCancelled = false;
bool m_syncDeferred = false;
bool m_showRecent = false;
qreal m_trailingExtent = 0;
Expand Down
Loading