Skip to content
Open
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
113 changes: 90 additions & 23 deletions panels/dock/package/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ Window {
id: dockAnimation
property bool useTransformBasedAnimation: Qt.platform.pluginName === "xcb"
property bool isShowing: false
property bool isPositionChanging: false
property var target: useTransformBasedAnimation ? dockTransform : dock
property string animProperty: {
if (useTransformBasedAnimation) return dock.useColumnLayout ? "x" : "y";
Expand Down Expand Up @@ -212,6 +213,17 @@ Window {
} else {
dock.visible = ((dock.useColumnLayout ? dock.width : dock.height) !== 1);
}

// If this was a hide animation during position change, handle the position change now
if (isPositionChanging && !isShowing) {
isPositionChanging = false;
positionChangeConnections.handlePositionChangeAfterHide();
} else {
// If this was a show animation and dock should be hidden, trigger auto-hide
if (isShowing && Panel.hideState === Dock.Hide) {
hideTimer.running = true;
}
}
}
}

Expand All @@ -221,34 +233,20 @@ Window {
required property int value
text: name

property var positionChangeCallback: function() {
// Disconnect any existing callback first
dockAnimation.onStopped.disconnect(positionChangeCallback);
// Stop any running animations first --fix bug with do not show dock
dockAnimation.stop();
// Reset transform before starting new animation--fix bug with change position,will have a blank area
dockTransform.x = 0;
dockTransform.y = 0;
onTriggered: {
if (Applet[prop] === value) {
// Manually restore checked state since Qt already toggled it
checked = true;
return;
}
Applet[prop] = value
}

Applet[prop] = value;
Component.onCompleted: {
checked = Qt.binding(function() {
return Applet[prop] === value;
});
dockAnimation.startAnimation(true);
}
onTriggered: {
if (prop === "position") {
// Connect the callback and start the hide animation
dockAnimation.onStopped.connect(positionChangeCallback);
dockAnimation.startAnimation(false);
} else {
Applet[prop] = value
checked = Qt.binding(function() {
return Applet[prop] === value
})
}
}
checked: Applet[prop] === value
}
component MutuallyExclusiveMenu: LP.Menu {
id: menu
Expand Down Expand Up @@ -665,9 +663,78 @@ Window {
}

Connections {
id: positionChangeConnections
property int previousPosition: Panel.position
property int savedNewPosition: -1
property bool isRestoringPosition: false

function onPositionChanged() {
// Ignore position changes triggered by our own restore operation
if (isRestoringPosition) {
return;
}

// Save the new position
savedNewPosition = Panel.position;

// Set flag to ignore the next position change
isRestoringPosition = true;

// Temporarily restore to previous position for hide animation
Applet.position = previousPosition;

// Clear the flag after restore
isRestoringPosition = false;

// Stop any running animations first
dockAnimation.stop();
hideShowAnimation.stop();

// Mark that we're changing position
dockAnimation.isPositionChanging = true;

// Check if dock is currently hidden
if (Panel.hideState === Dock.Hide && !dock.visible) {
// Directly handle position change without animation
dockAnimation.isPositionChanging = false;
handlePositionChangeAfterHide();
} else {
// Start hide animation at old position
dockAnimation.startAnimation(false);
}
}

function handlePositionChangeAfterHide() {
if (savedNewPosition === -1) return;

// Apply position change
previousPosition = savedNewPosition;
Applet.position = savedNewPosition;
savedNewPosition = -1;

changeDragAreaAnchor()
Panel.requestClosePopup()

// Set transform to hidden position before showing
if (dockAnimation.useTransformBasedAnimation) {
var hideOffset = (Applet.position === Dock.Left || Applet.position === Dock.Top) ? -Panel.dockSize : Panel.dockSize;
if (dock.useColumnLayout) {
dockTransform.x = hideOffset;
dockTransform.y = 0;
} else {
dockTransform.x = 0;
dockTransform.y = hideOffset;
}
} else {
dockTransform.x = 0;
dockTransform.y = 0;
}

dockAnimation.startAnimation(true);
}

Component.onCompleted: {
previousPosition = Panel.position
}
function onDockSizeChanged() {
dock.dockSize = Panel.dockSize
Expand Down