mirror of
https://github.com/kittywitch/nixfiles.git
synced 2026-02-09 04:19:19 -08:00
fix: notifications
This commit is contained in:
parent
04732abbc8
commit
fb4da4296e
4 changed files with 177 additions and 136 deletions
59
quickshell/Components/NotificationActions.qml
Normal file
59
quickshell/Components/NotificationActions.qml
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Widgets
|
||||||
|
import Quickshell.Io
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Controls
|
||||||
|
import "root:/DataSources"
|
||||||
|
import "root:/Helpers"
|
||||||
|
import Quickshell.Services.Notifications
|
||||||
|
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
required property Notification modelData_
|
||||||
|
|
||||||
|
Layout.minimumHeight: 0
|
||||||
|
Layout.preferredHeight: modelData_.actions != [] ? 30 : 0
|
||||||
|
visible: modelData_.actions != []
|
||||||
|
spacing: 5
|
||||||
|
Repeater {
|
||||||
|
model: modelData_.actions
|
||||||
|
|
||||||
|
Item {
|
||||||
|
required property NotificationAction actionData
|
||||||
|
|
||||||
|
width: 100
|
||||||
|
height: 30
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
leftMargin: 5
|
||||||
|
top: parent.top
|
||||||
|
topMargin: 5
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: Stylix.base02
|
||||||
|
radius: 5
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: actionData.text
|
||||||
|
color: Stylix.base05
|
||||||
|
font.pixelSize: 12
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
leftMargin: 10
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: actionData.invoke()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -65,7 +65,7 @@ Item {
|
||||||
id: wrapperPopup
|
id: wrapperPopup
|
||||||
visible: false
|
visible: false
|
||||||
anchor.window: root.QsWindow.window
|
anchor.window: root.QsWindow.window
|
||||||
anchor.rect.y: parentWindow.height
|
anchor.rect.y: parentWindow?.height ?? 0
|
||||||
anchor.rect.x: clicky
|
anchor.rect.x: clicky
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
|
|
@ -140,150 +140,40 @@ Item {
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: indivNotif
|
id: indivNotif
|
||||||
anchors {
|
|
||||||
fill: parent
|
|
||||||
leftMargin: 5
|
|
||||||
rightMargin: 5
|
|
||||||
}
|
|
||||||
color: Stylix.base02
|
color: Stylix.base02
|
||||||
ColumnLayout {
|
radius: 5
|
||||||
anchors {
|
anchors {
|
||||||
fill: parent
|
fill: parent
|
||||||
leftMargin: 5
|
leftMargin: 5
|
||||||
rightMargin: 5
|
rightMargin: 5
|
||||||
}
|
}
|
||||||
RowLayout {
|
RowLayout {
|
||||||
spacing: 5
|
anchors {
|
||||||
ClippingWrapperRectangle {
|
fill: parent
|
||||||
radius: 5
|
}
|
||||||
Layout.minimumWidth: 0
|
NotificationImage {
|
||||||
Layout.minimumHeight: 0
|
image: modelData.image
|
||||||
Layout.maximumWidth: 60
|
}
|
||||||
Layout.preferredWidth: 60
|
ColumnLayout {
|
||||||
Layout.preferredHeight: 60
|
|
||||||
Layout.leftMargin: 5
|
Layout.leftMargin: 5
|
||||||
Layout.rightMargin: 5
|
Layout.rightMargin: 5
|
||||||
visible: modelData.image != ""
|
Layout.fillWidth: true
|
||||||
Image {
|
NotificationHeader {
|
||||||
fillMode: Image.PreserveAspectCrop
|
modelData_: modelData
|
||||||
Layout.minimumWidth: 0
|
|
||||||
Layout.minimumHeight: 0
|
|
||||||
Layout.preferredWidth: 60
|
|
||||||
Layout.preferredHeight: 60
|
|
||||||
source: modelData.image
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ColumnLayout {
|
|
||||||
spacing: 5
|
|
||||||
RowLayout {
|
|
||||||
spacing: 5
|
|
||||||
IconImage {
|
|
||||||
function getIcon() {
|
|
||||||
console.log(modelData.appIcon)
|
|
||||||
if (modelData.appIcon != "") {
|
|
||||||
return Quickshell.iconPath(modelData.appIcon)
|
|
||||||
} else {
|
|
||||||
return iconForId(modelData.appName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
width: 24
|
|
||||||
height: 24
|
|
||||||
visible: modelData.appIcon != ""
|
|
||||||
source: Quickshell.iconPath(modelData.appIcon)
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
elide: Text.ElideRight
|
|
||||||
text: modelData.summary
|
|
||||||
color: Stylix.base05
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
id: dismiss
|
|
||||||
text: ""
|
|
||||||
color: Stylix.base08
|
|
||||||
font.pixelSize: 16
|
|
||||||
|
|
||||||
ToolTip {
|
|
||||||
id: dismissTooltip
|
|
||||||
visible: false
|
|
||||||
delay: 500
|
|
||||||
timeout: 1000
|
|
||||||
text: "Dismiss notification"
|
|
||||||
}
|
|
||||||
|
|
||||||
HoverHandler {
|
|
||||||
id: dismissHover
|
|
||||||
onHoveredChanged: {
|
|
||||||
dismissTooltip.visible = hovered
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Layout.topMargin: 5
|
|
||||||
Layout.rightMargin: 10
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: {
|
|
||||||
modelData.dismiss();
|
|
||||||
if (Notifications.list.length <= 0) {
|
|
||||||
popup.visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
font.pointSize: 10
|
font.pointSize: 10
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredWidth: modelData.image != "" ? indivNotif.width - 80 : indivNotif.width
|
||||||
|
Layout.maximumWidth: indivNotif.width
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
text: modelData.body
|
text: modelData.body
|
||||||
color: Stylix.base05
|
color: Stylix.base05
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
NotificationActions {
|
||||||
RowLayout {
|
modelData_: modelData
|
||||||
Layout.minimumHeight: 0
|
|
||||||
visible: modelData.actions != []
|
|
||||||
spacing: 5
|
|
||||||
Repeater {
|
|
||||||
model: modelData.actions
|
|
||||||
|
|
||||||
Item {
|
|
||||||
required property NotificationAction actionData
|
|
||||||
|
|
||||||
width: 400
|
|
||||||
height: 30
|
|
||||||
|
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
leftMargin: 5
|
|
||||||
top: parent.top
|
|
||||||
topMargin: 5
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
anchors.fill: parent
|
|
||||||
color: Stylix.base02
|
|
||||||
radius: 5
|
|
||||||
|
|
||||||
Text {
|
|
||||||
text: actionData.text
|
|
||||||
color: Stylix.base05
|
|
||||||
font.pixelSize: 12
|
|
||||||
|
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
leftMargin: 10
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: actionData.invoke()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
67
quickshell/Components/NotificationHeader.qml
Normal file
67
quickshell/Components/NotificationHeader.qml
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Widgets
|
||||||
|
import Quickshell.Io
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Controls
|
||||||
|
import "root:/DataSources"
|
||||||
|
import "root:/Helpers"
|
||||||
|
import Quickshell.Services.Notifications
|
||||||
|
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
required property Notification modelData_
|
||||||
|
IconImage {
|
||||||
|
function getIcon() {
|
||||||
|
console.log(modelData_.appIcon)
|
||||||
|
if (modelData_.appIcon != "") {
|
||||||
|
return Quickshell.iconPath(modelData_.appIcon)
|
||||||
|
} else {
|
||||||
|
return iconForId(modelData_.appName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
width: 24
|
||||||
|
height: 24
|
||||||
|
visible: modelData_.appIcon != ""
|
||||||
|
source: Quickshell.iconPath(modelData_.appIcon)
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
elide: Text.ElideRight
|
||||||
|
text: modelData_.summary
|
||||||
|
color: Stylix.base05
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
id: dismiss
|
||||||
|
text: ""
|
||||||
|
color: Stylix.base08
|
||||||
|
font.pixelSize: 16
|
||||||
|
|
||||||
|
ToolTip {
|
||||||
|
id: dismissTooltip
|
||||||
|
visible: false
|
||||||
|
delay: 500
|
||||||
|
timeout: 1000
|
||||||
|
text: "Dismiss notification"
|
||||||
|
}
|
||||||
|
|
||||||
|
HoverHandler {
|
||||||
|
id: dismissHover
|
||||||
|
onHoveredChanged: {
|
||||||
|
dismissTooltip.visible = hovered
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Layout.topMargin: 5
|
||||||
|
Layout.rightMargin: 10
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
modelData_.dismiss();
|
||||||
|
if (Notifications.list.length <= 0) {
|
||||||
|
popup.visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
quickshell/Components/NotificationImage.qml
Normal file
25
quickshell/Components/NotificationImage.qml
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Widgets
|
||||||
|
import Quickshell.Io
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Controls
|
||||||
|
import "root:/DataSources"
|
||||||
|
import "root:/Helpers"
|
||||||
|
import Quickshell.Services.Notifications
|
||||||
|
|
||||||
|
|
||||||
|
ClippingWrapperRectangle {
|
||||||
|
required property string image
|
||||||
|
radius: 5
|
||||||
|
Layout.preferredWidth: visible ? 80 : 0
|
||||||
|
Layout.preferredHeight: visible ? parent.height : 0
|
||||||
|
visible: image != ""
|
||||||
|
color: Stylix.base00
|
||||||
|
Image {
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
Layout.preferredWidth: 80
|
||||||
|
Layout.preferredHeight: parent.height
|
||||||
|
source: image
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue