mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
fix light/dark toggle and settings not re-opening after escape
This commit is contained in:
@@ -10,32 +10,44 @@ import qs.Widgets
|
||||
DankModal {
|
||||
id: settingsModal
|
||||
|
||||
property bool settingsVisible: false
|
||||
|
||||
signal closingModal()
|
||||
|
||||
onVisibleChanged: {
|
||||
if (!visible) {
|
||||
if (settingsVisible) {
|
||||
settingsVisible = false;
|
||||
}
|
||||
closingModal();
|
||||
}
|
||||
}
|
||||
|
||||
visible: settingsVisible
|
||||
width: 750
|
||||
height: 750
|
||||
keyboardFocus: "ondemand"
|
||||
onBackgroundClicked: {
|
||||
settingsVisible = false;
|
||||
function show() {
|
||||
settingsModal.visible = true;
|
||||
}
|
||||
|
||||
function hide() {
|
||||
settingsModal.visible = false;
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
if (settingsModal.visible)
|
||||
hide();
|
||||
else
|
||||
show();
|
||||
}
|
||||
|
||||
width: 750
|
||||
height: 750
|
||||
visible: false
|
||||
keyboardFocus: "ondemand"
|
||||
onBackgroundClicked: hide()
|
||||
|
||||
content: Component {
|
||||
Column {
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingM
|
||||
spacing: Theme.spacingS
|
||||
focus: true
|
||||
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 {
|
||||
width: parent.width
|
||||
@@ -67,7 +79,7 @@ DankModal {
|
||||
iconSize: Theme.iconSize - 4
|
||||
iconColor: Theme.surfaceText
|
||||
hoverColor: Theme.errorHover
|
||||
onClicked: settingsModal.settingsVisible = false
|
||||
onClicked: settingsModal.hide()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -152,27 +164,24 @@ DankModal {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
function open() {
|
||||
|
||||
settingsModal.settingsVisible = true;
|
||||
settingsModal.show();
|
||||
return "SETTINGS_OPEN_SUCCESS";
|
||||
}
|
||||
|
||||
function close() {
|
||||
|
||||
settingsModal.settingsVisible = false;
|
||||
settingsModal.hide();
|
||||
return "SETTINGS_CLOSE_SUCCESS";
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
|
||||
settingsModal.settingsVisible = !settingsModal.settingsVisible;
|
||||
settingsModal.toggle();
|
||||
return "SETTINGS_TOGGLE_SUCCESS";
|
||||
}
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ PanelWindow {
|
||||
hoverColor: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12)
|
||||
onClicked: {
|
||||
controlCenterVisible = false;
|
||||
settingsModal.settingsVisible = true;
|
||||
settingsModal.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -743,6 +743,8 @@ PanelWindow {
|
||||
description: "Use light theme instead of dark theme"
|
||||
checked: Prefs.isLightMode
|
||||
onToggled: (checked) => {
|
||||
Prefs.setLightMode(checked);
|
||||
Theme.isLightMode = checked;
|
||||
PortalService.setLightMode(checked);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,8 @@ ScrollView {
|
||||
description: "Use light theme instead of dark theme"
|
||||
checked: Prefs.isLightMode
|
||||
onToggled: (checked) => {
|
||||
Prefs.setLightMode(checked);
|
||||
Theme.isLightMode = checked;
|
||||
PortalService.setLightMode(checked);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ ScrollView {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: "xdg-desktop-portal-gtk missing"
|
||||
text: "accountsservice missing or not accessible"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.error
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
@@ -30,12 +30,6 @@ Singleton {
|
||||
}
|
||||
|
||||
function setLightMode(isLightMode) {
|
||||
if (typeof Theme !== "undefined") {
|
||||
Theme.isLightMode = isLightMode
|
||||
}
|
||||
if (typeof Prefs !== "undefined") {
|
||||
Prefs.setLightMode(isLightMode)
|
||||
}
|
||||
if (settingsPortalAvailable) {
|
||||
setSystemColorScheme(isLightMode)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user