refaktor
This commit is contained in:
@@ -2,23 +2,18 @@ import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Io
|
||||
import "../../../colors"
|
||||
import "../../../config"
|
||||
import "../states/Battery"
|
||||
|
||||
MouseArea {
|
||||
id: batteryButton
|
||||
width: clicked ? Math.max(batteryPercentageText.width + parent.spacing*3, bar.height) : Math.max(batteryText.width + parent.spacing*2, bar.height)
|
||||
width: expanded ? Math.max(batteryPercentageText.width + Config.spacing_fun(height), bar.height) : Math.max(batteryText.width + Config.spacing_fun(height)*2, bar.height)
|
||||
height: bar.height
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
visible: false
|
||||
visible: BatteryState.available
|
||||
|
||||
property bool clicked: false
|
||||
|
||||
Component.onCompleted: {
|
||||
batteryAvailibleScript.running = true
|
||||
}
|
||||
property bool expanded: false
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
@@ -30,7 +25,7 @@ MouseArea {
|
||||
|
||||
Text {
|
||||
id: batteryText
|
||||
visible : !clicked
|
||||
visible : !expanded
|
||||
anchors.centerIn: parent
|
||||
text:(
|
||||
BatteryState.percentage >= 95 ? "" :
|
||||
@@ -39,10 +34,13 @@ MouseArea {
|
||||
BatteryState.percentage >= 25 ? "" :
|
||||
""
|
||||
)
|
||||
font.pixelSize: Config.big_font_size(bar.height)
|
||||
font.pixelSize: Config.font_size(batteryButton.height)
|
||||
font.family: Config.font
|
||||
color: (
|
||||
BatteryState.charging ? BatteryState.percentage == 100 ? "white" : Colors.tertiary :
|
||||
BatteryState.charging ? (
|
||||
BatteryState.percentage == 100 ? Colors.secondary :
|
||||
Colors.tertiary
|
||||
) :
|
||||
BatteryState.percentage <= 5 ? Colors.errorContainer :
|
||||
BatteryState.percentage < 10 ? "yellow" :
|
||||
batteryButton.containsMouse ? Colors.tertiary_fg :
|
||||
@@ -51,11 +49,11 @@ MouseArea {
|
||||
}
|
||||
|
||||
Text {
|
||||
id: batteryChargingText
|
||||
visible : !clicked && BatteryState.charging
|
||||
id: chargeIcon
|
||||
visible : !expanded && BatteryState.charging
|
||||
anchors.centerIn: parent
|
||||
text: ""
|
||||
font.pixelSize: Config.big_font_size(bar.height)
|
||||
font.pixelSize: Config.iconSize(batteryButton.height)
|
||||
font.family: Config.font
|
||||
style: Text.Outline
|
||||
styleColor: Qt.alpha(Colors.tertiaryContainer, 0.5)
|
||||
@@ -63,10 +61,10 @@ MouseArea {
|
||||
}
|
||||
|
||||
Row {
|
||||
id: batteryPercentageRow
|
||||
visible: clicked
|
||||
id: expandedRow
|
||||
visible: expanded
|
||||
anchors.centerIn: parent
|
||||
spacing: batteryButton.parent.spacing/2
|
||||
spacing: Config.spacing_fun(batteryButton.height)
|
||||
|
||||
Text {
|
||||
id: batteryPercentageSymbol
|
||||
@@ -85,13 +83,16 @@ MouseArea {
|
||||
""
|
||||
)
|
||||
|
||||
font.pixelSize: batteryText.font.pixelSize * 0.75
|
||||
font.family: "CodeNewRoman Nerd Font"
|
||||
font.pixelSize: Config.labelSize(batteryButton.height)
|
||||
font.family: Config.font
|
||||
font.bold: true
|
||||
|
||||
color: (
|
||||
BatteryState.percentage <= 5 ? "red" :
|
||||
BatteryState.charging ? "green" :
|
||||
BatteryState.percentage <= 5 ? Colors.errorContainer :
|
||||
BatteryState.charging ? (
|
||||
BatteryState.percentage == 100 ? Colors.secondary :
|
||||
Colors.tertiary
|
||||
) :
|
||||
BatteryState.percentage < 10 ? "yellow" :
|
||||
batteryButton.containsMouse ? Colors.tertiary_fg :
|
||||
Colors.primary
|
||||
@@ -102,8 +103,8 @@ MouseArea {
|
||||
id: batteryPercentageText
|
||||
text: BatteryState.percentage + "%"
|
||||
|
||||
font.pixelSize: batteryText.font.pixelSize * 0.75
|
||||
font.family: "CodeNewRoman Nerd Font"
|
||||
font.pixelSize: Config.labelSize(batteryButton.height)
|
||||
font.family: Config.font
|
||||
font.bold: true
|
||||
|
||||
color: batteryPercentageSymbol.color
|
||||
@@ -111,25 +112,9 @@ MouseArea {
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: batteryAvailibleScript
|
||||
command: ["sh", "-c", "upower -e | grep -q '^/org/freedesktop/UPower/devices/battery' && echo '1' || echo '0'"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const hasBattery = this.text.trim() === "1"
|
||||
|
||||
batteryButton.visible = hasBattery
|
||||
if (hasBattery) {
|
||||
BatteryState.start()
|
||||
}
|
||||
|
||||
// console.log("battery available:", hasBattery)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
batteryButton.clicked = !batteryButton.clicked
|
||||
expanded = !expanded
|
||||
console.log("[Battery] Expanded: " + expanded + ", percentage: " + BatteryState.percentage + "%, charging: " + BatteryState.charging)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,68 +1,70 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import "../../../colors"
|
||||
import "../../../config"
|
||||
|
||||
Rectangle { //workspace
|
||||
id: timeAnchore
|
||||
width: dateTimer.running ? Math.max(dateDisplay.width + timeDisplay.width + Config.spacing*3, bar.height) : Math.max(dateDisplay.width + timeDisplay.width + Config.spacing*2, bar.height)
|
||||
id: clockRect
|
||||
width: dateTimer.running ? Math.max(dateText.width + timeText.width + Config.spacing_fun(height)*3, bar.height) : Math.max(dateText.width + timeText.width + Config.spacing_fun(height)*2, bar.height)
|
||||
height: bar.height
|
||||
radius: Config.radius
|
||||
color: timeAnchoreMouseArea.containsMouse ? Colors.tertiaryContainer : Colors.primaryContainer
|
||||
radius: Config.radius_fun(height)
|
||||
color: clockArea.containsMouse ? Colors.tertiaryContainer : Colors.primaryContainer
|
||||
border.color: (
|
||||
timeAnchoreMouseArea.containsMouse ? Colors.tertiaryContainer_fg :
|
||||
clockArea.containsMouse ? Colors.tertiaryContainer_fg :
|
||||
Colors.primaryContainer_fg
|
||||
)
|
||||
border.width: Config.border_width
|
||||
|
||||
MouseArea {
|
||||
id: timeAnchoreMouseArea
|
||||
id: clockArea
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
||||
onClicked: {
|
||||
dateTimer.running = !dateTimer.running
|
||||
if (!dateTimer.running) dateText.currentDate = ""
|
||||
console.log("[Clock] Date visible: " + dateTimer.running)
|
||||
}
|
||||
|
||||
Row {
|
||||
id: row
|
||||
spacing: Config.spacing
|
||||
anchors.centerIn: parent
|
||||
|
||||
Text {
|
||||
id: dateDisplay
|
||||
id: dateText
|
||||
property string currentDate: ""
|
||||
|
||||
text: currentDate
|
||||
color: (
|
||||
timeAnchoreMouseArea.containsMouse ? Colors.tertiary :
|
||||
clockArea.containsMouse ? Colors.tertiary :
|
||||
Colors.primary
|
||||
)
|
||||
font.pixelSize: Math.floor(bar.height/2)
|
||||
font.family: "Inter, sans-serif"
|
||||
font.pixelSize: Config.font_size_small(clockRect.height)
|
||||
font.family: Config.font
|
||||
|
||||
Timer {
|
||||
id: dateTimer
|
||||
interval: 60000
|
||||
interval: Config.reload_interval
|
||||
running: false
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: {
|
||||
var now = new Date()
|
||||
dateDisplay.currentDate = Qt.formatDate(now, "ddd, dd.MM.yyyy -")
|
||||
dateText.currentDate = Qt.formatDate(now, "ddd, dd.MM.yyyy - ")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
id: timeDisplay
|
||||
id: timeText
|
||||
property string currentTime: ""
|
||||
|
||||
text: currentTime
|
||||
color: (
|
||||
timeAnchoreMouseArea.containsMouse ? Colors.tertiary :
|
||||
clockArea.containsMouse ? Colors.tertiary :
|
||||
Colors.primary
|
||||
)
|
||||
font.pixelSize: Math.floor(bar.height/2)
|
||||
font.family: "Inter, sans-serif"
|
||||
font.pixelSize: Config.font_size_small(clockRect.height)
|
||||
font.family: Config.font
|
||||
|
||||
Component.onCompleted: {
|
||||
var now = new Date()
|
||||
@@ -75,14 +77,10 @@ Rectangle { //workspace
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
var now = new Date()
|
||||
timeDisplay.currentTime = Qt.formatTime(now, "hh:mm:ss")
|
||||
timeText.currentTime = Qt.formatTime(now, "hh:mm:ss")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
onClicked: {
|
||||
dateDisplay.currentDate = "";
|
||||
dateTimer.running = !dateTimer.running;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,70 +2,50 @@ import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Io
|
||||
import "../../../colors"
|
||||
import "../../../config"
|
||||
import "../states/Idle" as Global
|
||||
import "../states/Idle"
|
||||
|
||||
MouseArea {
|
||||
id: idleButton
|
||||
width: Math.max(idleText.width + parent.spacing*2, bar.height)
|
||||
width: Math.max(idleText.width + Config.spacing_fun(height)*2, height)
|
||||
height: bar.height
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
||||
Component.onCompleted: {
|
||||
idleStatusScript.running = true
|
||||
onClicked: {
|
||||
var newState = IdleState.idle ? 0 : 1
|
||||
console.log("[IdleButton] Toggling idle: " + (newState ? "enabled" : "disabled"))
|
||||
idleToggleProc.startDetached()
|
||||
IdleState.idle = newState
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: idleButton.containsMouse ? Colors.tertiary : Qt.alpha(Colors.tertiaryContainer, 0.25)
|
||||
radius: Config.radius
|
||||
radius: Config.radius_fun(idleButton.height)
|
||||
border.width: Config.border_width
|
||||
border.color: idleButton.containsMouse ? Colors.tertiaryContainer_fg
|
||||
: Colors.secondaryContainer_fg
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
Process {
|
||||
id: idleScript
|
||||
command: ["sh", "-c", Quickshell.env("HOME") + "/.config/quickshell/modules/bar/scripts/Idle.sh"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: Global.IdleState.idle ? console.log(`Disabling Idle`) : console.log(`Enabling Idle`)
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
console.log("Running Idle Script")
|
||||
idleScript.startDetached()
|
||||
Global.IdleState.idle = !Global.IdleState.idle
|
||||
console.log("Current Idle State: " + Global.IdleState.idle)
|
||||
}
|
||||
}
|
||||
}
|
||||
border.color: (
|
||||
idleButton.containsMouse ? Colors.tertiaryContainer_fg :
|
||||
Colors.secondaryContainer_fg
|
||||
)
|
||||
|
||||
Text {
|
||||
id: idleText
|
||||
anchors.centerIn: parent
|
||||
text: Global.IdleState.idle ? "" : ""
|
||||
font.pixelSize: Config.big_font_size(bar.height)
|
||||
text: IdleState.idle ? "" : ""
|
||||
font.pixelSize: Config.iconSize(idleButton.height)
|
||||
font.family: Config.font
|
||||
color: idleButton.containsMouse ? Colors.tertiary_fg : idleText.text == "" ? Colors.primary : Colors.tertiary
|
||||
color: (
|
||||
idleButton.containsMouse ? Colors.tertiary_fg :
|
||||
IdleState.idle ? Colors.tertiary
|
||||
: Colors.primary
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Process {
|
||||
id: idleStatusScript
|
||||
command: ["sh", "-c", Quickshell.env("HOME") + "/.config/quickshell/modules/bar/scripts/Idle.sh" + " --status"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
Global.IdleState.idle = this.text.trim() === "0" ? 1 : 0
|
||||
}
|
||||
}
|
||||
id: idleToggleProc
|
||||
command: ["sh", "-c", Config.configDir + "/modules/bar/scripts/Idle.sh"]
|
||||
running: false
|
||||
}
|
||||
}
|
||||
@@ -1,45 +1,38 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Io
|
||||
import "../../../colors"
|
||||
import "../../../config"
|
||||
|
||||
MouseArea {
|
||||
id: archButton
|
||||
width: Math.max(bar.height, archButtonText.width+Config.spacing)
|
||||
id: menuButton
|
||||
width: Math.max(bar.height, menuText.width + Config.spacing)
|
||||
height: bar.height
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
||||
onClicked: {
|
||||
archButtonScript.running = true
|
||||
menuProc.running = true
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: archButton.containsMouse ? Colors.secondaryContainer_fg : Qt.alpha(Colors.secondary, 0.75)
|
||||
color: menuButton.containsMouse ? Colors.secondaryContainer_fg : Qt.alpha(Colors.secondary, 0.75)
|
||||
radius: Config.radius
|
||||
border.width: 0
|
||||
|
||||
Text {
|
||||
id: archButtonText
|
||||
id: menuText
|
||||
anchors.centerIn: parent
|
||||
text: ""
|
||||
font.pixelSize: Config.big_font_size(bar.height)
|
||||
font.pixelSize: Config.bigIconSize(menuButton.height)
|
||||
font.family: Config.font
|
||||
color: archButton.containsMouse ? Colors.secondaryContainer : Colors.secondary_fg
|
||||
color: menuButton.containsMouse ? Colors.secondaryContainer : Colors.secondary_fg
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: archButtonScript
|
||||
id: menuProc
|
||||
command: ["sh", "-c", "wofi --show drun"]
|
||||
running: false
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
console.log("Opening wofi")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Io
|
||||
import "../../../colors"
|
||||
import "../../../config"
|
||||
import "../states/Network" as Global
|
||||
import "../states/Network"
|
||||
|
||||
MouseArea {
|
||||
id: networkButton
|
||||
|
||||
width: Math.max(networkText.width + Config.spacing*2, bar.height)
|
||||
width: Math.max(networkText.width + Config.spacing_fun(height)*2, height)
|
||||
height: bar.height
|
||||
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
||||
onClicked: {
|
||||
Global.NetworkState.networkScript.running = true
|
||||
// networkStatus.running = true
|
||||
console.log("[Network] Refreshing... current status: " + NetworkState.status)
|
||||
NetworkState.networkScript.running = true
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -30,31 +26,11 @@ MouseArea {
|
||||
|
||||
Text {
|
||||
id: networkText
|
||||
text: Global.NetworkState.status
|
||||
text: NetworkState.status
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: Config.big_font_size(bar.height)
|
||||
font.pixelSize: Config.iconSize(bar.height)
|
||||
font.family: Config.font
|
||||
color: networkButton.containsMouse ? Colors.tertiary_fg : networkText.text === " /" ? Colors.error : Colors.primary
|
||||
}
|
||||
|
||||
// Process {
|
||||
// id: networkStatus
|
||||
// command: ["sh", "-c", Quickshell.env("HOME") + "/.config/quickshell/modules/bar/scripts/Network.sh"]
|
||||
// running: true
|
||||
|
||||
// stdout: StdioCollector {
|
||||
// onStreamFinished: {
|
||||
// networkText.text = this.text.trim()
|
||||
// // console.log("networkScript networkText:", this.text.trim())
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// Timer {
|
||||
// interval: 10000
|
||||
// running: true
|
||||
// repeat: true
|
||||
// onTriggered: networkStatus.running = true
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -1,48 +1,30 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Io
|
||||
import "../../../colors"
|
||||
import "../../../config"
|
||||
|
||||
MouseArea {
|
||||
id: powerButton
|
||||
width: Math.max(powerText.width + Config.spacing, bar.height)
|
||||
width: Math.max(powerText.width + Config.spacing_fun(height), height)
|
||||
height: bar.height
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
||||
onClicked: {
|
||||
console.log("[PowerButton] Opening wlogout")
|
||||
root.openWlogout()
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: powerButton.containsMouse ? Colors.secondaryContainer_fg : Qt.alpha(Colors.secondary, 0.75)
|
||||
radius: Config.radius
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
// Process {
|
||||
// id: powerOff
|
||||
// command: ["wlogout", "-b", "2"]
|
||||
// stdout: StdioCollector {
|
||||
// onStreamFinished: console.log(`line read: ${this.text}`)
|
||||
// }
|
||||
// }
|
||||
|
||||
MouseArea {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
console.log("Running PowerOff Menu")
|
||||
root.openWlogout()
|
||||
}
|
||||
}
|
||||
}
|
||||
border.width: 0
|
||||
|
||||
Text {
|
||||
id: powerText
|
||||
anchors.centerIn: parent
|
||||
text: ""
|
||||
font.pixelSize: Config.big_font_size(bar.height)
|
||||
font.pixelSize: Config.bigIconSize(bar.height)
|
||||
font.family: Config.font
|
||||
color:powerButton.containsMouse ? Colors.secondaryContainer : Colors.secondary_fg
|
||||
}
|
||||
|
||||
@@ -1,29 +1,30 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Services.SystemTray
|
||||
import Quickshell.Io
|
||||
import "../../../colors"
|
||||
import "../../../config"
|
||||
|
||||
|
||||
Row { // Workspace Row
|
||||
id: trayRow
|
||||
spacing: Math.floor(bar.height/8)
|
||||
spacing: Config.small_spacing_fun(height)
|
||||
|
||||
Repeater {
|
||||
model: SystemTray.items
|
||||
Column{
|
||||
Rectangle{
|
||||
width: iconImage.width + Config.spacing
|
||||
height: Math.floor((bar.height-trayItem.height)/2)
|
||||
color: "transparent"
|
||||
Item {
|
||||
width: 1
|
||||
height: Math.floor((bar.height - trayItem.height) / 2)
|
||||
}
|
||||
|
||||
Rectangle { //trayItem
|
||||
id: trayItem
|
||||
width: iconImage.width + Config.spacing
|
||||
height: iconImage.height + Config.spacing
|
||||
radius: Config.small_radius
|
||||
color: "transparent"
|
||||
width: iconImage.width + Config.spacing_fun(bar.height)
|
||||
height: iconImage.height + Config.spacing_fun(bar.height)
|
||||
radius: Config.small_radius_fun(height)
|
||||
color: trayArea.containsMouse ? Colors.tertiaryContainer
|
||||
: modelData.active ? Colors.primaryContainer
|
||||
: Colors.secondaryContainer
|
||||
border.width: Config.border_width
|
||||
|
||||
Process {
|
||||
@@ -33,88 +34,59 @@ Row { // Workspace Row
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: workspaceButton
|
||||
id: trayArea
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
||||
property int clickX: 0
|
||||
property int clickY: 0
|
||||
onClicked: (mouse) => {
|
||||
switch (mouse.button) {
|
||||
case Qt.LeftButton:
|
||||
if (!modelData.onlyMenu) {
|
||||
modelData.activate()
|
||||
console.log('Activcate function of ', modelData.title)
|
||||
}
|
||||
if (modelData.title.trim()==="Steam") {
|
||||
console.log("[Tray] Activate: " + modelData.title)
|
||||
if (!modelData.onlyMenu) modelData.activate()
|
||||
if (modelData.title.trim() === "Steam") {
|
||||
console.log("[Tray] Starting Steam")
|
||||
steamRunner.startDetached()
|
||||
}
|
||||
break
|
||||
case Qt.RightButton:
|
||||
console.log("[Tray] Context menu: " + modelData.title)
|
||||
clickX = mouse.x
|
||||
clickY = mouse.y
|
||||
trayMenu.menu = modelData.menu
|
||||
trayMenu.open()
|
||||
break
|
||||
case Qt.MiddleButton:
|
||||
console.log("[Tray] Secondary activate: " + modelData.title)
|
||||
modelData.secondaryActivate()
|
||||
break
|
||||
// case Qt.RightButton:
|
||||
// if (modelData.hasMenu) {
|
||||
// console.log('Activcate menu of ', modelData.title)
|
||||
// menuAnchor.open()
|
||||
// }
|
||||
// break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// QsMenuAnchor {
|
||||
// id: menuAnchor
|
||||
// menu: modelData.menu
|
||||
// anchor.window: menuHost
|
||||
// }
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
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
|
||||
radius: Config.radius
|
||||
QsMenuAnchor {
|
||||
id: trayMenu
|
||||
anchor {
|
||||
item: trayArea
|
||||
edges: Edges.Top | Edges.Left
|
||||
gravity: Edges.Bottom | Edges.Right
|
||||
adjustment: PopupAdjustment.FlipX | PopupAdjustment.SlideY
|
||||
onAnchoring: {
|
||||
rect.x = trayArea.clickX
|
||||
rect.y = trayArea.clickY
|
||||
rect.w = 1
|
||||
rect.h = 1
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Image { // Image
|
||||
id: iconImage
|
||||
// source: modelData.icon; Does not work for some tray icons
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
|
||||
anchors.centerIn: parent
|
||||
|
||||
width: Config.big_font_size(bar.height)
|
||||
height: Config.big_font_size(bar.height)
|
||||
|
||||
// Component.onCompleted: {
|
||||
// // Default to the original icon
|
||||
// let src = modelData.icon;
|
||||
// // console.log("########## icon: " + modelData.icon)
|
||||
|
||||
// // Check if there is a "?" in the URL (custom path)
|
||||
// if (src.includes('goxlr')) {
|
||||
// let pathMatch = src.match(/path=([^&]+)/);
|
||||
// if (pathMatch && pathMatch[1]) {
|
||||
|
||||
// let folderPath = pathMatch[1];
|
||||
// // Build a file:// URL pointing to the actual icon file
|
||||
// let segments = folderPath.split('/');
|
||||
// let fileName = segments[segments.length - 1] + "-icon.png";
|
||||
// console.log("########## filename: " + fileName)
|
||||
// console.log("########## icon: " + modelData.icon)
|
||||
// src = "file://" + pathMatch[1] + "/" + fileName;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Set the resolved source
|
||||
// iconImage.source = src;
|
||||
|
||||
// // console.log("Resolved icon source:", src);
|
||||
// }
|
||||
width: Config.halfBigIconSize(bar.height)
|
||||
height: Config.halfBigIconSize(bar.height)
|
||||
asynchronous: true
|
||||
cache: true
|
||||
}
|
||||
@@ -127,21 +99,25 @@ Row { // Workspace Row
|
||||
onTriggered: {
|
||||
let src = modelData.icon;
|
||||
// console.log("########## icon: " + modelData.icon)
|
||||
|
||||
// Check if there is a "?" in the URL (custom path)
|
||||
if (src.includes('goxlr')) {
|
||||
// console.log("########## name: " + modelData.title)
|
||||
if (modelData.title.includes('GoXLR')) {
|
||||
// console.log("[Tray] Resolving GoXLR icon path")
|
||||
let pathMatch = src.match(/path=([^&]+)/);
|
||||
if (pathMatch && pathMatch[1]) {
|
||||
|
||||
let folderPath = pathMatch[1];
|
||||
// Build a file:// URL pointing to the actual icon file
|
||||
let segments = folderPath.split('/');
|
||||
let fileName = segments[segments.length - 1] + "-icon.png";
|
||||
// console.log("########## filename: " + fileName)
|
||||
// console.log("########## icon: " + modelData.icon)
|
||||
src = "file://" + pathMatch[1] + "/" + fileName;
|
||||
}
|
||||
}
|
||||
// if (modelData.title.includes('Nextcloud')) {
|
||||
// src = Quickshell.iconPath("Nextcloud")
|
||||
// }
|
||||
// console.log("########## icon: " + src)
|
||||
if (src.exists) {
|
||||
console.log("########## icon: " + src)
|
||||
}
|
||||
|
||||
// Set the resolved source
|
||||
iconImage.source = src;
|
||||
|
||||
@@ -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