1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-11 07:52:50 -05:00

settings: try to fix focus loss

This commit is contained in:
bbedward
2025-11-10 09:28:10 -05:00
parent c52df96af9
commit 7b3d2ab85a
6 changed files with 157 additions and 30 deletions

View File

@@ -76,6 +76,11 @@ PanelWindow {
onVisibleChanged: {
if (root.visible) {
opened()
Qt.callLater(() => {
if (shouldHaveFocus) {
focusScope.forceActiveFocus()
}
})
} else {
if (Qt.inputMethod) {
Qt.inputMethod.hide()
@@ -85,6 +90,12 @@ PanelWindow {
}
}
onShouldHaveFocusChanged: {
if (shouldHaveFocus && shouldBeVisible && visible) {
Qt.callLater(() => focusScope.forceActiveFocus())
}
}
Connections {
function onCloseAllModalsExcept(excludedModal) {
if (excludedModal !== root && !allowStacking && shouldBeVisible) {

View File

@@ -2,12 +2,14 @@ import QtQuick
import qs.Common
import qs.Modules.Settings
Item {
FocusScope {
id: root
property int currentIndex: 0
property var parentModal: null
focus: true
Rectangle {
anchors.fill: parent
anchors.leftMargin: 0
@@ -22,6 +24,7 @@ Item {
anchors.fill: parent
active: root.currentIndex === 0
visible: active
focus: active
sourceComponent: Component {
PersonalizationTab {
@@ -30,6 +33,12 @@ Item {
}
onActiveChanged: {
if (active && item) {
Qt.callLater(() => item.forceActiveFocus())
}
}
}
Loader {
@@ -38,10 +47,17 @@ Item {
anchors.fill: parent
active: root.currentIndex === 1
visible: active
focus: active
sourceComponent: TimeWeatherTab {
}
onActiveChanged: {
if (active && item) {
Qt.callLater(() => item.forceActiveFocus())
}
}
}
Loader {
@@ -50,11 +66,18 @@ Item {
anchors.fill: parent
active: root.currentIndex === 2
visible: active
focus: active
sourceComponent: DankBarTab {
parentModal: root.parentModal
}
onActiveChanged: {
if (active && item) {
Qt.callLater(() => item.forceActiveFocus())
}
}
}
Loader {
@@ -63,10 +86,17 @@ Item {
anchors.fill: parent
active: root.currentIndex === 3
visible: active
focus: active
sourceComponent: WidgetTweaksTab {
}
onActiveChanged: {
if (active && item) {
Qt.callLater(() => item.forceActiveFocus())
}
}
}
Loader {
@@ -75,6 +105,7 @@ Item {
anchors.fill: parent
active: root.currentIndex === 4
visible: active
focus: active
sourceComponent: Component {
DockTab {
@@ -82,6 +113,12 @@ Item {
}
onActiveChanged: {
if (active && item) {
Qt.callLater(() => item.forceActiveFocus())
}
}
}
Loader {
@@ -90,10 +127,17 @@ Item {
anchors.fill: parent
active: root.currentIndex === 5
visible: active
focus: active
sourceComponent: DisplaysTab {
}
onActiveChanged: {
if (active && item) {
Qt.callLater(() => item.forceActiveFocus())
}
}
}
Loader {
@@ -102,10 +146,17 @@ Item {
anchors.fill: parent
active: root.currentIndex === 6
visible: active
focus: active
sourceComponent: LauncherTab {
}
onActiveChanged: {
if (active && item) {
Qt.callLater(() => item.forceActiveFocus())
}
}
}
Loader {
@@ -114,10 +165,17 @@ Item {
anchors.fill: parent
active: root.currentIndex === 7
visible: active
focus: active
sourceComponent: ThemeColorsTab {
}
onActiveChanged: {
if (active && item) {
Qt.callLater(() => item.forceActiveFocus())
}
}
}
Loader {
@@ -126,10 +184,17 @@ Item {
anchors.fill: parent
active: root.currentIndex === 8
visible: active
focus: active
sourceComponent: PowerSettings {
}
onActiveChanged: {
if (active && item) {
Qt.callLater(() => item.forceActiveFocus())
}
}
}
Loader {
@@ -138,11 +203,18 @@ Item {
anchors.fill: parent
active: root.currentIndex === 9
visible: active
focus: active
sourceComponent: PluginsTab {
parentModal: root.parentModal
}
onActiveChanged: {
if (active && item) {
Qt.callLater(() => item.forceActiveFocus())
}
}
}
Loader {
@@ -151,10 +223,17 @@ Item {
anchors.fill: parent
active: root.currentIndex === 10
visible: active
focus: active
sourceComponent: AboutTab {
}
onActiveChanged: {
if (active && item) {
Qt.callLater(() => item.forceActiveFocus())
}
}
}
}

View File

@@ -45,7 +45,23 @@ DankModal {
}
content: settingsContent
onOpened: () => {
Qt.callLater(() => modalFocusScope.forceActiveFocus())
Qt.callLater(() => {
modalFocusScope.forceActiveFocus()
if (contentLoader.item) {
contentLoader.item.forceActiveFocus()
}
})
}
onVisibleChanged: {
if (visible && shouldBeVisible) {
Qt.callLater(() => {
modalFocusScope.forceActiveFocus()
if (contentLoader.item) {
contentLoader.item.forceActiveFocus()
}
})
}
}
modalFocusScope.Keys.onPressed: event => {
const tabCount = 11
@@ -113,6 +129,14 @@ DankModal {
}
onDialogClosed: () => {
allowStacking = true;
if (settingsModal.shouldBeVisible) {
Qt.callLater(() => {
settingsModal.modalFocusScope.forceActiveFocus()
if (settingsModal.contentLoader.item) {
settingsModal.contentLoader.item.forceActiveFocus()
}
})
}
}
}
@@ -132,6 +156,14 @@ DankModal {
}
onDialogClosed: () => {
allowStacking = true;
if (settingsModal.shouldBeVisible) {
Qt.callLater(() => {
settingsModal.modalFocusScope.forceActiveFocus()
if (settingsModal.contentLoader.item) {
settingsModal.contentLoader.item.forceActiveFocus()
}
})
}
}
}