mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-20 02:04:01 -04:00
notifications: add option to execute default action on body click
instead of expanding text fixes #2425
This commit is contained in:
@@ -899,6 +899,7 @@ Singleton {
|
||||
property bool notificationOverlayEnabled: false
|
||||
property bool notificationPopupShadowEnabled: true
|
||||
property bool notificationPopupPrivacyMode: false
|
||||
property bool notificationPopupBodyInvokesAction: false
|
||||
property bool notificationForegroundLayers: true
|
||||
property int overviewRows: 2
|
||||
property int overviewColumns: 5
|
||||
|
||||
@@ -465,6 +465,7 @@ var SPEC = {
|
||||
notificationOverlayEnabled: { def: false },
|
||||
notificationPopupShadowEnabled: { def: true },
|
||||
notificationPopupPrivacyMode: { def: false },
|
||||
notificationPopupBodyInvokesAction: { def: false },
|
||||
notificationForegroundLayers: { def: true },
|
||||
overviewRows: { def: 2, persist: false },
|
||||
overviewColumns: { def: 5, persist: false },
|
||||
|
||||
@@ -109,6 +109,7 @@ PanelWindow {
|
||||
readonly property string clearText: I18n.tr("Dismiss")
|
||||
property bool descriptionExpanded: false
|
||||
readonly property bool hasExpandableBody: (notificationData?.htmlBody || "").replace(/<[^>]*>/g, "").trim().length > 0
|
||||
readonly property bool bodyClickInvokesAction: SettingsData.notificationPopupBodyInvokesAction && (notificationData?.actions?.length ?? 0) > 0
|
||||
onDescriptionExpandedChanged: {
|
||||
if (connectedFrameMode)
|
||||
popupChromeGeometryChanged();
|
||||
@@ -176,6 +177,11 @@ PanelWindow {
|
||||
popupContextMenuLoader.active = false;
|
||||
}
|
||||
|
||||
function invokeDefaultAction() {
|
||||
notificationData.actions[0].invoke();
|
||||
NotificationService.dismissNotification(notificationData);
|
||||
}
|
||||
|
||||
function dismissPopupReliably() {
|
||||
if (!notificationData || win.exiting || win._isDestroying)
|
||||
return;
|
||||
@@ -966,10 +972,16 @@ PanelWindow {
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : (bodyText.hasMoreText || descriptionExpanded) ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
cursorShape: (parent.hoveredLink || win.bodyClickInvokesAction || bodyText.hasMoreText || descriptionExpanded) ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
|
||||
onClicked: mouse => {
|
||||
if (!parent.hoveredLink && (bodyText.hasMoreText || descriptionExpanded))
|
||||
if (parent.hoveredLink || win.exiting)
|
||||
return;
|
||||
if (win.bodyClickInvokesAction) {
|
||||
win.invokeDefaultAction();
|
||||
return;
|
||||
}
|
||||
if (bodyText.hasMoreText || descriptionExpanded)
|
||||
win.descriptionExpanded = !win.descriptionExpanded;
|
||||
}
|
||||
|
||||
@@ -1023,7 +1035,7 @@ PanelWindow {
|
||||
iconSize: compactMode ? 14 : 16
|
||||
buttonSize: compactMode ? 20 : 24
|
||||
z: 15
|
||||
visible: SettingsData.notificationPopupPrivacyMode && win.hasExpandableBody
|
||||
visible: (SettingsData.notificationPopupPrivacyMode || win.bodyClickInvokesAction) && win.hasExpandableBody
|
||||
|
||||
onClicked: {
|
||||
if (win.hasExpandableBody)
|
||||
@@ -1155,6 +1167,10 @@ PanelWindow {
|
||||
menu.showAt(win.margins.left + p.x, win.margins.top + p.y, win.screen);
|
||||
}
|
||||
} else if (mouse.button === Qt.LeftButton) {
|
||||
if (win.bodyClickInvokesAction) {
|
||||
win.invokeDefaultAction();
|
||||
return;
|
||||
}
|
||||
const canExpand = bodyText.hasMoreText || win.descriptionExpanded || (SettingsData.notificationPopupPrivacyMode && win.hasExpandableBody);
|
||||
if (canExpand) {
|
||||
win.descriptionExpanded = !win.descriptionExpanded;
|
||||
|
||||
@@ -342,6 +342,15 @@ Item {
|
||||
onToggled: checked => SettingsData.set("notificationPopupPrivacyMode", checked)
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
settingKey: "notificationPopupBodyInvokesAction"
|
||||
tags: ["notification", "popup", "click", "body", "action", "invoke", "expand", "open"]
|
||||
text: I18n.tr("Body Click Runs Default Action")
|
||||
description: I18n.tr("Clicking a popup runs its first action instead of expanding the body")
|
||||
checked: SettingsData.notificationPopupBodyInvokesAction
|
||||
onToggled: checked => SettingsData.set("notificationPopupBodyInvokesAction", checked)
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
settingKey: "notificationFocusedMonitor"
|
||||
tags: ["notification", "popup", "focused", "monitor", "display", "screen", "active"]
|
||||
|
||||
@@ -6915,6 +6915,32 @@
|
||||
],
|
||||
"description": "Control animation duration for notification popups and history"
|
||||
},
|
||||
{
|
||||
"section": "notificationPopupBodyInvokesAction",
|
||||
"label": "Body Click Runs Default Action",
|
||||
"tabIndex": 17,
|
||||
"category": "Notifications",
|
||||
"keywords": [
|
||||
"action",
|
||||
"alerts",
|
||||
"body",
|
||||
"click",
|
||||
"clicking",
|
||||
"default",
|
||||
"expand",
|
||||
"expanding",
|
||||
"first",
|
||||
"invoke",
|
||||
"messages",
|
||||
"notification",
|
||||
"notifications",
|
||||
"open",
|
||||
"popup",
|
||||
"runs",
|
||||
"toast"
|
||||
],
|
||||
"description": "Clicking a popup runs its first action instead of expanding the body"
|
||||
},
|
||||
{
|
||||
"section": "notificationBodyFontSize",
|
||||
"label": "Body Font Size",
|
||||
|
||||
Reference in New Issue
Block a user