use Dimensions config

This commit is contained in:
Benjamin Palko 2025-07-19 00:10:21 -04:00
parent dd6d45c4b6
commit 6df0784136
7 changed files with 147 additions and 63 deletions

44
config/Dimensions.qml Normal file
View file

@ -0,0 +1,44 @@
pragma Singleton
import QtQuick
import Quickshell
Singleton {
id: root
property int radius: 8
property Bar bar: Bar {}
property Clock clock: Clock {}
property Workspace workspace: Workspace {}
component Bar: QtObject {
id: bar
property int spacing: 6
property int border: 2
property int height: 50
property int verticalMargins: 4
property int horizontalMargins: 6
property int verticalPadding: 2
property int horizontalPadding: 6
}
component Clock: QtObject {
id: clock
property int fontSize: 14
property int width: 230
property int height: 30
}
component Workspace: QtObject {
id: workspace
property int spacing: 5
property int width: 30
property int height: 30
property int verticalPadding: 6
property int horizontalPadding: 7
}
}

View file

@ -13,24 +13,41 @@ Scope {
right: true right: true
} }
implicitHeight: 40 implicitHeight: Dimensions.bar.height
color: 'transparent' color: 'transparent'
Item {
anchors.fill: parent
anchors.leftMargin: Dimensions.bar.horizontalMargins
anchors.rightMargin: Dimensions.bar.horizontalMargins
anchors.topMargin: Dimensions.bar.verticalMargins
anchors.bottomMargin: Dimensions.bar.verticalMargins
Rectangle { Rectangle {
id: background id: background
anchors.fill: parent anchors.fill: parent
color: Theme.palette.base300 color: Theme.palette.base300
radius: Dimensions.radius
border {
color: Theme.palette.base100
width: Dimensions.bar.border
pixelAligned: true
}
} }
Row { Row {
id: leftbar id: leftbar
spacing: 6
anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.bottom: parent.bottom anchors.verticalCenter: parent.verticalCenter
anchors.margins: 2
anchors.leftMargin: Dimensions.bar.horizontalPadding
anchors.topMargin: Dimensions.bar.verticalPadding
anchors.bottomMargin: Dimensions.bar.verticalPadding
spacing: Dimensions.bar.spacing
Workspaces { Workspaces {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -40,10 +57,13 @@ Scope {
Row { Row {
id: centerbar id: centerbar
spacing: 6
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top anchors.verticalCenter: parent.verticalCenter
anchors.bottom: parent.bottom
anchors.topMargin: Dimensions.bar.verticalPadding
anchors.bottomMargin: Dimensions.bar.verticalPadding
spacing: Dimensions.bar.spacing
Clock {} Clock {}
} }
@ -51,9 +71,15 @@ Scope {
Row { Row {
id: rightbar id: rightbar
anchors.top: parent.top
anchors.right: parent.left anchors.right: parent.left
anchors.bottom: parent.bottom anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: Dimensions.bar.horizontalPadding
anchors.topMargin: Dimensions.bar.verticalPadding
anchors.bottomMargin: Dimensions.bar.verticalPadding
spacing: Dimensions.bar.spacing
}
} }
} }
} }

View file

@ -1,48 +1,39 @@
import Quickshell
import Quickshell.Io import Quickshell.Io
import QtQuick import QtQuick
import "root:styled" import "root:styled"
import "../../../config/"
Item { Item {
id: clock id: clock
implicitWidth: 200 implicitWidth: Dimensions.clock.width
implicitHeight: 30 implicitHeight: Dimensions.clock.height
StyledLabel { StyledLabel {
anchors.fill: parent anchors.fill: text
} }
StyledText { StyledText {
id: text id: text
anchors.centerIn: parent anchors.centerIn: parent
font.pixelSize: Dimensions.clock.fontSize
Process { Process {
// give the process object an id so we can talk
// about it from the timer
id: dateProc id: dateProc
command: ["date"] command: ["date"]
running: true running: true
stdout: StdioCollector { stdout: StdioCollector {
onStreamFinished: text.text = this.text onStreamFinished: text.text = ` ${this.text}`
} }
} }
// use a timer to rerun the process at an interval
Timer { Timer {
// 1000 milliseconds is 1 second
interval: 1000 interval: 1000
// start the timer immediately
running: true running: true
// run the timer again when it ends
repeat: true repeat: true
// when the timer is triggered, set the running property of the
// process to true, which reruns it if stopped.
onTriggered: dateProc.running = true onTriggered: dateProc.running = true
} }
} }

View file

@ -10,29 +10,50 @@ Item {
visible: modelData.id > 0 visible: modelData.id > 0
width: 30 width: Dimensions.workspace.width
height: 30 height: Dimensions.workspace.height
Rectangle {
id: rectangle
anchors.fill: button
color: Theme.palette.base100
radius: Dimensions.radius
}
Button { Button {
id: button id: button
anchors.centerIn: parent anchors.centerIn: parent
padding: 6 verticalPadding: Dimensions.workspace.verticalPadding
leftPadding: 7 horizontalPadding: Dimensions.workspace.horizontalPadding
rightPadding: 7
background: Rectangle { background: null
id: rectangle
anchors.fill: parent
color: "#161212"
radius: 8
}
rotation: workspace.modelData.active ? 0 : 180
icon.source: "/home/baobeld/dotfiles/quickshell/assets/triangle.svg" icon.source: "/home/baobeld/dotfiles/quickshell/assets/triangle.svg"
icon.color: workspace.modelData.active ? Theme.palette.primary : Theme.palette.basecontent icon.color: Theme.palette.basecontent
onClicked: workspace.modelData.activate() onClicked: workspace.modelData.activate()
states: State {
name: "active"
when: workspace.modelData.active
PropertyChanges {
button {
rotation: 180
icon.color: Theme.palette.primary
}
}
}
transitions: Transition {
from: ""
to: "active"
reversible: true
NumberAnimation {
properties: "rotation"
duration: 250
easing.type: Easing.InOutQuad
}
}
} }
} }

View file

@ -1,11 +1,12 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import Quickshell.Hyprland import Quickshell.Hyprland
import "../../../config/"
Row { Row {
id: root id: root
spacing: 4 spacing: Dimensions.workspace.spacing
Repeater { Repeater {

View file

@ -1,8 +1,8 @@
import QtQuick import QtQuick
import "root:config" import "../config/"
Rectangle { Rectangle {
color: Theme.palette.base100 color: Theme.palette.base100
radius: 5 radius: Dimensions.radius
} }

View file

@ -3,4 +3,5 @@ import "root:config"
Text { Text {
color: Theme.palette.basecontent color: Theme.palette.basecontent
font.family: Theme.fontFamily
} }