Add implicitWidth and implicitHeight to ButtonBackground

Remove unnecessary keyboardFocus property since visualFocus exists

Remove unnecessary parentControl property
This commit is contained in:
Noah Davis 2020-08-26 03:24:35 -04:00
parent 54069ee94c
commit 73865f7171

View File

@ -4,14 +4,10 @@
*/ */
import QtQuick 2.6 import QtQuick 2.6
import QtQuick.Templates @QQC2_VERSION@ as T
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
Item { Item {
id: root id: root
// TODO: mark this required when our minimum Qt version is new enough
property T.AbstractButton parentControl
// These should be used as the padding for the parent control // These should be used as the padding for the parent control
property real leftMargin property real leftMargin
property real topMargin property real topMargin
@ -24,28 +20,28 @@ Item {
*/ */
property string usedPrefix property string usedPrefix
readonly property bool keyboardFocus: parentControl.activeFocus && implicitWidth: PlasmaCore.Units.gridUnit + root.leftMargin + root.rightMargin
(parentControl.focusReason == Qt.TabFocusReason || parentControl.focusReason == Qt.BacktabFocusReason) implicitHeight: PlasmaCore.Units.gridUnit + root.topMargin + root.bottomMargin
FlatButtonBackground { FlatButtonBackground {
id: flatButtonBackground id: flatButtonBackground
anchors.fill: parent anchors.fill: parent
hovered: parentControl.hovered hovered: root.parent.hovered
pressed: parentControl.pressed pressed: root.parent.pressed
checked: parentControl.checked checked: root.parent.checked
focused: root.keyboardFocus focused: root.parent.visualFocus
} }
RaisedButtonBackground { RaisedButtonBackground {
id: raisedButtonBackground id: raisedButtonBackground
anchors.fill: parent anchors.fill: parent
hovered: parentControl.hovered hovered: root.parent.hovered
pressed: parentControl.pressed pressed: root.parent.pressed
checked: parentControl.checked checked: root.parent.checked
focused: root.keyboardFocus focused: root.parent.visualFocus
} }
state: parentControl.flat ? "flat" : "raised" state: root.parent.flat ? "flat" : "raised"
states: [ states: [
State { State {