forked from Shinonome/dots-hyprland
bar: move number showing logic from GlobalStates to Workspaces
This commit is contained in:
@@ -32,32 +32,15 @@ Singleton {
|
|||||||
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
|
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
// When user is not reluctant while pressing super, they probably don't need to see workspace numbers
|
|
||||||
onSuperReleaseMightTriggerChanged: {
|
|
||||||
workspaceShowNumbersTimer.stop()
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: workspaceShowNumbersTimer
|
|
||||||
interval: Config.options.bar.workspaces.showNumberDelay
|
|
||||||
repeat: false
|
|
||||||
onTriggered: {
|
|
||||||
workspaceShowNumbers = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GlobalShortcut {
|
GlobalShortcut {
|
||||||
name: "workspaceNumber"
|
name: "workspaceNumber"
|
||||||
description: "Hold to show workspace numbers, release to show icons"
|
description: "Hold to show workspace numbers, release to show icons"
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
root.superDown = true
|
root.superDown = true
|
||||||
workspaceShowNumbersTimer.start()
|
|
||||||
}
|
}
|
||||||
onReleased: {
|
onReleased: {
|
||||||
root.superDown = false
|
root.superDown = false
|
||||||
workspaceShowNumbersTimer.stop()
|
|
||||||
workspaceShowNumbers = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,30 @@ Item {
|
|||||||
property real workspaceIconMarginShrinked: -4
|
property real workspaceIconMarginShrinked: -4
|
||||||
property int workspaceIndexInGroup: (monitor?.activeWorkspace?.id - 1) % Config.options.bar.workspaces.shown
|
property int workspaceIndexInGroup: (monitor?.activeWorkspace?.id - 1) % Config.options.bar.workspaces.shown
|
||||||
|
|
||||||
|
property bool showNumbers: false
|
||||||
|
Timer {
|
||||||
|
id: showNumbersTimer
|
||||||
|
interval: (Config?.options.bar.autoHide.showWhenPressingSuper.delay ?? 100)
|
||||||
|
repeat: false
|
||||||
|
onTriggered: {
|
||||||
|
root.showNumbers = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: GlobalStates
|
||||||
|
function onSuperDownChanged() {
|
||||||
|
if (!Config?.options.bar.autoHide.showWhenPressingSuper.enable) return;
|
||||||
|
if (GlobalStates.superDown) showNumbersTimer.restart();
|
||||||
|
else {
|
||||||
|
showNumbersTimer.stop();
|
||||||
|
root.showNumbers = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function onSuperReleaseMightTriggerChanged() {
|
||||||
|
showNumbersTimer.stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Function to update workspaceOccupied
|
// Function to update workspaceOccupied
|
||||||
function updateWorkspaceOccupied() {
|
function updateWorkspaceOccupied() {
|
||||||
workspaceOccupied = Array.from({ length: Config.options.bar.workspaces.shown }, (_, i) => {
|
workspaceOccupied = Array.from({ length: Config.options.bar.workspaces.shown }, (_, i) => {
|
||||||
@@ -176,9 +200,9 @@ Item {
|
|||||||
property var mainAppIconSource: Quickshell.iconPath(AppSearch.guessIcon(biggestWindow?.class), "image-missing")
|
property var mainAppIconSource: Quickshell.iconPath(AppSearch.guessIcon(biggestWindow?.class), "image-missing")
|
||||||
|
|
||||||
StyledText { // Workspace number text
|
StyledText { // Workspace number text
|
||||||
opacity: GlobalStates.workspaceShowNumbers
|
opacity: root.showNumbers
|
||||||
|| ((Config.options?.bar.workspaces.alwaysShowNumbers && (!Config.options?.bar.workspaces.showAppIcons || !workspaceButtonBackground.biggestWindow || GlobalStates.workspaceShowNumbers))
|
|| ((Config.options?.bar.workspaces.alwaysShowNumbers && (!Config.options?.bar.workspaces.showAppIcons || !workspaceButtonBackground.biggestWindow || root.showNumbers))
|
||||||
|| (GlobalStates.workspaceShowNumbers && !Config.options?.bar.workspaces.showAppIcons)
|
|| (root.showNumbers && !Config.options?.bar.workspaces.showAppIcons)
|
||||||
) ? 1 : 0
|
) ? 1 : 0
|
||||||
z: 3
|
z: 3
|
||||||
|
|
||||||
@@ -200,7 +224,7 @@ Item {
|
|||||||
Rectangle { // Dot instead of ws number
|
Rectangle { // Dot instead of ws number
|
||||||
id: wsDot
|
id: wsDot
|
||||||
opacity: (Config.options?.bar.workspaces.alwaysShowNumbers
|
opacity: (Config.options?.bar.workspaces.alwaysShowNumbers
|
||||||
|| GlobalStates.workspaceShowNumbers
|
|| root.showNumbers
|
||||||
|| (Config.options?.bar.workspaces.showAppIcons && workspaceButtonBackground.biggestWindow)
|
|| (Config.options?.bar.workspaces.showAppIcons && workspaceButtonBackground.biggestWindow)
|
||||||
) ? 0 : 1
|
) ? 0 : 1
|
||||||
visible: opacity > 0
|
visible: opacity > 0
|
||||||
@@ -222,20 +246,20 @@ Item {
|
|||||||
width: workspaceButtonWidth
|
width: workspaceButtonWidth
|
||||||
height: workspaceButtonWidth
|
height: workspaceButtonWidth
|
||||||
opacity: !Config.options?.bar.workspaces.showAppIcons ? 0 :
|
opacity: !Config.options?.bar.workspaces.showAppIcons ? 0 :
|
||||||
(workspaceButtonBackground.biggestWindow && !GlobalStates.workspaceShowNumbers && Config.options?.bar.workspaces.showAppIcons) ?
|
(workspaceButtonBackground.biggestWindow && !root.showNumbers && Config.options?.bar.workspaces.showAppIcons) ?
|
||||||
1 : workspaceButtonBackground.biggestWindow ? workspaceIconOpacityShrinked : 0
|
1 : workspaceButtonBackground.biggestWindow ? workspaceIconOpacityShrinked : 0
|
||||||
visible: opacity > 0
|
visible: opacity > 0
|
||||||
IconImage {
|
IconImage {
|
||||||
id: mainAppIcon
|
id: mainAppIcon
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottomMargin: (!GlobalStates.workspaceShowNumbers && Config.options?.bar.workspaces.showAppIcons) ?
|
anchors.bottomMargin: (!root.showNumbers && Config.options?.bar.workspaces.showAppIcons) ?
|
||||||
(workspaceButtonWidth - workspaceIconSize) / 2 : workspaceIconMarginShrinked
|
(workspaceButtonWidth - workspaceIconSize) / 2 : workspaceIconMarginShrinked
|
||||||
anchors.rightMargin: (!GlobalStates.workspaceShowNumbers && Config.options?.bar.workspaces.showAppIcons) ?
|
anchors.rightMargin: (!root.showNumbers && Config.options?.bar.workspaces.showAppIcons) ?
|
||||||
(workspaceButtonWidth - workspaceIconSize) / 2 : workspaceIconMarginShrinked
|
(workspaceButtonWidth - workspaceIconSize) / 2 : workspaceIconMarginShrinked
|
||||||
|
|
||||||
source: workspaceButtonBackground.mainAppIconSource
|
source: workspaceButtonBackground.mainAppIconSource
|
||||||
implicitSize: (!GlobalStates.workspaceShowNumbers && Config.options?.bar.workspaces.showAppIcons) ? workspaceIconSize : workspaceIconSizeShrinked
|
implicitSize: (!root.showNumbers && Config.options?.bar.workspaces.showAppIcons) ? workspaceIconSize : workspaceIconSizeShrinked
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
|
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
|
||||||
|
|||||||
Reference in New Issue
Block a user