fix keyboard navigation
This commit is contained in:
parent
5880e5315c
commit
60db3ff72d
@ -201,5 +201,6 @@ Item {
|
||||
hoverEnabled: true
|
||||
onPressed: internal.pressButton()
|
||||
onReleased: internal.releaseButton()
|
||||
onCanceled: internal.releaseButton()
|
||||
}
|
||||
}
|
@ -49,7 +49,7 @@ Item {
|
||||
property alias layout: tabBarLayout
|
||||
|
||||
//Plasma extension
|
||||
property Item currentItem
|
||||
property Item currentTab
|
||||
|
||||
implicitWidth: tabBarLayout.implicitWidth + backgroundFrame.margins.left + backgroundFrame.margins.right + (buttonFrame.margins.left + buttonFrame.margins.right)*tabBarLayout.children.length
|
||||
implicitHeight: tabBarLayout.implicitHeight + backgroundFrame.margins.top + backgroundFrame.margins.bottom + buttonFrame.margins.top + buttonFrame.margins.bottom
|
||||
@ -65,10 +65,10 @@ Item {
|
||||
PlasmaCore.FrameSvgItem {
|
||||
id: buttonFrame
|
||||
|
||||
x: currentItem.x + backgroundFrame.margins.left
|
||||
x: currentTab.x + backgroundFrame.margins.left
|
||||
y: backgroundFrame.margins.top
|
||||
width: currentItem.width + buttonFrame.margins.left + buttonFrame.margins.right
|
||||
height: currentItem.height + buttonFrame.margins.top + buttonFrame.margins.bottom
|
||||
width: currentTab.width + buttonFrame.margins.left + buttonFrame.margins.right
|
||||
height: currentTab.height + buttonFrame.margins.top + buttonFrame.margins.bottom
|
||||
imagePath: "widgets/button"
|
||||
prefix: "normal"
|
||||
Behavior on x {
|
||||
|
@ -53,15 +53,18 @@ Item {
|
||||
Keys.onPressed: {
|
||||
if (event.key == Qt.Key_Right || event.key == Qt.Key_Left) {
|
||||
if (event.key == Qt.Key_Right || priv.mirrored) {
|
||||
var oldIndex = priv.currentButtonIndex()
|
||||
var oldIndex = priv.currentButtonIndex();
|
||||
|
||||
if (oldIndex != root.children.length - 1) {
|
||||
priv.tabGroup.currentTab = root.children[oldIndex + 1].tab
|
||||
root.parent.currentTab = root.children[oldIndex + 1]
|
||||
event.accepted = true
|
||||
}
|
||||
} else if (event.key == Qt.Key_Left || priv.mirrored) {
|
||||
var oldIndex = priv.currentButtonIndex()
|
||||
if (oldIndex != 0) {
|
||||
priv.tabGroup.currentTab = root.children[oldIndex - 1].tab
|
||||
root.parent.currentTab = root.children[oldIndex - 1]
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
@ -74,7 +77,7 @@ Item {
|
||||
id: priv
|
||||
property Item firstButton: root.children.length > 0 ? root.children[0] : null
|
||||
property Item firstTab: firstButton ? (firstButton.tab != null ? firstButton.tab : null) : null
|
||||
property Item tabGroup: firstTab ? (firstTab.parent ? firstTab.parent.parent : null) : null
|
||||
property Item tabGroup: firstTab ? (firstTab.parent ? firstTab.parent.parent.parent : null) : null
|
||||
property bool mirrored: root.LayoutMirroring.enabled
|
||||
|
||||
onMirroredChanged: layoutChildren()
|
||||
|
@ -63,7 +63,7 @@ Item {
|
||||
target: root
|
||||
onPressedChanged: {
|
||||
//TabBar is the granparent
|
||||
root.parent.parent.currentItem = root
|
||||
root.parent.parent.currentTab = root
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ Item {
|
||||
|
||||
Component.onCompleted: {
|
||||
if (internal.tabGroup.currentTab == tab) {
|
||||
parent.parent.currentItem = root
|
||||
parent.parent.currentTab = root
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -126,7 +126,7 @@ Item {
|
||||
internal.tabGroup.currentTab = tab
|
||||
}
|
||||
//TabBar is the granparent, done here too in case of no tabgroup
|
||||
root.parent.parent.currentItem = root
|
||||
root.parent.parent.currentTab = root
|
||||
}
|
||||
|
||||
anchors.fill: parent
|
||||
|
Loading…
x
Reference in New Issue
Block a user