VolumeControl.qml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import QtQuick 2.15
  2. import DMusic 1.0
  3. import "components"
  4. Item {
  5. id: root
  6. width: _icon.width
  7. height: _icon.height
  8. MouseArea {
  9. id: _bg_mouse
  10. anchors.horizontalCenter: parent.horizontalCenter
  11. anchors.bottom: parent.bottom
  12. width: 50
  13. height: 50 + 24 + _panel.height
  14. hoverEnabled: _ppc.opened
  15. enabled: _ppc.opened
  16. onExited: _ppc.opened = false
  17. PopupController {
  18. id: _ppc
  19. target: _panel
  20. }
  21. VolumeControlPanel {
  22. id: _panel
  23. width: 38
  24. height: 210
  25. anchors.horizontalCenter: parent.horizontalCenter
  26. anchors.top: parent.top
  27. anchors.topMargin: 12 + _ppc.shift
  28. }
  29. Icon {
  30. id: _icon
  31. width: 32
  32. height: 32
  33. anchors.bottom: parent.bottom
  34. anchors.horizontalCenter: parent.horizontalCenter
  35. anchors.horizontalCenterOffset: 4
  36. MouseArea {
  37. id: _mouse
  38. anchors.fill: parent
  39. hoverEnabled: true
  40. onEntered: _ppc.opened = true
  41. onClicked: AudioPlayer.muted = !AudioPlayer.muted
  42. onWheel: AudioPlayer.volume += 0.05 * wheel.angleDelta.y / 120
  43. }
  44. src: (AudioPlayer.volume <= 0.01 || AudioPlayer.muted)? "qrc:/resources/player/vol-muted.svg" : AudioPlayer.volume < 0.5? "qrc:/resources/player/vol-quiet.svg" : "qrc:/resources/player/vol.svg"
  45. color: _mouse.containsPress? Style.panel.icon.normal.pressedColor : _mouse.containsMouse? Style.panel.icon.normal.hoverColor : Style.panel.icon.normal.color
  46. }
  47. }
  48. }