mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-30 16:32:50 -05:00
@@ -303,6 +303,7 @@ Singleton {
|
|||||||
property bool osdPowerProfileEnabled: true
|
property bool osdPowerProfileEnabled: true
|
||||||
|
|
||||||
property bool powerActionConfirm: true
|
property bool powerActionConfirm: true
|
||||||
|
property int powerActionHoldDuration: 1
|
||||||
property var powerMenuActions: ["reboot", "logout", "poweroff", "lock", "suspend", "restart"]
|
property var powerMenuActions: ["reboot", "logout", "poweroff", "lock", "suspend", "restart"]
|
||||||
property string powerMenuDefaultAction: "logout"
|
property string powerMenuDefaultAction: "logout"
|
||||||
property bool powerMenuGridLayout: false
|
property bool powerMenuGridLayout: false
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ var SPEC = {
|
|||||||
osdPowerProfileEnabled: { def: false },
|
osdPowerProfileEnabled: { def: false },
|
||||||
|
|
||||||
powerActionConfirm: { def: true },
|
powerActionConfirm: { def: true },
|
||||||
|
powerActionHoldDuration: { def: 1 },
|
||||||
powerMenuActions: { def: ["reboot", "logout", "poweroff", "lock", "suspend", "restart"] },
|
powerMenuActions: { def: ["reboot", "logout", "poweroff", "lock", "suspend", "restart"] },
|
||||||
powerMenuDefaultAction: { def: "logout" },
|
powerMenuDefaultAction: { def: "logout" },
|
||||||
powerMenuGridLayout: { def: false },
|
powerMenuGridLayout: { def: false },
|
||||||
|
|||||||
@@ -343,16 +343,6 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LazyLoader {
|
|
||||||
id: powerConfirmModalLoader
|
|
||||||
|
|
||||||
active: false
|
|
||||||
|
|
||||||
ConfirmModal {
|
|
||||||
id: powerConfirmModal
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LazyLoader {
|
LazyLoader {
|
||||||
id: processListPopoutLoader
|
id: processListPopoutLoader
|
||||||
|
|
||||||
@@ -489,22 +479,6 @@ Item {
|
|||||||
id: powerMenuModal
|
id: powerMenuModal
|
||||||
|
|
||||||
onPowerActionRequested: (action, title, message) => {
|
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, () => actionApply(action), function () {});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
actionApply(action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onLockRequested: {
|
|
||||||
lock.activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
function actionApply(action) {
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "logout":
|
case "logout":
|
||||||
SessionService.logout();
|
SessionService.logout();
|
||||||
@@ -524,6 +498,10 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onLockRequested: {
|
||||||
|
lock.activate();
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
PopoutService.powerMenuModal = powerMenuModal;
|
PopoutService.powerMenuModal = powerMenuModal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,13 +55,16 @@ Item {
|
|||||||
ModalManager.openModal(root);
|
ModalManager.openModal(root);
|
||||||
closeTimer.stop();
|
closeTimer.stop();
|
||||||
shouldBeVisible = true;
|
shouldBeVisible = true;
|
||||||
|
contentWindow.visible = false;
|
||||||
if (useBackgroundWindow)
|
if (useBackgroundWindow)
|
||||||
backgroundWindow.visible = true;
|
backgroundWindow.visible = true;
|
||||||
|
Qt.callLater(() => {
|
||||||
contentWindow.visible = true;
|
contentWindow.visible = true;
|
||||||
shouldHaveFocus = false;
|
shouldHaveFocus = false;
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
shouldHaveFocus = Qt.binding(() => shouldBeVisible);
|
shouldHaveFocus = Qt.binding(() => shouldBeVisible);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
|
import QtQuick.Effects
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
import qs.Common
|
import qs.Common
|
||||||
@@ -10,6 +11,7 @@ DankModal {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
layerNamespace: "dms:power-menu"
|
layerNamespace: "dms:power-menu"
|
||||||
|
keepPopoutsOpen: true
|
||||||
|
|
||||||
HyprlandFocusGrab {
|
HyprlandFocusGrab {
|
||||||
windows: [root]
|
windows: [root]
|
||||||
@@ -25,9 +27,94 @@ DankModal {
|
|||||||
property int gridColumns: 3
|
property int gridColumns: 3
|
||||||
property int gridRows: 2
|
property int gridRows: 2
|
||||||
|
|
||||||
|
property string holdAction: ""
|
||||||
|
property int holdActionIndex: -1
|
||||||
|
property real holdProgress: 0
|
||||||
|
property bool showHoldHint: false
|
||||||
|
|
||||||
|
readonly property bool needsConfirmation: SettingsData.powerActionConfirm
|
||||||
|
readonly property int holdDurationMs: SettingsData.powerActionHoldDuration * 1000
|
||||||
|
|
||||||
signal powerActionRequested(string action, string title, string message)
|
signal powerActionRequested(string action, string title, string message)
|
||||||
signal lockRequested
|
signal lockRequested
|
||||||
|
|
||||||
|
function actionNeedsConfirm(action) {
|
||||||
|
return action !== "lock" && action !== "restart";
|
||||||
|
}
|
||||||
|
|
||||||
|
function startHold(action, actionIndex) {
|
||||||
|
if (!needsConfirmation || !actionNeedsConfirm(action)) {
|
||||||
|
executeAction(action);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
holdAction = action;
|
||||||
|
holdActionIndex = actionIndex;
|
||||||
|
holdProgress = 0;
|
||||||
|
showHoldHint = false;
|
||||||
|
holdTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelHold() {
|
||||||
|
if (holdAction === "")
|
||||||
|
return;
|
||||||
|
const wasHolding = holdProgress > 0;
|
||||||
|
holdTimer.stop();
|
||||||
|
if (wasHolding && holdProgress < 1) {
|
||||||
|
showHoldHint = true;
|
||||||
|
hintTimer.restart();
|
||||||
|
}
|
||||||
|
holdAction = "";
|
||||||
|
holdActionIndex = -1;
|
||||||
|
holdProgress = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function completeHold() {
|
||||||
|
if (holdProgress < 1) {
|
||||||
|
cancelHold();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const action = holdAction;
|
||||||
|
holdTimer.stop();
|
||||||
|
holdAction = "";
|
||||||
|
holdActionIndex = -1;
|
||||||
|
holdProgress = 0;
|
||||||
|
executeAction(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
function executeAction(action) {
|
||||||
|
if (action === "lock") {
|
||||||
|
close();
|
||||||
|
lockRequested();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (action === "restart") {
|
||||||
|
close();
|
||||||
|
Quickshell.execDetached(["dms", "restart"]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
root.powerActionRequested(action, "", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: holdTimer
|
||||||
|
interval: 16
|
||||||
|
repeat: true
|
||||||
|
onTriggered: {
|
||||||
|
root.holdProgress = Math.min(1, root.holdProgress + (interval / root.holdDurationMs));
|
||||||
|
if (root.holdProgress >= 1) {
|
||||||
|
stop();
|
||||||
|
root.completeHold();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: hintTimer
|
||||||
|
interval: 2000
|
||||||
|
onTriggered: root.showHoldHint = false
|
||||||
|
}
|
||||||
|
|
||||||
function openCentered() {
|
function openCentered() {
|
||||||
parentBounds = Qt.rect(0, 0, 0, 0);
|
parentBounds = Qt.rect(0, 0, 0, 0);
|
||||||
parentScreen = null;
|
parentScreen = null;
|
||||||
@@ -39,9 +126,7 @@ DankModal {
|
|||||||
parentBounds = bounds;
|
parentBounds = bounds;
|
||||||
parentScreen = targetScreen;
|
parentScreen = targetScreen;
|
||||||
backgroundOpacity = 0;
|
backgroundOpacity = 0;
|
||||||
keepPopoutsOpen = true;
|
|
||||||
open();
|
open();
|
||||||
keepPopoutsOpen = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateVisibleActions() {
|
function updateVisibleActions() {
|
||||||
@@ -142,44 +227,8 @@ DankModal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectOption(action) {
|
function selectOption(action, actionIndex) {
|
||||||
if (action === "lock") {
|
startHold(action, actionIndex !== undefined ? actionIndex : -1);
|
||||||
close();
|
|
||||||
lockRequested();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (action === "restart") {
|
|
||||||
close();
|
|
||||||
Quickshell.execDetached(["dms", "restart"]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
close();
|
|
||||||
const actions = {
|
|
||||||
"logout": {
|
|
||||||
"title": I18n.tr("Log Out"),
|
|
||||||
"message": I18n.tr("Are you sure you want to log out?")
|
|
||||||
},
|
|
||||||
"suspend": {
|
|
||||||
"title": I18n.tr("Suspend"),
|
|
||||||
"message": I18n.tr("Are you sure you want to suspend the system?")
|
|
||||||
},
|
|
||||||
"hibernate": {
|
|
||||||
"title": I18n.tr("Hibernate"),
|
|
||||||
"message": I18n.tr("Are you sure you want to hibernate the system?")
|
|
||||||
},
|
|
||||||
"reboot": {
|
|
||||||
"title": I18n.tr("Reboot"),
|
|
||||||
"message": I18n.tr("Are you sure you want to reboot the system?")
|
|
||||||
},
|
|
||||||
"poweroff": {
|
|
||||||
"title": I18n.tr("Power Off"),
|
|
||||||
"message": I18n.tr("Are you sure you want to power off the system?")
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const selected = actions[action];
|
|
||||||
if (selected) {
|
|
||||||
root.powerActionRequested(action, selected.title, selected.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldBeVisible: false
|
shouldBeVisible: false
|
||||||
@@ -208,8 +257,15 @@ DankModal {
|
|||||||
}
|
}
|
||||||
return Qt.point(0, 0);
|
return Qt.point(0, 0);
|
||||||
}
|
}
|
||||||
onBackgroundClicked: () => close()
|
onBackgroundClicked: () => {
|
||||||
|
cancelHold();
|
||||||
|
close();
|
||||||
|
}
|
||||||
onOpened: () => {
|
onOpened: () => {
|
||||||
|
holdAction = "";
|
||||||
|
holdActionIndex = -1;
|
||||||
|
holdProgress = 0;
|
||||||
|
showHoldHint = false;
|
||||||
updateVisibleActions();
|
updateVisibleActions();
|
||||||
const defaultIndex = getDefaultActionIndex();
|
const defaultIndex = getDefaultActionIndex();
|
||||||
if (SettingsData.powerMenuGridLayout) {
|
if (SettingsData.powerMenuGridLayout) {
|
||||||
@@ -221,16 +277,42 @@ DankModal {
|
|||||||
}
|
}
|
||||||
Qt.callLater(() => modalFocusScope.forceActiveFocus());
|
Qt.callLater(() => modalFocusScope.forceActiveFocus());
|
||||||
}
|
}
|
||||||
|
onDialogClosed: () => {
|
||||||
|
cancelHold();
|
||||||
|
}
|
||||||
Component.onCompleted: updateVisibleActions()
|
Component.onCompleted: updateVisibleActions()
|
||||||
modalFocusScope.Keys.onPressed: event => {
|
modalFocusScope.Keys.onPressed: event => {
|
||||||
|
if (event.isAutoRepeat) {
|
||||||
|
event.accepted = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (SettingsData.powerMenuGridLayout) {
|
if (SettingsData.powerMenuGridLayout) {
|
||||||
handleGridNavigation(event);
|
handleGridNavigation(event, true);
|
||||||
} else {
|
} else {
|
||||||
handleListNavigation(event);
|
handleListNavigation(event, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modalFocusScope.Keys.onReleased: event => {
|
||||||
|
if (event.isAutoRepeat) {
|
||||||
|
event.accepted = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (SettingsData.powerMenuGridLayout) {
|
||||||
|
handleGridNavigation(event, false);
|
||||||
|
} else {
|
||||||
|
handleListNavigation(event, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleListNavigation(event) {
|
function handleListNavigation(event, isPressed) {
|
||||||
|
if (!isPressed) {
|
||||||
|
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter || event.key === Qt.Key_R || event.key === Qt.Key_X || event.key === Qt.Key_L || event.key === Qt.Key_S || event.key === Qt.Key_H || event.key === Qt.Key_D || (event.key === Qt.Key_P && !(event.modifiers & Qt.ControlModifier))) {
|
||||||
|
cancelHold();
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case Qt.Key_Up:
|
case Qt.Key_Up:
|
||||||
case Qt.Key_Backtab:
|
case Qt.Key_Backtab:
|
||||||
@@ -244,7 +326,7 @@ DankModal {
|
|||||||
break;
|
break;
|
||||||
case Qt.Key_Return:
|
case Qt.Key_Return:
|
||||||
case Qt.Key_Enter:
|
case Qt.Key_Enter:
|
||||||
selectOption(getActionAtIndex(selectedIndex));
|
startHold(getActionAtIndex(selectedIndex), selectedIndex);
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
break;
|
break;
|
||||||
case Qt.Key_N:
|
case Qt.Key_N:
|
||||||
@@ -255,7 +337,8 @@ DankModal {
|
|||||||
break;
|
break;
|
||||||
case Qt.Key_P:
|
case Qt.Key_P:
|
||||||
if (!(event.modifiers & Qt.ControlModifier)) {
|
if (!(event.modifiers & Qt.ControlModifier)) {
|
||||||
selectOption("poweroff");
|
const idx = visibleActions.indexOf("poweroff");
|
||||||
|
startHold("poweroff", idx);
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
} else {
|
} else {
|
||||||
selectedIndex = (selectedIndex - 1 + visibleActions.length) % visibleActions.length;
|
selectedIndex = (selectedIndex - 1 + visibleActions.length) % visibleActions.length;
|
||||||
@@ -275,33 +358,41 @@ DankModal {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Qt.Key_R:
|
case Qt.Key_R:
|
||||||
selectOption("reboot");
|
startHold("reboot", visibleActions.indexOf("reboot"));
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
break;
|
break;
|
||||||
case Qt.Key_X:
|
case Qt.Key_X:
|
||||||
selectOption("logout");
|
startHold("logout", visibleActions.indexOf("logout"));
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
break;
|
break;
|
||||||
case Qt.Key_L:
|
case Qt.Key_L:
|
||||||
selectOption("lock");
|
startHold("lock", visibleActions.indexOf("lock"));
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
break;
|
break;
|
||||||
case Qt.Key_S:
|
case Qt.Key_S:
|
||||||
selectOption("suspend");
|
startHold("suspend", visibleActions.indexOf("suspend"));
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
break;
|
break;
|
||||||
case Qt.Key_H:
|
case Qt.Key_H:
|
||||||
selectOption("hibernate");
|
startHold("hibernate", visibleActions.indexOf("hibernate"));
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
break;
|
break;
|
||||||
case Qt.Key_D:
|
case Qt.Key_D:
|
||||||
selectOption("restart");
|
startHold("restart", visibleActions.indexOf("restart"));
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleGridNavigation(event) {
|
function handleGridNavigation(event, isPressed) {
|
||||||
|
if (!isPressed) {
|
||||||
|
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter || event.key === Qt.Key_R || event.key === Qt.Key_X || event.key === Qt.Key_L || event.key === Qt.Key_S || event.key === Qt.Key_H || event.key === Qt.Key_D || (event.key === Qt.Key_P && !(event.modifiers & Qt.ControlModifier))) {
|
||||||
|
cancelHold();
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case Qt.Key_Left:
|
case Qt.Key_Left:
|
||||||
selectedCol = (selectedCol - 1 + gridColumns) % gridColumns;
|
selectedCol = (selectedCol - 1 + gridColumns) % gridColumns;
|
||||||
@@ -327,7 +418,7 @@ DankModal {
|
|||||||
break;
|
break;
|
||||||
case Qt.Key_Return:
|
case Qt.Key_Return:
|
||||||
case Qt.Key_Enter:
|
case Qt.Key_Enter:
|
||||||
selectOption(getActionAtIndex(selectedIndex));
|
startHold(getActionAtIndex(selectedIndex), selectedIndex);
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
break;
|
break;
|
||||||
case Qt.Key_N:
|
case Qt.Key_N:
|
||||||
@@ -339,7 +430,8 @@ DankModal {
|
|||||||
break;
|
break;
|
||||||
case Qt.Key_P:
|
case Qt.Key_P:
|
||||||
if (!(event.modifiers & Qt.ControlModifier)) {
|
if (!(event.modifiers & Qt.ControlModifier)) {
|
||||||
selectOption("poweroff");
|
const idx = visibleActions.indexOf("poweroff");
|
||||||
|
startHold("poweroff", idx);
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
} else {
|
} else {
|
||||||
selectedCol = (selectedCol - 1 + gridColumns) % gridColumns;
|
selectedCol = (selectedCol - 1 + gridColumns) % gridColumns;
|
||||||
@@ -362,27 +454,27 @@ DankModal {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Qt.Key_R:
|
case Qt.Key_R:
|
||||||
selectOption("reboot");
|
startHold("reboot", visibleActions.indexOf("reboot"));
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
break;
|
break;
|
||||||
case Qt.Key_X:
|
case Qt.Key_X:
|
||||||
selectOption("logout");
|
startHold("logout", visibleActions.indexOf("logout"));
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
break;
|
break;
|
||||||
case Qt.Key_L:
|
case Qt.Key_L:
|
||||||
selectOption("lock");
|
startHold("lock", visibleActions.indexOf("lock"));
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
break;
|
break;
|
||||||
case Qt.Key_S:
|
case Qt.Key_S:
|
||||||
selectOption("suspend");
|
startHold("suspend", visibleActions.indexOf("suspend"));
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
break;
|
break;
|
||||||
case Qt.Key_H:
|
case Qt.Key_H:
|
||||||
selectOption("hibernate");
|
startHold("hibernate", visibleActions.indexOf("hibernate"));
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
break;
|
break;
|
||||||
case Qt.Key_D:
|
case Qt.Key_D:
|
||||||
selectOption("restart");
|
startHold("restart", visibleActions.indexOf("restart"));
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -391,12 +483,14 @@ DankModal {
|
|||||||
content: Component {
|
content: Component {
|
||||||
Item {
|
Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
implicitHeight: SettingsData.powerMenuGridLayout ? buttonGrid.implicitHeight + Theme.spacingL * 2 : buttonColumn.implicitHeight + Theme.spacingL * 2
|
implicitHeight: (SettingsData.powerMenuGridLayout ? buttonGrid.implicitHeight : buttonColumn.implicitHeight) + Theme.spacingL * 2 + (root.needsConfirmation ? hintRow.height + Theme.spacingM : 0)
|
||||||
|
|
||||||
Grid {
|
Grid {
|
||||||
id: buttonGrid
|
id: buttonGrid
|
||||||
visible: SettingsData.powerMenuGridLayout
|
visible: SettingsData.powerMenuGridLayout
|
||||||
anchors.centerIn: parent
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.topMargin: Theme.spacingL
|
||||||
columns: root.gridColumns
|
columns: root.gridColumns
|
||||||
columnSpacing: Theme.spacingS
|
columnSpacing: Theme.spacingS
|
||||||
rowSpacing: Theme.spacingS
|
rowSpacing: Theme.spacingS
|
||||||
@@ -405,12 +499,14 @@ DankModal {
|
|||||||
model: root.visibleActions
|
model: root.visibleActions
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
id: gridButtonRect
|
||||||
required property int index
|
required property int index
|
||||||
required property string modelData
|
required property string modelData
|
||||||
|
|
||||||
readonly property var actionData: root.getActionData(modelData)
|
readonly property var actionData: root.getActionData(modelData)
|
||||||
readonly property bool isSelected: root.selectedIndex === index
|
readonly property bool isSelected: root.selectedIndex === index
|
||||||
readonly property bool showWarning: modelData === "reboot" || modelData === "poweroff"
|
readonly property bool showWarning: modelData === "reboot" || modelData === "poweroff"
|
||||||
|
readonly property bool isHolding: root.holdActionIndex === index && root.holdProgress > 0
|
||||||
|
|
||||||
width: (root.modalWidth - Theme.spacingL * 2 - Theme.spacingS * (root.gridColumns - 1)) / root.gridColumns
|
width: (root.modalWidth - Theme.spacingL * 2 - Theme.spacingS * (root.gridColumns - 1)) / root.gridColumns
|
||||||
height: 100
|
height: 100
|
||||||
@@ -425,16 +521,50 @@ DankModal {
|
|||||||
border.color: isSelected ? Theme.primary : "transparent"
|
border.color: isSelected ? Theme.primary : "transparent"
|
||||||
border.width: isSelected ? 2 : 0
|
border.width: isSelected ? 2 : 0
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: gridProgressMask
|
||||||
|
anchors.fill: parent
|
||||||
|
radius: parent.radius
|
||||||
|
visible: false
|
||||||
|
layer.enabled: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
anchors.fill: parent
|
||||||
|
visible: gridButtonRect.isHolding
|
||||||
|
layer.enabled: gridButtonRect.isHolding
|
||||||
|
layer.effect: MultiEffect {
|
||||||
|
maskEnabled: true
|
||||||
|
maskSource: gridProgressMask
|
||||||
|
maskSpreadAtMin: 1
|
||||||
|
maskThresholdMin: 0.5
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
width: parent.width * root.holdProgress
|
||||||
|
color: {
|
||||||
|
if (gridButtonRect.modelData === "poweroff")
|
||||||
|
return Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.3);
|
||||||
|
if (gridButtonRect.modelData === "reboot")
|
||||||
|
return Qt.rgba(Theme.warning.r, Theme.warning.g, Theme.warning.b, 0.3);
|
||||||
|
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
spacing: Theme.spacingS
|
spacing: Theme.spacingS
|
||||||
|
|
||||||
DankIcon {
|
DankIcon {
|
||||||
name: parent.parent.actionData.icon
|
name: gridButtonRect.actionData.icon
|
||||||
size: Theme.iconSize + 8
|
size: Theme.iconSize + 8
|
||||||
color: {
|
color: {
|
||||||
if (parent.parent.showWarning && mouseArea.containsMouse) {
|
if (gridButtonRect.showWarning && (mouseArea.containsMouse || gridButtonRect.isHolding)) {
|
||||||
return parent.parent.modelData === "poweroff" ? Theme.error : Theme.warning;
|
return gridButtonRect.modelData === "poweroff" ? Theme.error : Theme.warning;
|
||||||
}
|
}
|
||||||
return Theme.surfaceText;
|
return Theme.surfaceText;
|
||||||
}
|
}
|
||||||
@@ -442,11 +572,11 @@ DankModal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: parent.parent.actionData.label
|
text: gridButtonRect.actionData.label
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
color: {
|
color: {
|
||||||
if (parent.parent.showWarning && mouseArea.containsMouse) {
|
if (gridButtonRect.showWarning && (mouseArea.containsMouse || gridButtonRect.isHolding)) {
|
||||||
return parent.parent.modelData === "poweroff" ? Theme.error : Theme.warning;
|
return gridButtonRect.modelData === "poweroff" ? Theme.error : Theme.warning;
|
||||||
}
|
}
|
||||||
return Theme.surfaceText;
|
return Theme.surfaceText;
|
||||||
}
|
}
|
||||||
@@ -462,7 +592,7 @@ DankModal {
|
|||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: parent.parent.parent.actionData.key
|
text: gridButtonRect.actionData.key
|
||||||
font.pixelSize: Theme.fontSizeSmall - 1
|
font.pixelSize: Theme.fontSizeSmall - 1
|
||||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.6)
|
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.6)
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
@@ -476,11 +606,14 @@ DankModal {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onPressed: {
|
||||||
root.selectedRow = Math.floor(index / root.gridColumns);
|
root.selectedRow = Math.floor(index / root.gridColumns);
|
||||||
root.selectedCol = index % root.gridColumns;
|
root.selectedCol = index % root.gridColumns;
|
||||||
root.selectOption(modelData);
|
root.selectedIndex = index;
|
||||||
|
root.startHold(modelData, index);
|
||||||
}
|
}
|
||||||
|
onReleased: root.cancelHold()
|
||||||
|
onCanceled: root.cancelHold()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -492,9 +625,10 @@ DankModal {
|
|||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: parent.right
|
right: parent.right
|
||||||
|
top: parent.top
|
||||||
leftMargin: Theme.spacingL
|
leftMargin: Theme.spacingL
|
||||||
rightMargin: Theme.spacingL
|
rightMargin: Theme.spacingL
|
||||||
verticalCenter: parent.verticalCenter
|
topMargin: Theme.spacingL
|
||||||
}
|
}
|
||||||
spacing: Theme.spacingS
|
spacing: Theme.spacingS
|
||||||
|
|
||||||
@@ -502,12 +636,14 @@ DankModal {
|
|||||||
model: root.visibleActions
|
model: root.visibleActions
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
id: listButtonRect
|
||||||
required property int index
|
required property int index
|
||||||
required property string modelData
|
required property string modelData
|
||||||
|
|
||||||
readonly property var actionData: root.getActionData(modelData)
|
readonly property var actionData: root.getActionData(modelData)
|
||||||
readonly property bool isSelected: root.selectedIndex === index
|
readonly property bool isSelected: root.selectedIndex === index
|
||||||
readonly property bool showWarning: modelData === "reboot" || modelData === "poweroff"
|
readonly property bool showWarning: modelData === "reboot" || modelData === "poweroff"
|
||||||
|
readonly property bool isHolding: root.holdActionIndex === index && root.holdProgress > 0
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 56
|
height: 56
|
||||||
@@ -522,6 +658,40 @@ DankModal {
|
|||||||
border.color: isSelected ? Theme.primary : "transparent"
|
border.color: isSelected ? Theme.primary : "transparent"
|
||||||
border.width: isSelected ? 2 : 0
|
border.width: isSelected ? 2 : 0
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: listProgressMask
|
||||||
|
anchors.fill: parent
|
||||||
|
radius: parent.radius
|
||||||
|
visible: false
|
||||||
|
layer.enabled: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
anchors.fill: parent
|
||||||
|
visible: listButtonRect.isHolding
|
||||||
|
layer.enabled: listButtonRect.isHolding
|
||||||
|
layer.effect: MultiEffect {
|
||||||
|
maskEnabled: true
|
||||||
|
maskSource: listProgressMask
|
||||||
|
maskSpreadAtMin: 1
|
||||||
|
maskThresholdMin: 0.5
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
width: parent.width * root.holdProgress
|
||||||
|
color: {
|
||||||
|
if (listButtonRect.modelData === "poweroff")
|
||||||
|
return Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.3);
|
||||||
|
if (listButtonRect.modelData === "reboot")
|
||||||
|
return Qt.rgba(Theme.warning.r, Theme.warning.g, Theme.warning.b, 0.3);
|
||||||
|
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
@@ -533,11 +703,11 @@ DankModal {
|
|||||||
spacing: Theme.spacingM
|
spacing: Theme.spacingM
|
||||||
|
|
||||||
DankIcon {
|
DankIcon {
|
||||||
name: parent.parent.actionData.icon
|
name: listButtonRect.actionData.icon
|
||||||
size: Theme.iconSize + 4
|
size: Theme.iconSize + 4
|
||||||
color: {
|
color: {
|
||||||
if (parent.parent.showWarning && listMouseArea.containsMouse) {
|
if (listButtonRect.showWarning && (listMouseArea.containsMouse || listButtonRect.isHolding)) {
|
||||||
return parent.parent.modelData === "poweroff" ? Theme.error : Theme.warning;
|
return listButtonRect.modelData === "poweroff" ? Theme.error : Theme.warning;
|
||||||
}
|
}
|
||||||
return Theme.surfaceText;
|
return Theme.surfaceText;
|
||||||
}
|
}
|
||||||
@@ -545,11 +715,11 @@ DankModal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: parent.parent.actionData.label
|
text: listButtonRect.actionData.label
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
color: {
|
color: {
|
||||||
if (parent.parent.showWarning && listMouseArea.containsMouse) {
|
if (listButtonRect.showWarning && (listMouseArea.containsMouse || listButtonRect.isHolding)) {
|
||||||
return parent.parent.modelData === "poweroff" ? Theme.error : Theme.warning;
|
return listButtonRect.modelData === "poweroff" ? Theme.error : Theme.warning;
|
||||||
}
|
}
|
||||||
return Theme.surfaceText;
|
return Theme.surfaceText;
|
||||||
}
|
}
|
||||||
@@ -570,7 +740,7 @@ DankModal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: parent.parent.actionData.key
|
text: listButtonRect.actionData.key
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.6)
|
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.6)
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
@@ -583,12 +753,51 @@ DankModal {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onPressed: {
|
||||||
root.selectedIndex = index;
|
root.selectedIndex = index;
|
||||||
root.selectOption(modelData);
|
root.startHold(modelData, index);
|
||||||
}
|
}
|
||||||
}
|
onReleased: root.cancelHold()
|
||||||
}
|
onCanceled: root.cancelHold()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: hintRow
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.bottomMargin: Theme.spacingS
|
||||||
|
spacing: Theme.spacingXS
|
||||||
|
visible: root.needsConfirmation
|
||||||
|
opacity: root.showHoldHint ? 1 : 0.5
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 150
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DankIcon {
|
||||||
|
name: root.showHoldHint ? "warning" : "touch_app"
|
||||||
|
size: Theme.fontSizeSmall
|
||||||
|
color: root.showHoldHint ? Theme.warning : Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.6)
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
readonly property int remainingSeconds: Math.ceil(SettingsData.powerActionHoldDuration * (1 - root.holdProgress))
|
||||||
|
text: {
|
||||||
|
if (root.showHoldHint)
|
||||||
|
return I18n.tr("Hold longer to confirm");
|
||||||
|
if (root.holdProgress > 0)
|
||||||
|
return I18n.tr("Hold to confirm (%1s)").arg(remainingSeconds);
|
||||||
|
return I18n.tr("Hold to confirm (%1s)").arg(SettingsData.powerActionHoldDuration);
|
||||||
|
}
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
color: root.showHoldHint ? Theme.warning : Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.6)
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -583,11 +583,54 @@ Item {
|
|||||||
|
|
||||||
DankToggle {
|
DankToggle {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
text: I18n.tr("Show Confirmation on Power Actions")
|
text: I18n.tr("Hold to Confirm Power Actions")
|
||||||
description: I18n.tr("Request confirmation on power off, restart, suspend, hibernate and logout actions")
|
description: I18n.tr("Require holding button/key to confirm power off, restart, suspend, hibernate and logout")
|
||||||
checked: SettingsData.powerActionConfirm
|
checked: SettingsData.powerActionConfirm
|
||||||
onToggled: checked => SettingsData.set("powerActionConfirm", checked)
|
onToggled: checked => SettingsData.set("powerActionConfirm", checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
width: parent.width
|
||||||
|
spacing: Theme.spacingS
|
||||||
|
visible: SettingsData.powerActionConfirm
|
||||||
|
|
||||||
|
Item {
|
||||||
|
width: parent.width - Theme.spacingM * 2
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
height: holdDurationLabel.height
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
id: holdDurationLabel
|
||||||
|
text: I18n.tr("Hold Duration")
|
||||||
|
font.pixelSize: Appearance.fontSize.normal
|
||||||
|
font.weight: Font.Medium
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: SettingsData.powerActionHoldDuration + "s"
|
||||||
|
font.pixelSize: Appearance.fontSize.normal
|
||||||
|
font.weight: Font.Medium
|
||||||
|
color: Theme.primary
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DankSlider {
|
||||||
|
width: parent.width - Theme.spacingM * 2
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
minimum: 1
|
||||||
|
maximum: 10
|
||||||
|
unit: "s"
|
||||||
|
wheelEnabled: false
|
||||||
|
showValue: false
|
||||||
|
thumbOutlineColor: Theme.surfaceContainerHigh
|
||||||
|
value: SettingsData.powerActionHoldDuration
|
||||||
|
onSliderValueChanged: newValue => SettingsData.set("powerActionHoldDuration", newValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user