1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

notifications: swipe to dismiss on history

This commit is contained in:
bbedward
2026-01-12 11:08:22 -05:00
parent 104762186f
commit 4e2ce82c0a
3 changed files with 115 additions and 16 deletions

View File

@@ -8,6 +8,7 @@ bind = SUPER, N, exec, dms ipc call notifications toggle
bind = SUPER SHIFT, N, exec, dms ipc call notepad toggle bind = SUPER SHIFT, N, exec, dms ipc call notepad toggle
bind = SUPER, Y, exec, dms ipc call dankdash wallpaper bind = SUPER, Y, exec, dms ipc call dankdash wallpaper
bind = SUPER, TAB, exec, dms ipc call hypr toggleOverview bind = SUPER, TAB, exec, dms ipc call hypr toggleOverview
bind = SUPER, X, exec, dms ipc call powermenu toggle
# === Cheat sheet # === Cheat sheet
bind = SUPER SHIFT, Slash, exec, dms ipc call keybinds toggle hyprland bind = SUPER SHIFT, Slash, exec, dms ipc call keybinds toggle hyprland

View File

@@ -15,6 +15,8 @@ binds {
Mod+M hotkey-overlay-title="Task Manager" { Mod+M hotkey-overlay-title="Task Manager" {
spawn "dms" "ipc" "call" "processlist" "focusOrToggle"; spawn "dms" "ipc" "call" "processlist" "focusOrToggle";
} }
Super+X hotkey-overlay-title="Power Menu: Toggle" { spawn "dms" "ipc" "call" "powermenu" "toggle"; }
Mod+Comma hotkey-overlay-title="Settings" { Mod+Comma hotkey-overlay-title="Settings" {
spawn "dms" "ipc" "call" "settings" "focusOrToggle"; spawn "dms" "ipc" "call" "settings" "focusOrToggle";
} }

View File

@@ -83,23 +83,54 @@ Item {
} }
readonly property var allFilters: [ readonly property var allFilters: [
{ label: I18n.tr("All", "notification history filter"), key: "all", maxDays: 0 }, {
{ label: I18n.tr("Last hour", "notification history filter"), key: "1h", maxDays: 1 }, label: I18n.tr("All", "notification history filter"),
{ label: I18n.tr("Today", "notification history filter"), key: "today", maxDays: 1 }, key: "all",
{ label: I18n.tr("Yesterday", "notification history filter"), key: "yesterday", maxDays: 2 }, maxDays: 0
{ label: I18n.tr("7 days", "notification history filter"), key: "7d", maxDays: 7 }, },
{ label: I18n.tr("30 days", "notification history filter"), key: "30d", maxDays: 30 }, {
{ label: I18n.tr("Older", "notification history filter for content older than other filters"), key: "older", maxDays: 0 } label: I18n.tr("Last hour", "notification history filter"),
key: "1h",
maxDays: 1
},
{
label: I18n.tr("Today", "notification history filter"),
key: "today",
maxDays: 1
},
{
label: I18n.tr("Yesterday", "notification history filter"),
key: "yesterday",
maxDays: 2
},
{
label: I18n.tr("7 days", "notification history filter"),
key: "7d",
maxDays: 7
},
{
label: I18n.tr("30 days", "notification history filter"),
key: "30d",
maxDays: 30
},
{
label: I18n.tr("Older", "notification history filter for content older than other filters"),
key: "older",
maxDays: 0
}
] ]
function filterRelevantForRetention(filter) { function filterRelevantForRetention(filter) {
const retention = SettingsData.notificationHistoryMaxAgeDays; const retention = SettingsData.notificationHistoryMaxAgeDays;
if (filter.key === "older") { if (filter.key === "older") {
if (retention === 0) return true; if (retention === 0)
return true;
return retention > 2 && retention < 7 || retention > 30; return retention > 2 && retention < 7 || retention > 30;
} }
if (retention === 0) return true; if (retention === 0)
if (filter.maxDays === 0) return true; return true;
if (filter.maxDays === 0)
return true;
return filter.maxDays <= retention; return filter.maxDays <= retention;
} }
@@ -119,10 +150,15 @@ Item {
const retention = SettingsData.notificationHistoryMaxAgeDays; const retention = SettingsData.notificationHistoryMaxAgeDays;
for (let i = 0; i < allFilters.length; i++) { for (let i = 0; i < allFilters.length; i++) {
const f = allFilters[i]; const f = allFilters[i];
if (!filterRelevantForRetention(f)) continue; if (!filterRelevantForRetention(f))
continue;
const count = countForFilter(f.key); const count = countForFilter(f.key);
if (f.key === "all" || count > 0) { if (f.key === "all" || count > 0) {
result.push({ label: f.label, key: f.key, count: count }); result.push({
label: f.label,
key: f.key,
count: count
});
} }
} }
return result; return result;
@@ -165,6 +201,14 @@ Item {
function enableAutoScroll() { function enableAutoScroll() {
} }
function removeWithScrollPreserve(itemId) {
historyListView.savedY = historyListView.contentY;
NotificationService.removeFromHistory(itemId);
Qt.callLater(() => {
historyListView.forceLayout();
});
}
Column { Column {
anchors.fill: parent anchors.fill: parent
spacing: Theme.spacingS spacing: Theme.spacingS
@@ -201,14 +245,66 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
} }
delegate: HistoryNotificationCard { delegate: Item {
id: delegateRoot
required property var modelData required property var modelData
required property int index required property int index
property real swipeOffset: 0
property bool isDismissing: false
readonly property real dismissThreshold: width * 0.35
width: ListView.view.width width: ListView.view.width
historyItem: modelData height: historyCard.height
isSelected: root.keyboardActive && root.selectedIndex === index clip: true
keyboardNavigationActive: root.keyboardActive
HistoryNotificationCard {
id: historyCard
width: parent.width
x: delegateRoot.swipeOffset
historyItem: modelData
isSelected: root.keyboardActive && root.selectedIndex === index
keyboardNavigationActive: root.keyboardActive
opacity: 1 - Math.abs(delegateRoot.swipeOffset) / (delegateRoot.width * 0.5)
Behavior on x {
enabled: !swipeDragHandler.active
NumberAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
Behavior on opacity {
NumberAnimation {
duration: Theme.shortDuration
}
}
}
DragHandler {
id: swipeDragHandler
target: null
yAxis.enabled: false
xAxis.enabled: true
onActiveChanged: {
if (active || delegateRoot.isDismissing)
return;
if (Math.abs(delegateRoot.swipeOffset) > delegateRoot.dismissThreshold) {
delegateRoot.isDismissing = true;
root.removeWithScrollPreserve(delegateRoot.modelData?.id || "");
} else {
delegateRoot.swipeOffset = 0;
}
}
onTranslationChanged: {
if (delegateRoot.isDismissing)
return;
delegateRoot.swipeOffset = translation.x;
}
}
} }
} }
} }