Compare commits
14
Commits
9788529f55
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c45074b247 | ||
|
|
cf2388f6d8 | ||
|
|
3014a4cc3b | ||
|
|
5ea11ae9f7 | ||
|
|
31378f9769 | ||
|
|
0fad9baa5b | ||
|
|
f9c14c84b4 | ||
|
|
510cbb0cec | ||
|
|
aea40a3e42 | ||
|
|
8eb08631f7 | ||
|
|
a827d1e92c | ||
|
|
27401c25a0 | ||
|
|
b59eb012ba | ||
|
|
2df40a2a76 |
@@ -4,3 +4,4 @@ modules/wlogout/scripts/helper.sh
|
|||||||
config/path/ConfigPath.qml
|
config/path/ConfigPath.qml
|
||||||
config/path/WallpaperPath.qml
|
config/path/WallpaperPath.qml
|
||||||
modules/notification/assets/notification.ogg
|
modules/notification/assets/notification.ogg
|
||||||
|
*.json
|
||||||
+1
-1
@@ -81,5 +81,5 @@ QtObject {
|
|||||||
return maxWidth;
|
return maxWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
property string debug: "Notification"
|
property string debug: ""
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ Item {
|
|||||||
active: true // loads object
|
active: true // loads object
|
||||||
sourceComponent: Bar {
|
sourceComponent: Bar {
|
||||||
screen: modelData
|
screen: modelData
|
||||||
visible: !Hyprland.monitorFor(modelData).activeWorkspace.hasFullscreen
|
visible: !Hyprland.monitorFor(modelData).activeWorkspace?.hasFullscreen
|
||||||
} // creates instance of bar component
|
} // creates instance of bar component
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,6 +183,8 @@ Item {
|
|||||||
"lightburn": "",
|
"lightburn": "",
|
||||||
"wofi": "",
|
"wofi": "",
|
||||||
// Screenshare
|
// Screenshare
|
||||||
"moonlight": "ßß"
|
"moonlight": "",
|
||||||
|
// PCB
|
||||||
|
"kicad": "",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,144 @@
|
|||||||
pragma Singleton
|
pragma Singleton
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
import Quickshell.Services.UPower
|
import Quickshell.Services.UPower
|
||||||
|
import "../../../../config"
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
property bool available: UPower.displayDevice.isLaptopBattery
|
id: root
|
||||||
|
// show widget for laptop battery *or* UPS (your main PC), hide otherwise
|
||||||
|
// displayDevice is aggregate - for UPS it is type Ups, isLaptopBattery is false
|
||||||
|
property bool available: {
|
||||||
|
const d = UPower.displayDevice
|
||||||
|
if (d && d.ready && d.isPresent && (d.isLaptopBattery || d.type === UPowerDeviceType.Ups)) return true
|
||||||
|
// fallback: scan all devices (some systems don't set DisplayDevice to UPS)
|
||||||
|
const devs = UPower.devices.values
|
||||||
|
for (let i = 0; i < devs.length; i++) {
|
||||||
|
const dev = devs[i]
|
||||||
|
if (dev.isPresent && (dev.isLaptopBattery || dev.type === UPowerDeviceType.Ups)) return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
property real percentage: UPower.displayDevice.percentage*100
|
property real percentage: UPower.displayDevice.percentage*100
|
||||||
property string state: UPowerDeviceState.toString(UPower.displayDevice.state)
|
// 'state' shadows Item.state (qmllint) -> use chargeState
|
||||||
property bool charging: state == "Charging"
|
property string chargeState: UPowerDeviceState.toString(UPower.displayDevice.state)
|
||||||
property bool full: state == "FullyCharged"
|
// keep alias via getter would still shadow, so expose via function if needed; prefer chargeState
|
||||||
|
property bool charging: chargeState == "Charging"
|
||||||
|
property bool full: chargeState == "FullyCharged"
|
||||||
property real energy: UPower.displayDevice.energy
|
property real energy: UPower.displayDevice.energy
|
||||||
property real energy_formated: Math.round(energy*10)/10
|
property real energy_formated: Math.round(energy*10)/10
|
||||||
property real time_to_empty: UPower.displayDevice.timeToEmpty
|
property real time_to_empty: UPower.displayDevice.timeToEmpty
|
||||||
|
property real time_to_full: UPower.displayDevice.timeToFull
|
||||||
property real hour_to_empty: Math.floor(time_to_empty/3600)
|
property real hour_to_empty: Math.floor(time_to_empty/3600)
|
||||||
property real min_to_empty: Math.floor((time_to_empty%3600)/60)
|
property real min_to_empty: Math.floor((time_to_empty%3600)/60)
|
||||||
|
property real hour_to_full: Math.floor(time_to_full/3600)
|
||||||
|
property real min_to_full: Math.floor((time_to_full%3600)/60)
|
||||||
property real energy_rate: UPower.displayDevice.changeRate
|
property real energy_rate: UPower.displayDevice.changeRate
|
||||||
property real energy_rate_formated: Math.round(energy_rate*10)/10
|
property real energy_rate_formated: Math.round(energy_rate*10)/10
|
||||||
property bool healthSupported: UPower.displayDevice.healthSupported
|
property bool healthSupported: UPower.displayDevice.healthSupported
|
||||||
property real health: healthSupported ? UPower.displayDevice.healthPercentage : NaN
|
property real health: healthSupported ? UPower.displayDevice.healthPercentage : NaN
|
||||||
|
|
||||||
|
property int _maxHistory: 60*60 // 1h window
|
||||||
|
|
||||||
|
property var percentageHistory: [{time: Date.now() - _maxHistory*1000, value: 0}, {time: Date.now(), value: 0}]
|
||||||
|
property var percentageHistoryExists: false
|
||||||
|
property var energyHistory: [{time: Date.now() - _maxHistory*1000, value: 0}, {time: Date.now(), value: 0}]
|
||||||
|
property var energyHistoryExists: false
|
||||||
|
property var usageHistory: [{time: Date.now() - _maxHistory*1000, value: 0}, {time: Date.now(), value: 0}]
|
||||||
|
property var usageHistoryExists: false
|
||||||
|
|
||||||
|
// ---- persistence: survives reload AND close (FileView -> disk) ----
|
||||||
|
// use Config.configDir (base dir) so path is stable and visible in repo
|
||||||
|
readonly property string _historyPath: Config.configDir + "/modules/bar/states/Battery/battery_history.json"
|
||||||
|
// guard: don't try to read non-existent file (avoids FileView warning)
|
||||||
|
Process {
|
||||||
|
id: historyFileExistsCheck
|
||||||
|
command: ["test", "-f", root._historyPath]
|
||||||
|
onExited: function(exitCode, exitStatus) {
|
||||||
|
if (exitCode === 0) historyFile.path = root._historyPath
|
||||||
|
// else keep historyFile.path empty -> no read attempt, writes will set it later
|
||||||
|
}
|
||||||
|
Component.onCompleted: running = true
|
||||||
|
}
|
||||||
|
FileView {
|
||||||
|
id: historyFile
|
||||||
|
printErrors: false
|
||||||
|
// adapter holds json, synced to disk via writeAdapter()
|
||||||
|
adapter: JsonAdapter {
|
||||||
|
property var percentageHistory: []
|
||||||
|
property var energyHistory: []
|
||||||
|
property var usageHistory: []
|
||||||
|
}
|
||||||
|
onLoaded: {
|
||||||
|
function prune(arr) {
|
||||||
|
if (!arr || typeof arr.length !== "number" || arr.length===0) return null
|
||||||
|
const f = arr.filter(p => p && typeof p.time==="number" && typeof p.value==="number")
|
||||||
|
if (f.length < 2) return null
|
||||||
|
return f.length > root._maxHistory ? f.slice(-root._maxHistory) : f
|
||||||
|
}
|
||||||
|
const p = prune(adapter.percentageHistory)
|
||||||
|
if (p) { root.percentageHistory = p; root.percentageHistoryExists = p.some(i=>i.value!==0) }
|
||||||
|
const e = prune(adapter.energyHistory)
|
||||||
|
if (e) { root.energyHistory = e; root.energyHistoryExists = e.some(i=>i.value!==0) }
|
||||||
|
const u = prune(adapter.usageHistory)
|
||||||
|
if (u) { root.usageHistory = u; root.usageHistoryExists = u.some(i=>i.value!==0) }
|
||||||
|
}
|
||||||
|
onLoadFailed: {} // first run, file missing -> keep defaults
|
||||||
|
}
|
||||||
|
|
||||||
|
// periodic save every 10s (debounce-restart would never fire while statsTimer pushes every 1s)
|
||||||
|
Timer {
|
||||||
|
id: saveTimer
|
||||||
|
interval: 10000
|
||||||
|
repeat: true
|
||||||
|
running: true
|
||||||
|
onTriggered: {
|
||||||
|
if (historyFile.path === "") historyFile.path = root._historyPath
|
||||||
|
historyFile.adapter.percentageHistory = root.percentageHistory
|
||||||
|
historyFile.adapter.energyHistory = root.energyHistory
|
||||||
|
historyFile.adapter.usageHistory = root.usageHistory
|
||||||
|
historyFile.writeAdapter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: statsTimer
|
||||||
|
interval: 1000
|
||||||
|
repeat: true
|
||||||
|
running: true
|
||||||
|
onTriggered: {
|
||||||
|
const now = Date.now()
|
||||||
|
|
||||||
|
// Creating percentage History
|
||||||
|
let pHist = root.percentageHistory.slice()
|
||||||
|
pHist.push({time: now, value: percentage})
|
||||||
|
if (pHist.length > root._maxHistory) pHist.shift()
|
||||||
|
root.percentageHistoryExists = pHist.some(item => item.value !== 0 && item.value !== undefined)
|
||||||
|
root.percentageHistory = pHist
|
||||||
|
|
||||||
|
// Creating energy History
|
||||||
|
let eHist = root.energyHistory.slice()
|
||||||
|
eHist.push({time: now, value: energy_formated})
|
||||||
|
if (eHist.length > root._maxHistory) eHist.shift()
|
||||||
|
root.energyHistoryExists = eHist.some(item => item.value !== 0 && item.value !== undefined)
|
||||||
|
root.energyHistory = eHist
|
||||||
|
|
||||||
|
// Creating usage History
|
||||||
|
let uHist = root.usageHistory.slice()
|
||||||
|
uHist.push({time: now, value: energy_rate_formated})
|
||||||
|
if (uHist.length > root._maxHistory) uHist.shift()
|
||||||
|
root.usageHistoryExists = uHist.some(item => item.value !== 0 && item.value !== undefined)
|
||||||
|
root.usageHistory = uHist
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ensure save on clean close / reload (best-effort, reload preserves via FileView anyway)
|
||||||
|
Component.onDestruction: {
|
||||||
|
if (historyFile.path === "") historyFile.path = root._historyPath
|
||||||
|
historyFile.adapter.percentageHistory = root.percentageHistory
|
||||||
|
historyFile.adapter.energyHistory = root.energyHistory
|
||||||
|
historyFile.adapter.usageHistory = root.usageHistory
|
||||||
|
historyFile.writeAdapter()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ import QtQuick
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import Quickshell.Networking
|
import Quickshell.Networking
|
||||||
|
import "../../../../config"
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
@@ -38,6 +39,62 @@ QtObject {
|
|||||||
|
|
||||||
readonly property var networking: Networking
|
readonly property var networking: Networking
|
||||||
|
|
||||||
|
// ---- persistence: survives reload AND close (disk) ----
|
||||||
|
// use Config.configDir (base dir) so path is stable and visible in repo
|
||||||
|
readonly property string _historyPath: Config.configDir + "/modules/bar/states/Network/network_history.json"
|
||||||
|
// guard: don't try to read non-existent file
|
||||||
|
property Process historyFileExistsCheck: Process {
|
||||||
|
command: ["test", "-f", root._historyPath]
|
||||||
|
onExited: function(exitCode, exitStatus) {
|
||||||
|
if (exitCode === 0) root.historyFile.path = root._historyPath
|
||||||
|
}
|
||||||
|
Component.onCompleted: running = true
|
||||||
|
}
|
||||||
|
// QtObject has no default property, so hold FileView as typed property
|
||||||
|
property FileView historyFile: FileView {
|
||||||
|
printErrors: false
|
||||||
|
adapter: JsonAdapter {
|
||||||
|
property var downloadHistory: []
|
||||||
|
property var uploadHistory: []
|
||||||
|
property var pingHistory: []
|
||||||
|
}
|
||||||
|
onLoaded: {
|
||||||
|
function prune(arr) {
|
||||||
|
if (!arr || typeof arr.length !== "number" || arr.length===0) return null
|
||||||
|
const f = arr.filter(p => p && typeof p.time==="number" && typeof p.value==="number")
|
||||||
|
if (f.length < 2) return null
|
||||||
|
return f.length > root._maxHistory ? f.slice(-root._maxHistory) : f
|
||||||
|
}
|
||||||
|
const d = prune(adapter.downloadHistory)
|
||||||
|
if (d) root.downloadHistory = d
|
||||||
|
const u = prune(adapter.uploadHistory)
|
||||||
|
if (u) root.uploadHistory = u
|
||||||
|
const p = prune(adapter.pingHistory)
|
||||||
|
if (p) root.pingHistory = p
|
||||||
|
}
|
||||||
|
onLoadFailed: {} // first run
|
||||||
|
}
|
||||||
|
// periodic save every 10s (restart-debounce would never fire while statsTimer pushes every 1s)
|
||||||
|
property Timer saveTimer: Timer {
|
||||||
|
interval: 10000
|
||||||
|
repeat: true
|
||||||
|
running: true
|
||||||
|
onTriggered: {
|
||||||
|
if (root.historyFile.path === "") root.historyFile.path = root._historyPath
|
||||||
|
root.historyFile.adapter.downloadHistory = root.downloadHistory
|
||||||
|
root.historyFile.adapter.uploadHistory = root.uploadHistory
|
||||||
|
root.historyFile.adapter.pingHistory = root.pingHistory
|
||||||
|
root.historyFile.writeAdapter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Component.onDestruction: {
|
||||||
|
if (root.historyFile.path === "") root.historyFile.path = root._historyPath
|
||||||
|
root.historyFile.adapter.downloadHistory = root.downloadHistory
|
||||||
|
root.historyFile.adapter.uploadHistory = root.uploadHistory
|
||||||
|
root.historyFile.adapter.pingHistory = root.pingHistory
|
||||||
|
root.historyFile.writeAdapter()
|
||||||
|
}
|
||||||
|
|
||||||
function findAllConnectedDevices() {
|
function findAllConnectedDevices() {
|
||||||
var devs = networking.devices.values
|
var devs = networking.devices.values
|
||||||
var result = []
|
var result = []
|
||||||
@@ -70,7 +127,8 @@ QtObject {
|
|||||||
var nets = dev.networks.values
|
var nets = dev.networks.values
|
||||||
for (var j = 0; j < nets.length; j++) {
|
for (var j = 0; j < nets.length; j++) {
|
||||||
if (nets[j].connected) {
|
if (nets[j].connected) {
|
||||||
sig += ":" + nets[j].name
|
// include signalStrength & name so hover updates live on signal change
|
||||||
|
sig += ":" + nets[j].name + ":" + Math.round(nets[j].signalStrength*100)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Hyprland
|
|
||||||
import "../../../config"
|
import "../../../config"
|
||||||
import "../states/Battery"
|
import "../states/Battery"
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ MouseArea {
|
|||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: batteryText
|
id: batteryText
|
||||||
visible : !expanded
|
visible : !batteryButton.expanded
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text:(
|
text:(
|
||||||
BatteryState.percentage >= 90 ? "" :
|
BatteryState.percentage >= 90 ? "" :
|
||||||
@@ -49,7 +48,7 @@ MouseArea {
|
|||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: chargeIcon
|
id: chargeIcon
|
||||||
visible : !expanded && BatteryState.charging
|
visible : !batteryButton.expanded && BatteryState.charging
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: ""
|
text: ""
|
||||||
font.pixelSize: Config.iconSize(batteryButton.height)
|
font.pixelSize: Config.iconSize(batteryButton.height)
|
||||||
@@ -61,7 +60,7 @@ MouseArea {
|
|||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: expandedRow
|
id: expandedRow
|
||||||
visible: expanded
|
visible: batteryButton.expanded
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
spacing: Config.bar_spacing_fun(batteryButton.height)
|
spacing: Config.bar_spacing_fun(batteryButton.height)
|
||||||
|
|
||||||
@@ -100,7 +99,7 @@ MouseArea {
|
|||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: batteryPercentageText
|
id: batteryPercentageText
|
||||||
text: BatteryState.percentage + "%"
|
text: Math.round(BatteryState.percentage) + "%"
|
||||||
|
|
||||||
font.pixelSize: Config.labelSize(batteryButton.height)
|
font.pixelSize: Config.labelSize(batteryButton.height)
|
||||||
font.family: Config.font
|
font.family: Config.font
|
||||||
@@ -125,9 +124,87 @@ MouseArea {
|
|||||||
radiusValue: Config.radius_fun(batteryButton.height)
|
radiusValue: Config.radius_fun(batteryButton.height)
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
spacing: parent.spacing
|
spacing: batteryPopup.spacingValue
|
||||||
Text {
|
Text {
|
||||||
text: "percentage: " + BatteryState.percentage + "%"
|
text: "State: " + BatteryState.chargeState
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
color: Colors.primary
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
font.pixelSize: Config.font_size_tiny(bar.height)
|
||||||
|
font.family: Config.font
|
||||||
|
}
|
||||||
|
Column {
|
||||||
|
width: parent.width
|
||||||
|
spacing: 2
|
||||||
|
visible: BatteryState.percentageHistoryExists
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: "percentage: " + Math.round(BatteryState.percentage) + "%"
|
||||||
|
color: Colors.primary
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
font.pixelSize: Config.font_size_tiny(bar.height)
|
||||||
|
font.family: Config.font
|
||||||
|
}
|
||||||
|
|
||||||
|
Sparkline {
|
||||||
|
values: BatteryState.percentageHistory
|
||||||
|
lineColor: Colors.primary
|
||||||
|
width: parent.width
|
||||||
|
windowMs: BatteryState._maxHistory * 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Column {
|
||||||
|
width: parent.width
|
||||||
|
spacing: 2
|
||||||
|
visible: BatteryState.energyHistoryExists
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: "energy: " + BatteryState.energy_formated + " Wh"
|
||||||
|
color: Colors.primary
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
font.pixelSize: Config.font_size_tiny(bar.height)
|
||||||
|
font.family: Config.font
|
||||||
|
}
|
||||||
|
|
||||||
|
Sparkline {
|
||||||
|
values: BatteryState.energyHistory
|
||||||
|
lineColor: Colors.primary
|
||||||
|
width: parent.width
|
||||||
|
windowMs: BatteryState._maxHistory * 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Column {
|
||||||
|
width: parent.width
|
||||||
|
spacing: 2
|
||||||
|
visible: BatteryState.usageHistoryExists
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: "Usage: " + BatteryState.energy_rate_formated + " W"
|
||||||
|
color: Colors.primary
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
font.pixelSize: Config.font_size_tiny(bar.height)
|
||||||
|
font.family: Config.font
|
||||||
|
}
|
||||||
|
|
||||||
|
Sparkline {
|
||||||
|
values: BatteryState.usageHistory
|
||||||
|
lineColor: Colors.primary
|
||||||
|
width: parent.width
|
||||||
|
windowMs: BatteryState._maxHistory * 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
text: {
|
||||||
|
if (BatteryState.charging) {
|
||||||
|
if (BatteryState.hour_to_full > 0) return "Remaining: " + BatteryState.hour_to_full + "h " + BatteryState.min_to_full + "min (to full)"
|
||||||
|
if (BatteryState.min_to_full > 0) return "Remaining: " + BatteryState.min_to_full + "min (to full)"
|
||||||
|
return BatteryState.full ? "Fully charged" : "Calculating..."
|
||||||
|
} else {
|
||||||
|
if (BatteryState.hour_to_empty > 0) return "Remaining: " + BatteryState.hour_to_empty + "h " + BatteryState.min_to_empty + "min"
|
||||||
|
if (BatteryState.min_to_empty > 0) return "Remaining: " + BatteryState.min_to_empty + "min"
|
||||||
|
return "Calculating..."
|
||||||
|
}
|
||||||
|
}
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
color: Colors.primary
|
color: Colors.primary
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
@@ -135,42 +212,7 @@ MouseArea {
|
|||||||
font.family: Config.font
|
font.family: Config.font
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
text: "State: " + BatteryState.state
|
text: "Health: " + Math.round(BatteryState.health) + " %"
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
color: Colors.primary
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
font.pixelSize: Config.font_size_tiny(bar.height)
|
|
||||||
font.family: Config.font
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
text: "energy: " + Math.round(BatteryState.energy*10)/10 + " W"
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
color: Colors.primary
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
font.pixelSize: Config.font_size_tiny(bar.height)
|
|
||||||
font.family: Config.font
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
text: (
|
|
||||||
BatteryState.hour_to_empty > 0 ? "Remaining: " + BatteryState.hour_to_empty + "h " + BatteryState.min_to_empty + "min" :
|
|
||||||
BatteryState.min_to_empty > 0 ? "Remaining: " + BatteryState.min_to_empty + "min" :
|
|
||||||
"NaN")
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
color: Colors.primary
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
font.pixelSize: Config.font_size_tiny(bar.height)
|
|
||||||
font.family: Config.font
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
text: "Usage: " + BatteryState.energy_rate_formated + " W"
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
color: Colors.primary
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
font.pixelSize: Config.font_size_tiny(bar.height)
|
|
||||||
font.family: Config.font
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
text: "Health: " + BatteryState.health + " %"
|
|
||||||
visible: BatteryState.healthSupported
|
visible: BatteryState.healthSupported
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
color: Colors.primary
|
color: Colors.primary
|
||||||
|
|||||||
@@ -13,11 +13,20 @@ MouseArea {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
// NotificationS.soundEnabled = !NotificationS.soundEnabled
|
// NotificationS.notificationPopupEnabled = !NotificationS.notificationPopupEnabled
|
||||||
console.log("[NotificationButton] Opening NotificationHistory")
|
console.log("[NotificationButton] Opening NotificationHistory")
|
||||||
root.toggleNotificationHistory()
|
root.toggleNotificationHistory()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Report hover to NotificationServer for auto-close logic ──
|
||||||
|
onContainsMouseChanged: NotificationS.buttonHovered = containsMouse
|
||||||
|
Component.onDestruction: {
|
||||||
|
if (containsMouse) NotificationS.buttonHovered = false
|
||||||
|
}
|
||||||
|
onVisibleChanged: {
|
||||||
|
if (!visible && NotificationS.buttonHovered) NotificationS.buttonHovered = false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
anchors.top: parent.topBar
|
anchors.top: parent.topBar
|
||||||
@@ -47,17 +56,10 @@ MouseArea {
|
|||||||
id: notificationText
|
id: notificationText
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
// text: Quickshell.iconPath("discord")
|
// text: Quickshell.iconPath("discord")
|
||||||
text: NotificationS.soundEnabled ? "" : ""
|
text: NotificationS.notificationPopupEnabled ? "" : ""
|
||||||
font.pixelSize: Config.bigIconSize(bar.height)
|
font.pixelSize: Config.bigIconSize(bar.height)
|
||||||
font.family: Config.font
|
font.family: Config.font
|
||||||
color: Colors.secondaryContainer_fg
|
color: Colors.secondaryContainer_fg
|
||||||
}
|
}
|
||||||
|
|
||||||
// Image{
|
|
||||||
// id: iconImage
|
|
||||||
// source: Quickshell.iconPath("discord")
|
|
||||||
// width: Config.bigIconSize(notificationButton.height)
|
|
||||||
// height: Config.bigIconSize(notificationButton.height)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import "../../config"
|
import "../../config"
|
||||||
|
import "./notificationServer"
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
|
|
||||||
@@ -16,6 +17,14 @@ Rectangle {
|
|||||||
// When used in history overview we don't want auto-timeout or click-to-close
|
// When used in history overview we don't want auto-timeout or click-to-close
|
||||||
property bool isHistory: false
|
property bool isHistory: false
|
||||||
|
|
||||||
|
// Helpers to handle summary/body placement
|
||||||
|
// - "Message:" title is always static (fixed bug where appName replaced it when image existed)
|
||||||
|
// - If notification only has summary and no body, show summary on the right side
|
||||||
|
property bool hasBody: notification.body !== undefined && notification.body !== null && String(notification.body).trim() !== ""
|
||||||
|
property bool hasSummary: notification.summary !== undefined && notification.summary !== null && String(notification.summary).trim() !== ""
|
||||||
|
property bool showSummaryOnLeft: hasSummary && hasBody
|
||||||
|
property bool showSummaryOnRight: hasSummary && !hasBody
|
||||||
|
|
||||||
property real duration: isHistory ? 0 : (
|
property real duration: isHistory ? 0 : (
|
||||||
notification.expireTimeout > 0 ? notification.expireTimeout*1000 :
|
notification.expireTimeout > 0 ? notification.expireTimeout*1000 :
|
||||||
urgency ? urgency * 2000 :
|
urgency ? urgency * 2000 :
|
||||||
@@ -37,6 +46,18 @@ Rectangle {
|
|||||||
property color textColor: urgency != 3 ? Colors.primary : Colors.tertiary
|
property color textColor: urgency != 3 ? Colors.primary : Colors.tertiary
|
||||||
property color textBGColor: urgency != 3 ? Qt.alpha(Colors.primaryContainer, 0.75) : Qt.alpha(Colors.tertiaryContainer, 0.75)
|
property color textBGColor: urgency != 3 ? Qt.alpha(Colors.primaryContainer, 0.75) : Qt.alpha(Colors.tertiaryContainer, 0.75)
|
||||||
|
|
||||||
|
// Expose hover state for history auto-close (reuse paused logic)
|
||||||
|
readonly property bool isHovered: mouseArea.containsMouse || closingMouseArea.containsMouse || inlineReplyButtonMouseArea.containsMouse || _hoveredActionCount > 0 || inlineReplyTextField.hovered || inlineReplyTextField.activeFocus
|
||||||
|
|
||||||
|
HoverHandler {
|
||||||
|
enabled: root.isHistory
|
||||||
|
blocking: false
|
||||||
|
grabPermissions: PointerHandler.CanTakeOverFromAnything
|
||||||
|
onHoveredChanged: if (hovered) NotificationS.historyHovered = true
|
||||||
|
}
|
||||||
|
// When in history, also keep historyHovered true while any inner element is hovered
|
||||||
|
onIsHoveredChanged: if (isHistory && isHovered) NotificationS.historyHovered = true
|
||||||
|
|
||||||
function closeNotification(dismiss){
|
function closeNotification(dismiss){
|
||||||
if (closing) {
|
if (closing) {
|
||||||
return
|
return
|
||||||
@@ -73,8 +94,8 @@ Rectangle {
|
|||||||
height: Math.max(iconRectangle.height, contentRectangle.height)+contentRow.anchors.margins*2
|
height: Math.max(iconRectangle.height, contentRectangle.height)+contentRow.anchors.margins*2
|
||||||
width: parent.width
|
width: parent.width
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
border.width: Config.border_width
|
// border.width: Config.border_width
|
||||||
border.color: textColor
|
// border.color: textColor
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: closingMouseArea
|
id: closingMouseArea
|
||||||
@@ -82,26 +103,26 @@ Rectangle {
|
|||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.margins: Config.spacing
|
anchors.margins: Config.spacing
|
||||||
|
|
||||||
width: closeIconText.implicitHeight + Config.spacing
|
width: closeIconText.implicitHeight
|
||||||
height: closeIconText.implicitHeight + Config.spacing
|
height: closeIconText.implicitHeight
|
||||||
|
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
radius: Config.radius
|
radius: Config.radius
|
||||||
color: parent.containsMouse ? Colors.errorContainer : "transparent"
|
color: parent.containsMouse ? "red" : "transparent"
|
||||||
|
|
||||||
border.width: Config.border_width
|
border.width: Config.border_width
|
||||||
border.color: parent.containsMouse ? Colors.error : textColor
|
border.color: parent.containsMouse ? "white" : textColor
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: closeIconText
|
id: closeIconText
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: "✕"; // or "✕"
|
text: ""; // or "✕"
|
||||||
font.family: Config.font
|
font.family: Config.font
|
||||||
font.pixelSize: Config.screen_height_to_font_small(screen.height)
|
font.pixelSize: Config.screen_height_to_font_medium(screen.height)
|
||||||
color: parent.parent.containsMouse ? Colors.error_fg : textColor
|
color: parent.parent.containsMouse ? "white" : textColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onClicked: function(mouse){
|
onClicked: function(mouse){
|
||||||
@@ -153,10 +174,10 @@ Rectangle {
|
|||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: summaryText
|
id: summaryText
|
||||||
// height: implicitHeight + font.pixelSize + Config.spacing
|
|
||||||
|
|
||||||
text: root.notification.summary
|
text: root.notification.summary
|
||||||
visible: root.notification.summary ? true : false
|
// Only show summary under icon when both summary and body exist.
|
||||||
|
// If only summary exists (no body), it will be shown on the right instead.
|
||||||
|
visible: root.showSummaryOnLeft
|
||||||
width: iconColumn.width
|
width: iconColumn.width
|
||||||
font.family: Config.font
|
font.family: Config.font
|
||||||
font.pixelSize: Config.screen_height_to_font_small(screen.height)
|
font.pixelSize: Config.screen_height_to_font_small(screen.height)
|
||||||
@@ -172,37 +193,54 @@ Rectangle {
|
|||||||
Rectangle{
|
Rectangle{
|
||||||
id: contentRectangle
|
id: contentRectangle
|
||||||
width: root.width - iconColumn.width - contentRow.spacing - contentRow.anchors.margins*2
|
width: root.width - iconColumn.width - contentRow.spacing - contentRow.anchors.margins*2
|
||||||
height: iconRectangle.height
|
height: Math.max(iconRectangle.height, contentBodyColumn.implicitHeight)
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: contentBodyColumn
|
id: contentBodyColumn
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: Math.max(childrenRect.height, iconRectangle.height)
|
|
||||||
spacing: Config.spacing
|
spacing: Config.spacing
|
||||||
|
|
||||||
Text {
|
Item {
|
||||||
id: bodyTitleText
|
id: titleTextItem
|
||||||
text: {
|
width: parent.width-closingMouseArea.width
|
||||||
if (notification.image) return notification.appName.charAt(0).toUpperCase() + notification.appName.slice(1)
|
height: closingMouseArea.height
|
||||||
return "Message:"
|
Text {
|
||||||
|
id: bodyTitleText
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: (!notification.appName || !notification.appName.split(".").pop()
|
||||||
|
? "Message"
|
||||||
|
: notification.appName.split(".").pop().charAt(0).toUpperCase()
|
||||||
|
+ notification.appName.split(".").pop().slice(1))
|
||||||
|
font.family: Config.font
|
||||||
|
font.bold: true
|
||||||
|
font.pixelSize: Config.screen_height_to_font_medium(screen.height)
|
||||||
|
color: textColor
|
||||||
}
|
}
|
||||||
font.family: Config.font
|
|
||||||
font.bold: true
|
|
||||||
font.pixelSize: closingMouseArea.height //Config.screen_height_to_font_small(screen.height)
|
|
||||||
color: textColor
|
|
||||||
}
|
}
|
||||||
|
Rectangle {
|
||||||
|
width: parent.width
|
||||||
|
height: Math.max(iconRectangle.height - titleTextItem.height - contentBodyColumn.spacing, 64)
|
||||||
|
color: textBGColor
|
||||||
|
radius: Config.screen_big_radius_fun(screen.height)
|
||||||
|
border.width: Config.border_width
|
||||||
|
border.color: textColor
|
||||||
|
Item{
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: Config.spacing
|
||||||
|
Text {
|
||||||
|
id: bodyText
|
||||||
|
// If only summary exists (no body), show summary on the right instead of left
|
||||||
|
text: root.hasBody ? root.notification.body : (root.showSummaryOnRight ? root.notification.summary : "")
|
||||||
|
visible: root.hasBody || root.showSummaryOnRight
|
||||||
|
|
||||||
Text {
|
width: parent.width - 2*parent.anchors.margins
|
||||||
id: bodyText
|
font.family: Config.font
|
||||||
text: root.notification.body
|
font.pixelSize: Config.screen_height_to_font_tiny(screen.height)
|
||||||
visible: root.notification.body ? true : false
|
color: textColor
|
||||||
|
wrapMode: Text.Wrap
|
||||||
width: contentBodyColumn.width
|
}
|
||||||
font.family: Config.font
|
}
|
||||||
font.pixelSize: Config.screen_height_to_font_tiny(screen.height)
|
|
||||||
color: textColor
|
|
||||||
wrapMode: Text.Wrap
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -213,8 +251,8 @@ Rectangle {
|
|||||||
id: actionRowRectangle
|
id: actionRowRectangle
|
||||||
width: root.width
|
width: root.width
|
||||||
height: Config.screen_height_to_font_tiny(screen.height)+2*Config.spacing
|
height: Config.screen_height_to_font_tiny(screen.height)+2*Config.spacing
|
||||||
border.width: Config.border_width
|
// border.width: Config.border_width
|
||||||
border.color: textColor
|
// border.color: textColor
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
visible: notification.actions.length > 0
|
visible: notification.actions.length > 0
|
||||||
Row{
|
Row{
|
||||||
@@ -298,8 +336,8 @@ Rectangle {
|
|||||||
id: inlineReplyRectangle
|
id: inlineReplyRectangle
|
||||||
width: root.width
|
width: root.width
|
||||||
height: Config.screen_height_to_font_small(screen.height)+2*Config.spacing
|
height: Config.screen_height_to_font_small(screen.height)+2*Config.spacing
|
||||||
border.width: Config.border_width
|
// border.width: Config.border_width
|
||||||
border.color: textColor
|
// border.color: textColor
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
visible: notification.hasInlineReply
|
visible: notification.hasInlineReply
|
||||||
|
|
||||||
@@ -394,8 +432,7 @@ Rectangle {
|
|||||||
from: 1.0
|
from: 1.0
|
||||||
to: 0.0
|
to: 0.0
|
||||||
duration: root.duration
|
duration: root.duration
|
||||||
paused: mouseArea.containsMouse || closingMouseArea.containsMouse || inlineReplyButtonMouseArea.containsMouse || root._hoveredActionCount > 0 || inlineReplyTextField.hovered || inlineReplyTextField.activeFocus
|
paused: isHovered && !isHistory
|
||||||
|
|
||||||
onFinished: root.closeNotification(false)
|
onFinished: root.closeNotification(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import "./notificationServer"
|
|||||||
PanelWindow {
|
PanelWindow {
|
||||||
id: root
|
id: root
|
||||||
implicitWidth: screen.width/5
|
implicitWidth: screen.width/5
|
||||||
implicitHeight: screen.height - Config.barHeight(screen.height)*2
|
implicitHeight: screen.height - Config.barHeight(screen.height)
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
visible: true
|
visible: true
|
||||||
focusable: true
|
focusable: true
|
||||||
@@ -31,8 +31,7 @@ PanelWindow {
|
|||||||
|
|
||||||
property var grouped: {
|
property var grouped: {
|
||||||
const vals = NotificationS.trackedNotifications.values
|
const vals = NotificationS.trackedNotifications.values
|
||||||
const len = vals.length
|
if (!vals || vals.length === 0) return []
|
||||||
if (len < 0) return []
|
|
||||||
let map = {}
|
let map = {}
|
||||||
for (let i = 0; i < vals.length; ++i) {
|
for (let i = 0; i < vals.length; ++i) {
|
||||||
const n = vals[i]
|
const n = vals[i]
|
||||||
@@ -65,22 +64,54 @@ PanelWindow {
|
|||||||
expandedGroups = ({})
|
expandedGroups = ({})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function closeNHistory() {
|
||||||
|
console.log("[NotificationHistory] closeNHistory() requested")
|
||||||
|
NotificationS.historyHovered = false
|
||||||
|
NotificationS.closeHistoryRequested()
|
||||||
|
}
|
||||||
|
|
||||||
|
property bool _allowAutoClose: false
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: graceTimer
|
||||||
|
interval: 500
|
||||||
|
running: root.visible && !_allowAutoClose
|
||||||
|
repeat: false
|
||||||
|
onTriggered: _allowAutoClose = true
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: hoverCloseTimer
|
||||||
|
interval: NotificationS.historyAutoCloseDelay
|
||||||
|
running: root.visible && _allowAutoClose && !NotificationS.historyHovered && !NotificationS.buttonHovered
|
||||||
|
repeat: false
|
||||||
|
onTriggered: {
|
||||||
|
if (!NotificationS.historyHovered && !NotificationS.buttonHovered) {
|
||||||
|
console.log("[NotificationHistory] Auto-closing after hover timeout (" + interval + "ms)")
|
||||||
|
root.closeNHistory()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onVisibleChanged: {
|
||||||
|
if (!visible) {
|
||||||
|
NotificationS.historyHovered = false
|
||||||
|
_allowAutoClose = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Component.onDestruction: NotificationS.historyHovered = false
|
||||||
|
|
||||||
FocusScope {
|
FocusScope {
|
||||||
id: nHistoryScope
|
id: nHistoryScope
|
||||||
|
anchors.fill: parent
|
||||||
focus: true
|
focus: true
|
||||||
|
|
||||||
Keys.onReleased: function(event) {
|
Keys.onReleased: function(event) {
|
||||||
if (event.key === Qt.Key_Escape) {
|
if (event.key === Qt.Key_Escape) {
|
||||||
console.log("Pressed Escape, closing JLearner")
|
console.log("Pressed Escape, closing NotificationHistory")
|
||||||
notifificationHistoryLoader.active = false
|
root.closeNHistory()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
anchors.fill: parent
|
|
||||||
color: "lightblue"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -92,21 +123,14 @@ PanelWindow {
|
|||||||
border.color: textColor
|
border.color: textColor
|
||||||
radius: Config.screen_big_radius_fun(screen.height)
|
radius: Config.screen_big_radius_fun(screen.height)
|
||||||
|
|
||||||
// Text {
|
|
||||||
// anchors.centerIn: parent
|
|
||||||
// font.family: Config.font
|
|
||||||
// font.pixelSize: bigFontSize
|
|
||||||
// color: textColor
|
|
||||||
// wrapMode: Text.Wrap
|
|
||||||
// text: NotificationS.trackedNotifications.values[0]
|
|
||||||
// }
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
HoverHandler {
|
||||||
for (var notification in NotificationS.trackedNotifications.values) {
|
id: backgroundHoverHandler
|
||||||
console.log("[NotificationHistory]: " + notification.appName + " Notifications")
|
blocking: false
|
||||||
}
|
grabPermissions: PointerHandler.CanTakeOverFromAnything
|
||||||
for (var i =0; i < NotificationS.notificationNum; i++) {
|
onHoveredChanged: {
|
||||||
console.log("[NotificationHistory]: " + NotificationS.trackedNotifications.values[i].appName + " Notifications")
|
NotificationS.historyHovered = hovered
|
||||||
|
if (Config.debug == "Notification") console.log("[NotificationHistory] background hovered:", hovered)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +143,7 @@ PanelWindow {
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
id: topBar
|
id: topBar
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: bigFontSize*1.25
|
height: bigFontSize*2.5
|
||||||
color: textBGColor
|
color: textBGColor
|
||||||
radius: Config.screen_big_radius_fun(screen.height)
|
radius: Config.screen_big_radius_fun(screen.height)
|
||||||
border.width: Config.border_width
|
border.width: Config.border_width
|
||||||
@@ -135,20 +159,22 @@ PanelWindow {
|
|||||||
Text{
|
Text{
|
||||||
text: "Notifications:"
|
text: "Notifications:"
|
||||||
font.family: Config.font
|
font.family: Config.font
|
||||||
font.pixelSize: bigFontSize
|
font.pixelSize: topBar.height*0.75
|
||||||
color: textColor
|
color: textColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row{
|
Row{
|
||||||
id: backgroundCenter
|
id: backgroundRight
|
||||||
anchors.centerIn: parent
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
spacing: Config.screen_small_bar_spacing_fun(screen.height)
|
anchors.right: parent.right
|
||||||
|
anchors.rightMargin: Config.screen_spacing_fun(screen.height)
|
||||||
|
spacing: Config.screen_spacing_fun(screen.height)
|
||||||
|
|
||||||
Text{
|
Text{
|
||||||
text: NotificationS.soundEnabled ? "" : ""
|
text: NotificationS.notificationPopupEnabled ? "" : ""
|
||||||
font.family: Config.font
|
font.family: Config.font
|
||||||
font.pixelSize: bigFontSize
|
font.pixelSize: topBar.height*0.75
|
||||||
color: textColor
|
color: textColor
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,9 +182,18 @@ PanelWindow {
|
|||||||
id: notificationVolumeSwitch
|
id: notificationVolumeSwitch
|
||||||
|
|
||||||
implicitWidth: notificationVolumeSwitch.height*2
|
implicitWidth: notificationVolumeSwitch.height*2
|
||||||
implicitHeight: bigFontSize
|
implicitHeight: topBar.height*0.75
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
checked: NotificationS.soundEnabled
|
checked: NotificationS.notificationPopupEnabled
|
||||||
|
hoverEnabled: true
|
||||||
|
|
||||||
|
HoverHandler {
|
||||||
|
id: switchHoverHandler
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
blocking: false
|
||||||
|
grabPermissions: PointerHandler.CanTakeOverFromAnything
|
||||||
|
onHoveredChanged: if (hovered) NotificationS.historyHovered = true
|
||||||
|
}
|
||||||
|
|
||||||
indicator: Rectangle {
|
indicator: Rectangle {
|
||||||
implicitWidth: notificationVolumeSwitch.width
|
implicitWidth: notificationVolumeSwitch.width
|
||||||
@@ -195,25 +230,20 @@ PanelWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
NotificationS.soundEnabled = notificationVolumeSwitch.checked
|
NotificationS.notificationPopupEnabled = notificationVolumeSwitch.checked
|
||||||
console.log("NotificationS.soundEnabled:", NotificationS.soundEnabled)
|
console.log("NotificationS.notificationPopupEnabled:", NotificationS.notificationPopupEnabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Row{
|
|
||||||
id: backgroundRight
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.rightMargin: Config.screen_spacing_fun(screen.height)
|
|
||||||
spacing: Config.screen_spacing_fun(screen.height)
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: closeArea
|
id: closeArea
|
||||||
width: bigFontSize
|
width: closeArea.height
|
||||||
height: bigFontSize
|
height: topBar.height*0.75
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
|
onContainsMouseChanged: if (containsMouse) NotificationS.historyHovered = true
|
||||||
Rectangle{
|
Rectangle{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: closeArea.containsMouse ? "red" : textBGColor
|
color: closeArea.containsMouse ? "red" : textBGColor
|
||||||
@@ -221,15 +251,15 @@ PanelWindow {
|
|||||||
border.width: Config.border_width
|
border.width: Config.border_width
|
||||||
border.color: closeArea.containsMouse ? "white" : textColor
|
border.color: closeArea.containsMouse ? "white" : textColor
|
||||||
Text{
|
Text{
|
||||||
text: ""
|
text: ""
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
font.family: Config.font
|
font.family: Config.font
|
||||||
font.pixelSize: bigFontSize
|
font.pixelSize: closeArea.height - Config.spacing
|
||||||
color: closeArea.containsMouse ? "white" : textColor
|
color: closeArea.containsMouse ? "white" : textColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
closeNHistory()
|
root.clearAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,7 +267,7 @@ PanelWindow {
|
|||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height - topBar.height - bgColumn.spacing //- bgColumn.anchors.margins*2
|
height: parent.height - topBar.height - bgColumn.spacing
|
||||||
color: textBGColor
|
color: textBGColor
|
||||||
radius: Config.screen_big_radius_fun(screen.height)
|
radius: Config.screen_big_radius_fun(screen.height)
|
||||||
border.width: Config.border_width
|
border.width: Config.border_width
|
||||||
@@ -255,8 +285,8 @@ PanelWindow {
|
|||||||
|
|
||||||
Flickable {
|
Flickable {
|
||||||
id: flick
|
id: flick
|
||||||
width: parent.width
|
anchors.fill: parent
|
||||||
// height: Math.min(root.maxContentHeight, contentColumn.implicitHeight)
|
anchors.margins: Config.screen_spacing_fun(screen.height)
|
||||||
contentWidth: width
|
contentWidth: width
|
||||||
contentHeight: contentColumn.implicitHeight
|
contentHeight: contentColumn.implicitHeight
|
||||||
clip: true
|
clip: true
|
||||||
@@ -268,6 +298,182 @@ PanelWindow {
|
|||||||
width: flick.width
|
width: flick.width
|
||||||
spacing: Config.spacing
|
spacing: Config.spacing
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
id: groupedRepeater
|
||||||
|
model: root.grouped
|
||||||
|
delegate: Item {
|
||||||
|
id: delegateRoot
|
||||||
|
required property var modelData
|
||||||
|
required property int index
|
||||||
|
property var group: modelData
|
||||||
|
property bool isGrouped: group.notes.length > 1
|
||||||
|
property bool isExpanded: root.expandedGroups[group.appName] === true
|
||||||
|
|
||||||
|
width: contentColumn.width
|
||||||
|
implicitHeight: isGrouped ? groupedCard.implicitHeight : singleBody.implicitHeight
|
||||||
|
height: implicitHeight
|
||||||
|
|
||||||
|
HoverHandler {
|
||||||
|
blocking: false
|
||||||
|
grabPermissions: PointerHandler.CanTakeOverFromAnything
|
||||||
|
onHoveredChanged: if (hovered) NotificationS.historyHovered = true
|
||||||
|
}
|
||||||
|
|
||||||
|
NotificationBody {
|
||||||
|
id: singleBody
|
||||||
|
visible: !delegateRoot.isGrouped
|
||||||
|
width: parent.width
|
||||||
|
screen: root.screen
|
||||||
|
notification: delegateRoot.group.notes[0]
|
||||||
|
isHistory: true
|
||||||
|
onDismissed: function(notification, dismiss) {
|
||||||
|
if (notification && notification.tracked) notification.dismiss()
|
||||||
|
else if (notification && notification.close) notification.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: groupedCard
|
||||||
|
visible: delegateRoot.isGrouped
|
||||||
|
width: parent.width
|
||||||
|
implicitHeight: groupColumn.implicitHeight + Config.spacing * 2
|
||||||
|
color: Qt.alpha(Colors.surfaceContainerHigh, 0.45)
|
||||||
|
radius: Config.screen_big_radius_fun(root.screen.height)
|
||||||
|
border.width: Config.border_width
|
||||||
|
border.color: root.textColor
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: groupColumn
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: Config.spacing
|
||||||
|
spacing: Config.spacing
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: groupHeader
|
||||||
|
width: parent.width
|
||||||
|
height: Math.max(appNameText.implicitHeight, countText.implicitHeight, expandIcon.implicitHeight, clearGroupIcon.implicitHeight) + Config.spacing * 1.5
|
||||||
|
color: root.bGColor
|
||||||
|
radius: Config.radius
|
||||||
|
border.width: Config.border_width
|
||||||
|
border.color: root.textColor
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
hoverEnabled: true
|
||||||
|
onContainsMouseChanged: if (containsMouse) NotificationS.historyHovered = true
|
||||||
|
onClicked: root.toggleGroup(group.appName)
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: headerLeft
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: Config.spacing
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
spacing: Config.spacing
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: expandIcon
|
||||||
|
text: delegateRoot.isExpanded ? "" : ""
|
||||||
|
font.family: Config.font
|
||||||
|
font.pixelSize: root.fontSize
|
||||||
|
color: root.textColor
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
id: appNameText
|
||||||
|
text: group.appName
|
||||||
|
font.family: Config.font
|
||||||
|
font.pixelSize: root.fontSize
|
||||||
|
font.bold: true
|
||||||
|
color: root.textColor
|
||||||
|
elide: Text.ElideRight
|
||||||
|
maximumLineCount: 1
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
id: countText
|
||||||
|
text: "(" + group.notes.length + ")"
|
||||||
|
font.family: Config.font
|
||||||
|
font.pixelSize: Config.screen_height_to_font_tiny(root.screen.height)
|
||||||
|
color: Qt.alpha(root.textColor, 0.8)
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: headerRight
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.rightMargin: Config.spacing
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
spacing: Config.spacing
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: clearGroupArea
|
||||||
|
width: bigFontSize + Config.spacing
|
||||||
|
height: bigFontSize + Config.spacing
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onContainsMouseChanged: if (containsMouse) NotificationS.historyHovered = true
|
||||||
|
onClicked: function(mouse) {
|
||||||
|
mouse.accepted = true
|
||||||
|
root.clearGroup(group.appName)
|
||||||
|
}
|
||||||
|
Rectangle{
|
||||||
|
anchors.fill: parent
|
||||||
|
radius: Config.screen_big_radius_fun(screen.height)
|
||||||
|
color: clearGroupArea.containsMouse ? "red" : textBGColor
|
||||||
|
border.width: Config.border_width
|
||||||
|
border.color: clearGroupArea.containsMouse ? "white" : textColor
|
||||||
|
Text{
|
||||||
|
id: clearGroupIcon
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: ""
|
||||||
|
font.family: Config.font
|
||||||
|
font.pixelSize: bigFontSize
|
||||||
|
color: clearGroupArea.containsMouse ? "white" : textColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: notificationsColumn
|
||||||
|
width: parent.width
|
||||||
|
spacing: Config.spacing
|
||||||
|
visible: delegateRoot.isExpanded
|
||||||
|
Repeater {
|
||||||
|
model: group.notes
|
||||||
|
delegate: NotificationBody {
|
||||||
|
required property var modelData
|
||||||
|
required property int index
|
||||||
|
width: notificationsColumn.width
|
||||||
|
screen: root.screen
|
||||||
|
notification: modelData
|
||||||
|
isHistory: true
|
||||||
|
onDismissed: function(notification, dismiss) {
|
||||||
|
if (notification && notification.tracked) notification.dismiss()
|
||||||
|
else if (notification && notification.close) notification.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
visible: !delegateRoot.isExpanded && group.notes.length > 1
|
||||||
|
width: parent.width
|
||||||
|
text: group.notes.length + " notification" + (group.notes.length > 1 ? "s hidden" : " hidden") + " — click header to expand"
|
||||||
|
font.family: Config.font
|
||||||
|
font.pixelSize: Config.screen_height_to_font_tiny(root.screen.height)
|
||||||
|
color: Qt.alpha(root.textColor, 0.6)
|
||||||
|
elide: Text.ElideRight
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,20 @@ Item { // container, invisible
|
|||||||
active: false
|
active: false
|
||||||
NotificationHistory {
|
NotificationHistory {
|
||||||
id: nHistory
|
id: nHistory
|
||||||
|
// closeNHistory() is defined inside NotificationHistory.qml and
|
||||||
|
// emits NotificationS.closeHistoryRequested(); the loader listens below
|
||||||
|
// and actually deactivates. Keeping instance id for potential direct access.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function closeNHistory() {
|
// React to close requests coming from NotificationHistory (hover timer, Escape)
|
||||||
nHistoryLoader.closeNHistory()
|
// or any other component via the singleton signal. This is the single
|
||||||
}
|
// source of truth for deactivating the history panel.
|
||||||
|
Connections {
|
||||||
|
target: NotificationS
|
||||||
|
function onCloseHistoryRequested() {
|
||||||
|
console.log("[NotificationHistoryLoader] closeHistoryRequested received -> closing")
|
||||||
|
nHistoryLoader.closeNHistory()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,11 +47,19 @@ Item { // container, invisible
|
|||||||
}
|
}
|
||||||
|
|
||||||
function closeNHistory() {
|
function closeNHistory() {
|
||||||
|
// Reset hover states so timer doesn't immediately re-trigger on next open
|
||||||
|
NotificationS.historyHovered = false
|
||||||
|
// buttonHovered is managed by the button itself; don't force false here
|
||||||
|
// in case button is still hovered when history closes
|
||||||
notifificationHistoryLoader.active = false
|
notifificationHistoryLoader.active = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleNHistory() {
|
function toggleNHistory() {
|
||||||
notifificationHistoryLoader.active = !notifificationHistoryLoader.active
|
if (notifificationHistoryLoader.active) {
|
||||||
|
closeNHistory()
|
||||||
|
} else {
|
||||||
|
openNHistory()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
|||||||
@@ -12,13 +12,24 @@ Item {
|
|||||||
|
|
||||||
property var focusedMonitor: null
|
property var focusedMonitor: null
|
||||||
property var newestNotification: null
|
property var newestNotification: null
|
||||||
property bool soundEnabled: true
|
property bool notificationPopupEnabled: true
|
||||||
|
|
||||||
property alias trackedNotifications: notificationServer.trackedNotifications
|
property alias trackedNotifications: notificationServer.trackedNotifications
|
||||||
property int notificationNum: trackedNotifications.values.length
|
property int notificationNum: trackedNotifications.values.length
|
||||||
|
|
||||||
signal notificationReceived(var notification)
|
signal notificationReceived(var notification)
|
||||||
|
|
||||||
|
// ── Hover state for history auto-close ──
|
||||||
|
// Updated by NotificationHistory.qml (PanelWindow hover) and NotificationButton.qml (bar button hover)
|
||||||
|
property bool historyHovered: false
|
||||||
|
property bool buttonHovered: false
|
||||||
|
property int historyAutoCloseDelay: 1000
|
||||||
|
signal closeHistoryRequested()
|
||||||
|
|
||||||
|
// Debug logging for hover transitions
|
||||||
|
onHistoryHoveredChanged: Config.debug == "Notification" && console.log("[NotificationServer] historyHovered:", historyHovered)
|
||||||
|
onButtonHoveredChanged: Config.debug == "Notification" && console.log("[NotificationServer] buttonHovered:", buttonHovered)
|
||||||
|
|
||||||
function correctMonitor(screen) {
|
function correctMonitor(screen) {
|
||||||
return (Hyprland.monitorFor(screen) === focusedMonitor)
|
return (Hyprland.monitorFor(screen) === focusedMonitor)
|
||||||
}
|
}
|
||||||
@@ -83,7 +94,7 @@ Item {
|
|||||||
repeat: false
|
repeat: false
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if(!notification.lastGeneration && notificationServerState.soundEnabled){
|
if((!notification.lastGeneration && notificationServerState.notificationPopupEnabled) || Config.debug == "Notification"){
|
||||||
focusedMonitor = Hyprland.focusedMonitor
|
focusedMonitor = Hyprland.focusedMonitor
|
||||||
notificationReceived(notification)
|
notificationReceived(notification)
|
||||||
notificationSound.play()
|
notificationSound.play()
|
||||||
|
|||||||
Reference in New Issue
Block a user