fixed language selector

This commit is contained in:
Cyril Anisimov 2024-09-20 00:22:14 +02:00
parent 01e31b4b4d
commit 78a4caa47e
2 changed files with 138 additions and 140 deletions

View file

@ -24,11 +24,11 @@ DrawerType2 {
target: root
enabled: !GC.isMobile()
function onOpened() {
FocusController.setRoot(root)
FocusController.setRootItem(root)
}
function onClosed() {
FocusController.setRoot(null)
FocusController.setRootItem(null)
}
}
@ -42,25 +42,19 @@ DrawerType2 {
BackButtonType {
id: backButton
Layout.fillWidth: true
Layout.topMargin: 16
Layout.rightMargin: 16
Layout.leftMargin: 16
backButtonImage: "qrc:/images/controls/arrow-left.svg"
backButtonFunction: function() { root.closeTriggered() }
}
}
FlickableType {
anchors.top: backButtonLayout.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
contentHeight: content.implicitHeight
ColumnLayout {
id: content
anchors.fill: parent
Header2Type {
id: header
Layout.fillWidth: true
Layout.topMargin: 16
Layout.rightMargin: 16
@ -68,15 +62,20 @@ DrawerType2 {
headerText: qsTr("Choose language")
}
}
ListView {
id: listView
Layout.fillWidth: true
height: listView.contentItem.height
anchors.top: backButtonLayout.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
clip: true
interactive: false
interactive: true
property bool isFocusable: true
model: LanguageModel
currentIndex: LanguageModel.currentLanguageIndex
@ -85,15 +84,13 @@ DrawerType2 {
id: buttonGroup
}
property int currentFocusIndex: 0
activeFocusOnTab: true
onActiveFocusChanged: {
if (activeFocus) {
this.currentFocusIndex = 0
this.itemAtIndex(currentFocusIndex).forceActiveFocus()
}
}
// activeFocusOnTab: true
// onActiveFocusChanged: {
// if (activeFocus) {
// this.currentFocusIndex = 0
// this.itemAtIndex(currentFocusIndex).forceActiveFocus()
// }
// }
// Keys.onTabPressed: {
// if (currentFocusIndex < this.count - 1) {
@ -105,29 +102,29 @@ DrawerType2 {
// }
// }
Item {
id: listViewFocusItem
Keys.onTabPressed: {
root.forceActiveFocus()
}
}
// Item {
// id: listViewFocusItem // TODO: delete?
// Keys.onTabPressed: {
// root.forceActiveFocus()
// }
// }
onVisibleChanged: {
if (visible) {
listViewFocusItem.forceActiveFocus()
focusItem.forceActiveFocus()
}
}
// onVisibleChanged: {
// if (visible) {
// listViewFocusItem.forceActiveFocus()
// focusItem.forceActiveFocus()
// }
// }
delegate: Item {
implicitWidth: root.width
implicitHeight: delegateContent.implicitHeight
onActiveFocusChanged: {
if (activeFocus) {
radioButton.forceActiveFocus()
}
}
// onActiveFocusChanged: {
// if (activeFocus) {
// radioButton.forceActiveFocus()
// }
// }
ColumnLayout {
id: delegateContent
@ -142,6 +139,32 @@ DrawerType2 {
hoverEnabled: true
property bool isFocusable: true
Keys.onTabPressed: {
FocusController.nextKeyTabItem()
}
Keys.onBacktabPressed: {
FocusController.previousKeyTabItem()
}
Keys.onUpPressed: {
FocusController.nextKeyUpItem()
}
Keys.onDownPressed: {
FocusController.nextKeyDownItem()
}
Keys.onLeftPressed: {
FocusController.nextKeyLeftItem()
}
Keys.onRightPressed: {
FocusController.nextKeyRightItem()
}
indicator: Rectangle {
width: parent.width - 1
height: parent.height
@ -203,6 +226,4 @@ DrawerType2 {
}
}
}
}
}
}

View file

@ -56,8 +56,6 @@ Item {
target: PageController
function onCloseTopDrawer() {
console.debug("===>> onCloseTopDrawer function")
if (depthIndex === PageController.getDrawerDepth()) {
if (isCollapsedStateActive()) {
return
@ -76,8 +74,6 @@ Item {
target: root
function onCloseTriggered() {
console.debug("***>> onClose root connection")
if (isCollapsedStateActive()) {
return
}
@ -88,8 +84,6 @@ Item {
}
function onClosed() {
console.debug("***>> onClosed root connection")
drawerContent.state = root.drawerCollapsedStateName
if (root.isCollapsedStateActive()) {
@ -105,8 +99,6 @@ Item {
}
function onOpenTriggered() {
console.debug("===>> onOpen root connection")
if (root.isExpandedStateActive()) {
return
}
@ -119,10 +111,7 @@ Item {
function onOpened() {
drawerContent.state = root.drawerExpandedStateName
console.debug("===>> onOpened root connection")
if (isExpandedStateActive()) {
console.error("new state - extended")
if (PageController.getInitialPageNavigationBarColor() !== 0xFF1C1D21) {
PageController.updateNavigationBarColor(0xFF1C1D21)
}
@ -130,7 +119,6 @@ Item {
depthIndex = PageController.incrementDrawerDepth()
FocusController.setRootItem(root)
console.debug("===>> Root item has changed to ", root)
}
}
@ -150,7 +138,6 @@ Item {
anchors.fill: parent
onClicked: {
console.debug("===>> onClicked emptyArea")
root.closeTriggered()
}
}
@ -171,8 +158,6 @@ Item {
/** If drag area is released at any point other than min or max y, transition to the other state */
onReleased: {
console.debug("===>> onReleased dragArea")
if (isCollapsedStateActive() && drawerContent.y < dragArea.drag.maximumY) {
root.openTriggered()
return
@ -184,24 +169,16 @@ Item {
}
onEntered: {
console.debug("===>> onEntered dragArea")
root.cursorEntered()
}
onExited: {
console.debug("===>> onExited dragArea")
root.cursorExited()
}
onPressedChanged: {
console.debug("===>> onPressedChanged dragArea")
root.pressed(pressed, entered)
}
onClicked: {
console.debug("===>> onClicked dragArea")
if (isCollapsedStateActive()) {
root.openTriggered()
}