1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-29 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: { onVisibleChanged: {
if (root.visible) { if (root.visible) {
opened() opened()
Qt.callLater(() => {
if (shouldHaveFocus) {
focusScope.forceActiveFocus()
}
})
} else { } else {
if (Qt.inputMethod) { if (Qt.inputMethod) {
Qt.inputMethod.hide() Qt.inputMethod.hide()
@@ -85,6 +90,12 @@ PanelWindow {
} }
} }
onShouldHaveFocusChanged: {
if (shouldHaveFocus && shouldBeVisible && visible) {
Qt.callLater(() => focusScope.forceActiveFocus())
}
}
Connections { Connections {
function onCloseAllModalsExcept(excludedModal) { function onCloseAllModalsExcept(excludedModal) {
if (excludedModal !== root && !allowStacking && shouldBeVisible) { if (excludedModal !== root && !allowStacking && shouldBeVisible) {

View File

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

View File

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

View File

@@ -110,6 +110,11 @@ DankModal {
parentModal.shouldHaveFocus = Qt.binding(() => { parentModal.shouldHaveFocus = Qt.binding(() => {
return parentModal.shouldBeVisible return parentModal.shouldBeVisible
}) })
Qt.callLater(() => {
if (parentModal.modalFocusScope) {
parentModal.modalFocusScope.forceActiveFocus()
}
})
} }
} }

View File

@@ -44,7 +44,7 @@
{ {
"term": "3rd party", "term": "3rd party",
"context": "3rd party", "context": "3rd party",
"reference": "Modules/Settings/PluginBrowser.qml:408", "reference": "Modules/Settings/PluginBrowser.qml:413",
"comment": "" "comment": ""
}, },
{ {
@@ -542,7 +542,7 @@
{ {
"term": "Browse Plugins", "term": "Browse Plugins",
"context": "Browse Plugins", "context": "Browse Plugins",
"reference": "Modules/Settings/PluginBrowser.qml:177", "reference": "Modules/Settings/PluginBrowser.qml:182",
"comment": "" "comment": ""
}, },
{ {
@@ -590,7 +590,7 @@
{ {
"term": "Cancel", "term": "Cancel",
"context": "Cancel", "context": "Cancel",
"reference": "Modals/BluetoothPairingModal.qml:251, Modals/PolkitAuthModal.qml:291, Modals/WifiPasswordModal.qml:494, Modals/FileBrowser/FileBrowserOverwriteDialog.qml:83, Modules/Settings/PluginBrowser.qml:630", "reference": "Modals/BluetoothPairingModal.qml:251, Modals/PolkitAuthModal.qml:291, Modals/WifiPasswordModal.qml:494, Modals/FileBrowser/FileBrowserOverwriteDialog.qml:83, Modules/Settings/PluginBrowser.qml:635",
"comment": "" "comment": ""
}, },
{ {
@@ -1796,7 +1796,7 @@
{ {
"term": "I Understand", "term": "I Understand",
"context": "I Understand", "context": "I Understand",
"reference": "Modules/Settings/PluginBrowser.qml:636", "reference": "Modules/Settings/PluginBrowser.qml:641",
"comment": "" "comment": ""
}, },
{ {
@@ -1880,7 +1880,7 @@
{ {
"term": "Install plugins from the DMS plugin registry", "term": "Install plugins from the DMS plugin registry",
"context": "Install plugins from the DMS plugin registry", "context": "Install plugins from the DMS plugin registry",
"reference": "Modules/Settings/PluginBrowser.qml:231", "reference": "Modules/Settings/PluginBrowser.qml:236",
"comment": "" "comment": ""
}, },
{ {
@@ -2036,7 +2036,7 @@
{ {
"term": "Loading plugins...", "term": "Loading plugins...",
"context": "Loading plugins...", "context": "Loading plugins...",
"reference": "Modules/Settings/PluginBrowser.qml:299", "reference": "Modules/Settings/PluginBrowser.qml:304",
"comment": "" "comment": ""
}, },
{ {
@@ -2450,7 +2450,7 @@
{ {
"term": "No plugins found", "term": "No plugins found",
"context": "No plugins found", "context": "No plugins found",
"reference": "Modules/Settings/PluginBrowser.qml:533", "reference": "Modules/Settings/PluginBrowser.qml:538",
"comment": "" "comment": ""
}, },
{ {
@@ -3146,7 +3146,7 @@
{ {
"term": "Search plugins...", "term": "Search plugins...",
"context": "Search plugins...", "context": "Search plugins...",
"reference": "Modules/Settings/PluginBrowser.qml:255", "reference": "Modules/Settings/PluginBrowser.qml:260",
"comment": "" "comment": ""
}, },
{ {
@@ -3260,7 +3260,7 @@
{ {
"term": "Settings", "term": "Settings",
"context": "Settings", "context": "Settings",
"reference": "Services/AppSearchService.qml:176, Modals/Settings/SettingsModal.qml:168, Modules/DankDash/DankDashPopout.qml:249", "reference": "Services/AppSearchService.qml:176, Modals/Settings/SettingsModal.qml:200, Modules/DankDash/DankDashPopout.qml:249",
"comment": "" "comment": ""
}, },
{ {
@@ -3686,13 +3686,13 @@
{ {
"term": "Third-Party Plugin Warning", "term": "Third-Party Plugin Warning",
"context": "Third-Party Plugin Warning", "context": "Third-Party Plugin Warning",
"reference": "Modules/Settings/PluginBrowser.qml:581", "reference": "Modules/Settings/PluginBrowser.qml:586",
"comment": "" "comment": ""
}, },
{ {
"term": "Third-party plugins are created by the community and are not officially supported by DankMaterialShell.\\n\\nThese plugins may pose security and privacy risks - install at your own risk.", "term": "Third-party plugins are created by the community and are not officially supported by DankMaterialShell.\\n\\nThese plugins may pose security and privacy risks - install at your own risk.",
"context": "Third-party plugins are created by the community and are not officially supported by DankMaterialShell.\\n\\nThese plugins may pose security and privacy risks - install at your own risk.", "context": "Third-party plugins are created by the community and are not officially supported by DankMaterialShell.\\n\\nThese plugins may pose security and privacy risks - install at your own risk.",
"reference": "Modules/Settings/PluginBrowser.qml:591", "reference": "Modules/Settings/PluginBrowser.qml:596",
"comment": "" "comment": ""
}, },
{ {
@@ -4178,7 +4178,7 @@
{ {
"term": "official", "term": "official",
"context": "official", "context": "official",
"reference": "Modules/Settings/PluginBrowser.qml:388", "reference": "Modules/Settings/PluginBrowser.qml:393",
"comment": "" "comment": ""
}, },
{ {
@@ -4190,7 +4190,7 @@
{ {
"term": "• Install only from trusted sources", "term": "• Install only from trusted sources",
"context": "• Install only from trusted sources", "context": "• Install only from trusted sources",
"reference": "Modules/Settings/PluginBrowser.qml:614", "reference": "Modules/Settings/PluginBrowser.qml:619",
"comment": "" "comment": ""
}, },
{ {
@@ -4220,13 +4220,13 @@
{ {
"term": "• Plugins may contain bugs or security issues", "term": "• Plugins may contain bugs or security issues",
"context": "• Plugins may contain bugs or security issues", "context": "• Plugins may contain bugs or security issues",
"reference": "Modules/Settings/PluginBrowser.qml:602", "reference": "Modules/Settings/PluginBrowser.qml:607",
"comment": "" "comment": ""
}, },
{ {
"term": "• Review code before installation when possible", "term": "• Review code before installation when possible",
"context": "• Review code before installation when possible", "context": "• Review code before installation when possible",
"reference": "Modules/Settings/PluginBrowser.qml:608", "reference": "Modules/Settings/PluginBrowser.qml:613",
"comment": "" "comment": ""
}, },
{ {

View File

@@ -312,7 +312,7 @@
"Center Section": "中间区域" "Center Section": "中间区域"
}, },
"Changes:": { "Changes:": {
"Changes:": "" "Changes:": "更改:"
}, },
"Check for system updates": { "Check for system updates": {
"Check for system updates": "检查系统更新" "Check for system updates": "检查系统更新"
@@ -414,7 +414,7 @@
"Confirm": "确认" "Confirm": "确认"
}, },
"Confirm Display Changes": { "Confirm Display Changes": {
"Confirm Display Changes": "" "Confirm Display Changes": "确认显示更改"
}, },
"Confirm passkey for ": { "Confirm passkey for ": {
"Confirm passkey for ": "确认密钥 " "Confirm passkey for ": "确认密钥 "
@@ -591,7 +591,7 @@
"Disable Autoconnect": "禁用自动连接" "Disable Autoconnect": "禁用自动连接"
}, },
"Disabled": { "Disabled": {
"Disabled": "" "Disabled": "已关闭"
}, },
"Disconnect": { "Disconnect": {
"Disconnect": "断开连接" "Disconnect": "断开连接"
@@ -621,7 +621,7 @@
"Display currently focused application title": "显示当前聚焦应用的标题" "Display currently focused application title": "显示当前聚焦应用的标题"
}, },
"Display settings for ": { "Display settings for ": {
"Display settings for ": "" "Display settings for ": "显示设置 "
}, },
"Display volume and brightness percentage values by default in OSD popups": { "Display volume and brightness percentage values by default in OSD popups": {
"Display volume and brightness percentage values by default in OSD popups": "在OSD弹窗中默认显示音量与亮度数值" "Display volume and brightness percentage values by default in OSD popups": "在OSD弹窗中默认显示音量与亮度数值"
@@ -699,7 +699,7 @@
"Enable loginctl lock integration": "启用 loginctl 锁定集成" "Enable loginctl lock integration": "启用 loginctl 锁定集成"
}, },
"Enabled": { "Enabled": {
"Enabled": "" "Enabled": "已开启"
}, },
"End": { "End": {
"End": "结束" "End": "结束"
@@ -966,7 +966,7 @@
"Individual Batteries": "分别显示电池" "Individual Batteries": "分别显示电池"
}, },
"Inhibit idle timeout when audio or video is playing": { "Inhibit idle timeout when audio or video is playing": {
"Inhibit idle timeout when audio or video is playing": "" "Inhibit idle timeout when audio or video is playing": "在播放音频或视频时,禁止待机超时"
}, },
"Input Devices": { "Input Devices": {
"Input Devices": "输入设备" "Input Devices": "输入设备"
@@ -993,7 +993,7 @@
"Jobs: ": "任务: " "Jobs: ": "任务: "
}, },
"Keep Changes": { "Keep Changes": {
"Keep Changes": "" "Keep Changes": "保持更改"
}, },
"Keyboard Layout Name": { "Keyboard Layout Name": {
"Keyboard Layout Name": "键盘布局名称" "Keyboard Layout Name": "键盘布局名称"
@@ -1164,7 +1164,7 @@
"Mode:": "模式:" "Mode:": "模式:"
}, },
"Mode: ": { "Mode: ": {
"Mode: ": "" "Mode: ": "模式: "
}, },
"Monitor": { "Monitor": {
"Monitor": "显示器" "Monitor": "显示器"
@@ -1449,7 +1449,7 @@
"Position": "位置" "Position": "位置"
}, },
"Position: ": { "Position: ": {
"Position: ": "" "Position: ": "位置: "
}, },
"Power & Security": { "Power & Security": {
"Power & Security": "电源与安全" "Power & Security": "电源与安全"
@@ -1470,7 +1470,7 @@
"Pressure": "气压" "Pressure": "气压"
}, },
"Prevent idle for media": { "Prevent idle for media": {
"Prevent idle for media": "" "Prevent idle for media": "防止媒体播放时进入待机状态"
}, },
"Prevent screen timeout": { "Prevent screen timeout": {
"Prevent screen timeout": "防止屏幕超时" "Prevent screen timeout": "防止屏幕超时"
@@ -1560,10 +1560,10 @@
"Resume": "恢复" "Resume": "恢复"
}, },
"Revert": { "Revert": {
"Revert": "" "Revert": "恢复: "
}, },
"Reverting in:": { "Reverting in:": {
"Reverting in:": "" "Reverting in:": "恢复于:"
}, },
"Right": { "Right": {
"Right": "右侧" "Right": "右侧"
@@ -2037,7 +2037,7 @@
"VPN status and quick connect": "VPN 状态与快速连接" "VPN status and quick connect": "VPN 状态与快速连接"
}, },
"VRR: ": { "VRR: ": {
"VRR: ": "" "VRR: ": "可变刷新率: "
}, },
"Vibrant palette with playful saturation.": { "Vibrant palette with playful saturation.": {
"Vibrant palette with playful saturation.": "充满活力的调色板,有着俏皮的饱和度。" "Vibrant palette with playful saturation.": "充满活力的调色板,有着俏皮的饱和度。"