This commit is contained in:
Ly-sec 2025-09-12 22:20:48 +02:00
commit 5136af5d95
2 changed files with 325 additions and 275 deletions

View file

@ -12,10 +12,10 @@ import qs.Widgets
Variants { Variants {
model: Quickshell.screens model: Quickshell.screens
delegate: Loader { delegate: Item {
required property ShellScreen modelData required property ShellScreen modelData
property real scaling: ScalingService.getScreenScale(modelData) property real scaling: ScalingService.getScreenScale(modelData)
Connections { Connections {
target: ScalingService target: ScalingService
function onScaleChanged(screenName, scale) { function onScaleChanged(screenName, scale) {
@ -25,312 +25,362 @@ Variants {
} }
} }
active: Settings.isLoaded && modelData ? Settings.data.dock.monitors.includes(modelData.name) : false // Shared properties between peek and dock windows
readonly property bool autoHide: Settings.data.dock.autoHide
readonly property int hideDelay: 500
readonly property int showDelay: 100
readonly property int hideAnimationDuration: Style.animationFast
readonly property int showAnimationDuration: Style.animationFast
readonly property int peekHeight: 1 // no scaling for peek
readonly property int iconSize: 36 * scaling
readonly property int floatingMargin: Settings.data.dock.floatingRatio * Style.marginL * scaling
sourceComponent: PanelWindow { // Bar detection and positioning properties
id: dockWindow readonly property bool hasBar: modelData.name ? (Settings.data.bar.monitors.includes(modelData.name)
|| (Settings.data.bar.monitors.length === 0)) : false
readonly property bool barAtBottom: hasBar && Settings.data.bar.position === "bottom"
readonly property int barHeight: Style.barHeight * scaling
screen: modelData // Shared state between windows
property bool dockHovered: false
property bool anyAppHovered: false
property bool hidden: autoHide
property bool peekHovered: false
readonly property bool autoHide: Settings.data.dock.autoHide // Separate property to control Loader - stays true during animations
readonly property int hideDelay: 500 property bool dockLoaded: !autoHide // Start loaded if autoHide is off
readonly property int showDelay: 100
readonly property int hideAnimationDuration: Style.animationFast
readonly property int showAnimationDuration: Style.animationFast
readonly property int peekHeight: 7 * scaling
readonly property int fullHeight: dockContainer.height
readonly property int iconSize: 36 * scaling
readonly property int floatingMargin: Settings.data.dock.floatingRatio * Style.marginL * scaling // Margin to make dock float
// Bar detection and positioning properties // Timer to unload dock after hide animation completes
readonly property bool hasBar: modelData.name ? (Settings.data.bar.monitors.includes(modelData.name) Timer {
|| (Settings.data.bar.monitors.length === 0)) : false id: unloadTimer
readonly property bool barAtBottom: hasBar && Settings.data.bar.position === "bottom" interval: hideAnimationDuration + 50 // Add small buffer
readonly property bool barAtTop: hasBar && Settings.data.bar.position === "top" onTriggered: {
readonly property int barHeight: (barAtBottom || barAtTop) ? Settings.data.bar.height * scaling : 0 if (hidden && autoHide) {
readonly property int dockSpacing: 8 * scaling // Space between dock and bar/edge dockLoaded = false
}
}
}
// Track hover state // Timer for auto-hide delay
property bool dockHovered: false Timer {
property bool anyAppHovered: false id: hideTimer
property bool hidden: autoHide interval: hideDelay
onTriggered: {
// Dock is positioned at the bottom if (autoHide && !dockHovered && !anyAppHovered && !peekHovered) {
anchors.bottom: true
focusable: false
color: Color.transparent
WlrLayershell.namespace: "noctalia-dock"
WlrLayershell.exclusionMode: Settings.data.dock.exclusive ? ExclusionMode.Auto : ExclusionMode.Ignore
// Set the window size - include extra height only if bar is at bottom
implicitWidth: dockContainer.width + (Style.marginM * 2 * scaling)
implicitHeight: fullHeight + floatingMargin + (barAtBottom ? barHeight + dockSpacing : 0)
// Position the entire window above the bar only when bar is at bottom
margins.bottom: barAtBottom ? barHeight : 0
// Watch for autoHide setting changes
onAutoHideChanged: {
if (!autoHide) {
// If auto-hide is disabled, show the dock
hidden = false
hideTimer.stop()
showTimer.stop()
} else {
// If auto-hide is enabled, start hidden
hidden = true hidden = true
unloadTimer.restart() // Start unload timer when hiding
} }
} }
}
// Timer for auto-hide delay // Timer for show delay
Timer { Timer {
id: hideTimer id: showTimer
interval: hideDelay interval: showDelay
onTriggered: { onTriggered: {
if (autoHide && !dockHovered && !anyAppHovered && !peekArea.containsMouse) { if (autoHide) {
hidden = true dockLoaded = true // Load dock immediately
} hidden = false // Then trigger show animation
unloadTimer.stop() // Cancel any pending unload
} }
} }
}
// Timer for show delay // Watch for autoHide setting changes
Timer { onAutoHideChanged: {
id: showTimer if (!autoHide) {
interval: showDelay hidden = false
onTriggered: { dockLoaded = true
if (autoHide) { hideTimer.stop()
hidden = false showTimer.stop()
} unloadTimer.stop()
} } else {
hidden = true
unloadTimer.restart() // Schedule unload after animation
} }
}
// Peek area that remains visible when dock is hidden // PEEK WINDOW - Always visible when auto-hide is enabled
MouseArea { Loader {
id: peekArea active: Settings.isLoaded && modelData && Settings.data.dock.monitors.includes(modelData.name) && autoHide
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
height: peekHeight + floatingMargin + (barAtBottom ? dockSpacing : 0)
hoverEnabled: autoHide
visible: autoHide
onEntered: { sourceComponent: PanelWindow {
if (autoHide && hidden) { id: peekWindow
showTimer.start()
}
}
onExited: { screen: modelData
if (autoHide && !hidden && !dockHovered && !anyAppHovered) { anchors.bottom: true
hideTimer.restart() anchors.left: true
} anchors.right: true
} focusable: false
} color: Color.transparent
Rectangle { WlrLayershell.namespace: "noctalia-dock-peek"
id: dockContainer WlrLayershell.exclusionMode: ExclusionMode.Auto // Always exclusive
width: dockLayout.implicitWidth + Style.marginM * scaling * 2
height: Math.round(iconSize * 1.5)
color: Qt.alpha(Color.mSurface, Settings.data.dock.backgroundOpacity)
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: floatingMargin + (barAtBottom ? dockSpacing : 0)
radius: Style.radiusL * scaling
border.width: Math.max(1, Style.borderS * scaling)
border.color: Color.mOutline
// Fade and zoom animation properties implicitHeight: peekHeight
opacity: hidden ? 0 : 1
scale: hidden ? 0.85 : 1
Behavior on opacity { Rectangle {
NumberAnimation { anchors.fill: parent
duration: hidden ? hideAnimationDuration : showAnimationDuration color: barAtBottom ? Qt.alpha(Color.mSurface, Settings.data.bar.backgroundOpacity) : Color.transparent
easing.type: Easing.InOutQuad
}
}
Behavior on scale {
NumberAnimation {
duration: hidden ? hideAnimationDuration : showAnimationDuration
easing.type: hidden ? Easing.InQuad : Easing.OutBack
easing.overshoot: hidden ? 0 : 1.05
}
} }
MouseArea { MouseArea {
id: dockMouseArea id: peekArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onEntered: { onEntered: {
dockHovered = true peekHovered = true
if (autoHide) { if (hidden) {
showTimer.stop() showTimer.start()
hideTimer.stop()
if (hidden) {
hidden = false
}
} }
} }
onExited: { onExited: {
dockHovered = false peekHovered = false
// Only start hide timer if we're not hovering over any app or the peek area if (!hidden && !dockHovered && !anyAppHovered) {
if (autoHide && !anyAppHovered && !peekArea.containsMouse) {
hideTimer.restart() hideTimer.restart()
} }
} }
} }
}
}
// DOCK WINDOW
Loader {
active: Settings.isLoaded && modelData && Settings.data.dock.monitors.includes(modelData.name) && dockLoaded
sourceComponent: PanelWindow {
id: dockWindow
screen: modelData
focusable: false
color: Color.transparent
WlrLayershell.namespace: "noctalia-dock-main"
WlrLayershell.exclusionMode: Settings.data.dock.exclusive ? ExclusionMode.Auto : ExclusionMode.Ignore
// Size to fit the dock container exactly
implicitWidth: dockContainerWrapper.width
implicitHeight: dockContainerWrapper.height
// Position above the bar if it's at bottom
anchors.bottom: true
margins.bottom: barAtBottom ? barHeight + floatingMargin : floatingMargin
// Rectangle {
// anchors.fill: parent
// color: "#000FF0"
// z: -1
// }
// Wrapper item for scale/opacity animations
Item { Item {
id: dock id: dockContainerWrapper
width: dockLayout.implicitWidth width: dockContainer.width
height: parent.height - (Style.marginM * 2 * scaling) height: dockContainer.height
anchors.centerIn: parent anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
function getAppIcon(toplevel: Toplevel): string { // Apply animations to this wrapper
if (!toplevel) opacity: hidden ? 0 : 1
return "" scale: hidden ? 0.85 : 1
return AppIcons.iconForAppId(toplevel.appId?.toLowerCase())
Behavior on opacity {
NumberAnimation {
duration: hidden ? hideAnimationDuration : showAnimationDuration
easing.type: Easing.InOutQuad
}
} }
RowLayout { Behavior on scale {
id: dockLayout NumberAnimation {
spacing: Style.marginM * scaling duration: hidden ? hideAnimationDuration : showAnimationDuration
Layout.preferredHeight: parent.height easing.type: hidden ? Easing.InQuad : Easing.OutBack
easing.overshoot: hidden ? 0 : 1.05
}
}
Rectangle {
id: dockContainer
width: dockLayout.implicitWidth + Style.marginM * scaling * 2
height: Math.round(iconSize * 1.5)
color: Qt.alpha(Color.mSurface, Settings.data.dock.backgroundOpacity)
anchors.centerIn: parent anchors.centerIn: parent
radius: Style.radiusL * scaling
border.width: Math.max(1, Style.borderS * scaling)
border.color: Color.mOutline
Repeater { MouseArea {
model: ToplevelManager ? ToplevelManager.toplevels : null id: dockMouseArea
anchors.fill: parent
hoverEnabled: true
delegate: Item { onEntered: {
id: appButton dockHovered = true
Layout.preferredWidth: iconSize if (autoHide) {
Layout.preferredHeight: iconSize showTimer.stop()
Layout.alignment: Qt.AlignCenter hideTimer.stop()
unloadTimer.stop() // Cancel unload if hovering
property bool isActive: ToplevelManager.activeToplevel && ToplevelManager.activeToplevel === modelData
property bool hovered: appMouseArea.containsMouse
property string appId: modelData ? modelData.appId : ""
property string appTitle: modelData ? modelData.title : ""
// Individual tooltip for this app
NTooltip {
id: appTooltip
target: appButton
positionAbove: true
visible: false
} }
}
Image { onExited: {
id: appIcon dockHovered = false
width: iconSize if (autoHide && !anyAppHovered && !peekHovered) {
height: iconSize hideTimer.restart()
anchors.centerIn: parent }
source: dock.getAppIcon(modelData) }
visible: source.toString() !== "" }
sourceSize.width: iconSize * 2
sourceSize.height: iconSize * 2
smooth: true
mipmap: true
antialiasing: true
fillMode: Image.PreserveAspectFit
cache: true
scale: appButton.hovered ? 1.15 : 1.0 Item {
id: dock
width: dockLayout.implicitWidth
height: parent.height - (Style.marginM * 2 * scaling)
anchors.centerIn: parent
Behavior on scale { function getAppIcon(toplevel: Toplevel): string {
NumberAnimation { if (!toplevel)
duration: Style.animationNormal return ""
easing.type: Easing.OutBack return AppIcons.iconForAppId(toplevel.appId?.toLowerCase())
easing.overshoot: 1.2 }
RowLayout {
id: dockLayout
spacing: Style.marginM * scaling
Layout.preferredHeight: parent.height
anchors.centerIn: parent
Repeater {
model: ToplevelManager ? ToplevelManager.toplevels : null
delegate: Item {
id: appButton
Layout.preferredWidth: iconSize
Layout.preferredHeight: iconSize
Layout.alignment: Qt.AlignCenter
property bool isActive: ToplevelManager.activeToplevel
&& ToplevelManager.activeToplevel === modelData
property bool hovered: appMouseArea.containsMouse
property string appId: modelData ? modelData.appId : ""
property string appTitle: modelData ? modelData.title : ""
// Individual tooltip for this app
NTooltip {
id: appTooltip
target: appButton
positionAbove: true
visible: false
} }
}
}
// Fall back if no icon Image {
NIcon { id: appIcon
anchors.centerIn: parent width: iconSize
visible: !appIcon.visible height: iconSize
icon: "question-mark" anchors.centerIn: parent
font.pointSize: iconSize * 0.7 source: dock.getAppIcon(modelData)
color: appButton.isActive ? Color.mPrimary : Color.mOnSurfaceVariant visible: source.toString() !== ""
scale: appButton.hovered ? 1.15 : 1.0 sourceSize.width: iconSize * 2
sourceSize.height: iconSize * 2
smooth: true
mipmap: true
antialiasing: true
fillMode: Image.PreserveAspectFit
cache: true
Behavior on scale { scale: appButton.hovered ? 1.15 : 1.0
NumberAnimation {
duration: Style.animationFast
easing.type: Easing.OutBack
easing.overshoot: 1.2
}
}
}
MouseArea { Behavior on scale {
id: appMouseArea NumberAnimation {
anchors.fill: parent duration: Style.animationNormal
hoverEnabled: true easing.type: Easing.OutBack
cursorShape: Qt.PointingHandCursor easing.overshoot: 1.2
acceptedButtons: Qt.LeftButton | Qt.MiddleButton }
onEntered: {
anyAppHovered = true
const appName = appButton.appTitle || appButton.appId || "Unknown"
appTooltip.text = appName.length > 40 ? appName.substring(0, 37) + "..." : appName
appTooltip.isVisible = true
if (autoHide) {
showTimer.stop()
hideTimer.stop()
if (hidden) {
hidden = false
} }
} }
}
onExited: { // Fall back if no icon
anyAppHovered = false NIcon {
appTooltip.hide() anchors.centerIn: parent
// Only start hide timer if we're not hovering over the dock or peek area visible: !appIcon.visible
if (autoHide && !dockHovered && !peekArea.containsMouse) { icon: "question-mark"
hideTimer.restart() font.pointSize: iconSize * 0.7
} color: appButton.isActive ? Color.mPrimary : Color.mOnSurfaceVariant
} scale: appButton.hovered ? 1.15 : 1.0
onClicked: function (mouse) { Behavior on scale {
if (mouse.button === Qt.MiddleButton && modelData?.close) { NumberAnimation {
modelData.close() duration: Style.animationFast
easing.type: Easing.OutBack
easing.overshoot: 1.2
}
}
} }
if (mouse.button === Qt.LeftButton && modelData?.activate) {
modelData.activate()
}
}
}
// Active indicator MouseArea {
Rectangle { id: appMouseArea
visible: isActive anchors.fill: parent
width: iconSize * 0.2 hoverEnabled: true
height: iconSize * 0.1 cursorShape: Qt.PointingHandCursor
color: Color.mPrimary acceptedButtons: Qt.LeftButton | Qt.MiddleButton
radius: Style.radiusXS * scaling
anchors.top: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
// Pulse animation for active indicator onEntered: {
SequentialAnimation on opacity { anyAppHovered = true
running: isActive const appName = appButton.appTitle || appButton.appId || "Unknown"
loops: Animation.Infinite appTooltip.text = appName.length > 40 ? appName.substring(0, 37) + "..." : appName
NumberAnimation { appTooltip.isVisible = true
to: 0.6 if (autoHide) {
duration: Style.animationSlowest showTimer.stop()
easing.type: Easing.InOutQuad hideTimer.stop()
unloadTimer.stop() // Cancel unload if hovering app
}
}
onExited: {
anyAppHovered = false
appTooltip.hide()
if (autoHide && !dockHovered && !peekHovered) {
hideTimer.restart()
}
}
onClicked: function (mouse) {
if (mouse.button === Qt.MiddleButton && modelData?.close) {
modelData.close()
}
if (mouse.button === Qt.LeftButton && modelData?.activate) {
modelData.activate()
}
}
} }
NumberAnimation {
to: 1.0 // Active indicator
duration: Style.animationSlowest Rectangle {
easing.type: Easing.InOutQuad visible: isActive
width: iconSize * 0.2
height: iconSize * 0.1
color: Color.mPrimary
radius: Style.radiusXS * scaling
anchors.top: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
// Pulse animation for active indicator
SequentialAnimation on opacity {
running: isActive
loops: Animation.Infinite
NumberAnimation {
to: 0.6
duration: Style.animationSlowest
easing.type: Easing.InOutQuad
}
NumberAnimation {
to: 1.0
duration: Style.animationSlowest
easing.type: Easing.InOutQuad
}
}
} }
} }
} }

View file

@ -53,32 +53,32 @@ ColumnLayout {
} }
} }
// ColumnLayout { ColumnLayout {
// spacing: Style.marginXXS * scaling spacing: Style.marginXXS * scaling
// Layout.fillWidth: true Layout.fillWidth: true
// NLabel { NLabel {
// label: "Dock Floating Distance" label: "Dock Floating Distance"
// description: "Adjust the floating distance from the screen edge." description: "Adjust the floating distance from the screen edge."
// } }
// RowLayout { RowLayout {
// NSlider { NSlider {
// Layout.fillWidth: true Layout.fillWidth: true
// from: 0 from: 0
// to: 4 to: 4
// stepSize: 0.01 stepSize: 0.01
// value: Settings.data.dock.floatingRatio value: Settings.data.dock.floatingRatio
// onMoved: Settings.data.dock.floatingRatio = value onMoved: Settings.data.dock.floatingRatio = value
// cutoutColor: Color.mSurface cutoutColor: Color.mSurface
// } }
// NText { NText {
// text: Math.floor(Settings.data.dock.floatingRatio * 100) + "%" text: Math.floor(Settings.data.dock.floatingRatio * 100) + "%"
// Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
// Layout.leftMargin: Style.marginS * scaling Layout.leftMargin: Style.marginS * scaling
// color: Color.mOnSurface color: Color.mOnSurface
// } }
// } }
// } }
} }