Skip to content

Commit 90e6876

Browse files
committed
fix: Dragging an application will hide the dock
Add contextDragging state to DockPanel AppItem and TrayPlugin will update when dragged and dropped pms: BUG-289207 pms: BUG-289205
1 parent 222cd3d commit 90e6876

File tree

7 files changed

+41
-3
lines changed

7 files changed

+41
-3
lines changed

panels/dock/dockhelper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class DockHelper : public QObject
3939

4040
void updateAllDockWakeArea();
4141

42-
private Q_SLOTS:
42+
public Q_SLOTS:
4343
void checkNeedHideOrNot();
4444
void checkNeedShowOrNot();
4545

panels/dock/dockpanel.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ DockPanel::DockPanel(QObject *parent)
3838
, m_loadTrayPlugins(new LoadTrayPlugins(this))
3939
, m_compositorReady(false)
4040
, m_launcherShown(false)
41+
, m_contextDragging(false)
4142
{
4243
connect(this, &DockPanel::compositorReadyChanged, this, [this] {
4344
if (!m_compositorReady) return;
@@ -366,7 +367,7 @@ D_APPLET_CLASS(DockPanel)
366367

367368
void DockPanel::setHideState(HideState newHideState)
368369
{
369-
if (m_hideState == newHideState)
370+
if (m_contextDragging | m_hideState == newHideState)
370371
return;
371372
m_hideState = newHideState;
372373
Q_EMIT hideStateChanged(m_hideState);
@@ -409,6 +410,21 @@ bool DockPanel::eventFilter(QObject *watched, QEvent *event)
409410

410411
return false;
411412
}
413+
414+
bool DockPanel::contextDragging() const
415+
{
416+
return m_contextDragging;
417+
}
418+
419+
void DockPanel::setContextDragging(bool newContextDragging)
420+
{
421+
if (m_contextDragging == newContextDragging)
422+
return;
423+
m_contextDragging = newContextDragging;
424+
if (!m_contextDragging)
425+
m_helper->checkNeedHideOrNot();
426+
emit contextDraggingChanged();
427+
}
412428
}
413429

414430
#include "dockpanel.moc"

panels/dock/dockpanel.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext
3737

3838
Q_PROPERTY(bool debugMode READ debugMode FINAL CONSTANT)
3939

40+
Q_PROPERTY(bool contextDragging READ contextDragging WRITE setContextDragging NOTIFY contextDraggingChanged FINAL)
41+
4042
public:
4143
explicit DockPanel(QObject *parent = nullptr);
4244

@@ -86,6 +88,9 @@ class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext
8688

8789
qreal devicePixelRatio() const;
8890

91+
bool contextDragging() const;
92+
void setContextDragging(bool newContextDragging);
93+
8994
protected:
9095
bool eventFilter(QObject *watched, QEvent *event) override;
9196

@@ -112,6 +117,8 @@ private Q_SLOTS:
112117
void requestClosePopup();
113118
void devicePixelRatioChanged(qreal ratio);
114119

120+
void contextDraggingChanged();
121+
115122
private:
116123
ColorTheme m_theme;
117124
HideState m_hideState;
@@ -120,6 +127,7 @@ private Q_SLOTS:
120127
LoadTrayPlugins *m_loadTrayPlugins;
121128
bool m_compositorReady;
122129
bool m_launcherShown;
130+
bool m_contextDragging;
123131
};
124132

125133
}

panels/dock/taskmanager/package/AppItem.qml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,12 @@ Item {
298298
acceptedButtons: Qt.LeftButton | Qt.RightButton
299299
drag.target: root
300300
drag.onActiveChanged: {
301-
if (!drag.active)
301+
if (!drag.active) {
302+
Panel.contextDragging = false
302303
root.dragFinished()
304+
return
305+
}
306+
Panel.contextDragging = true
303307
}
304308

305309
onPressed: function (mouse) {
@@ -390,6 +394,8 @@ Item {
390394
keys: ["dfm_app_type_for_drag"]
391395

392396
onDropped: function (drop){
397+
// Panel.contextDragging = false
398+
// console.log("Dropped on AppItem: " + drop.urls)
393399
root.dropFilesOnItem(root.itemId, drop.urls)
394400
}
395401
}

panels/dock/taskmanager/package/TaskManager.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ ContainmentItem {
145145
}
146146

147147
onDropped: function(drop) {
148+
Panel.contextDragging = false
148149
if (launcherDndDesktopId === "") return
149150
let curX = taskmanager.useColumnLayout ? drop.y : drop.x
150151
let cellWidth = visualModel.cellWidth

panels/dock/tray/package/ActionLegacyTrayPluginDelegate.qml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,12 @@ AppletItemButton {
169169
Drag.onActiveChanged: {
170170
DDT.TraySortOrderModel.actionsAlwaysVisible = Drag.active
171171
if (!Drag.active) {
172+
Panel.contextDragging = false
172173
// reset position on drop
173174
Qt.callLater(() => { x = 0; y = 0; });
175+
return
174176
}
177+
Panel.contextDragging = true
175178
}
176179

177180
DragHandler {

panels/dock/tray/package/DummyDelegate.qml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import QtQuick
66
import QtQuick.Controls
7+
import org.deepin.ds.dock 1.0
78
import org.deepin.ds.dock.tray 1.0 as DDT
89

910
Button {
@@ -25,9 +26,12 @@ Button {
2526
Drag.onActiveChanged: {
2627
DDT.TraySortOrderModel.actionsAlwaysVisible = Drag.active
2728
if (!Drag.active) {
29+
Panel.contextDragging = false
2830
// reset position on drop
2931
Qt.callLater(() => { x = 0; y = 0; });
32+
return
3033
}
34+
Panel.contextDragging = true
3135
}
3236
contentItem: Rectangle {
3337
color: "grey"

0 commit comments

Comments
 (0)