refaktor
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user