| 1 |
import QtQuick |
| 2 |
|
| 3 |
import Muse.Ui |
| 4 |
import Muse.UiComponents |
| 5 |
|
| 6 |
StyledPopupView { |
| 7 |
id: root |
| 8 |
|
| 9 |
padding: 8 |
| 10 |
margins: 8 |
| 11 |
contentWidth: contentRect.width |
| 12 |
contentHeight: contentRect.height |
| 13 |
|
| 14 |
placement: PopupView.PreferAbove |
| 15 |
openPolicies: PopupView.NoActivateFocus |
| 16 |
|
| 17 |
property double volume |
| 18 |
property rect contentRect: fontMetrics.boundingRect("-60.0dB") |
| 19 |
|
| 20 |
Item { |
| 21 |
id: content |
| 22 |
|
| 23 |
anchors.fill: parent |
| 24 |
|
| 25 |
Text { |
| 26 |
anchors.right: parent.right |
| 27 |
text: { |
| 28 |
let value = root.volume.toFixed(1); |
| 29 |
return `${value}dB` |
| 30 |
} |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
FontMetrics { |
| 35 |
id: fontMetrics |
| 36 |
|
| 37 |
font: content.font |
| 38 |
} |
| 39 |
|
| 40 |
Timer { |
| 41 |
id: openTimer |
| 42 |
|
| 43 |
interval: ui.theme.tooltipDelay |
| 44 |
repeat: false |
| 45 |
|
| 46 |
onTriggered: { |
| 47 |
open() |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
Timer { |
| 52 |
id: closeTimer |
| 53 |
|
| 54 |
interval: ui.theme.tooltipDelay |
| 55 |
repeat: false |
| 56 |
|
| 57 |
onTriggered: { |
| 58 |
close() |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
function show() { |
| 63 |
openTimer.restart() |
| 64 |
closeTimer.stop() |
| 65 |
} |
| 66 |
|
| 67 |
function hide() { |
| 68 |
closeTimer.restart() |
| 69 |
openTimer.stop() |
| 70 |
} |
| 71 |
} |