Reduce the tap target of RoomTreeSection
For some reason I don't understand, the ItemDelegate used for these sections are ginormous. There is quite a bit of padding which confuses users as its unexpectedly used for the tap area. I changed it so we only listen for taps inside of the contentItem itself, which is a more suitable area.
This commit is contained in:
@@ -31,43 +31,56 @@ QQC2.ItemDelegate {
|
|||||||
activeFocusOnTab: false
|
activeFocusOnTab: false
|
||||||
background: null
|
background: null
|
||||||
|
|
||||||
onClicked: root.treeView.toggleExpanded(row)
|
|
||||||
|
|
||||||
Keys.onEnterPressed: root.treeView.toggleExpanded(row)
|
Keys.onEnterPressed: root.treeView.toggleExpanded(row)
|
||||||
Keys.onReturnPressed: root.treeView.toggleExpanded(row)
|
Keys.onReturnPressed: root.treeView.toggleExpanded(row)
|
||||||
Keys.onSpacePressed: root.treeView.toggleExpanded(row)
|
Keys.onSpacePressed: root.treeView.toggleExpanded(row)
|
||||||
|
|
||||||
contentItem: RowLayout {
|
contentItem: Item {
|
||||||
spacing: 0
|
implicitWidth: layout.implicitWidth
|
||||||
Kirigami.ListSectionHeader {
|
implicitHeight: layout.implicitHeight
|
||||||
Layout.fillWidth: true
|
|
||||||
visible: !root.collapsed
|
|
||||||
horizontalPadding: 0
|
|
||||||
topPadding: 0
|
|
||||||
bottomPadding: 0
|
|
||||||
text: root.collapsed ? "" : root.displayName
|
|
||||||
|
|
||||||
onClicked: root.treeView.toggleExpanded(row)
|
RowLayout {
|
||||||
}
|
id: layout
|
||||||
QQC2.ToolButton {
|
|
||||||
id: collapseButton
|
|
||||||
Layout.alignment: Qt.AlignHCenter
|
|
||||||
|
|
||||||
icon {
|
width: root.contentItem.width
|
||||||
name: root.expanded ? "go-up" : "go-down"
|
|
||||||
width: Kirigami.Units.iconSizes.small
|
spacing: 0
|
||||||
height: Kirigami.Units.iconSizes.small
|
|
||||||
|
Kirigami.ListSectionHeader {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
visible: !root.collapsed
|
||||||
|
horizontalPadding: 0
|
||||||
|
topPadding: 0
|
||||||
|
bottomPadding: 0
|
||||||
|
text: root.collapsed ? "" : root.displayName
|
||||||
|
|
||||||
|
onClicked: root.treeView.toggleExpanded(row)
|
||||||
}
|
}
|
||||||
text: root.expanded ? i18nc("Collapse <section name>", "Collapse %1", root.displayName) : i18nc("Expand <section name", "Expand %1", root.displayName)
|
QQC2.ToolButton {
|
||||||
display: QQC2.Button.IconOnly
|
id: collapseButton
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
||||||
activeFocusOnTab: false
|
icon {
|
||||||
|
name: root.expanded ? "go-up" : "go-down"
|
||||||
|
width: Kirigami.Units.iconSizes.small
|
||||||
|
height: Kirigami.Units.iconSizes.small
|
||||||
|
}
|
||||||
|
text: root.expanded ? i18nc("Collapse <section name>", "Collapse %1", root.displayName) : i18nc("Expand <section name", "Expand %1", root.displayName)
|
||||||
|
display: QQC2.Button.IconOnly
|
||||||
|
|
||||||
QQC2.ToolTip.text: text
|
activeFocusOnTab: false
|
||||||
QQC2.ToolTip.visible: hovered
|
|
||||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
|
||||||
|
|
||||||
onClicked: root.treeView.toggleExpanded(root.row)
|
QQC2.ToolTip.text: text
|
||||||
|
QQC2.ToolTip.visible: hovered
|
||||||
|
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||||
|
|
||||||
|
onClicked: root.treeView.toggleExpanded(root.row)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reduce the size of the tap target, this is smaller the ginormous section header ItemDelegate
|
||||||
|
TapHandler {
|
||||||
|
onTapped: root.treeView.toggleExpanded(root.row)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user