fixed language selector
This commit is contained in:
parent
01e31b4b4d
commit
78a4caa47e
2 changed files with 138 additions and 140 deletions
|
|
@ -24,11 +24,11 @@ DrawerType2 {
|
||||||
target: root
|
target: root
|
||||||
enabled: !GC.isMobile()
|
enabled: !GC.isMobile()
|
||||||
function onOpened() {
|
function onOpened() {
|
||||||
FocusController.setRoot(root)
|
FocusController.setRootItem(root)
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClosed() {
|
function onClosed() {
|
||||||
FocusController.setRoot(null)
|
FocusController.setRootItem(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,166 +42,187 @@ DrawerType2 {
|
||||||
|
|
||||||
BackButtonType {
|
BackButtonType {
|
||||||
id: backButton
|
id: backButton
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
|
||||||
backButtonImage: "qrc:/images/controls/arrow-left.svg"
|
backButtonImage: "qrc:/images/controls/arrow-left.svg"
|
||||||
backButtonFunction: function() { root.closeTriggered() }
|
backButtonFunction: function() { root.closeTriggered() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Header2Type {
|
||||||
|
id: header
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
|
||||||
|
headerText: qsTr("Choose language")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FlickableType {
|
ListView {
|
||||||
|
id: listView
|
||||||
|
|
||||||
anchors.top: backButtonLayout.bottom
|
anchors.top: backButtonLayout.bottom
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
contentHeight: content.implicitHeight
|
|
||||||
|
|
||||||
ColumnLayout {
|
clip: true
|
||||||
id: content
|
interactive: true
|
||||||
|
|
||||||
anchors.fill: parent
|
property bool isFocusable: true
|
||||||
|
|
||||||
Header2Type {
|
model: LanguageModel
|
||||||
id: header
|
currentIndex: LanguageModel.currentLanguageIndex
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 16
|
|
||||||
Layout.rightMargin: 16
|
|
||||||
Layout.leftMargin: 16
|
|
||||||
|
|
||||||
headerText: qsTr("Choose language")
|
ButtonGroup {
|
||||||
}
|
id: buttonGroup
|
||||||
|
}
|
||||||
|
|
||||||
ListView {
|
// activeFocusOnTab: true
|
||||||
id: listView
|
// onActiveFocusChanged: {
|
||||||
|
// if (activeFocus) {
|
||||||
|
// this.currentFocusIndex = 0
|
||||||
|
// this.itemAtIndex(currentFocusIndex).forceActiveFocus()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
Layout.fillWidth: true
|
// Keys.onTabPressed: {
|
||||||
height: listView.contentItem.height
|
// if (currentFocusIndex < this.count - 1) {
|
||||||
|
// currentFocusIndex += 1
|
||||||
|
// this.itemAtIndex(currentFocusIndex).forceActiveFocus()
|
||||||
|
// } else {
|
||||||
|
// listViewFocusItem.forceActiveFocus()
|
||||||
|
// focusItem.forceActiveFocus()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
clip: true
|
// Item {
|
||||||
interactive: false
|
// id: listViewFocusItem // TODO: delete?
|
||||||
|
// Keys.onTabPressed: {
|
||||||
|
// root.forceActiveFocus()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
model: LanguageModel
|
// onVisibleChanged: {
|
||||||
currentIndex: LanguageModel.currentLanguageIndex
|
// if (visible) {
|
||||||
|
// listViewFocusItem.forceActiveFocus()
|
||||||
|
// focusItem.forceActiveFocus()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
ButtonGroup {
|
delegate: Item {
|
||||||
id: buttonGroup
|
implicitWidth: root.width
|
||||||
}
|
implicitHeight: delegateContent.implicitHeight
|
||||||
|
|
||||||
property int currentFocusIndex: 0
|
// onActiveFocusChanged: {
|
||||||
|
// if (activeFocus) {
|
||||||
|
// radioButton.forceActiveFocus()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
activeFocusOnTab: true
|
ColumnLayout {
|
||||||
onActiveFocusChanged: {
|
id: delegateContent
|
||||||
if (activeFocus) {
|
|
||||||
this.currentFocusIndex = 0
|
|
||||||
this.itemAtIndex(currentFocusIndex).forceActiveFocus()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Keys.onTabPressed: {
|
anchors.fill: parent
|
||||||
// if (currentFocusIndex < this.count - 1) {
|
|
||||||
// currentFocusIndex += 1
|
RadioButton {
|
||||||
// this.itemAtIndex(currentFocusIndex).forceActiveFocus()
|
id: radioButton
|
||||||
// } else {
|
|
||||||
// listViewFocusItem.forceActiveFocus()
|
implicitWidth: parent.width
|
||||||
// focusItem.forceActiveFocus()
|
implicitHeight: radioButtonContent.implicitHeight
|
||||||
// }
|
|
||||||
// }
|
hoverEnabled: true
|
||||||
|
|
||||||
|
property bool isFocusable: true
|
||||||
|
|
||||||
Item {
|
|
||||||
id: listViewFocusItem
|
|
||||||
Keys.onTabPressed: {
|
Keys.onTabPressed: {
|
||||||
root.forceActiveFocus()
|
FocusController.nextKeyTabItem()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
onVisibleChanged: {
|
Keys.onBacktabPressed: {
|
||||||
if (visible) {
|
FocusController.previousKeyTabItem()
|
||||||
listViewFocusItem.forceActiveFocus()
|
|
||||||
focusItem.forceActiveFocus()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
delegate: Item {
|
Keys.onUpPressed: {
|
||||||
implicitWidth: root.width
|
FocusController.nextKeyUpItem()
|
||||||
implicitHeight: delegateContent.implicitHeight
|
}
|
||||||
|
|
||||||
onActiveFocusChanged: {
|
Keys.onDownPressed: {
|
||||||
if (activeFocus) {
|
FocusController.nextKeyDownItem()
|
||||||
radioButton.forceActiveFocus()
|
}
|
||||||
|
|
||||||
|
Keys.onLeftPressed: {
|
||||||
|
FocusController.nextKeyLeftItem()
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onRightPressed: {
|
||||||
|
FocusController.nextKeyRightItem()
|
||||||
|
}
|
||||||
|
|
||||||
|
indicator: Rectangle {
|
||||||
|
width: parent.width - 1
|
||||||
|
height: parent.height
|
||||||
|
color: radioButton.hovered ? AmneziaStyle.color.slateGray : AmneziaStyle.color.onyxBlack
|
||||||
|
border.color: radioButton.focus ? AmneziaStyle.color.paleGray : AmneziaStyle.color.transparent
|
||||||
|
border.width: radioButton.focus ? 1 : 0
|
||||||
|
|
||||||
|
Behavior on color {
|
||||||
|
PropertyAnimation { duration: 200 }
|
||||||
|
}
|
||||||
|
Behavior on border.color {
|
||||||
|
PropertyAnimation { duration: 200 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
RowLayout {
|
||||||
id: delegateContent
|
id: radioButtonContent
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
RadioButton {
|
anchors.rightMargin: 16
|
||||||
id: radioButton
|
anchors.leftMargin: 16
|
||||||
|
|
||||||
implicitWidth: parent.width
|
spacing: 0
|
||||||
implicitHeight: radioButtonContent.implicitHeight
|
|
||||||
|
|
||||||
hoverEnabled: true
|
z: 1
|
||||||
|
|
||||||
indicator: Rectangle {
|
ParagraphTextType {
|
||||||
width: parent.width - 1
|
Layout.fillWidth: true
|
||||||
height: parent.height
|
Layout.topMargin: 20
|
||||||
color: radioButton.hovered ? AmneziaStyle.color.slateGray : AmneziaStyle.color.onyxBlack
|
Layout.bottomMargin: 20
|
||||||
border.color: radioButton.focus ? AmneziaStyle.color.paleGray : AmneziaStyle.color.transparent
|
|
||||||
border.width: radioButton.focus ? 1 : 0
|
|
||||||
|
|
||||||
Behavior on color {
|
text: languageName
|
||||||
PropertyAnimation { duration: 200 }
|
}
|
||||||
}
|
|
||||||
Behavior on border.color {
|
|
||||||
PropertyAnimation { duration: 200 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
Image {
|
||||||
id: radioButtonContent
|
source: "qrc:/images/controls/check.svg"
|
||||||
anchors.fill: parent
|
visible: radioButton.checked
|
||||||
|
|
||||||
anchors.rightMargin: 16
|
width: 24
|
||||||
anchors.leftMargin: 16
|
height: 24
|
||||||
|
|
||||||
spacing: 0
|
Layout.rightMargin: 8
|
||||||
|
|
||||||
z: 1
|
|
||||||
|
|
||||||
ParagraphTextType {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 20
|
|
||||||
Layout.bottomMargin: 20
|
|
||||||
|
|
||||||
text: languageName
|
|
||||||
}
|
|
||||||
|
|
||||||
Image {
|
|
||||||
source: "qrc:/images/controls/check.svg"
|
|
||||||
visible: radioButton.checked
|
|
||||||
|
|
||||||
width: 24
|
|
||||||
height: 24
|
|
||||||
|
|
||||||
Layout.rightMargin: 8
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ButtonGroup.group: buttonGroup
|
|
||||||
checked: listView.currentIndex === index
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
listView.currentIndex = index
|
|
||||||
LanguageModel.changeLanguage(languageIndex)
|
|
||||||
root.closeTriggered()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onEnterPressed: radioButton.clicked()
|
ButtonGroup.group: buttonGroup
|
||||||
Keys.onReturnPressed: radioButton.clicked()
|
checked: listView.currentIndex === index
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
listView.currentIndex = index
|
||||||
|
LanguageModel.changeLanguage(languageIndex)
|
||||||
|
root.closeTriggered()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Keys.onEnterPressed: radioButton.clicked()
|
||||||
|
Keys.onReturnPressed: radioButton.clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,6 @@ Item {
|
||||||
target: PageController
|
target: PageController
|
||||||
|
|
||||||
function onCloseTopDrawer() {
|
function onCloseTopDrawer() {
|
||||||
console.debug("===>> onCloseTopDrawer function")
|
|
||||||
|
|
||||||
if (depthIndex === PageController.getDrawerDepth()) {
|
if (depthIndex === PageController.getDrawerDepth()) {
|
||||||
if (isCollapsedStateActive()) {
|
if (isCollapsedStateActive()) {
|
||||||
return
|
return
|
||||||
|
|
@ -76,8 +74,6 @@ Item {
|
||||||
target: root
|
target: root
|
||||||
|
|
||||||
function onCloseTriggered() {
|
function onCloseTriggered() {
|
||||||
console.debug("***>> onClose root connection")
|
|
||||||
|
|
||||||
if (isCollapsedStateActive()) {
|
if (isCollapsedStateActive()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -88,8 +84,6 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClosed() {
|
function onClosed() {
|
||||||
console.debug("***>> onClosed root connection")
|
|
||||||
|
|
||||||
drawerContent.state = root.drawerCollapsedStateName
|
drawerContent.state = root.drawerCollapsedStateName
|
||||||
|
|
||||||
if (root.isCollapsedStateActive()) {
|
if (root.isCollapsedStateActive()) {
|
||||||
|
|
@ -105,8 +99,6 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onOpenTriggered() {
|
function onOpenTriggered() {
|
||||||
console.debug("===>> onOpen root connection")
|
|
||||||
|
|
||||||
if (root.isExpandedStateActive()) {
|
if (root.isExpandedStateActive()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -119,10 +111,7 @@ Item {
|
||||||
function onOpened() {
|
function onOpened() {
|
||||||
drawerContent.state = root.drawerExpandedStateName
|
drawerContent.state = root.drawerExpandedStateName
|
||||||
|
|
||||||
console.debug("===>> onOpened root connection")
|
|
||||||
|
|
||||||
if (isExpandedStateActive()) {
|
if (isExpandedStateActive()) {
|
||||||
console.error("new state - extended")
|
|
||||||
if (PageController.getInitialPageNavigationBarColor() !== 0xFF1C1D21) {
|
if (PageController.getInitialPageNavigationBarColor() !== 0xFF1C1D21) {
|
||||||
PageController.updateNavigationBarColor(0xFF1C1D21)
|
PageController.updateNavigationBarColor(0xFF1C1D21)
|
||||||
}
|
}
|
||||||
|
|
@ -130,7 +119,6 @@ Item {
|
||||||
|
|
||||||
depthIndex = PageController.incrementDrawerDepth()
|
depthIndex = PageController.incrementDrawerDepth()
|
||||||
FocusController.setRootItem(root)
|
FocusController.setRootItem(root)
|
||||||
console.debug("===>> Root item has changed to ", root)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,7 +138,6 @@ Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
console.debug("===>> onClicked emptyArea")
|
|
||||||
root.closeTriggered()
|
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 */
|
/** If drag area is released at any point other than min or max y, transition to the other state */
|
||||||
onReleased: {
|
onReleased: {
|
||||||
console.debug("===>> onReleased dragArea")
|
|
||||||
|
|
||||||
if (isCollapsedStateActive() && drawerContent.y < dragArea.drag.maximumY) {
|
if (isCollapsedStateActive() && drawerContent.y < dragArea.drag.maximumY) {
|
||||||
root.openTriggered()
|
root.openTriggered()
|
||||||
return
|
return
|
||||||
|
|
@ -184,24 +169,16 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
onEntered: {
|
onEntered: {
|
||||||
console.debug("===>> onEntered dragArea")
|
|
||||||
|
|
||||||
root.cursorEntered()
|
root.cursorEntered()
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: {
|
||||||
console.debug("===>> onExited dragArea")
|
|
||||||
|
|
||||||
root.cursorExited()
|
root.cursorExited()
|
||||||
}
|
}
|
||||||
onPressedChanged: {
|
onPressedChanged: {
|
||||||
console.debug("===>> onPressedChanged dragArea")
|
|
||||||
|
|
||||||
root.pressed(pressed, entered)
|
root.pressed(pressed, entered)
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
console.debug("===>> onClicked dragArea")
|
|
||||||
|
|
||||||
if (isCollapsedStateActive()) {
|
if (isCollapsedStateActive()) {
|
||||||
root.openTriggered()
|
root.openTriggered()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue