1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-14 17:52:10 -04:00

enhancement: let power actions confirmation optional (#427)

This commit is contained in:
max72bra
2025-10-14 19:59:12 +02:00
committed by GitHub
parent 563bc7b359
commit c2f32b7bdc
4 changed files with 134 additions and 70 deletions

View File

@@ -185,6 +185,7 @@ Singleton {
property int notificationTimeoutCritical: 0 property int notificationTimeoutCritical: 0
property int notificationPopupPosition: SettingsData.Position.Top property int notificationPopupPosition: SettingsData.Position.Top
property bool osdAlwaysShowValue: false property bool osdAlwaysShowValue: false
property bool powerActionConfirm: true
property bool updaterUseCustomCommand: false property bool updaterUseCustomCommand: false
property string updaterCustomCommand: "" property string updaterCustomCommand: ""
property string updaterTerminalAdditionalParams: "" property string updaterTerminalAdditionalParams: ""
@@ -428,6 +429,7 @@ Singleton {
notificationTimeoutCritical = settings.notificationTimeoutCritical !== undefined ? settings.notificationTimeoutCritical : 0 notificationTimeoutCritical = settings.notificationTimeoutCritical !== undefined ? settings.notificationTimeoutCritical : 0
notificationPopupPosition = settings.notificationPopupPosition !== undefined ? settings.notificationPopupPosition : SettingsData.Position.Top notificationPopupPosition = settings.notificationPopupPosition !== undefined ? settings.notificationPopupPosition : SettingsData.Position.Top
osdAlwaysShowValue = settings.osdAlwaysShowValue !== undefined ? settings.osdAlwaysShowValue : false osdAlwaysShowValue = settings.osdAlwaysShowValue !== undefined ? settings.osdAlwaysShowValue : false
powerActionConfirm = settings.powerActionConfirm !== undefined ? settings.powerActionConfirm : true
updaterUseCustomCommand = settings.updaterUseCustomCommand !== undefined ? settings.updaterUseCustomCommand : false; updaterUseCustomCommand = settings.updaterUseCustomCommand !== undefined ? settings.updaterUseCustomCommand : false;
updaterCustomCommand = settings.updaterCustomCommand !== undefined ? settings.updaterCustomCommand : ""; updaterCustomCommand = settings.updaterCustomCommand !== undefined ? settings.updaterCustomCommand : "";
updaterTerminalAdditionalParams = settings.updaterTerminalAdditionalParams !== undefined ? settings.updaterTerminalAdditionalParams : ""; updaterTerminalAdditionalParams = settings.updaterTerminalAdditionalParams !== undefined ? settings.updaterTerminalAdditionalParams : "";
@@ -594,6 +596,7 @@ Singleton {
"notificationTimeoutCritical": notificationTimeoutCritical, "notificationTimeoutCritical": notificationTimeoutCritical,
"notificationPopupPosition": notificationPopupPosition, "notificationPopupPosition": notificationPopupPosition,
"osdAlwaysShowValue": osdAlwaysShowValue, "osdAlwaysShowValue": osdAlwaysShowValue,
"powerActionConfirm": powerActionConfirm,
"updaterUseCustomCommand": updaterUseCustomCommand, "updaterUseCustomCommand": updaterUseCustomCommand,
"updaterCustomCommand": updaterCustomCommand, "updaterCustomCommand": updaterCustomCommand,
"updaterTerminalAdditionalParams": updaterTerminalAdditionalParams, "updaterTerminalAdditionalParams": updaterTerminalAdditionalParams,
@@ -653,6 +656,11 @@ Singleton {
saveSettings(); saveSettings();
} }
function setPowerActionConfirm(confirm) {
powerActionConfirm = confirm;
saveSettings();
}
function setWorkspaceNameIcon(workspaceName, iconData) { function setWorkspaceNameIcon(workspaceName, iconData) {
var iconMap = JSON.parse(JSON.stringify(workspaceNameIcons)) var iconMap = JSON.parse(JSON.stringify(workspaceNameIcons))
iconMap[workspaceName] = iconData iconMap[workspaceName] = iconData

View File

@@ -251,10 +251,18 @@ Item {
id: powerMenu id: powerMenu
onPowerActionRequested: (action, title, message) => { onPowerActionRequested: (action, title, message) => {
if (SettingsData.powerActionConfirm) {
powerConfirmModalLoader.active = true powerConfirmModalLoader.active = true
if (powerConfirmModalLoader.item) { if (powerConfirmModalLoader.item) {
powerConfirmModalLoader.item.confirmButtonColor = action === "poweroff" ? Theme.error : action === "reboot" ? Theme.warning : Theme.primary powerConfirmModalLoader.item.confirmButtonColor = action === "poweroff" ? Theme.error : action === "reboot" ? Theme.warning : Theme.primary
powerConfirmModalLoader.item.show(title, message, function () { powerConfirmModalLoader.item.show(title, message, actionApply(action), function () {})
}
} else {
actionApply(action)
}
}
function actionApply(action) {
switch (action) { switch (action) {
case "logout": case "logout":
SessionService.logout() SessionService.logout()
@@ -272,8 +280,6 @@ Item {
SessionService.poweroff() SessionService.poweroff()
break break
} }
}, function () {})
}
} }
} }
} }
@@ -424,10 +430,19 @@ Item {
id: powerMenuModal id: powerMenuModal
onPowerActionRequested: (action, title, message) => { onPowerActionRequested: (action, title, message) => {
console.log("CONFIRM: ", SettingsData.powerActionConfirm)
if (SettingsData.powerActionConfirm) {
powerConfirmModalLoader.active = true powerConfirmModalLoader.active = true
if (powerConfirmModalLoader.item) { if (powerConfirmModalLoader.item) {
powerConfirmModalLoader.item.confirmButtonColor = action === "poweroff" ? Theme.error : action === "reboot" ? Theme.warning : Theme.primary powerConfirmModalLoader.item.confirmButtonColor = action === "poweroff" ? Theme.error : action === "reboot" ? Theme.warning : Theme.primary
powerConfirmModalLoader.item.show(title, message, function () { powerConfirmModalLoader.item.show(title, message, actionApply(action), function () {})
}
} else {
actionApply(action)
}
}
function actionApply(action) {
switch (action) { switch (action) {
case "logout": case "logout":
SessionService.logout() SessionService.logout()
@@ -445,8 +460,6 @@ Item {
SessionService.poweroff() SessionService.poweroff()
break break
} }
}, function () {})
}
} }
Component.onCompleted: { Component.onCompleted: {

View File

@@ -79,7 +79,7 @@ Item {
DankToggle { DankToggle {
width: parent.width width: parent.width
text: I18n.tr("Enable loginctl lock integration") text: I18n.tr("Enable loginctl lock integration")
description: "Bind lock screen to dbus signals from loginctl. Disable if using an external lock screen." description: "Bind lock screen to dbus signals from loginctl. Disable if using an external lock screen"
checked: SessionService.loginctlAvailable && SessionData.loginctlLockIntegration checked: SessionService.loginctlAvailable && SessionData.loginctlLockIntegration
enabled: SessionService.loginctlAvailable enabled: SessionService.loginctlAvailable
onToggled: checked => { onToggled: checked => {
@@ -313,6 +313,49 @@ Item {
} }
} }
StyledRect {
width: parent.width
height: powerCommandConfirmSection.implicitHeight + Theme.spacingL * 2
radius: Theme.cornerRadius
color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.3)
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
border.width: 0
Column {
id: powerCommandConfirmSection
anchors.fill: parent
anchors.margins: Theme.spacingL
spacing: Theme.spacingM
Row {
width: parent.width
spacing: Theme.spacingM
DankIcon {
name: "check_circle"
size: Theme.iconSize
color: Theme.primary
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
text: I18n.tr("Power Action Confirmation")
font.pixelSize: Theme.fontSizeLarge
font.weight: Font.Medium
color: Theme.surfaceText
anchors.verticalCenter: parent.verticalCenter
}
}
DankToggle {
width: parent.width
text: I18n.tr("Show Confirmation on Power Actions")
description: "Request confirmation on power off, restart, suspend, hibernate and logout actions"
checked: SettingsData.powerActionConfirm
onToggled: checked => SettingsData.setPowerActionConfirm(checked)
}
}
}
} }
} }
} }

View File

@@ -33,8 +33,8 @@ Rectangle {
"text": I18n.tr("Theme & Colors"), "text": I18n.tr("Theme & Colors"),
"icon": "palette" "icon": "palette"
}, { }, {
"text": I18n.tr("Idle & Lock Screen"), "text": I18n.tr("Power & Battery"),
"icon": "lock" "icon": "power"
}, { }, {
"text": I18n.tr("Plugins"), "text": I18n.tr("Plugins"),
"icon": "extension" "icon": "extension"