summaryrefslogtreecommitdiff
path: root/Volume.qml
blob: cbf41e963a4dafd1baa4dc4f8166fcf4f1109645 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// SPDX-License-Identifier: Unlicense

import QtQuick.Controls 2.13

Button {
    property bool muted
    property alias value: volume.value

    implicitWidth: implicitHeight
    icon.name: 'audio-volume-' +
        (muted ? 'muted' :
         (value < 0.33 ? 'low' :
          (value < 0.66 ? 'medium' : 'high')))

    checkable: true
    checked: popup.opened

    onClicked: popup.opened ? popup.close() : popup.open()
    Popup {
        id: popup
        y: -height
        height: 100
        closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
        Slider {
            id: volume
            anchors.fill: parent
            orientation: Qt.Vertical
        }
    }
}