Fix HButton/HTile focus and click

This commit is contained in:
miruka 2019-09-14 17:39:17 -04:00
parent 784cb3b19c
commit 38e781c9f7
3 changed files with 12 additions and 11 deletions

View File

@ -24,6 +24,9 @@ Button {
implicitContentHeight + topPadding + bottomPadding implicitContentHeight + topPadding + bottomPadding
) )
// Prevent button from gaining focus and being highlighted on click
focusPolicy: Qt.TabFocus
readonly property alias iconItem: contentItem.icon readonly property alias iconItem: contentItem.icon
readonly property alias label: contentItem.label readonly property alias label: contentItem.label

View File

@ -38,6 +38,7 @@ HButton {
HLabel { HLabel {
id: rightInfo id: rightInfo
font.pixelSize: theme.fontSize.small font.pixelSize: theme.fontSize.small
color: theme.colors.halfDimText
visible: Layout.maximumWidth > 0 visible: Layout.maximumWidth > 0
Layout.maximumWidth: Layout.maximumWidth:
@ -52,6 +53,7 @@ HButton {
textFormat: Text.StyledText textFormat: Text.StyledText
font.pixelSize: theme.fontSize.small font.pixelSize: theme.fontSize.small
elide: Text.ElideRight elide: Text.ElideRight
color: theme.colors.dimText
visible: Layout.maximumHeight > 0 visible: Layout.maximumHeight > 0
Layout.maximumHeight: text ? implicitWidth : 0 Layout.maximumHeight: text ? implicitWidth : 0

View File

@ -4,6 +4,13 @@ import QtQuick.Layouts 1.12
HTile { HTile {
id: tile id: tile
onActivated: view.currentIndex = model.index onActivated: view.currentIndex = model.index
onClicked: {
view.highlightRangeMode = ListView.NoHighlightRange
view.highlightMoveDuration = 0
activated()
view.highlightRangeMode = ListView.ApplyRange
view.highlightMoveDuration = theme.animationDuration
}
signal activated() signal activated()
@ -25,17 +32,6 @@ HTile {
onTriggered: if (shouldBeCurrent) view.currentIndex = model.index onTriggered: if (shouldBeCurrent) view.currentIndex = model.index
} }
TapHandler {
acceptedButtons: Qt.LeftButton
onTapped: {
view.highlightRangeMode = ListView.NoHighlightRange
view.highlightMoveDuration = 0
activated()
view.highlightRangeMode = ListView.ApplyRange
view.highlightMoveDuration = theme.animationDuration
}
}
TapHandler { TapHandler {
acceptedButtons: Qt.RightButton acceptedButtons: Qt.RightButton
onTapped: if (contextMenu.count > 0) contextMenu.popup() onTapped: if (contextMenu.count > 0) contextMenu.popup()