feat: make right bar side dependant on devices
This commit is contained in:
1 parent
c7fb3f9c02
commit
832d2544da
13 files changed
+630
-17
No files matched your search
@@ -66,6 +66,8 @@
|
|||||||
hyprmod.packages.${pkgs.stdenv.hostPlatform.system}.default
|
hyprmod.packages.${pkgs.stdenv.hostPlatform.system}.default
|
||||||
librepods
|
librepods
|
||||||
easyeffects
|
easyeffects
|
||||||
|
lutris
|
||||||
|
claude-code
|
||||||
];
|
];
|
||||||
|
|
||||||
home.file = {
|
home.file = {
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ show_swap = true
|
|||||||
swap_disk = true
|
swap_disk = true
|
||||||
|
|
||||||
#* If mem box should be split to also show disks info.
|
#* If mem box should be split to also show disks info.
|
||||||
show_disks = true
|
show_disks = false
|
||||||
|
|
||||||
#* Filter out non physical disks. Set this to False to include network disks, RAM disks and similar.
|
#* Filter out non physical disks. Set this to False to include network disks, RAM disks and similar.
|
||||||
only_physical = true
|
only_physical = true
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import Quickshell
|
|||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
|
import Quickshell.Services.UPower
|
||||||
import "../Shared"
|
import "../Shared"
|
||||||
|
|
||||||
PanelWindow {
|
PanelWindow {
|
||||||
@@ -10,6 +11,10 @@ PanelWindow {
|
|||||||
|
|
||||||
// Reference to global state
|
// Reference to global state
|
||||||
property QtObject rootState
|
property QtObject rootState
|
||||||
|
// Shared overlay window that renders tray icon hover tooltips (see
|
||||||
|
// TrayTooltip.qml) so this bar's own surface can stay exactly as tall
|
||||||
|
// as the pill itself.
|
||||||
|
property QtObject trayTooltip
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
top: true
|
top: true
|
||||||
@@ -17,17 +22,24 @@ PanelWindow {
|
|||||||
right: true
|
right: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Matches hyprland.lua's general.gaps_out (20) so the gap above the bar
|
||||||
|
// (this margin) and the gap below it (added by Hyprland once the
|
||||||
|
// exclusiveZone ends) read as the same size.
|
||||||
|
readonly property int hyprGapsOut: 20
|
||||||
|
|
||||||
margins {
|
margins {
|
||||||
top: Theme.geometry.padding
|
top: hyprGapsOut
|
||||||
left: Theme.geometry.padding
|
left: hyprGapsOut
|
||||||
right: Theme.geometry.padding
|
right: hyprGapsOut
|
||||||
}
|
}
|
||||||
|
|
||||||
exclusiveZone: implicitHeight + margins.top + Theme.geometry.padding
|
// No separate bottom buffer here — Hyprland's gaps_out already adds its
|
||||||
|
// own gap between the reserved zone and the tiled window below.
|
||||||
|
exclusiveZone: implicitHeight + margins.top
|
||||||
|
|
||||||
implicitHeight: 40
|
implicitHeight: 40
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
WlrLayershell.layer: WlrLayer.Top
|
WlrLayershell.layer: WlrLayer.Top
|
||||||
WlrLayershell.namespace: "quickshell-bar"
|
WlrLayershell.namespace: "quickshell-bar"
|
||||||
|
|
||||||
@@ -100,10 +112,179 @@ PanelWindow {
|
|||||||
Text {
|
Text {
|
||||||
id: clockText
|
id: clockText
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: Qt.formatDateTime(clock.date, "hh:mm") // 24h format
|
text: Qt.formatDateTime(clock.date, "hh:mm")
|
||||||
color: Theme.colors.text
|
color: Theme.colors.text
|
||||||
font.family: Theme.font.family
|
font.family: Theme.font.family
|
||||||
font.bold: true
|
font.bold: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Right Pill (System tray: WiFi, Bluetooth, Battery)
|
||||||
|
// Hidden entirely when none of the tray icons have anything to show.
|
||||||
|
Rectangle {
|
||||||
|
id: rightPill
|
||||||
|
visible: wifiPoll.connected || bluetoothPoll.connectedDevices.length > 0 || battery.isPresent
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
height: parent.height
|
||||||
|
width: rightPillRow.width + Theme.geometry.padding * 2
|
||||||
|
radius: Theme.geometry.pillRadius
|
||||||
|
color: Theme.colors.surface
|
||||||
|
border.color: Theme.colors.border
|
||||||
|
border.width: 1
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: rightPillRow
|
||||||
|
anchors.centerIn: parent
|
||||||
|
spacing: Theme.geometry.spacing
|
||||||
|
|
||||||
|
TrayIcon {
|
||||||
|
glyph: "" // nf-fa-wifi
|
||||||
|
active: wifiPoll.connected
|
||||||
|
tooltip: "WiFi: " + wifiPoll.ssid
|
||||||
|
visible: wifiPoll.connected
|
||||||
|
tooltipWindow: barWindow.trayTooltip
|
||||||
|
}
|
||||||
|
|
||||||
|
TrayIcon {
|
||||||
|
glyph: "" // nf-fa-bluetooth_b
|
||||||
|
active: true
|
||||||
|
tooltip: "Bluetooth: " + bluetoothPoll.connectedDevices
|
||||||
|
visible: bluetoothPoll.connectedDevices.length > 0
|
||||||
|
tooltipWindow: barWindow.trayTooltip
|
||||||
|
}
|
||||||
|
|
||||||
|
TrayIcon {
|
||||||
|
glyph: {
|
||||||
|
let p = battery.percentage;
|
||||||
|
if (!battery.isPresent) return ""; // nf-fa-plug (desktop/no battery)
|
||||||
|
if (p >= 0.9) return "";
|
||||||
|
if (p >= 0.65) return "";
|
||||||
|
if (p >= 0.4) return "";
|
||||||
|
if (p >= 0.15) return "";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
active: battery.state === UPowerDeviceState.Charging
|
||||||
|
tooltip: battery.isPresent
|
||||||
|
? "Battery: " + Math.round(battery.percentage * 100) + "%"
|
||||||
|
+ (battery.state === UPowerDeviceState.Charging ? " (charging)" : "")
|
||||||
|
: "No battery"
|
||||||
|
visible: battery.isPresent
|
||||||
|
tooltipWindow: barWindow.trayTooltip
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
property QtObject battery: UPower.displayDevice
|
||||||
|
|
||||||
|
// --- WiFi status (polled via nmcli; requires NetworkManager) ---
|
||||||
|
QtObject {
|
||||||
|
id: wifiPoll
|
||||||
|
property bool connected: false
|
||||||
|
property string ssid: ""
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
interval: 5000
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
triggeredOnStart: true
|
||||||
|
onTriggered: wifiProcess.restart()
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: wifiProcess
|
||||||
|
command: ["bash", "-c", "nmcli -t -f ACTIVE,SSID dev wifi 2>/dev/null | awk -F: '$1==\"yes\"{print $2; exit}'"]
|
||||||
|
running: false
|
||||||
|
function restart() { running = false; running = true; }
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
let ssid = this.text.trim();
|
||||||
|
wifiPoll.connected = ssid.length > 0;
|
||||||
|
wifiPoll.ssid = ssid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Bluetooth status (polled via bluetoothctl) ---
|
||||||
|
QtObject {
|
||||||
|
id: bluetoothPoll
|
||||||
|
property bool available: true
|
||||||
|
property bool powered: false
|
||||||
|
property string connectedDevices: ""
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
interval: 5000
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
triggeredOnStart: true
|
||||||
|
onTriggered: bluetoothProcess.restart()
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: bluetoothProcess
|
||||||
|
command: ["bash", "-c", "powered=$(bluetoothctl show 2>/dev/null | awk -F': ' '/Powered/{print $2}'); devices=$(bluetoothctl devices Connected 2>/dev/null | sed -E 's/^Device [0-9A-F:]+ //' | paste -sd, -); echo \"$powered|$devices\""]
|
||||||
|
running: false
|
||||||
|
function restart() { running = false; running = true; }
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
let parts = this.text.trim().split("|");
|
||||||
|
if (parts[0] === undefined || parts[0] === "") {
|
||||||
|
bluetoothPoll.available = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bluetoothPoll.available = true;
|
||||||
|
bluetoothPoll.powered = parts[0] === "yes";
|
||||||
|
bluetoothPoll.connectedDevices = parts[1] || "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inline component for a hoverable tray icon. The tooltip itself is
|
||||||
|
// rendered by the shared TrayTooltip overlay window (see tooltipWindow)
|
||||||
|
// so it isn't clipped by this bar's small surface.
|
||||||
|
component TrayIcon: Item {
|
||||||
|
id: trayIcon
|
||||||
|
property string glyph: ""
|
||||||
|
property string tooltip: ""
|
||||||
|
property bool active: false
|
||||||
|
property QtObject tooltipWindow
|
||||||
|
|
||||||
|
width: 24
|
||||||
|
height: 24
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
radius: Theme.geometry.radius / 2
|
||||||
|
color: hoverArea.containsMouse
|
||||||
|
? Theme.colors.surfaceHover
|
||||||
|
: (trayIcon.active ? Qt.alpha(Theme.colors.primary, 0.15) : "transparent")
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: trayIcon.glyph
|
||||||
|
font.family: "JetBrainsMono Nerd Font"
|
||||||
|
font.pixelSize: 13
|
||||||
|
color: trayIcon.active ? Theme.colors.primary : Theme.colors.text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: hoverArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
onEntered: {
|
||||||
|
if (trayIcon.tooltipWindow && trayIcon.tooltip.length > 0) {
|
||||||
|
// Anchor on the icon's horizontal center; the tooltip
|
||||||
|
// window centers its bubble under this point itself.
|
||||||
|
let pos = trayIcon.mapToGlobal(trayIcon.width / 2, trayIcon.height + Theme.geometry.spacing / 2);
|
||||||
|
trayIcon.tooltipWindow.showAt(pos.x, pos.y, trayIcon.tooltip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onExited: {
|
||||||
|
if (trayIcon.tooltipWindow) trayIcon.tooltipWindow.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Wayland
|
||||||
|
import "../Shared"
|
||||||
|
|
||||||
|
// Full-screen, click-through overlay used to render tray icon tooltips.
|
||||||
|
// Kept as its own window so the Bar's own surface can stay exactly as tall
|
||||||
|
// as the pill itself (no shadow/margin bloat from an oversized surface).
|
||||||
|
PanelWindow {
|
||||||
|
id: tooltipWindow
|
||||||
|
|
||||||
|
property string shownText: ""
|
||||||
|
property real anchorX: 0
|
||||||
|
property real anchorY: 0
|
||||||
|
|
||||||
|
function showAt(x, y, text) {
|
||||||
|
anchorX = x;
|
||||||
|
anchorY = y;
|
||||||
|
shownText = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide() {
|
||||||
|
shownText = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
top: true
|
||||||
|
left: true
|
||||||
|
right: true
|
||||||
|
bottom: true
|
||||||
|
}
|
||||||
|
|
||||||
|
exclusiveZone: 0
|
||||||
|
color: "transparent"
|
||||||
|
visible: shownText.length > 0
|
||||||
|
|
||||||
|
WlrLayershell.layer: WlrLayer.Overlay
|
||||||
|
WlrLayershell.namespace: "quickshell-tray-tooltip"
|
||||||
|
|
||||||
|
// Never accept input; this window only ever draws a small label.
|
||||||
|
mask: Region {}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
// anchorX is the icon's horizontal center; center this bubble on it,
|
||||||
|
// clamped so it never runs past the screen edges.
|
||||||
|
x: Math.max(
|
||||||
|
Theme.geometry.spacing,
|
||||||
|
Math.min(tooltipWindow.anchorX - width / 2, tooltipWindow.width - width - Theme.geometry.spacing)
|
||||||
|
)
|
||||||
|
y: tooltipWindow.anchorY
|
||||||
|
radius: Theme.geometry.radius / 2
|
||||||
|
color: Theme.colors.background
|
||||||
|
border.color: Theme.colors.border
|
||||||
|
border.width: 1
|
||||||
|
width: label.implicitWidth + Theme.geometry.padding * 2
|
||||||
|
height: label.implicitHeight + Theme.geometry.padding
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: label
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: tooltipWindow.shownText
|
||||||
|
color: Theme.colors.text
|
||||||
|
font.family: Theme.font.family
|
||||||
|
font.pixelSize: 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,6 +25,7 @@ PanelWindow {
|
|||||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
|
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
id: backdrop
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: rootState.clipboardManagerOpen = false
|
onClicked: rootState.clipboardManagerOpen = false
|
||||||
}
|
}
|
||||||
@@ -61,10 +62,13 @@ PanelWindow {
|
|||||||
clip: true
|
clip: true
|
||||||
color: Theme.colors.surface
|
color: Theme.colors.surface
|
||||||
radius: Theme.geometry.radius
|
radius: Theme.geometry.radius
|
||||||
|
border.width: 1
|
||||||
|
border.color: searchInput.activeFocus ? Theme.colors.primary : Theme.colors.border
|
||||||
|
|
||||||
Behavior on height { NumberAnimation { duration: Theme.animation.durationFast } }
|
Behavior on height { NumberAnimation { duration: Theme.animation.durationFast } }
|
||||||
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationFast } }
|
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationFast } }
|
||||||
|
Behavior on border.color { ColorAnimation { duration: Theme.animation.durationFast } }
|
||||||
|
|
||||||
TextInput {
|
TextInput {
|
||||||
id: searchInput
|
id: searchInput
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -165,12 +169,27 @@ PanelWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
id: clipItemMouse
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
onEntered: clipList.currentIndex = index
|
onEntered: clipList.currentIndex = index
|
||||||
onClicked: {
|
onClicked: (mouse) => {
|
||||||
clipList.currentIndex = index;
|
clipList.currentIndex = index;
|
||||||
copyToClipboard(model.id);
|
if (mouse.button === Qt.RightButton) {
|
||||||
|
let pos = clipItemMouse.mapToItem(backdrop, mouse.x, mouse.y);
|
||||||
|
let itemId = model.id;
|
||||||
|
let rawLine = model.rawLine;
|
||||||
|
let itemIndex = index;
|
||||||
|
contextMenu.model = [
|
||||||
|
{ label: "Copy", icon: "⧉", action: function() { copyToClipboard(itemId); } },
|
||||||
|
{ separator: true },
|
||||||
|
{ label: "Delete", icon: "🗑", destructive: true, action: function() { deleteFromClipboard(itemId, rawLine, itemIndex); } }
|
||||||
|
];
|
||||||
|
contextMenu.openAt(pos.x, pos.y);
|
||||||
|
} else {
|
||||||
|
copyToClipboard(model.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,6 +197,17 @@ PanelWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
visible: contextMenu.visible
|
||||||
|
z: 999
|
||||||
|
onClicked: contextMenu.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
ContextMenu {
|
||||||
|
id: contextMenu
|
||||||
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: loadProcess
|
id: loadProcess
|
||||||
command: [
|
command: [
|
||||||
|
|||||||
@@ -88,10 +88,13 @@ PanelWindow {
|
|||||||
clip: true
|
clip: true
|
||||||
color: Theme.colors.surface
|
color: Theme.colors.surface
|
||||||
radius: Theme.geometry.radius
|
radius: Theme.geometry.radius
|
||||||
|
border.width: 1
|
||||||
|
border.color: searchInput.activeFocus ? Theme.colors.primary : Theme.colors.border
|
||||||
|
|
||||||
Behavior on height { NumberAnimation { duration: Theme.animation.durationFast } }
|
Behavior on height { NumberAnimation { duration: Theme.animation.durationFast } }
|
||||||
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationFast } }
|
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationFast } }
|
||||||
|
Behavior on border.color { ColorAnimation { duration: Theme.animation.durationFast } }
|
||||||
|
|
||||||
TextInput {
|
TextInput {
|
||||||
id: searchInput
|
id: searchInput
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ PanelWindow {
|
|||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: Theme.colors.background // Full screen dim/blur
|
color: Theme.colors.overlay // Full screen dim/blur
|
||||||
|
|
||||||
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationNormal } }
|
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationNormal } }
|
||||||
opacity: rootState.logoutMenuOpen ? 1 : 0
|
opacity: rootState.logoutMenuOpen ? 1 : 0
|
||||||
|
|||||||
@@ -0,0 +1,180 @@
|
|||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Wayland
|
||||||
|
import Quickshell.Services.Notifications
|
||||||
|
import "../Shared"
|
||||||
|
|
||||||
|
PanelWindow {
|
||||||
|
id: notifWindow
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
top: true
|
||||||
|
right: true
|
||||||
|
}
|
||||||
|
|
||||||
|
margins {
|
||||||
|
top: Theme.geometry.padding
|
||||||
|
right: Theme.geometry.padding
|
||||||
|
}
|
||||||
|
|
||||||
|
exclusiveZone: 0
|
||||||
|
color: "transparent"
|
||||||
|
implicitWidth: 320
|
||||||
|
implicitHeight: list.height
|
||||||
|
|
||||||
|
WlrLayershell.layer: WlrLayer.Overlay
|
||||||
|
WlrLayershell.namespace: "quickshell-notifications"
|
||||||
|
|
||||||
|
NotificationServer {
|
||||||
|
id: server
|
||||||
|
keepOnReload: true
|
||||||
|
bodySupported: true
|
||||||
|
bodyMarkupSupported: true
|
||||||
|
actionsSupported: true
|
||||||
|
imageSupported: true
|
||||||
|
|
||||||
|
onNotification: notification => {
|
||||||
|
notification.tracked = true;
|
||||||
|
toastModel.insert(0, {
|
||||||
|
notifObj: notification,
|
||||||
|
appName: notification.appName,
|
||||||
|
summary: notification.summary,
|
||||||
|
body: notification.body,
|
||||||
|
urgency: notification.urgency
|
||||||
|
});
|
||||||
|
|
||||||
|
function removeFromModel() {
|
||||||
|
for (let i = 0; i < toastModel.count; i++) {
|
||||||
|
if (toastModel.get(i).notifObj === notification) {
|
||||||
|
toastModel.remove(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
notification.closed.connect(removeFromModel);
|
||||||
|
|
||||||
|
let timeout = notification.expireTimeout > 0 ? notification.expireTimeout : 5000;
|
||||||
|
dismissTimer.createObject(notifWindow, { targetNotification: notification, interval: timeout });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: dismissTimer
|
||||||
|
Timer {
|
||||||
|
property var targetNotification
|
||||||
|
running: true
|
||||||
|
repeat: false
|
||||||
|
onTriggered: {
|
||||||
|
for (let i = 0; i < toastModel.count; i++) {
|
||||||
|
if (toastModel.get(i).notifObj === targetNotification) {
|
||||||
|
toastModel.remove(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ListModel {
|
||||||
|
id: toastModel
|
||||||
|
}
|
||||||
|
|
||||||
|
function colorFor(urgency) {
|
||||||
|
if (urgency === NotificationUrgency.Critical) return Theme.colors.alert;
|
||||||
|
if (urgency === NotificationUrgency.Low) return Theme.colors.success;
|
||||||
|
return Theme.colors.primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
function labelFor(urgency) {
|
||||||
|
if (urgency === NotificationUrgency.Critical) return "Warning";
|
||||||
|
if (urgency === NotificationUrgency.Low) return "Notice";
|
||||||
|
return "Info";
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: list
|
||||||
|
width: parent.width
|
||||||
|
spacing: Theme.geometry.spacing
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: toastModel
|
||||||
|
|
||||||
|
delegate: Rectangle {
|
||||||
|
id: toast
|
||||||
|
width: list.width
|
||||||
|
height: content.implicitHeight + Theme.geometry.padding * 2
|
||||||
|
radius: Theme.geometry.radius
|
||||||
|
color: Qt.alpha(notifWindow.colorFor(model.urgency), 0.15)
|
||||||
|
border.color: Qt.alpha(notifWindow.colorFor(model.urgency), 0.3)
|
||||||
|
border.width: 1
|
||||||
|
|
||||||
|
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationNormal } }
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: content
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.margins: Theme.geometry.padding
|
||||||
|
spacing: Theme.geometry.spacing
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: 16
|
||||||
|
height: 16
|
||||||
|
radius: 8
|
||||||
|
color: notifWindow.colorFor(model.urgency)
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.topMargin: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
width: content.width - 16 - Theme.geometry.spacing - closeIcon.width - Theme.geometry.spacing
|
||||||
|
spacing: 2
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: model.summary && model.summary.length > 0 ? model.summary : model.appName
|
||||||
|
font.family: Theme.font.family
|
||||||
|
font.pixelSize: 12
|
||||||
|
font.bold: true
|
||||||
|
color: notifWindow.colorFor(model.urgency)
|
||||||
|
width: parent.width
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
visible: model.body && model.body.length > 0
|
||||||
|
text: model.body
|
||||||
|
font.family: Theme.font.family
|
||||||
|
font.pixelSize: 12
|
||||||
|
color: Theme.colors.text
|
||||||
|
width: parent.width
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
maximumLineCount: 3
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: closeIcon
|
||||||
|
text: "✕"
|
||||||
|
color: Theme.colors.textMuted
|
||||||
|
font.pixelSize: 12
|
||||||
|
anchors.top: parent.top
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: -6
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: {
|
||||||
|
model.notifObj.dismiss();
|
||||||
|
toastModel.remove(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import QtQuick
|
||||||
|
import "."
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: button
|
||||||
|
|
||||||
|
// "primary" | "secondary" | "accent" | "destructive"
|
||||||
|
property string variant: "primary"
|
||||||
|
property string text: ""
|
||||||
|
signal clicked()
|
||||||
|
|
||||||
|
readonly property bool filled: variant === "primary" || variant === "accent"
|
||||||
|
readonly property color tint: variant === "accent" ? Theme.colors.accent
|
||||||
|
: variant === "destructive" ? Theme.colors.alert
|
||||||
|
: Theme.colors.primary
|
||||||
|
|
||||||
|
implicitWidth: label.implicitWidth + Theme.geometry.padding * 2
|
||||||
|
implicitHeight: label.implicitHeight + Theme.geometry.padding
|
||||||
|
|
||||||
|
radius: Theme.geometry.radius
|
||||||
|
color: filled
|
||||||
|
? (mouseArea.pressed ? Qt.darker(tint, 1.1) : tint)
|
||||||
|
: (mouseArea.containsMouse ? Qt.alpha(tint, 0.22) : Qt.alpha(tint, 0.15))
|
||||||
|
border.width: filled ? 0 : 1
|
||||||
|
border.color: Qt.alpha(tint, 0.3)
|
||||||
|
|
||||||
|
Behavior on color { ColorAnimation { duration: Theme.animation.durationFast } }
|
||||||
|
Behavior on scale { SpringAnimation { spring: 4; damping: 0.3 } }
|
||||||
|
scale: mouseArea.pressed ? 0.97 : 1.0
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: label
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: button.text
|
||||||
|
font.family: Theme.font.family
|
||||||
|
font.pixelSize: 13
|
||||||
|
font.bold: true
|
||||||
|
color: button.filled ? Theme.colors.background : button.tint
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: mouseArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: button.clicked()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
import QtQuick
|
||||||
|
import "."
|
||||||
|
|
||||||
|
// Reusable right-click menu. `model` is a plain JS array of
|
||||||
|
// { label, icon, destructive, separator, action } entries.
|
||||||
|
Rectangle {
|
||||||
|
id: menu
|
||||||
|
|
||||||
|
property var model: []
|
||||||
|
|
||||||
|
visible: false
|
||||||
|
z: 1000
|
||||||
|
width: 180
|
||||||
|
radius: 10
|
||||||
|
color: Theme.colors.background
|
||||||
|
border.color: Theme.colors.border
|
||||||
|
border.width: 1
|
||||||
|
height: column.implicitHeight + Theme.geometry.spacing
|
||||||
|
|
||||||
|
function openAt(px, py) {
|
||||||
|
x = px;
|
||||||
|
y = py;
|
||||||
|
visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Absorb clicks inside the menu so they don't fall through to the backdrop.
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: column
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: Theme.geometry.spacing / 2
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: menu.model
|
||||||
|
|
||||||
|
delegate: Rectangle {
|
||||||
|
width: column.width
|
||||||
|
height: modelData.separator ? 1 : 28
|
||||||
|
radius: modelData.separator ? 0 : 6
|
||||||
|
color: modelData.separator
|
||||||
|
? Theme.colors.border
|
||||||
|
: (itemMouse.containsMouse ? Theme.colors.surfaceHover : "transparent")
|
||||||
|
|
||||||
|
Row {
|
||||||
|
visible: !modelData.separator
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: Theme.geometry.spacing
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
spacing: Theme.geometry.spacing
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: modelData.icon || ""
|
||||||
|
width: 14
|
||||||
|
font.pixelSize: 12
|
||||||
|
color: modelData.destructive ? Theme.colors.alert : Theme.colors.text
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: modelData.label || ""
|
||||||
|
font.family: Theme.font.family
|
||||||
|
font.pixelSize: 12
|
||||||
|
color: modelData.destructive ? Theme.colors.alert : Theme.colors.text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: itemMouse
|
||||||
|
anchors.fill: parent
|
||||||
|
enabled: !modelData.separator
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: {
|
||||||
|
menu.close();
|
||||||
|
if (modelData.action) modelData.action();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,14 +5,17 @@ QtObject {
|
|||||||
id: theme
|
id: theme
|
||||||
|
|
||||||
property QtObject colors: QtObject {
|
property QtObject colors: QtObject {
|
||||||
property color background: "#4011111b" // Translucent dark for blur
|
property color background: "#e611111b" // Opaque dark for better readability
|
||||||
property color surface: "#80181825"
|
property color surface: "#e6181825"
|
||||||
property color surfaceHover: "#a0313244"
|
property color surfaceHover: "#f2313244"
|
||||||
|
property color overlay: "#6011111b" // Translucent dark for full screen dim
|
||||||
|
|
||||||
property color primary: "#89b4fa"
|
property color primary: "#89b4fa"
|
||||||
property color secondary: "#b4befe"
|
property color secondary: "#b4befe"
|
||||||
|
property color accent: "#cba6f7"
|
||||||
property color alert: "#f38ba8"
|
property color alert: "#f38ba8"
|
||||||
property color success: "#a6e3a1"
|
property color success: "#a6e3a1"
|
||||||
|
property color warning: "#f9e2af"
|
||||||
|
|
||||||
property color text: "#cdd6f4"
|
property color text: "#cdd6f4"
|
||||||
property color textMuted: "#a6adc8"
|
property color textMuted: "#a6adc8"
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
singleton Theme 1.0 Theme.qml
|
singleton Theme 1.0 Theme.qml
|
||||||
|
Button 1.0 Button.qml
|
||||||
|
ContextMenu 1.0 ContextMenu.qml
|
||||||
@@ -8,6 +8,7 @@ import "components/OSD"
|
|||||||
import "components/Shared"
|
import "components/Shared"
|
||||||
import "components/LogoutMenu"
|
import "components/LogoutMenu"
|
||||||
import "components/ClipboardManager"
|
import "components/ClipboardManager"
|
||||||
|
import "components/Notifications"
|
||||||
|
|
||||||
ShellRoot {
|
ShellRoot {
|
||||||
id: root
|
id: root
|
||||||
@@ -60,9 +61,14 @@ ShellRoot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TrayTooltip {
|
||||||
|
id: trayTooltip
|
||||||
|
}
|
||||||
|
|
||||||
Bar {
|
Bar {
|
||||||
id: bar
|
id: bar
|
||||||
rootState: root
|
rootState: root
|
||||||
|
trayTooltip: trayTooltip
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandPalette {
|
CommandPalette {
|
||||||
@@ -83,4 +89,8 @@ ShellRoot {
|
|||||||
OSD {
|
OSD {
|
||||||
id: osd
|
id: osd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Notifications {
|
||||||
|
id: notifications
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user