mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 16:02:51 -05:00
enhancement: let power actions confirmation optional (#427)
This commit is contained in:
@@ -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,9 +596,10 @@ Singleton {
|
|||||||
"notificationTimeoutCritical": notificationTimeoutCritical,
|
"notificationTimeoutCritical": notificationTimeoutCritical,
|
||||||
"notificationPopupPosition": notificationPopupPosition,
|
"notificationPopupPosition": notificationPopupPosition,
|
||||||
"osdAlwaysShowValue": osdAlwaysShowValue,
|
"osdAlwaysShowValue": osdAlwaysShowValue,
|
||||||
"updaterUseCustomCommand": updaterUseCustomCommand,
|
"powerActionConfirm": powerActionConfirm,
|
||||||
"updaterCustomCommand": updaterCustomCommand,
|
"updaterUseCustomCommand": updaterUseCustomCommand,
|
||||||
"updaterTerminalAdditionalParams": updaterTerminalAdditionalParams,
|
"updaterCustomCommand": updaterCustomCommand,
|
||||||
|
"updaterTerminalAdditionalParams": updaterTerminalAdditionalParams,
|
||||||
"screenPreferences": screenPreferences,
|
"screenPreferences": screenPreferences,
|
||||||
"animationSpeed": animationSpeed
|
"animationSpeed": animationSpeed
|
||||||
}, null, 2))
|
}, null, 2))
|
||||||
@@ -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
|
||||||
|
|||||||
139
DMSShell.qml
139
DMSShell.qml
@@ -243,39 +243,45 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LazyLoader {
|
LazyLoader {
|
||||||
id: powerMenuLoader
|
id: powerMenuLoader
|
||||||
|
|
||||||
active: false
|
active: false
|
||||||
|
|
||||||
PowerMenu {
|
PowerMenu {
|
||||||
id: powerMenu
|
id: powerMenu
|
||||||
|
|
||||||
onPowerActionRequested: (action, title, message) => {
|
onPowerActionRequested: (action, title, message) => {
|
||||||
powerConfirmModalLoader.active = true
|
if (SettingsData.powerActionConfirm) {
|
||||||
if (powerConfirmModalLoader.item) {
|
powerConfirmModalLoader.active = true
|
||||||
powerConfirmModalLoader.item.confirmButtonColor = action === "poweroff" ? Theme.error : action === "reboot" ? Theme.warning : Theme.primary
|
if (powerConfirmModalLoader.item) {
|
||||||
powerConfirmModalLoader.item.show(title, message, function () {
|
powerConfirmModalLoader.item.confirmButtonColor = action === "poweroff" ? Theme.error : action === "reboot" ? Theme.warning : Theme.primary
|
||||||
switch (action) {
|
powerConfirmModalLoader.item.show(title, message, actionApply(action), function () {})
|
||||||
case "logout":
|
}
|
||||||
SessionService.logout()
|
} else {
|
||||||
break
|
actionApply(action)
|
||||||
case "suspend":
|
}
|
||||||
SessionService.suspend()
|
}
|
||||||
break
|
|
||||||
case "hibernate":
|
function actionApply(action) {
|
||||||
SessionService.hibernate()
|
switch (action) {
|
||||||
break
|
case "logout":
|
||||||
case "reboot":
|
SessionService.logout()
|
||||||
SessionService.reboot()
|
break
|
||||||
break
|
case "suspend":
|
||||||
case "poweroff":
|
SessionService.suspend()
|
||||||
SessionService.poweroff()
|
break
|
||||||
break
|
case "hibernate":
|
||||||
}
|
SessionService.hibernate()
|
||||||
}, function () {})
|
break
|
||||||
}
|
case "reboot":
|
||||||
}
|
SessionService.reboot()
|
||||||
}
|
break
|
||||||
|
case "poweroff":
|
||||||
|
SessionService.poweroff()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LazyLoader {
|
LazyLoader {
|
||||||
@@ -416,43 +422,50 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LazyLoader {
|
LazyLoader {
|
||||||
id: powerMenuModalLoader
|
id: powerMenuModalLoader
|
||||||
|
|
||||||
active: false
|
active: false
|
||||||
|
|
||||||
PowerMenuModal {
|
PowerMenuModal {
|
||||||
id: powerMenuModal
|
id: powerMenuModal
|
||||||
|
|
||||||
onPowerActionRequested: (action, title, message) => {
|
onPowerActionRequested: (action, title, message) => {
|
||||||
powerConfirmModalLoader.active = true
|
console.log("CONFIRM: ", SettingsData.powerActionConfirm)
|
||||||
if (powerConfirmModalLoader.item) {
|
if (SettingsData.powerActionConfirm) {
|
||||||
powerConfirmModalLoader.item.confirmButtonColor = action === "poweroff" ? Theme.error : action === "reboot" ? Theme.warning : Theme.primary
|
powerConfirmModalLoader.active = true
|
||||||
powerConfirmModalLoader.item.show(title, message, function () {
|
if (powerConfirmModalLoader.item) {
|
||||||
switch (action) {
|
powerConfirmModalLoader.item.confirmButtonColor = action === "poweroff" ? Theme.error : action === "reboot" ? Theme.warning : Theme.primary
|
||||||
case "logout":
|
powerConfirmModalLoader.item.show(title, message, actionApply(action), function () {})
|
||||||
SessionService.logout()
|
}
|
||||||
break
|
} else {
|
||||||
case "suspend":
|
actionApply(action)
|
||||||
SessionService.suspend()
|
}
|
||||||
break
|
}
|
||||||
case "hibernate":
|
|
||||||
SessionService.hibernate()
|
|
||||||
break
|
|
||||||
case "reboot":
|
|
||||||
SessionService.reboot()
|
|
||||||
break
|
|
||||||
case "poweroff":
|
|
||||||
SessionService.poweroff()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}, function () {})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
function actionApply(action) {
|
||||||
PopoutService.powerMenuModal = powerMenuModal
|
switch (action) {
|
||||||
}
|
case "logout":
|
||||||
}
|
SessionService.logout()
|
||||||
|
break
|
||||||
|
case "suspend":
|
||||||
|
SessionService.suspend()
|
||||||
|
break
|
||||||
|
case "hibernate":
|
||||||
|
SessionService.hibernate()
|
||||||
|
break
|
||||||
|
case "reboot":
|
||||||
|
SessionService.reboot()
|
||||||
|
break
|
||||||
|
case "poweroff":
|
||||||
|
SessionService.poweroff()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
PopoutService.powerMenuModal = powerMenuModal
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DMSShellIPC {
|
DMSShellIPC {
|
||||||
|
|||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
Reference in New Issue
Block a user