diff options
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/NotificationInhibitorWidget.qml')
| -rw-r--r-- | accounts/gkleen@sif/shell/quickshell/NotificationInhibitorWidget.qml | 213 |
1 files changed, 213 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/NotificationInhibitorWidget.qml b/accounts/gkleen@sif/shell/quickshell/NotificationInhibitorWidget.qml index 3dadbc69..1005182a 100644 --- a/accounts/gkleen@sif/shell/quickshell/NotificationInhibitorWidget.qml +++ b/accounts/gkleen@sif/shell/quickshell/NotificationInhibitorWidget.qml | |||
| @@ -2,6 +2,9 @@ import Quickshell | |||
| 2 | import QtQuick | 2 | import QtQuick |
| 3 | import Quickshell.Widgets | 3 | import Quickshell.Widgets |
| 4 | import qs.Services | 4 | import qs.Services |
| 5 | import QtQuick.Controls | ||
| 6 | import QtQuick.Layouts | ||
| 7 | import QtQuick.Shapes | ||
| 5 | 8 | ||
| 6 | Item { | 9 | Item { |
| 7 | id: root | 10 | id: root |
| @@ -44,4 +47,214 @@ Item { | |||
| 44 | } | 47 | } |
| 45 | } | 48 | } |
| 46 | } | 49 | } |
| 50 | |||
| 51 | Loader { | ||
| 52 | id: tooltipLoader | ||
| 53 | |||
| 54 | active: false | ||
| 55 | |||
| 56 | Connections { | ||
| 57 | target: widgetMouseArea | ||
| 58 | function onContainsMouseChanged() { | ||
| 59 | if (widgetMouseArea.containsMouse) | ||
| 60 | tooltipLoader.active = true; | ||
| 61 | } | ||
| 62 | } | ||
| 63 | |||
| 64 | sourceComponent: PopupWindow { | ||
| 65 | id: tooltip | ||
| 66 | |||
| 67 | property bool nextVisible: !NotificationManager.displayInhibited && (widgetMouseArea.containsMouse || tooltipMouseArea.containsMouse) | ||
| 68 | |||
| 69 | anchor { | ||
| 70 | item: widgetMouseArea | ||
| 71 | edges: Edges.Bottom | Edges.Left | ||
| 72 | } | ||
| 73 | visible: false | ||
| 74 | |||
| 75 | onNextVisibleChanged: hangTimer.restart() | ||
| 76 | |||
| 77 | Timer { | ||
| 78 | id: hangTimer | ||
| 79 | interval: tooltip.visible ? 100 : 500 | ||
| 80 | onTriggered: { | ||
| 81 | tooltip.visible = tooltip.nextVisible; | ||
| 82 | if (!tooltip.visible) | ||
| 83 | tooltipLoader.active = false; | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | implicitWidth: 400 | ||
| 88 | implicitHeight: Math.min(tooltip.screen.height * 0.66, Math.max(100, scroll.contentHeight + 16)) | ||
| 89 | color: "black" | ||
| 90 | |||
| 91 | WrapperMouseArea { | ||
| 92 | id: tooltipMouseArea | ||
| 93 | |||
| 94 | hoverEnabled: true | ||
| 95 | enabled: true | ||
| 96 | |||
| 97 | anchors.fill: parent | ||
| 98 | |||
| 99 | WrapperItem { | ||
| 100 | margin: 8 | ||
| 101 | |||
| 102 | ScrollView { | ||
| 103 | id: scroll | ||
| 104 | |||
| 105 | contentWidth: availableWidth | ||
| 106 | // ScrollBar.vertical.policy: ScrollBar.AlwaysOn | ||
| 107 | |||
| 108 | ColumnLayout { | ||
| 109 | id: historyLayout | ||
| 110 | anchors { | ||
| 111 | left: parent.left | ||
| 112 | right: parent.right | ||
| 113 | } | ||
| 114 | |||
| 115 | spacing: 8 | ||
| 116 | |||
| 117 | Repeater { | ||
| 118 | model: ScriptModel { | ||
| 119 | values: [...NotificationManager.history].reverse().map(o => o.notification) | ||
| 120 | } | ||
| 121 | |||
| 122 | delegate: GridLayout { | ||
| 123 | id: notif | ||
| 124 | |||
| 125 | Layout.fillWidth: true | ||
| 126 | Layout.preferredHeight: notifSummary.contentHeight + (notifBody.visible ? notifBody.contentHeight + 8 : 0) + (notifSep.visible ? notifSep.height + 8 : 0) + notifTime.contentHeight + 8 | ||
| 127 | |||
| 128 | required property var modelData | ||
| 129 | required property int index | ||
| 130 | |||
| 131 | columnSpacing: 8 | ||
| 132 | rowSpacing: 8 | ||
| 133 | |||
| 134 | columns: notifImage.visible ? 2 : 1 | ||
| 135 | rows: { | ||
| 136 | var res = 2; | ||
| 137 | if (notifBody.visible) | ||
| 138 | res += 1; | ||
| 139 | if (notifSep.visible) | ||
| 140 | res += 1; | ||
| 141 | return res; | ||
| 142 | } | ||
| 143 | |||
| 144 | Shape { | ||
| 145 | id: notifSep | ||
| 146 | |||
| 147 | visible: notif.index != 0 | ||
| 148 | |||
| 149 | height: 2 | ||
| 150 | width: 400 - 32 | ||
| 151 | |||
| 152 | ShapePath { | ||
| 153 | strokeWidth: 2 | ||
| 154 | strokeColor: "#20ffffff" | ||
| 155 | startX: 0; startY: 0; | ||
| 156 | PathLine { x: 400 - 32; y: 0; } | ||
| 157 | } | ||
| 158 | |||
| 159 | Layout.row: 0 | ||
| 160 | Layout.column: 0 | ||
| 161 | Layout.columnSpan: notifImage.visible ? 2 : 1 | ||
| 162 | Layout.alignment: Qt.AlignHCenter | ||
| 163 | } | ||
| 164 | |||
| 165 | Text { | ||
| 166 | id: notifSummary | ||
| 167 | |||
| 168 | text: notif.modelData?.summary ?? "" | ||
| 169 | |||
| 170 | font.pointSize: 10 | ||
| 171 | font.family: "Fira Sans" | ||
| 172 | font.italic: true | ||
| 173 | color: "white" | ||
| 174 | maximumLineCount: 1 | ||
| 175 | elide: Text.ElideRight | ||
| 176 | |||
| 177 | Layout.fillWidth: true | ||
| 178 | Layout.row: notifSep.visible ? 1 : 0 | ||
| 179 | Layout.column: notifImage.visible ? 1 : 0 | ||
| 180 | } | ||
| 181 | |||
| 182 | Image { | ||
| 183 | id: notifImage | ||
| 184 | |||
| 185 | visible: (notif.modelData?.image || notif.modelData?.appIcon) ?? false | ||
| 186 | |||
| 187 | onStatusChanged: { | ||
| 188 | if (notifImage.status == Image.Error) | ||
| 189 | notifImage.visible = false; | ||
| 190 | } | ||
| 191 | |||
| 192 | source: (notif.modelData?.image || notif.modelData?.appIcon) ?? "" | ||
| 193 | fillMode: Image.PreserveAspectFit | ||
| 194 | asynchronous: true | ||
| 195 | smooth: true | ||
| 196 | mipmap: true | ||
| 197 | |||
| 198 | Layout.maximumWidth: 50 | ||
| 199 | Layout.column: 0 | ||
| 200 | Layout.row: notifSep.visible ? 1 : 0 | ||
| 201 | Layout.fillHeight: true | ||
| 202 | Layout.rowSpan: notifBody.visible ? 3 : 2 | ||
| 203 | } | ||
| 204 | |||
| 205 | Text { | ||
| 206 | id: notifBody | ||
| 207 | |||
| 208 | visible: notif.modelData?.body ?? false | ||
| 209 | text: notif.modelData?.body ?? "" | ||
| 210 | textFormat: Text.RichText | ||
| 211 | wrapMode: Text.Wrap | ||
| 212 | |||
| 213 | font.pointSize: 10 | ||
| 214 | font.family: "Fira Sans" | ||
| 215 | color: "white" | ||
| 216 | |||
| 217 | Layout.fillWidth: true | ||
| 218 | Layout.row: notifSep.visible ? 2 : 1 | ||
| 219 | Layout.column: notifImage.visible ? 1 : 0 | ||
| 220 | } | ||
| 221 | |||
| 222 | Text { | ||
| 223 | id: notifTime | ||
| 224 | |||
| 225 | Connections { | ||
| 226 | target: NotificationManager.clock | ||
| 227 | function onDateChanged() { | ||
| 228 | notifTime.text = NotificationManager.formatTime(notif.modelData?.receivedTime); | ||
| 229 | } | ||
| 230 | } | ||
| 231 | |||
| 232 | text: NotificationManager.formatTime(notif.modelData?.receivedTime) | ||
| 233 | |||
| 234 | font.pointSize: 8 | ||
| 235 | font.family: "Fira Sans" | ||
| 236 | font.italic: true | ||
| 237 | color: "#555" | ||
| 238 | maximumLineCount: 1 | ||
| 239 | horizontalAlignment: Text.AlignRight | ||
| 240 | |||
| 241 | Layout.fillWidth: true | ||
| 242 | Layout.row: { | ||
| 243 | var res = 1; | ||
| 244 | if (notifSep.visible) | ||
| 245 | res += 1; | ||
| 246 | if (notifBody.visible) | ||
| 247 | res += 1; | ||
| 248 | return res; | ||
| 249 | } | ||
| 250 | Layout.column: notifImage.visible ? 1 : 0 | ||
| 251 | } | ||
| 252 | } | ||
| 253 | } | ||
| 254 | } | ||
| 255 | } | ||
| 256 | } | ||
| 257 | } | ||
| 258 | } | ||
| 259 | } | ||
| 47 | } | 260 | } |
