Updated my own swayshell just for funsies
This commit is contained in:
parent
c4ebdccebe
commit
ecf0cc6a68
2 changed files with 316 additions and 305 deletions
|
|
@ -64,16 +64,16 @@
|
||||||
|
|
||||||
;; Vterm
|
;; Vterm
|
||||||
(use-package vterm
|
(use-package vterm
|
||||||
|
:ensure t
|
||||||
:config
|
:config
|
||||||
(add-hook 'vterm-mode-hook (lambda () (setq evil-default-state 'emacs)))
|
(add-hook 'vterm-mode-hook (lambda () (setq evil-default-state 'emacs))))
|
||||||
:ensure t)
|
|
||||||
|
|
||||||
;; QML
|
;; QML
|
||||||
(use-package qml-mode :ensure t)
|
(use-package qml-mode :ensure t)
|
||||||
|
|
||||||
;; LSP / Eglot
|
;; LSP / Eglot
|
||||||
|
|
||||||
(setq eglot-ignored-server-capabilities '(:documentOnTypeFormattingProvider :documentFormattingProvider :documentRangeFormattingProvider))
|
;;(setq eglot-ignored-server-capabilities '(:documentOnTypeFormattingProvider :documentFormattingProvider :documentRangeFormattingProvider))
|
||||||
|
|
||||||
;; (add-hook 'nix-mode-hook #'eglot-ensure) ;;(for nix)
|
;; (add-hook 'nix-mode-hook #'eglot-ensure) ;;(for nix)
|
||||||
(add-hook 'eglot-managed-mode-hook (lambda () (eglot-inlay-hints-mode -1)))
|
(add-hook 'eglot-managed-mode-hook (lambda () (eglot-inlay-hints-mode -1)))
|
||||||
|
|
@ -83,8 +83,7 @@
|
||||||
(with-eval-after-load 'eglot
|
(with-eval-after-load 'eglot
|
||||||
(add-to-list 'eglot-server-programs '(c-mode . ("clangd")))
|
(add-to-list 'eglot-server-programs '(c-mode . ("clangd")))
|
||||||
(add-to-list 'eglot-server-programs '(c++-mode . ("clangd")))
|
(add-to-list 'eglot-server-programs '(c++-mode . ("clangd")))
|
||||||
(add-to-list 'eglot-server-programs '(qml-mode . ("~/Projects/Code/Random/qmlls")))
|
(add-to-list 'eglot-server-programs '(qml-mode . ("~/Projects/Code/Random/qmlls"))))
|
||||||
(add-hook 'after-save-hook 'eglot-format))
|
|
||||||
|
|
||||||
;; Set some basic stuff up
|
;; Set some basic stuff up
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,326 +10,338 @@ import Quickshell.Services.Pipewire
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
// Some credit goes to my friends Lucy and Babsi
|
// Some credit goes to my friends Lucy and Babsi
|
||||||
// Work in progress (Audio)
|
// Zoe here, ignore the wide ass code, emacs qml-mode adds 2 on my tab-width for some reason
|
||||||
|
|
||||||
PanelWindow {
|
PanelWindow {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property color colBg: "#64320a"
|
property color colBg: "#454545"
|
||||||
property color colAppBg: "#2d1405"
|
property color colAppBg: "#333333"
|
||||||
property color colFg: "#d2d2d2"
|
property color colFg: "#ffffff"
|
||||||
property color colDark: "#230f05"
|
property string fontFamily: "Hack Nerd Font"
|
||||||
property string fontFamily: "Noto Sans"
|
property int fontSize: 16
|
||||||
property int fontSize: 18
|
property int appletRadHeight: 25
|
||||||
property int appletRadHeight: 25
|
property int appletSpacing: 6
|
||||||
property int appletSpacing: 6
|
|
||||||
|
|
||||||
|
|
||||||
property int cpuUsage: 0
|
property int cpuUsage: 0
|
||||||
property var lastCpuIdle: 0
|
property var lastCpuIdle: 0
|
||||||
property var lastCpuTotal: 0
|
property var lastCpuTotal: 0
|
||||||
property real ramUsage: 0.00
|
property real ramUsage: 0.00
|
||||||
property var batTime: 0
|
|
||||||
property var batCharMin: (UPower.displayDevice.timeToFull / 60).toFixed(2)
|
|
||||||
property var batDisMin: (UPower.displayDevice.timeToEmpty / 60).toFixed(2)
|
|
||||||
|
|
||||||
anchors {
|
property var batCharMin: (UPower.displayDevice.timeToFull / 60).toFixed(2)
|
||||||
right: true
|
property var batDisMin: (UPower.displayDevice.timeToEmpty / 60).toFixed(2)
|
||||||
left: true
|
property var batTime: 0
|
||||||
top:true
|
|
||||||
}
|
|
||||||
|
|
||||||
color: "transparent"
|
anchors {
|
||||||
implicitHeight: root.appletRadHeight + 10
|
right: true
|
||||||
margins {
|
left: true
|
||||||
right: 5
|
top:true
|
||||||
left: 5
|
}
|
||||||
top: 5
|
|
||||||
bottom: 0
|
|
||||||
}
|
|
||||||
Rectangle {
|
|
||||||
color: root.colBg
|
|
||||||
anchors.fill: parent
|
|
||||||
radius: root.appletRadHeight
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
color: "transparent"
|
||||||
id: leftRow
|
implicitHeight: root.appletRadHeight + 5
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
margins {
|
||||||
anchors.left: parent.left
|
right: 0 // 5
|
||||||
Item {
|
left: 0 // 5
|
||||||
id: rootItem
|
top: 0 // 5
|
||||||
implicitWidth: root.appletRadHeight
|
bottom: 0
|
||||||
height: root.appletRadHeight
|
}
|
||||||
Row {
|
Rectangle {
|
||||||
id: workspaceRow
|
color: root.colBg
|
||||||
|
anchors.fill: parent
|
||||||
|
// radius: root.appletRadHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: leftRow
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
leftPadding: 10
|
Item {
|
||||||
|
id: rootItem
|
||||||
|
implicitWidth: root.appletRadHeight
|
||||||
|
height: root.appletRadHeight
|
||||||
|
Row {
|
||||||
|
id: workspaceRow
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.left: parent.left
|
||||||
|
leftPadding: 10
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: wsRepeater
|
id: wsRepeater
|
||||||
model: I3.workspaces
|
model: I3.workspaces
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
property var ws: I3.workspaces
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: workspaceNumber
|
id: workspaceNumber
|
||||||
property bool isOnMon: {
|
property bool isOnMon: {
|
||||||
if (!modelData)
|
if (!modelData)
|
||||||
return false
|
return false
|
||||||
if (!modelData.monitor)
|
if (!modelData.monitor)
|
||||||
return false
|
return false
|
||||||
if (!rootItem.screen)
|
if (!rootItem.screen)
|
||||||
return false;
|
return false;
|
||||||
return modelData.monitor.name === rootItem.screen.name;
|
return modelData.monitor.name === rootItem.screen.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
required property var modelData
|
||||||
|
height: root.appletRadHeight * 1.1
|
||||||
|
width: root.appletRadHeight * 1.1
|
||||||
|
radius: root.appletRadHeight
|
||||||
|
color: root.colAppBg
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: parent.modelData.number
|
||||||
|
color: root.colFg
|
||||||
|
opacity: workspaceNumber.modelData.focused ? 1 : 0.5
|
||||||
|
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {parent.modelData.activate();}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
required property var modelData
|
|
||||||
height: root.appletRadHeight * 1.1
|
|
||||||
width: root.appletRadHeight * 1.1
|
|
||||||
radius: root.appletRadHeight
|
|
||||||
color: root.colAppBg
|
|
||||||
Text {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: parent.modelData.number
|
|
||||||
color: root.colFg
|
|
||||||
opacity: workspaceNumber.modelData.focused ? 1 : 0.5
|
|
||||||
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: {parent.modelData.activate();}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
/*
|
||||||
/*
|
RowLayout {
|
||||||
RowLayout {
|
id: centerRow
|
||||||
id: centerRow
|
spacing: root.appletSpacing
|
||||||
spacing: root.appletSpacing
|
anchors.right: parent.right
|
||||||
anchors.right: parent.right
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
}
|
||||||
}
|
*/
|
||||||
*/
|
RowLayout {
|
||||||
RowLayout {
|
id: rightRow
|
||||||
id: rightRow
|
anchors.right: parent.right
|
||||||
anchors.right: parent.right
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
spacing: root.appletSpacing
|
||||||
spacing: root.appletSpacing
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
Process {
|
||||||
Process {
|
id: cpuProc
|
||||||
id: cpuProc
|
command: ["sh", "-c", "head -1 /proc/stat"]
|
||||||
command: ["sh", "-c", "head -1 /proc/stat"]
|
stdout: SplitParser {
|
||||||
stdout: SplitParser {
|
onRead: data => {
|
||||||
onRead: data => {
|
if (!data) return
|
||||||
if (!data) return
|
var p = data.trim().split(/\s+/)
|
||||||
var p = data.trim().split(/\s+/)
|
var idle = parseInt(p[4]) + parseInt(p[5])
|
||||||
var idle = parseInt(p[4]) + parseInt(p[5])
|
var total = p.slice(1, 8).reduce((a, b) => a + parseInt(b), 0)
|
||||||
var total = p.slice(1, 8).reduce((a, b) => a + parseInt(b), 0)
|
if (lastCpuTotal > 0) {
|
||||||
if (lastCpuTotal > 0) {
|
cpuUsage = Math.round(100 * (1 - (idle - lastCpuIdle) / (total - lastCpuTotal)))
|
||||||
cpuUsage = Math.round(100 * (1 - (idle - lastCpuIdle) / (total - lastCpuTotal)))
|
}
|
||||||
|
lastCpuTotal = total
|
||||||
|
lastCpuIdle = idle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Component.onCompleted: running = true
|
||||||
}
|
}
|
||||||
lastCpuTotal = total
|
|
||||||
lastCpuIdle = idle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Component.onCompleted: running = true
|
|
||||||
}
|
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: ramProc
|
id: ramProc
|
||||||
command: ["sh", "-c", "free | grep Mem"]
|
command: ["sh", "-c", "free | grep Mem"]
|
||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
onRead: data => {
|
onRead: data => {
|
||||||
if (!data) return
|
if (!data) return
|
||||||
var parts = data.trim().split(/\s+/)
|
var parts = data.trim().split(/\s+/)
|
||||||
var used = parseInt(parts[2]) || 0
|
var used = parseInt(parts[2]) || 0
|
||||||
ramUsage = used /1048576
|
ramUsage = used /1048576
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Component.onCompleted: running = true
|
||||||
|
}
|
||||||
|
Timer {
|
||||||
|
interval: 2000
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
onTriggered: {
|
||||||
|
cpuProc.running = true
|
||||||
|
ramProc.running = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Item {
|
||||||
|
id: procItem
|
||||||
|
Row {
|
||||||
|
id: procRow
|
||||||
|
spacing: root.appletSpacing
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
leftPadding: 10
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
id: batLoader
|
||||||
|
active: true
|
||||||
|
sourceComponent: Rectangle {
|
||||||
|
id: batRect
|
||||||
|
clip: true
|
||||||
|
color: root.colAppBg
|
||||||
|
visible: UPower.displayDevice.isPresent
|
||||||
|
implicitHeight: root.appletRadHeight
|
||||||
|
implicitWidth: batText.implicitWidth + 25
|
||||||
|
radius: root.appletRadHeight
|
||||||
|
|
||||||
|
function getBatStat() {
|
||||||
|
if (UPower.displayDevice.state == UPowerDeviceState.Discharging) {
|
||||||
|
batTime = Math.floor(batDisMin / 60) + "h " + ((batDisMin - (Math.floor(batDisMin / 60) * 60)).toFixed(0)) + "min"
|
||||||
|
return batTime;
|
||||||
|
}
|
||||||
|
if (UPower.displayDevice.state == UPowerDeviceState.Charging) {
|
||||||
|
batTime = Math.floor(batCharMin / 60) + "h " + ((batCharMin - (Math.floor(batCharMin / 60) * 60)).toFixed(0)) + "min"
|
||||||
|
return batTime;
|
||||||
|
}
|
||||||
|
if (UPower.displayDevice.state == UPowerDeviceState.FullyCharged) {
|
||||||
|
return "Full";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function batStatProc() {
|
||||||
|
return Math.round(UPower.displayDevice.percentage * 100) + "%";
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: batText
|
||||||
|
anchors.centerIn: parent
|
||||||
|
color: root.colFg
|
||||||
|
text: batStatProc() + " - " + getBatStat()
|
||||||
|
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
height: root.appletRadHeight
|
||||||
|
width: cpuText.paintedWidth + 25
|
||||||
|
radius: root.appletRadHeight
|
||||||
|
color: root.colAppBg
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: cpuText
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: "CPU: " + cpuUsage + "%"
|
||||||
|
color: root.colFg
|
||||||
|
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
height: root.appletRadHeight
|
||||||
|
width: ramText.paintedWidth + 28
|
||||||
|
radius: root.appletRadHeight
|
||||||
|
color: root.colAppBg
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: ramText
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: "RAM: " + ramUsage.toFixed(2) + " GiB"
|
||||||
|
color: root.colFg
|
||||||
|
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
id: pwRect
|
||||||
|
color: root.colAppBg
|
||||||
|
property PwNode defaultAudio: Pipewire.ready ? Pipewire.preferredDefaultAudioSink : null
|
||||||
|
property bool mute: Pipewire.ready ? defaultAudio?.audio.muted : null
|
||||||
|
radius: root.appletRadHeight
|
||||||
|
implicitHeight: root.appletRadHeight
|
||||||
|
implicitWidth: pwText.implicitWidth + 25
|
||||||
|
|
||||||
|
PwObjectTracker {
|
||||||
|
objects: [Pipewire.ready ? Pipewire.defaultAudioSink : null]
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: pavuLauncher
|
||||||
|
command: ["pavucontrol"]
|
||||||
|
running: false
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: pwText
|
||||||
|
anchors.centerIn: pwRect
|
||||||
|
color: root.colFg
|
||||||
|
opacity: pwRect.defaultAudio?.audio.muted ? 0.6 : 1.0
|
||||||
|
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
||||||
|
text: pwRect.mute ? "MUT: " + Math.floor(pwRect.defaultAudio?.audio.volume * 100) + "%" : "VOL: " + Math.floor(pwRect.defaultAudio?.audio.volume * 100) + "%"
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: clickHandler
|
||||||
|
hoverEnabled: true
|
||||||
|
acceptedButtons: Qt.LeftButton
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
anchors.fill: pwRect
|
||||||
|
onClicked: pavuLauncher.running = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Component.onCompleted: running = true
|
|
||||||
}
|
|
||||||
Timer {
|
|
||||||
interval: 2000
|
|
||||||
running: true
|
|
||||||
repeat: true
|
|
||||||
onTriggered: {
|
|
||||||
cpuProc.running = true
|
|
||||||
ramProc.running = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Item {
|
|
||||||
id: procItem
|
|
||||||
Row {
|
Row {
|
||||||
id: procRow
|
id: clockRow
|
||||||
spacing: root.appletSpacing
|
Rectangle {
|
||||||
anchors.right: parent.right
|
id: clockRect
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
clip: true
|
||||||
leftPadding: 10
|
implicitHeight: root.appletRadHeight
|
||||||
|
implicitWidth: clockText.implicitWidth + 25
|
||||||
Loader {
|
color: root.colAppBg
|
||||||
id: statLoader
|
radius: root.appletRadHeight
|
||||||
active: true
|
SystemClock {
|
||||||
sourceComponent: Rectangle {
|
id: clock
|
||||||
id: batRect
|
precision: SystemClock.Seconds
|
||||||
height: root.appletRadHeight
|
|
||||||
width: batText.paintedWidth + root.appletRadHeight
|
|
||||||
radius: root.appletRadHeight
|
|
||||||
color: root.colAppBg
|
|
||||||
|
|
||||||
function getBatStat() {
|
|
||||||
if (UPower.displayDevice.state == UPowerDeviceState.Discharging) {
|
|
||||||
batTime = Math.floor(batDisMin / 60) + "h " + ((batDisMin - (Math.floor(batDisMin / 60) * 60)).toFixed(0)) + "min"
|
|
||||||
return batTime;
|
|
||||||
}
|
}
|
||||||
if (UPower.displayDevice.state == UPowerDeviceState.Charging) {
|
Text {
|
||||||
batTime = Math.floor(batCharMin / 60) + "h " + ((batCharMin - (Math.floor(batCharMin / 60) * 60)).toFixed(0)) + "min"
|
id: clockText
|
||||||
return batTime;
|
anchors.centerIn: clockRect
|
||||||
|
color: root.colFg
|
||||||
|
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
||||||
|
text: Qt.formatDateTime(clock.date, "yyyy.MM.dd - hh:mm:ss")
|
||||||
}
|
}
|
||||||
if (UPower.displayDevice.state == UPowerDeviceState.FullyCharged) {
|
|
||||||
return "Full";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function batStatProc() {
|
|
||||||
return Math.round(UPower.displayDevice.percentage * 100) + "%";
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: batText
|
|
||||||
anchors.centerIn: parent
|
|
||||||
color: root.colFg
|
|
||||||
text: batStatProc() + " - " + getBatStat()
|
|
||||||
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Rectangle {
|
|
||||||
height: root.appletRadHeight
|
|
||||||
width: cpuText.paintedWidth + 25
|
|
||||||
radius: root.appletRadHeight
|
|
||||||
color: root.colAppBg
|
|
||||||
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: cpuText
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: "CPU: " + cpuUsage + "%"
|
|
||||||
color: root.colFg
|
|
||||||
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Rectangle {
|
|
||||||
height: root.appletRadHeight
|
|
||||||
width: ramText.paintedWidth + 28
|
|
||||||
radius: root.appletRadHeight
|
|
||||||
color: root.colAppBg
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: ramText
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: "RAM: " + ramUsage.toFixed(2) + " GiB"
|
|
||||||
color: root.colFg
|
|
||||||
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
Row {
|
||||||
}
|
id: trayWholeRow
|
||||||
|
rightPadding: 10
|
||||||
|
Rectangle {
|
||||||
|
id: trayRect
|
||||||
|
color: root.colAppBg
|
||||||
|
visible: iconRepeater.count != 0
|
||||||
|
radius: root.appletRadHeight
|
||||||
|
Layout.fillHeight: true
|
||||||
|
implicitHeight: root.appletRadHeight
|
||||||
|
implicitWidth: iconlayout.implicitWidth + 16
|
||||||
|
|
||||||
Row {
|
RowLayout {
|
||||||
id: clockRow
|
id: iconlayout
|
||||||
Rectangle {
|
anchors.centerIn: trayRect
|
||||||
height: root.appletRadHeight
|
Repeater {
|
||||||
width: clock.paintedWidth + root.appletRadHeight
|
id: iconRepeater
|
||||||
radius: root.appletRadHeight
|
model: SystemTray.items
|
||||||
color: root.colAppBg
|
delegate: WrapperMouseArea {
|
||||||
|
id: iconWrapper
|
||||||
Text {
|
required property var modelData
|
||||||
id: clock
|
child: IconImage {
|
||||||
anchors.centerIn: parent
|
source: iconWrapper.modelData.icon
|
||||||
anchors.right: parent.right
|
implicitSize: 16
|
||||||
text: Qt.formatDateTime(new Date(), "yyyy.MM.dd - HH:mm:ss")
|
}
|
||||||
color: root.colFg
|
QsMenuAnchor {
|
||||||
font { family: root.fontFamily; pixelSize: root.fontSize; bold: true }
|
id: menu
|
||||||
|
anchor.item: iconWrapper
|
||||||
Timer {
|
menu: modelData.menu
|
||||||
interval: 1000
|
}
|
||||||
running: true
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
repeat: true
|
onClicked: mouse => {
|
||||||
onTriggered: clock.text = Qt.formatDateTime(new Date(), "yyyy.MM.dd - HH:mm:ss")
|
if (mouse.button == Qt.RightButton) {
|
||||||
}
|
menu.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Row {
|
}
|
||||||
id: trayWholeRow
|
|
||||||
rightPadding: 10
|
|
||||||
Item{
|
|
||||||
id: miscItem
|
|
||||||
implicitHeight: root.appletRadHeight
|
|
||||||
implicitWidth: trayRect.implicitWidth
|
|
||||||
visible: trayRepeater.count > 0
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: trayRect
|
|
||||||
implicitHeight: root.appletRadHeight
|
|
||||||
implicitWidth: trayRow.implicitWidth + 10
|
|
||||||
radius: root.appletRadHeight
|
|
||||||
color: root.colAppBg
|
|
||||||
anchors.centerIn: parent
|
|
||||||
|
|
||||||
Row {
|
|
||||||
id: trayRow
|
|
||||||
spacing: root.appletSpacing
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.centerIn: parent
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
id: trayRepeater
|
|
||||||
model: SystemTray.items
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: trayMouse
|
|
||||||
property var bar: trayMouse.QsWindow.window
|
|
||||||
required property SystemTrayItem modelData
|
|
||||||
|
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
||||||
implicitWidth: 16
|
|
||||||
implicitHeight: 16
|
|
||||||
|
|
||||||
onClicked: event => {
|
|
||||||
if (event.button === Qt.LeftButton) {
|
|
||||||
modelData.activate();
|
|
||||||
}
|
|
||||||
else if (modelData.hasMenu) {
|
|
||||||
menu.open();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QsMenuAnchor {
|
|
||||||
id: menu
|
|
||||||
menu: trayMouse.modelData.hasMenu ? trayMouse.modelData.menu : null
|
|
||||||
anchor.item: trayMouse
|
|
||||||
}
|
|
||||||
|
|
||||||
IconImage {
|
|
||||||
id: trayIcon
|
|
||||||
width: parent.implicitWidth
|
|
||||||
height: parent.implicitHeight
|
|
||||||
source: trayMouse.modelData.icon
|
|
||||||
anchors.centerIn: parent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue