1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -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()
}
})
}
}
}

View File

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

View File

@@ -44,7 +44,7 @@
{
"term": "3rd party",
"context": "3rd party",
"reference": "Modules/Settings/PluginBrowser.qml:408",
"reference": "Modules/Settings/PluginBrowser.qml:413",
"comment": ""
},
{
@@ -542,7 +542,7 @@
{
"term": "Browse Plugins",
"context": "Browse Plugins",
"reference": "Modules/Settings/PluginBrowser.qml:177",
"reference": "Modules/Settings/PluginBrowser.qml:182",
"comment": ""
},
{
@@ -590,7 +590,7 @@
{
"term": "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": ""
},
{
@@ -1796,7 +1796,7 @@
{
"term": "I Understand",
"context": "I Understand",
"reference": "Modules/Settings/PluginBrowser.qml:636",
"reference": "Modules/Settings/PluginBrowser.qml:641",
"comment": ""
},
{
@@ -1880,7 +1880,7 @@
{
"term": "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": ""
},
{
@@ -2036,7 +2036,7 @@
{
"term": "Loading plugins...",
"context": "Loading plugins...",
"reference": "Modules/Settings/PluginBrowser.qml:299",
"reference": "Modules/Settings/PluginBrowser.qml:304",
"comment": ""
},
{
@@ -2450,7 +2450,7 @@
{
"term": "No plugins found",
"context": "No plugins found",
"reference": "Modules/Settings/PluginBrowser.qml:533",
"reference": "Modules/Settings/PluginBrowser.qml:538",
"comment": ""
},
{
@@ -3146,7 +3146,7 @@
{
"term": "Search plugins...",
"context": "Search plugins...",
"reference": "Modules/Settings/PluginBrowser.qml:255",
"reference": "Modules/Settings/PluginBrowser.qml:260",
"comment": ""
},
{
@@ -3260,7 +3260,7 @@
{
"term": "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": ""
},
{
@@ -3686,13 +3686,13 @@
{
"term": "Third-Party Plugin Warning",
"context": "Third-Party Plugin Warning",
"reference": "Modules/Settings/PluginBrowser.qml:581",
"reference": "Modules/Settings/PluginBrowser.qml:586",
"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.",
"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": ""
},
{
@@ -4178,7 +4178,7 @@
{
"term": "official",
"context": "official",
"reference": "Modules/Settings/PluginBrowser.qml:388",
"reference": "Modules/Settings/PluginBrowser.qml:393",
"comment": ""
},
{
@@ -4190,7 +4190,7 @@
{
"term": "• Install only from trusted sources",
"context": "• Install only from trusted sources",
"reference": "Modules/Settings/PluginBrowser.qml:614",
"reference": "Modules/Settings/PluginBrowser.qml:619",
"comment": ""
},
{
@@ -4220,13 +4220,13 @@
{
"term": "• 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": ""
},
{
"term": "• 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": ""
},
{

View File

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