mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-15 02:02:08 -04:00
Right-Click to set Rules on Notifications directly
This commit is contained in:
@@ -2140,6 +2140,9 @@ Singleton {
|
|||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property bool _pendingExpandNotificationRules: false
|
||||||
|
property int _pendingNotificationRuleIndex: -1
|
||||||
|
|
||||||
function addNotificationRule() {
|
function addNotificationRule() {
|
||||||
var rules = JSON.parse(JSON.stringify(notificationRules || []));
|
var rules = JSON.parse(JSON.stringify(notificationRules || []));
|
||||||
rules.push({
|
rules.push({
|
||||||
@@ -2154,6 +2157,27 @@ Singleton {
|
|||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addNotificationRuleForNotification(appName, desktopEntry) {
|
||||||
|
var rules = JSON.parse(JSON.stringify(notificationRules || []));
|
||||||
|
var pattern = (desktopEntry && desktopEntry !== "") ? desktopEntry : (appName || "");
|
||||||
|
var field = (desktopEntry && desktopEntry !== "") ? "desktopEntry" : "appName";
|
||||||
|
var rule = {
|
||||||
|
enabled: true,
|
||||||
|
field: pattern ? field : "appName",
|
||||||
|
pattern: pattern || "",
|
||||||
|
matchType: pattern ? "exact" : "contains",
|
||||||
|
action: "default",
|
||||||
|
urgency: "default"
|
||||||
|
};
|
||||||
|
rules.push(rule);
|
||||||
|
notificationRules = rules;
|
||||||
|
saveSettings();
|
||||||
|
var index = rules.length - 1;
|
||||||
|
_pendingExpandNotificationRules = true;
|
||||||
|
_pendingNotificationRuleIndex = index;
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
function addMuteRuleForApp(appName, desktopEntry) {
|
function addMuteRuleForApp(appName, desktopEntry) {
|
||||||
var rules = JSON.parse(JSON.stringify(notificationRules || []));
|
var rules = JSON.parse(JSON.stringify(notificationRules || []));
|
||||||
var pattern = (desktopEntry && desktopEntry !== "") ? desktopEntry : (appName || "");
|
var pattern = (desktopEntry && desktopEntry !== "") ? desktopEntry : (appName || "");
|
||||||
|
|||||||
@@ -873,7 +873,7 @@ Rectangle {
|
|||||||
|
|
||||||
Menu {
|
Menu {
|
||||||
id: notificationCardContextMenu
|
id: notificationCardContextMenu
|
||||||
width: 300
|
width: 220
|
||||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
@@ -883,6 +883,31 @@ Rectangle {
|
|||||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.12)
|
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.12)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MenuItem {
|
||||||
|
id: setNotificationRulesItem
|
||||||
|
text: I18n.tr("Set notification rules")
|
||||||
|
|
||||||
|
contentItem: StyledText {
|
||||||
|
text: parent.text
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
color: Theme.surfaceText
|
||||||
|
leftPadding: Theme.spacingS
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
color: parent.hovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : "transparent"
|
||||||
|
radius: Theme.cornerRadius / 2
|
||||||
|
}
|
||||||
|
|
||||||
|
onTriggered: {
|
||||||
|
const appName = notificationGroup?.appName || "";
|
||||||
|
const desktopEntry = notificationGroup?.latestNotification?.desktopEntry || "";
|
||||||
|
SettingsData.addNotificationRuleForNotification(appName, desktopEntry);
|
||||||
|
PopoutService.openSettingsWithTab("notifications");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
id: muteUnmuteItem
|
id: muteUnmuteItem
|
||||||
readonly property bool isMuted: SettingsData.isAppMuted(notificationGroup?.appName || "", notificationGroup?.latestNotification?.desktopEntry || "")
|
readonly property bool isMuted: SettingsData.isAppMuted(notificationGroup?.appName || "", notificationGroup?.latestNotification?.desktopEntry || "")
|
||||||
|
|||||||
@@ -835,7 +835,10 @@ PanelWindow {
|
|||||||
|
|
||||||
Menu {
|
Menu {
|
||||||
id: popupContextMenu
|
id: popupContextMenu
|
||||||
width: 300
|
width: 220
|
||||||
|
contentHeight: 130
|
||||||
|
margins: -1
|
||||||
|
popupType: Popup.Window
|
||||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
@@ -845,6 +848,31 @@ PanelWindow {
|
|||||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.12)
|
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.12)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MenuItem {
|
||||||
|
id: setNotificationRulesItem
|
||||||
|
text: I18n.tr("Set notification rules")
|
||||||
|
|
||||||
|
contentItem: StyledText {
|
||||||
|
text: parent.text
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
color: Theme.surfaceText
|
||||||
|
leftPadding: Theme.spacingS
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
color: parent.hovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : "transparent"
|
||||||
|
radius: Theme.cornerRadius / 2
|
||||||
|
}
|
||||||
|
|
||||||
|
onTriggered: {
|
||||||
|
const appName = notificationData?.appName || "";
|
||||||
|
const desktopEntry = notificationData?.desktopEntry || "";
|
||||||
|
SettingsData.addNotificationRuleForNotification(appName, desktopEntry);
|
||||||
|
PopoutService.openSettingsWithTab("notifications");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
id: muteUnmuteItem
|
id: muteUnmuteItem
|
||||||
readonly property bool isMuted: SettingsData.isAppMuted(notificationData?.appName || "", notificationData?.desktopEntry || "")
|
readonly property bool isMuted: SettingsData.isAppMuted(notificationData?.appName || "", notificationData?.desktopEntry || "")
|
||||||
|
|||||||
@@ -6,6 +6,15 @@ import qs.Modules.Settings.Widgets
|
|||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
if (SettingsData._pendingExpandNotificationRules) {
|
||||||
|
SettingsData._pendingExpandNotificationRules = false;
|
||||||
|
notificationRulesCard.userToggledCollapse = true;
|
||||||
|
notificationRulesCard.expanded = true;
|
||||||
|
SettingsData._pendingNotificationRuleIndex = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
readonly property var mutedRules: {
|
readonly property var mutedRules: {
|
||||||
var rules = SettingsData.notificationRules || [];
|
var rules = SettingsData.notificationRules || [];
|
||||||
var out = [];
|
var out = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user