1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05: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 notificationPopupPosition: SettingsData.Position.Top
property bool osdAlwaysShowValue: false
property bool powerActionConfirm: true
property bool updaterUseCustomCommand: false
property string updaterCustomCommand: ""
property string updaterTerminalAdditionalParams: ""
@@ -428,6 +429,7 @@ Singleton {
notificationTimeoutCritical = settings.notificationTimeoutCritical !== undefined ? settings.notificationTimeoutCritical : 0
notificationPopupPosition = settings.notificationPopupPosition !== undefined ? settings.notificationPopupPosition : SettingsData.Position.Top
osdAlwaysShowValue = settings.osdAlwaysShowValue !== undefined ? settings.osdAlwaysShowValue : false
powerActionConfirm = settings.powerActionConfirm !== undefined ? settings.powerActionConfirm : true
updaterUseCustomCommand = settings.updaterUseCustomCommand !== undefined ? settings.updaterUseCustomCommand : false;
updaterCustomCommand = settings.updaterCustomCommand !== undefined ? settings.updaterCustomCommand : "";
updaterTerminalAdditionalParams = settings.updaterTerminalAdditionalParams !== undefined ? settings.updaterTerminalAdditionalParams : "";
@@ -594,6 +596,7 @@ Singleton {
"notificationTimeoutCritical": notificationTimeoutCritical,
"notificationPopupPosition": notificationPopupPosition,
"osdAlwaysShowValue": osdAlwaysShowValue,
"powerActionConfirm": powerActionConfirm,
"updaterUseCustomCommand": updaterUseCustomCommand,
"updaterCustomCommand": updaterCustomCommand,
"updaterTerminalAdditionalParams": updaterTerminalAdditionalParams,
@@ -653,6 +656,11 @@ Singleton {
saveSettings();
}
function setPowerActionConfirm(confirm) {
powerActionConfirm = confirm;
saveSettings();
}
function setWorkspaceNameIcon(workspaceName, iconData) {
var iconMap = JSON.parse(JSON.stringify(workspaceNameIcons))
iconMap[workspaceName] = iconData

View File

@@ -251,10 +251,18 @@ Item {
id: powerMenu
onPowerActionRequested: (action, title, message) => {
if (SettingsData.powerActionConfirm) {
powerConfirmModalLoader.active = true
if (powerConfirmModalLoader.item) {
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) {
case "logout":
SessionService.logout()
@@ -272,8 +280,6 @@ Item {
SessionService.poweroff()
break
}
}, function () {})
}
}
}
}
@@ -424,10 +430,19 @@ Item {
id: powerMenuModal
onPowerActionRequested: (action, title, message) => {
console.log("CONFIRM: ", SettingsData.powerActionConfirm)
if (SettingsData.powerActionConfirm) {
powerConfirmModalLoader.active = true
if (powerConfirmModalLoader.item) {
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) {
case "logout":
SessionService.logout()
@@ -445,8 +460,6 @@ Item {
SessionService.poweroff()
break
}
}, function () {})
}
}
Component.onCompleted: {

View File

@@ -79,7 +79,7 @@ Item {
DankToggle {
width: parent.width
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
enabled: SessionService.loginctlAvailable
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"),
"icon": "palette"
}, {
"text": I18n.tr("Idle & Lock Screen"),
"icon": "lock"
"text": I18n.tr("Power & Battery"),
"icon": "power"
}, {
"text": I18n.tr("Plugins"),
"icon": "extension"