refaktor
This commit is contained in:
@@ -1,119 +1,83 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Io
|
||||
import "../../../colors"
|
||||
import "../../../config"
|
||||
import "../states/Apps"
|
||||
|
||||
Row { // Workspace Row
|
||||
Row {
|
||||
id: workspacesRow
|
||||
|
||||
required property HyprlandMonitor thisMonitor
|
||||
spacing: Math.floor(bar.height/4)
|
||||
spacing: Config.spacing_fun(bar.height)
|
||||
|
||||
// Get infos of Type Unknown
|
||||
// Repeater {
|
||||
// model: Hyprland.workspaces
|
||||
|
||||
// Rectangle {
|
||||
// Component.onCompleted: {
|
||||
// console.log("roles:")
|
||||
// console.log("id:", modelData.id)
|
||||
// console.log("monitor:", modelData.monitor)
|
||||
// console.log("monitorId:", modelData.monitorId)
|
||||
// console.log("name:", modelData.name)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
Repeater { // repeats workspaces
|
||||
Repeater {
|
||||
model: Hyprland.workspaces
|
||||
Loader {
|
||||
active: modelData.monitor === thisMonitor
|
||||
sourceComponent: Rectangle { //workspace
|
||||
// visible: modelData.monitor === thisMonitor
|
||||
width: workspaceText.text.length === 0 ? Math.max(workspaceNum.width + Config.spacing*2, workspaceNum.height + Config.spacing) : Math.max(workspaceNum.width + workspaceText.width + Config.spacing*2, bar.height)
|
||||
height: workspaceNum.height + Config.spacing
|
||||
radius: Config.small_radius
|
||||
color: (
|
||||
workspaceButton.containsMouse ? Colors.tertiaryContainer :
|
||||
modelData.active ? Colors.primaryContainer :
|
||||
Colors.secondaryContainer
|
||||
)
|
||||
border.color: (
|
||||
workspaceButton.containsMouse ? Colors.tertiaryContainer_fg :
|
||||
modelData.active ? Colors.primaryContainer_fg :
|
||||
Colors.secondaryContainer_fg
|
||||
)
|
||||
sourceComponent: Rectangle {
|
||||
id: wsRect
|
||||
property var workspaceData: modelData
|
||||
|
||||
width: {
|
||||
var cw = wsNum.width
|
||||
if (wsIconsRow.children.length > 0)
|
||||
cw += Config.spacing_fun(workspacesRow.height) + wsIconsRow.width
|
||||
Math.max(cw + Config.spacing_fun(workspacesRow.height), wsNum.height + Config.spacing_fun(workspacesRow.height))
|
||||
}
|
||||
height: wsNum.height + Config.spacing_fun(wsNum.height)
|
||||
radius: Config.radius_fun(height)
|
||||
color: wsArea.containsMouse ? Colors.tertiaryContainer
|
||||
: workspaceData.active ? Colors.primaryContainer
|
||||
: Colors.secondaryContainer
|
||||
border.color: wsArea.containsMouse ? Colors.tertiaryContainer_fg
|
||||
: workspaceData.active ? Colors.primaryContainer_fg
|
||||
: Colors.secondaryContainer_fg
|
||||
border.width: Config.border_width
|
||||
|
||||
MouseArea {
|
||||
id: workspaceButton
|
||||
id: wsArea
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
Hyprland.dispatch("workspace " + modelData.id)
|
||||
// console.log("workspaceText: " + workspaceText.text.length)
|
||||
console.log("[Workspaces] Switch to workspace: " + workspaceData.id)
|
||||
Hyprland.dispatch("workspace " + workspaceData.id)
|
||||
}
|
||||
|
||||
|
||||
Row {
|
||||
id: workspaceRow
|
||||
anchors.centerIn: parent
|
||||
spacing: Math.floor(bar.height/8)
|
||||
leftPadding: workspaceText.text.length === 0 ? 0 : Math.floor(bar.height / 4)
|
||||
spacing: Config.spacing_fun(parent.height)
|
||||
|
||||
Text {
|
||||
id: workspaceNum
|
||||
text: modelData.id
|
||||
id: wsNum
|
||||
text: workspaceData.id
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: workspaceButton.containsMouse ? Colors.tertiary
|
||||
: modelData.active ? Colors.primary
|
||||
color: wsArea.containsMouse ? Colors.tertiary
|
||||
: workspaceData.active ? Colors.primary
|
||||
: Colors.secondary
|
||||
|
||||
font.pixelSize: Config.medium_scaling(bar.height)
|
||||
font.pixelSize: Config.iconSize(bar.height)
|
||||
font.family: Config.font
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
Text {
|
||||
id: workspaceText
|
||||
text: ""
|
||||
Row {
|
||||
id: wsIconsRow
|
||||
spacing: Config.spacing_fun(workspacesRow.height)
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: workspaceButton.containsMouse ? Colors.tertiary
|
||||
: modelData.active ? Colors.primary
|
||||
: Colors.secondary
|
||||
|
||||
font.pixelSize: Config.medium_scaling(bar.height)*0.8
|
||||
font.family: Config.font
|
||||
font.letterSpacing: Math.floor(Config.medium_scaling(bar.height) * (2 / 3))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: workspaceContent
|
||||
command: ["sh", "-c", Quickshell.env("HOME") + "/.config/quickshell/modules/bar/scripts/Apps.sh " + modelData.id]
|
||||
running: true
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
if (this.text.length > 1) {
|
||||
workspaceText.text = this.text
|
||||
} else {
|
||||
workspaceText.text = ""
|
||||
Repeater {
|
||||
model: AppsState.iconsForWorkspace(workspaceData.id)
|
||||
delegate: Text {
|
||||
text: modelData
|
||||
color: wsArea.containsMouse ? Colors.tertiary
|
||||
: Colors.secondary
|
||||
font.pixelSize: Config.labelSize(bar.height)
|
||||
font.family: Config.font
|
||||
}
|
||||
}
|
||||
// console.log("workspaceScript output:", workspaceText.text, workspaceText.text.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: Config.fast_reload_interval
|
||||
running: true
|
||||
repeat: true
|
||||
onTriggered: workspaceContent.running = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,6 +86,6 @@ Row { // Workspace Row
|
||||
visible: Hyprland.workspaces.length === 0
|
||||
text: "No Workspaces"
|
||||
color: Colors.error
|
||||
font.pixelSize: Config.big_font_size(bar.height)
|
||||
font.pixelSize: Config.iconSize(bar.height)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user