1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-15 18:22:08 -04:00

Update more sidebar settings nav

This commit is contained in:
purian23
2025-10-18 23:10:08 -04:00
parent bcb22ec265
commit 5a32398446
3 changed files with 36 additions and 79 deletions

View File

@@ -2,12 +2,11 @@ import QtQuick
import qs.Common import qs.Common
import qs.Modules.Settings import qs.Modules.Settings
FocusScope { Item {
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
@@ -23,7 +22,6 @@ FocusScope {
anchors.fill: parent anchors.fill: parent
active: root.currentIndex === 0 active: root.currentIndex === 0
visible: active visible: active
asynchronous: true
sourceComponent: Component { sourceComponent: Component {
PersonalizationTab { PersonalizationTab {
@@ -40,7 +38,6 @@ FocusScope {
anchors.fill: parent anchors.fill: parent
active: root.currentIndex === 1 active: root.currentIndex === 1
visible: active visible: active
asynchronous: true
sourceComponent: TimeWeatherTab { sourceComponent: TimeWeatherTab {
} }
@@ -53,7 +50,6 @@ FocusScope {
anchors.fill: parent anchors.fill: parent
active: root.currentIndex === 2 active: root.currentIndex === 2
visible: active visible: active
asynchronous: true
sourceComponent: DankBarTab { sourceComponent: DankBarTab {
parentModal: root.parentModal parentModal: root.parentModal
@@ -67,7 +63,6 @@ FocusScope {
anchors.fill: parent anchors.fill: parent
active: root.currentIndex === 3 active: root.currentIndex === 3
visible: active visible: active
asynchronous: true
sourceComponent: WidgetTweaksTab { sourceComponent: WidgetTweaksTab {
} }
@@ -80,7 +75,6 @@ FocusScope {
anchors.fill: parent anchors.fill: parent
active: root.currentIndex === 4 active: root.currentIndex === 4
visible: active visible: active
asynchronous: true
sourceComponent: Component { sourceComponent: Component {
DockTab { DockTab {
@@ -96,7 +90,6 @@ FocusScope {
anchors.fill: parent anchors.fill: parent
active: root.currentIndex === 5 active: root.currentIndex === 5
visible: active visible: active
asynchronous: true
sourceComponent: DisplaysTab { sourceComponent: DisplaysTab {
} }
@@ -109,7 +102,6 @@ FocusScope {
anchors.fill: parent anchors.fill: parent
active: root.currentIndex === 6 active: root.currentIndex === 6
visible: active visible: active
asynchronous: true
sourceComponent: LauncherTab { sourceComponent: LauncherTab {
} }
@@ -122,7 +114,6 @@ FocusScope {
anchors.fill: parent anchors.fill: parent
active: root.currentIndex === 7 active: root.currentIndex === 7
visible: active visible: active
asynchronous: true
sourceComponent: ThemeColorsTab { sourceComponent: ThemeColorsTab {
} }
@@ -135,7 +126,6 @@ FocusScope {
anchors.fill: parent anchors.fill: parent
active: root.currentIndex === 8 active: root.currentIndex === 8
visible: active visible: active
asynchronous: true
sourceComponent: PowerSettings { sourceComponent: PowerSettings {
} }
@@ -148,7 +138,6 @@ FocusScope {
anchors.fill: parent anchors.fill: parent
active: root.currentIndex === 9 active: root.currentIndex === 9
visible: active visible: active
asynchronous: true
sourceComponent: PluginsTab { sourceComponent: PluginsTab {
parentModal: root.parentModal parentModal: root.parentModal
@@ -162,7 +151,6 @@ FocusScope {
anchors.fill: parent anchors.fill: parent
active: root.currentIndex === 10 active: root.currentIndex === 10
visible: active visible: active
asynchronous: true
sourceComponent: AboutTab { sourceComponent: AboutTab {
} }

View File

@@ -13,6 +13,7 @@ DankModal {
property Component settingsContent property Component settingsContent
property alias profileBrowser: profileBrowser property alias profileBrowser: profileBrowser
property int currentTabIndex: 0
signal closingModal() signal closingModal()
@@ -40,6 +41,25 @@ DankModal {
return hide(); return hide();
} }
content: settingsContent content: settingsContent
onOpened: () => {
Qt.callLater(() => modalFocusScope.forceActiveFocus())
}
modalFocusScope.Keys.onPressed: event => {
const tabCount = 11
if (event.key === Qt.Key_Down) {
currentTabIndex = (currentTabIndex + 1) % tabCount
event.accepted = true
} else if (event.key === Qt.Key_Up) {
currentTabIndex = (currentTabIndex - 1 + tabCount) % tabCount
event.accepted = true
} else if (event.key === Qt.Key_Tab && !event.modifiers) {
currentTabIndex = (currentTabIndex + 1) % tabCount
event.accepted = true
} else if (event.key === Qt.Key_Backtab || (event.key === Qt.Key_Tab && event.modifiers & Qt.ShiftModifier)) {
currentTabIndex = (currentTabIndex - 1 + tabCount) % tabCount
event.accepted = true
}
}
IpcHandler { IpcHandler {
function open(): string { function open(): string {
@@ -111,15 +131,9 @@ DankModal {
} }
settingsContent: Component { settingsContent: Component {
FocusScope { Item {
id: rootScope id: rootScope
anchors.fill: parent anchors.fill: parent
focus: true
Keys.onEscapePressed: event => {
settingsModal.hide()
event.accepted = true
}
Column { Column {
anchors.fill: parent anchors.fill: parent
@@ -178,8 +192,10 @@ DankModal {
id: sidebar id: sidebar
parentModal: settingsModal parentModal: settingsModal
focus: true currentIndex: settingsModal.currentTabIndex
onCurrentIndexChanged: content.currentIndex = currentIndex onCurrentIndexChanged: {
settingsModal.currentTabIndex = currentIndex
}
} }
SettingsContent { SettingsContent {
@@ -188,7 +204,7 @@ DankModal {
width: parent.width - sidebar.width width: parent.width - sidebar.width
height: parent.height height: parent.height
parentModal: settingsModal parentModal: settingsModal
currentIndex: sidebar.currentIndex currentIndex: settingsModal.currentTabIndex
} }
} }

View File

@@ -1,15 +1,15 @@
pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import qs.Common import qs.Common
import qs.Modals.Settings import qs.Modals.Settings
import qs.Widgets import qs.Widgets
FocusScope { Rectangle {
id: sidebarContainer id: sidebarContainer
property int currentIndex: 0 property int currentIndex: 0
property var parentModal: null property var parentModal: null
activeFocusOnTab: true
readonly property var sidebarItems: [{ readonly property var sidebarItems: [{
"text": I18n.tr("Personalization"), "text": I18n.tr("Personalization"),
"icon": "person" "icon": "person"
@@ -55,57 +55,9 @@ FocusScope {
width: 270 width: 270
height: parent.height height: parent.height
Component.onCompleted: {
forceActiveFocus()
}
Timer {
id: refocusTimer
interval: 50
onTriggered: sidebarContainer.forceActiveFocus()
}
Connections {
target: parentModal
function onOpened() {
refocusTimer.restart()
}
}
Keys.onPressed: event => {
if (event.key === Qt.Key_Down) {
navigateNext()
Qt.callLater(() => sidebarContainer.forceActiveFocus())
event.accepted = true
} else if (event.key === Qt.Key_Up) {
navigatePrevious()
Qt.callLater(() => sidebarContainer.forceActiveFocus())
event.accepted = true
} else if (event.key === Qt.Key_Tab && !event.modifiers) {
navigateNext()
Qt.callLater(() => sidebarContainer.forceActiveFocus())
event.accepted = true
} else if (event.key === Qt.Key_Backtab || (event.key === Qt.Key_Tab && event.modifiers & Qt.ShiftModifier)) {
navigatePrevious()
Qt.callLater(() => sidebarContainer.forceActiveFocus())
event.accepted = true
}
}
Rectangle {
anchors.fill: parent
color: Theme.surfaceContainer color: Theme.surfaceContainer
radius: Theme.cornerRadius radius: Theme.cornerRadius
MouseArea {
anchors.fill: parent
onPressed: mouse => {
sidebarContainer.forceActiveFocus()
mouse.accepted = false
}
}
Column { Column {
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: Theme.spacingS anchors.leftMargin: Theme.spacingS
@@ -135,7 +87,10 @@ FocusScope {
model: sidebarContainer.sidebarItems model: sidebarContainer.sidebarItems
Rectangle { delegate: Rectangle {
required property int index
required property var modelData
property bool isActive: sidebarContainer.currentIndex === index property bool isActive: sidebarContainer.currentIndex === index
width: parent.width - Theme.spacingS * 2 width: parent.width - Theme.spacingS * 2
@@ -192,5 +147,3 @@ FocusScope {
} }
} }
}