feat: add DnD, notification status icon and fallback image for media preview

This commit is contained in:
Nydragon 2024-12-23 18:40:11 +01:00
parent 4566e0d449
commit 8b27f1f47d
Signed by: nydragon
SSH key fingerprint: SHA256:WcjW5NJPQ8Dx4uQDmoIlVPLWE27Od3fxoe0IUvuoPHE
9 changed files with 82 additions and 18 deletions

View file

@ -131,6 +131,7 @@ PanelWindow {
from: 0
to: 100
stepSize: 1
visible: NyshState.binBrightnessctl
value: Brightness.value
onMoved: Brightness.value = value
}

View file

@ -7,6 +7,7 @@ import "windows/notificationtoast"
import "base"
import "provider"
import Quickshell
import Quickshell.Widgets
import QtQuick
import QtQuick.Layouts
@ -74,6 +75,19 @@ PanelWindow {
BButton {
id: mouse
onClicked: NyshState.toggleDash()
IconImage {
source: {
if (NyshState.dndOn)
Quickshell.iconPath("notifications-disabled");
else if (Notifications.list.values.length)
Quickshell.iconPath("notification-active-symbolic");
else
Quickshell.iconPath("notification-inactive-symbolic");
}
anchors.margins: 2
anchors.fill: parent
}
height: width
width: 30
anchors.bottom: parent.bottom

View file

@ -12,6 +12,7 @@ Rectangle {
anchors.fill: parent
source: root.source
Layout.alignment: Qt.AlignHCenter
fillMode: Image.PreserveAspectCrop
visible: false
}
@ -33,8 +34,7 @@ Rectangle {
Rectangle {
id: mask
width: image.width
height: image.height
anchors.fill: parent
layer.enabled: true
visible: false

View file

@ -8,7 +8,7 @@ Singleton {
property int value: -1
property bool first: true
function refresh() {
get.running = true;
get.running = true && NyshState.binBrightnessctl;
}
onValueChanged: () => {
@ -21,7 +21,7 @@ Singleton {
Process {
id: get
command: ["brightnessctl", "i", "-m"]
running: true
running: true && NyshState.binBrightnessctl
stdout: SplitParser {
onRead: rawData => {
const value = Number(rawData.split(",")[3]?.replace("%", "") ?? "");

View file

@ -8,6 +8,18 @@ Singleton {
property bool dashOpen: false
property bool workspaceViewOpen: false
property bool binBrightnessctl: false
property bool dndOn: false
Process {
command: ["which", "brightnessctl"]
running: true
onExited: (code, status) => {
state.binBrightnessctl = !code;
}
}
IpcHandler {
target: "dash"
@ -16,6 +28,18 @@ Singleton {
}
}
IpcHandler {
target: "dnd"
function toggle() {
state.toggleDnD();
}
function set(val: bool) {
state.dndOn = val;
}
}
IpcHandler {
target: "workspace-view"
@ -24,6 +48,10 @@ Singleton {
}
}
function toggleDnD() {
state.dndOn = !state.dndOn;
}
function toggleWorkspaceView() {
state.workspaceViewOpen = !state.workspaceViewOpen;
}

View file

@ -47,7 +47,7 @@ Singleton {
case "296":
return day ? "weather-showers-scattered" : "weather-showers-scattered-night";
default:
console.log("Unknown weather code:", weatherCode);
weatherCode != "undefined" && console.log("Unknown weather code:", weatherCode);
return "weather-none-available";
}
}

View file

@ -27,15 +27,25 @@ BRectangle {
spacing: 10
delegate: BRectangle {
id: card
required property int index
required property var modelData
property MprisPlayer player: modelData
visible: card.player?.trackTitle
width: mprisSmall.width
height: mprisSmall.height
radius: 15
property string albumArt: {
if (card.player?.trackArtUrl?.length)
card.player?.trackArtUrl;
else
Quickshell.iconPath(DesktopEntries.byId(card.player?.desktopEntry).icon);
}
BlurredImage {
source: card.player?.trackArtUrl ?? ""
source: albumArt
anchors.fill: parent
radius: parent.radius
}
@ -47,7 +57,7 @@ BRectangle {
id: im
color: "transparent"
visible: false
source: card.player?.trackArtUrl ?? ""
source: albumArt
radius: 15
}

View file

@ -1,5 +1,7 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import "../../provider"
import "../../base"
@ -11,13 +13,24 @@ ColumnLayout {
width: parent.width
BButton {
width: 30
height: 30
onClicked: () => {
Notifications.clearAll();
RowLayout {
BButton {
width: 30
height: 30
onClicked: () => {
Notifications.clearAll();
}
Layout.alignment: Qt.AlignRight
}
Switch {
id: sw
text: qsTr("DnD")
onClicked: () => {
NyshState.dndOn = checked;
}
checked: NyshState.dndOn
}
Layout.alignment: Qt.AlignRight
}
ListView {

View file

@ -1,13 +1,11 @@
import QtQuick
import Quickshell
import QtQuick.Controls
import "root:provider"
import "root:base"
import "../../provider"
import "../../widgets/notifications"
PanelWindow {
id: popups
visible: true
visible: !NyshState.dndOn
anchors {
left: true
@ -44,7 +42,7 @@ PanelWindow {
id: data
Component.onCompleted: () => {
Notifications.incomingAdded.connect(n => {
data.insert(0, {
!NyshState.dndOn && data.insert(0, {
notif: n
});
});