Skip to content

Commit

Permalink
examples/QMLPlayer: touch screen optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Feb 26, 2016
1 parent c9a00e7 commit d57a47a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
4 changes: 2 additions & 2 deletions examples/QMLPlayer/qml/QMLPlayer/Button.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Rectangle {
property color bgColorSelected: "#ee6666dd"
property color textColor: "white"
property bool hovered: false //mouseArea.containsMouse
readonly property alias pressed: mouseArea.pressed
signal clicked()
signal pressAndHold()

Expand Down Expand Up @@ -66,11 +67,10 @@ Rectangle {
}
onHoveredChanged: {
//console.log("button.hover mouseX: " + mouseX)
if (mouseArea.mouseX == 2147483447) //qt5.6 touch screen release finger becomes 0x7fffffff
if (mouseX > 65535) //qt5.6 touch screen release finger becomes very large e.g. 0x7fffffff
return
hovered = mouseArea.containsMouse
}

onPressAndHold: root.pressAndHold()
}
states: [
Expand Down
24 changes: 19 additions & 5 deletions examples/QMLPlayer/qml/QMLPlayer/ControlPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Rectangle {
property string mediaSource
property int duration: 0
property real volume: 1
property alias mute: volBtn.checked
property bool mute: false
property bool hiding: false
property int previewHeight: preview.height
signal seek(int ms)
Expand Down Expand Up @@ -402,14 +402,28 @@ Rectangle {
height: Utils.scaled(30)
icon: Utils.resurl("theme/default/volume.svg")
iconChecked: Utils.resurl("theme/default/mute.svg")
readonly property bool isTouchDevice: !(Qt.platform.os === "windows" || Qt.platform.os === "wince" || Qt.platform.os === "winrt" || Qt.platform.os === "linux" || Qt.platform.os === "osx")
onClicked: {
if (!isTouchDevice) {
console.log("desktop checked: " + checked)
root.mute = checked
return
}
volBar.visible = !volBar.visible
checked = root.mute
}
onPressAndHold: { //for qt5.6 mobile
volBar.anchors.bottom = parent.top
volBar.anchors.bottomMargin = -(y + 2)//height/2)
volBar.x = parent.volBarPos - volBar.width/2
if (!isTouchDevice)
return
root.mute = !root.mute
checked = root.mute
}
onHoveredChanged: {
volBar.anchors.bottom = parent.top
volBar.anchors.bottomMargin = -(y + 2)//height/2)
if (isTouchDevice)
volBar.anchors.bottomMargin = 0 //ensure grip does not cover volBtn
else
volBar.anchors.bottomMargin = -(y + 2)//height/2)
volBar.x = parent.volBarPos - volBar.width/2
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/QMLPlayer/qml/QMLPlayer/Slider.qml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Item {
hoverEnabled: true
onHoveredChanged: {
//console.log("slider.hover mouseX: " + mouseX)
if (mouseArea.mouseX == 2147483447) //qt5.6 touch screen release finger becomes 0x7fffffff
if (mouseX > 65535) //qt5.6 touch screen release finger becomes very large e.g. 0x7fffffff
return
hovered = mouseArea.containsMouse
}
Expand Down Expand Up @@ -79,7 +79,7 @@ Item {
hoverEnabled: true
onHoveredChanged: {
//console.log("slider.grip.hover mouseX: " + mouseX)
if (gripMouseArea.mouseX == 2147483447) //qt5.6 touch screen release finger becomes 0x7fffffff
if (mouseX > 65535) //qt5.6 touch screen release finger becomes very large e.g. 0x7fffffff
return
hovered = gripMouseArea.containsMouse
}
Expand Down

0 comments on commit d57a47a

Please sign in to comment.