Only draw the focus indicator when we got focus via the keyboard

QQC2 controls gain activeFocus on press this is a difference to controls 1
which had activeFocusOnPress property that defaulted to false. qqc2-desktop-style
also only sets the focus flag if it was gained via keyboard (kquickstyleitem.cpp:705).
BUG:424446
This commit is contained in:
David Redondo 2020-07-20 10:46:30 +02:00
parent 711789908b
commit 3e225d8664

View File

@ -108,14 +108,16 @@ T.ToolButton {
background: Item { background: Item {
Private.ButtonShadow { Private.ButtonShadow {
anchors.fill: parent anchors.fill: parent
visible: (!control.flat || control.hovered || control.activeFocus) && (!control.pressed || !control.checked) readonly property bool keyboardFocus: control.activeFocus &&
(control.focusReason == Qt.TabFocusReason || control.focusReason == Qt.BacktabFocusReason)
visible: (!control.flat || control.hovered || keyboardFocus) && (!control.pressed || !control.checked)
state: { state: {
if (control.pressed) { if (control.pressed) {
return "hidden" return "hidden"
} else if (control.hovered) { } else if (control.hovered) {
return "hover" return "hover"
} else if (control.activeFocus) { } else if (keyboardFocus) {
return "focus" return "focus"
} else { } else {
return control.flat ? "shadow" : "hidden" return control.flat ? "shadow" : "hidden"