Commit e3bea66e authored by Chupligin Sergey's avatar Chupligin Sergey

[VolumeControl] added repeating of volume change if key stay pressed

parent 4622bc51
...@@ -42,6 +42,8 @@ ProgressBar { ...@@ -42,6 +42,8 @@ ProgressBar {
maximumValue: volumeControl.maximumVolume maximumValue: volumeControl.maximumVolume
property bool shouldbevisible property bool shouldbevisible
property int pressedKey
opacity: volumeSlider.shouldbevisible ? 1 : 0 opacity: volumeSlider.shouldbevisible ? 1 : 0
Behavior on opacity { Behavior on opacity {
NumberAnimation { NumberAnimation {
...@@ -49,6 +51,7 @@ ProgressBar { ...@@ -49,6 +51,7 @@ ProgressBar {
onRunningChanged: if (!running && volumeSlider.opacity == 0) volumeControl.windowVisible = false onRunningChanged: if (!running && volumeSlider.opacity == 0) volumeControl.windowVisible = false
} }
} }
Timer { Timer {
id: voltimer id: voltimer
interval: 2000 interval: 2000
...@@ -58,7 +61,70 @@ ProgressBar { ...@@ -58,7 +61,70 @@ ProgressBar {
Connections { Connections {
target: volumeControl target: volumeControl
onVolumeKeyPressed: { onVolumeKeyPressed: {
if(key == Qt.Key_VolumeUp) volumeSlider.pressedKey = key;
volumeControl.windowVisible = true
volumeChange()
keyPressTimer.start()
maxMinTimer.start()
if (volumeControl.windowVisible) {
voltimer.restart()
}
}
onVolumeKeyReleased: {
keyPressTimer.stop()
maxMinTimer.stop()
volumeSlider.pressedKey = ""
}
onWindowVisibleChanged: {
if (volumeControl.windowVisible) {
volumeSlider.shouldbevisible = true
voltimer.restart()
}
}
}
PropertyAnimation {
id: volumeChangeAinmation
target: volumeSlider
property: "value"
to: volumeControl.volume
duration: 100
}
Timer{
id: keyPressTimer
interval: 500
onTriggered: {
volumeChange()
voltimer.restart()
}
repeat: true
}
Timer{
id: maxMinTimer
interval: 1900
onTriggered: {
if(volumeSlider.pressedKey == Qt.Key_VolumeUp)
{
volumeControl.volume = volumeSlider.maximumValue
}
else if(volumeSlider.pressedKey == Qt.Key_VolumeDown)
{
volumeControl.volume = 0
}
volumeChangeAinmation.start()
}
}
function volumeChange()
{
if(volumeSlider.pressedKey == Qt.Key_VolumeUp)
{ {
//up volume //up volume
if(volumeControl.volume < maximumValue) if(volumeControl.volume < maximumValue)
...@@ -66,7 +132,7 @@ ProgressBar { ...@@ -66,7 +132,7 @@ ProgressBar {
volumeControl.volume = volumeControl.volume+1 volumeControl.volume = volumeControl.volume+1
} }
} }
else else if(volumeSlider.pressedKey == Qt.Key_VolumeDown)
{ {
//down volume //down volume
if(volumeControl.volume > 0) if(volumeControl.volume > 0)
...@@ -74,19 +140,6 @@ ProgressBar { ...@@ -74,19 +140,6 @@ ProgressBar {
volumeControl.volume = volumeControl.volume-1 volumeControl.volume = volumeControl.volume-1
} }
} }
volumeChangeAinmation.start()
volumeControl.windowVisible = true
volumeSlider.value = volumeControl.volume
if (volumeControl.windowVisible) {
voltimer.restart()
}
}
onWindowVisibleChanged: {
if (volumeControl.windowVisible) {
volumeSlider.shouldbevisible = true
voltimer.restart()
}
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment