1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-29 07:52:50 -05:00

fix light/dark toggle and settings not re-opening after escape

This commit is contained in:
bbedward
2025-08-05 17:32:53 -04:00
parent c88dc67dbc
commit 081f8533c4
5 changed files with 43 additions and 36 deletions

View File

@@ -10,32 +10,44 @@ import qs.Widgets
DankModal { DankModal {
id: settingsModal id: settingsModal
property bool settingsVisible: false
signal closingModal() signal closingModal()
onVisibleChanged: { function show() {
if (!visible) { settingsModal.visible = true;
if (settingsVisible) { }
settingsVisible = false;
} function hide() {
closingModal(); settingsModal.visible = false;
} }
function toggle() {
if (settingsModal.visible)
hide();
else
show();
} }
visible: settingsVisible
width: 750 width: 750
height: 750 height: 750
visible: false
keyboardFocus: "ondemand" keyboardFocus: "ondemand"
onBackgroundClicked: { onBackgroundClicked: hide()
settingsVisible = false;
}
content: Component { content: Component {
Column { Item {
anchors.fill: parent anchors.fill: parent
anchors.margins: Theme.spacingM focus: true
spacing: Theme.spacingS Keys.onPressed: function(event) {
if (event.key === Qt.Key_Escape) {
settingsModal.hide();
event.accepted = true;
}
}
Column {
anchors.fill: parent
anchors.margins: Theme.spacingM
spacing: Theme.spacingS
Row { Row {
width: parent.width width: parent.width
@@ -67,7 +79,7 @@ DankModal {
iconSize: Theme.iconSize - 4 iconSize: Theme.iconSize - 4
iconColor: Theme.surfaceText iconColor: Theme.surfaceText
hoverColor: Theme.errorHover hoverColor: Theme.errorHover
onClicked: settingsModal.settingsVisible = false onClicked: settingsModal.hide()
} }
} }
@@ -152,27 +164,24 @@ DankModal {
} }
} }
} }
} }
}
} }
IpcHandler { IpcHandler {
function open() { function open() {
settingsModal.show();
settingsModal.settingsVisible = true;
return "SETTINGS_OPEN_SUCCESS"; return "SETTINGS_OPEN_SUCCESS";
} }
function close() { function close() {
settingsModal.hide();
settingsModal.settingsVisible = false;
return "SETTINGS_CLOSE_SUCCESS"; return "SETTINGS_CLOSE_SUCCESS";
} }
function toggle() { function toggle() {
settingsModal.toggle();
settingsModal.settingsVisible = !settingsModal.settingsVisible;
return "SETTINGS_TOGGLE_SUCCESS"; return "SETTINGS_TOGGLE_SUCCESS";
} }

View File

@@ -344,7 +344,7 @@ PanelWindow {
hoverColor: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) hoverColor: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12)
onClicked: { onClicked: {
controlCenterVisible = false; controlCenterVisible = false;
settingsModal.settingsVisible = true; settingsModal.show();
} }
} }
@@ -743,6 +743,8 @@ PanelWindow {
description: "Use light theme instead of dark theme" description: "Use light theme instead of dark theme"
checked: Prefs.isLightMode checked: Prefs.isLightMode
onToggled: (checked) => { onToggled: (checked) => {
Prefs.setLightMode(checked);
Theme.isLightMode = checked;
PortalService.setLightMode(checked); PortalService.setLightMode(checked);
} }
} }

View File

@@ -76,6 +76,8 @@ ScrollView {
description: "Use light theme instead of dark theme" description: "Use light theme instead of dark theme"
checked: Prefs.isLightMode checked: Prefs.isLightMode
onToggled: (checked) => { onToggled: (checked) => {
Prefs.setLightMode(checked);
Theme.isLightMode = checked;
PortalService.setLightMode(checked); PortalService.setLightMode(checked);
} }
} }

View File

@@ -186,7 +186,7 @@ ScrollView {
} }
StyledText { StyledText {
text: "xdg-desktop-portal-gtk missing" text: "accountsservice missing or not accessible"
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: Theme.error color: Theme.error
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter

View File

@@ -30,12 +30,6 @@ Singleton {
} }
function setLightMode(isLightMode) { function setLightMode(isLightMode) {
if (typeof Theme !== "undefined") {
Theme.isLightMode = isLightMode
}
if (typeof Prefs !== "undefined") {
Prefs.setLightMode(isLightMode)
}
if (settingsPortalAvailable) { if (settingsPortalAvailable) {
setSystemColorScheme(isLightMode) setSystemColorScheme(isLightMode)
} }