small quickshell changes

This commit is contained in:
Daniel Bulant 2025-06-20 10:13:58 +02:00
parent 3fc1005c35
commit 92877d2341
No known key found for this signature in database
4 changed files with 63 additions and 42 deletions

View file

@ -11,7 +11,8 @@ Scope {
property font customFont: Qt.font({ property font customFont: Qt.font({
bold: true, bold: true,
pointSize: 12, pointSize: 12,
family: "FantasqueSansMNerdFont" // forgot which font I'm actually using, this yields some fallback that works well.
family: "NF"
}) })
Variants { Variants {
@ -34,8 +35,8 @@ Scope {
right: 10 right: 10
} }
height: 50 implicitHeight: 50
color: "#171a18" color: "#15121b"
RowLayout { RowLayout {
spacing: 15 spacing: 15
@ -54,8 +55,8 @@ Scope {
HyprlandWorkspacesWidget { HyprlandWorkspacesWidget {
font: customFont font: customFont
default_color: "#689D6A" default_color: "#cdd6f4"
active_color: "#8ec07c" active_color: "#ebbcba"
empty_color: "#928374" empty_color: "#928374"
spacing: 15 spacing: 15
} }

View file

@ -1,39 +1,52 @@
import QtQuick import QtQuick
import Quickshell.Hyprland import Quickshell.Hyprland
import Quickshell.Widgets
Text { WrapperRectangle {
id: text
required property int id required property int id
required property string icon required property string icon
required property color default_color required property color default_color
required property color empty_color required property color empty_color
required property color active_color required property color active_color
required property font font
property bool active: false
color: active ? "#753a88" : "transparent"
text: icon radius: 20
color: empty_color topMargin: 3
bottomMargin: 3
leftMargin: active ? 12 : 6
rightMargin: active ? 12 : 6
Component.onCompleted: { Text {
Hyprland.rawEvent.connect(hyprEvent) text: icon
colorWorkspace() color: active ? parent.active_color : parent.empty_color
} font: parent.font
function hyprEvent(e) { Component.onCompleted: {
if (e.name == "workspace") { Hyprland.rawEvent.connect(hyprEvent)
if (e.data == id) { colorWorkspace()
text.color = text.active_color }
function hyprEvent(e) {
if (e.name == "workspace") {
parent.active = e.data == id
if (e.data == id) {
text.color = parent.active_color
} else {
colorWorkspace()
}
}
}
function colorWorkspace() {
if (Hyprland.workspaces.values.some((w) => {
return w.id == id && w.lastIpcObject.windows > 0
})) {
text.color = parent.default_color
} else { } else {
colorWorkspace() text.color = parent.empty_color
} }
} }
} }
function colorWorkspace() {
if (Hyprland.workspaces.values.some((w) => {
return w.id == id && w.lastIpcObject.windows > 0
})) {
text.color = text.default_color
} else {
text.color = text.empty_color
}
}
} }

View file

@ -10,8 +10,8 @@ PanelWindow {
required property color text_color required property color text_color
property list<QtObject> notification_objects property list<QtObject> notification_objects
width: 500 implicitWidth: 500
height: 600 implicitHeight: 600
color: "#171a18" color: "#171a18"

View file

@ -4,7 +4,7 @@ import QtQuick.Layouts
RowLayout { RowLayout {
id: container id: container
property var icons: {1: "一", 2: "二", 3: "三", 4: "四", 5: "五"} property var icons: {1: "1", 2: "2", 3: "3", 4: "4", 5: "5"}
property int nWorkspaces: 5 property int nWorkspaces: 5
property font font property font font
property color default_color property color default_color
@ -12,22 +12,29 @@ RowLayout {
property color active_color property color active_color
Component.onCompleted: { Component.onCompleted: {
var workspaceComponent = Qt.createComponent("../components/HyprlandWorkspace.qml"); var workspaceComponent = Qt.createComponent("../components/HyprlandWorkspace.qml")
Hyprland.rawEvent.connect(hyprEvent)
for (var i = 1; i <= nWorkspaces; i++) { for (var i = 1; i <= nWorkspaces; i++) {
var workspace = workspaceComponent var workspace = workspaceComponent
.createObject(container, .createObject(container,
{ {
id: i, id: i,
icon: icons[i], icon: icons[i],
font: font, font: font,
default_color: default_color, default_color: default_color,
empty_color: empty_color, empty_color: empty_color,
active_color: active_color active_color: active_color
} }
) )
if (workspace == null) { if (workspace == null) {
console.log("Error creating workspace") console.log("Error creating workspace")
} }
} }
} }
function hyprEvent(e) {
// console.log(e.name, e.data)
// console.log(Hyprland.workspaces.values)
// console.log(Hyprland)
}
} }