no hover effect on touchscreen+mobile

still normal hover effect on laptops with touchscreen

Change-Id: I64f101e1572eed9d48174f0cf290fdfea085aaeb
This commit is contained in:
Marco Martin 2015-09-18 20:07:31 +02:00
parent 7453beb9ce
commit 244574edd1

View File

@ -35,6 +35,8 @@ QtQuickControlStyle.ButtonStyle {
property int minimumWidth
property int minimumHeight
property bool flat: control.flat !== undefined ? control.flat : !(control.checkable && control.checked)
property bool controlHovered: control.hovered && !(QtQuickControlsPrivate.Settings.hasTouchScreen && QtQuickControlsPrivate.Settings.isMobile)
label: Item {
//wrapper is needed as we are adjusting the preferredHeight of the layout from the default
//and the implicitHeight is implicitly read only
@ -76,8 +78,8 @@ QtQuickControlStyle.ButtonStyle {
visible: valid
Layout.minimumHeight: Layout.minimumWidth
Layout.maximumHeight: Layout.minimumWidth
active: control.hovered
colorGroup: control.hovered || !style.flat ? PlasmaCore.Theme.ButtonColorGroup : PlasmaCore.Theme.NormalColorGroup
active: style.controlHovered
colorGroup: style.controlHovered || !style.flat ? PlasmaCore.Theme.ButtonColorGroup : PlasmaCore.Theme.NormalColorGroup
}
PlasmaComponents.Label {
@ -88,7 +90,7 @@ QtQuickControlStyle.ButtonStyle {
visible: control.text != ""
Layout.fillWidth: true
height: parent.height
color: control.hovered || !style.flat ? theme.buttonTextColor : PlasmaCore.ColorScope.textColor
color: style.controlHovered || !style.flat ? theme.buttonTextColor : PlasmaCore.ColorScope.textColor
horizontalAlignment: icon.valid ? Text.AlignLeft : Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
@ -109,7 +111,7 @@ QtQuickControlStyle.ButtonStyle {
anchors.fill: parent
svg: PlasmaCore.Svg {
imagePath: "widgets/arrows"
colorGroup: control.hovered || !style.flat ? PlasmaCore.Theme.ButtonColorGroup : PlasmaCore.Theme.NormalColorGroup
colorGroup: style.controlHovered || !style.flat ? PlasmaCore.Theme.ButtonColorGroup : PlasmaCore.Theme.NormalColorGroup
}
elementId: "down-arrow"
}
@ -147,7 +149,7 @@ QtQuickControlStyle.ButtonStyle {
state: {
if (control.pressed) {
return "hidden"
} else if (control.hovered) {
} else if (style.controlHovered) {
return "hover"
} else if (control.activeFocus) {
return "focus"
@ -170,7 +172,7 @@ QtQuickControlStyle.ButtonStyle {
height: width
anchors.centerIn: parent
//internal: if there is no hover status, don't paint on mouse over in touchscreens
opacity: (control.pressed || control.checked || !style.flat || (roundShadow.hasOverState && control.hovered)) ? 1 : 0
opacity: (control.pressed || control.checked || !style.flat || (roundShadow.hasOverState && style.controlHovered)) ? 1 : 0
Behavior on opacity {
PropertyAnimation { duration: units.longDuration }
}
@ -194,7 +196,7 @@ QtQuickControlStyle.ButtonStyle {
Connections {
target: control
onHoveredChanged: {
if (control.hovered) {
if (style.controlHovered) {
button.z += 2
} else {
button.z -= 2
@ -209,7 +211,7 @@ QtQuickControlStyle.ButtonStyle {
state: {
if (control.pressed) {
return "hidden"
} else if (control.hovered) {
} else if (style.controlHovered) {
return "hover"
} else if (control.activeFocus) {
return "focus"
@ -349,7 +351,7 @@ QtQuickControlStyle.ButtonStyle {
}
}
state: (control.pressed || control.checked ? "pressed" : (control.hovered ? "hover" : "normal"))
state: (control.pressed || control.checked ? "pressed" : (style.controlHovered ? "hover" : "normal"))
states: [
State { name: "normal"