add peak values to qml

This commit is contained in:
Zach Pomerantz 2017-06-27 17:37:24 -04:00
parent 5353437f59
commit 9b72ab96ff
2 changed files with 25 additions and 7 deletions

View file

@ -36,6 +36,23 @@ Rectangle {
return root.parent.objectName == "loader";
}
property bool showPeaks: true;
function enablePeakValues() {
Audio.devices.input.peakValuesEnabled = true;
Audio.devices.input.peakValuesEnabledChanged.connect(function(enabled) {
if (!enabled && root.showPeaks) {
Audio.devices.input.peakValuesEnabled = true;
}
});
}
function disablePeakValues() {
root.showPeaks = false;
Audio.devices.input.peakValuesEnabled = false;
}
Component.onCompleted: enablePeakValues();
Component.onDestruction: disablePeakValues();
Column {
y: 16; // padding does not work
spacing: 16;
@ -122,7 +139,7 @@ Rectangle {
width: parent.width;
AudioControls.CheckBox {
Layout.maximumWidth: parent.width - level.width - 40;
Layout.maximumWidth: parent.width - inputPeak.width - 40;
text: display;
wrap: false;
checked: selected;
@ -131,11 +148,12 @@ Rectangle {
checked = Qt.binding(function() { return selected; }); // restore binding
}
}
InputLevel {
id: level;
InputPeak {
id: inputPeak;
visible: Audio.devices.input.peakValuesAvailable;
peak: model.peak;
Layout.alignment: Qt.AlignRight;
Layout.rightMargin: 30;
visible: selected;
}
}
}

View file

@ -1,5 +1,5 @@
//
// InputLevel.qml
// InputPeak.qml
// qml/hifi/audio
//
// Created by Zach Pomerantz on 6/20/2017
@ -15,7 +15,7 @@ import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0
Rectangle {
readonly property var level: Audio.inputLevel;
property var peak;
width: 70;
height: 8;
@ -65,7 +65,7 @@ Rectangle {
Rectangle { // mask
id: mask;
width: parent.width * level;
width: parent.width * peak;
radius: 5;
anchors {
bottom: parent.bottom;