Dock: Fixed dock autohide when bar is at the bottom.
This commit is contained in:
parent
5859270ad0
commit
d79011355c
1 changed files with 70 additions and 36 deletions
|
|
@ -32,30 +32,41 @@ Variants {
|
||||||
|
|
||||||
screen: modelData
|
screen: modelData
|
||||||
|
|
||||||
// Auto-hide properties - make reactive to settings changes
|
property bool autoHide: Settings.data.dock.autoHide
|
||||||
property bool autoHide: Settings.data.dock.autoHide || (Settings.data.bar.position === "bottom")
|
|
||||||
property bool hidden: autoHide
|
property bool hidden: autoHide
|
||||||
property int hideDelay: 500
|
property int hideDelay: 500
|
||||||
property int showDelay: 100
|
property int showDelay: 100
|
||||||
property int hideAnimationDuration: Style.animationFast
|
property int hideAnimationDuration: Style.animationFast
|
||||||
property int showAnimationDuration: Style.animationFast
|
property int showAnimationDuration: Style.animationFast
|
||||||
property int peekHeight: 2
|
property int peekHeight: 7 * scaling
|
||||||
property int fullHeight: dockContainer.height
|
property int fullHeight: dockContainer.height
|
||||||
property int iconSize: 36
|
property int iconSize: 36
|
||||||
|
|
||||||
|
// Bar positioning properties
|
||||||
|
property bool barAtBottom: Settings.data.bar.position === "bottom"
|
||||||
|
property int barHeight: barAtBottom ? (Settings.data.bar.height || 30) * scaling : 0
|
||||||
|
property int dockSpacing: 4 * scaling // Space between dock and bar
|
||||||
|
|
||||||
// Track hover state
|
// Track hover state
|
||||||
property bool dockHovered: false
|
property bool dockHovered: false
|
||||||
property bool anyAppHovered: false
|
property bool anyAppHovered: false
|
||||||
|
|
||||||
// Dock is only shown if explicitely toggled
|
// Dock is positioned at the bottom
|
||||||
exclusionMode: ExclusionMode.Ignore
|
|
||||||
|
|
||||||
anchors.bottom: true
|
anchors.bottom: true
|
||||||
implicitWidth: dockContainer.width
|
|
||||||
|
|
||||||
|
// Dock should be above bar but not create its own exclusion zone
|
||||||
|
exclusionMode: ExclusionMode.Ignore
|
||||||
focusable: false
|
focusable: false
|
||||||
|
|
||||||
|
// Make the window transparent
|
||||||
color: Color.transparent
|
color: Color.transparent
|
||||||
implicitHeight: iconSize * 1.4 * scaling
|
|
||||||
|
// Set the window size - always include space for peek area when auto-hide is enabled
|
||||||
|
implicitWidth: dockContainer.width
|
||||||
|
implicitHeight: fullHeight + (barAtBottom ? barHeight + dockSpacing : 0)
|
||||||
|
|
||||||
|
// Position the entire window above the bar when bar is at bottom
|
||||||
|
margins.bottom: barAtBottom ? barHeight : 0
|
||||||
|
|
||||||
// Watch for autoHide setting changes
|
// Watch for autoHide setting changes
|
||||||
onAutoHideChanged: {
|
onAutoHideChanged: {
|
||||||
|
|
@ -75,7 +86,7 @@ Variants {
|
||||||
id: hideTimer
|
id: hideTimer
|
||||||
interval: hideDelay
|
interval: hideDelay
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (autoHide && !dockHovered && !anyAppHovered) {
|
if (autoHide && !dockHovered && !anyAppHovered && !peekArea.containsMouse) {
|
||||||
hidden = true
|
hidden = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -85,40 +96,36 @@ Variants {
|
||||||
Timer {
|
Timer {
|
||||||
id: showTimer
|
id: showTimer
|
||||||
interval: showDelay
|
interval: showDelay
|
||||||
onTriggered: hidden = false
|
onTriggered: {
|
||||||
|
if (autoHide) {
|
||||||
|
hidden = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Behavior for smooth hide/show animations
|
|
||||||
Behavior on margins.bottom {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: hidden ? hideAnimationDuration : showAnimationDuration
|
|
||||||
easing.type: Easing.InOutQuad
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Peek area that remains visible when dock is hidden
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: screenEdgeMouseArea
|
id: peekArea
|
||||||
x: 0
|
anchors.bottom: parent.bottom
|
||||||
y: modelData && modelData.geometry ? modelData.geometry.height - (fullHeight + 10 * scaling) : 0
|
anchors.left: parent.left
|
||||||
width: screen.width
|
anchors.right: parent.right
|
||||||
height: fullHeight + 10 * scaling
|
height: peekHeight + dockSpacing
|
||||||
hoverEnabled: true
|
hoverEnabled: autoHide
|
||||||
propagateComposedEvents: true
|
visible: autoHide
|
||||||
|
|
||||||
onEntered: {
|
onEntered: {
|
||||||
if (autoHide && hidden) {
|
if (autoHide && hidden) {
|
||||||
showTimer.start()
|
showTimer.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onExited: {
|
onExited: {
|
||||||
if (autoHide && !hidden && !dockHovered && !anyAppHovered) {
|
if (autoHide && !hidden && !dockHovered && !anyAppHovered) {
|
||||||
hideTimer.start()
|
hideTimer.restart()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
margins.bottom: hidden ? -(fullHeight - peekHeight) : 0
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: dockContainer
|
id: dockContainer
|
||||||
width: dock.width + 48 * scaling
|
width: dock.width + 48 * scaling
|
||||||
|
|
@ -126,28 +133,53 @@ Variants {
|
||||||
color: Color.mSurface
|
color: Color.mSurface
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.bottomMargin: dockSpacing
|
||||||
topLeftRadius: Style.radiusL * scaling
|
topLeftRadius: Style.radiusL * scaling
|
||||||
topRightRadius: Style.radiusL * scaling
|
topRightRadius: Style.radiusL * scaling
|
||||||
|
|
||||||
|
// Animate the dock sliding up and down
|
||||||
|
transform: Translate {
|
||||||
|
y: hidden ? (fullHeight - peekHeight) : 0
|
||||||
|
|
||||||
|
Behavior on y {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: hidden ? hideAnimationDuration : showAnimationDuration
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Drop shadow for better visibility when bar is transparent
|
||||||
|
layer.enabled: true
|
||||||
|
layer.effect: MultiEffect {
|
||||||
|
shadowEnabled: true
|
||||||
|
shadowColor: Qt.rgba(0, 0, 0, 0.3)
|
||||||
|
shadowBlur: 0.5
|
||||||
|
shadowVerticalOffset: 2
|
||||||
|
shadowHorizontalOffset: 0
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: dockMouseArea
|
id: dockMouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
propagateComposedEvents: true
|
|
||||||
|
|
||||||
onEntered: {
|
onEntered: {
|
||||||
dockHovered = true
|
dockHovered = true
|
||||||
if (autoHide) {
|
if (autoHide) {
|
||||||
showTimer.stop()
|
showTimer.stop()
|
||||||
hideTimer.stop()
|
hideTimer.stop()
|
||||||
|
if (hidden) {
|
||||||
hidden = false
|
hidden = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onExited: {
|
onExited: {
|
||||||
dockHovered = false
|
dockHovered = false
|
||||||
// Only start hide timer if we're not hovering over any app
|
// Only start hide timer if we're not hovering over any app or the peek area
|
||||||
if (autoHide && !anyAppHovered) {
|
if (autoHide && !anyAppHovered && !peekArea.containsMouse) {
|
||||||
hideTimer.start()
|
hideTimer.restart()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -265,16 +297,18 @@ Variants {
|
||||||
if (autoHide) {
|
if (autoHide) {
|
||||||
showTimer.stop()
|
showTimer.stop()
|
||||||
hideTimer.stop()
|
hideTimer.stop()
|
||||||
|
if (hidden) {
|
||||||
hidden = false
|
hidden = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onExited: {
|
onExited: {
|
||||||
anyAppHovered = false
|
anyAppHovered = false
|
||||||
appTooltip.hide()
|
appTooltip.hide()
|
||||||
// Only start hide timer if we're not hovering over the dock
|
// Only start hide timer if we're not hovering over the dock or peek area
|
||||||
if (autoHide && !dockHovered) {
|
if (autoHide && !dockHovered && !peekArea.containsMouse) {
|
||||||
hideTimer.start()
|
hideTimer.restart()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue