Improved Midi Ports DevTools
This commit is contained in:
parent
f18144b5af
commit
c13b797369
3 changed files with 108 additions and 191 deletions
|
@ -19,211 +19,126 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import MuseScore.UiComponents 1.0
|
||||
import MuseScore.Midi 1.0
|
||||
|
||||
Item {
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 12
|
||||
spacing: 12
|
||||
|
||||
MidiPortDevModel {
|
||||
id: midiModel
|
||||
|
||||
onOutputDevicesChanged: {
|
||||
outputDevicesRepeater.model = 0
|
||||
outputDevicesRepeater.model = midiModel.outputDevices()
|
||||
}
|
||||
|
||||
onInputDevicesChanged: {
|
||||
inputDevicesRepeater.model = 0
|
||||
inputDevicesRepeater.model = midiModel.inputDevices()
|
||||
}
|
||||
|
||||
onInputEventsChanged: {
|
||||
inputEventsRepeator.model = 0
|
||||
inputEventsRepeator.model = midiModel.inputEvents()
|
||||
}
|
||||
}
|
||||
|
||||
Flickable {
|
||||
anchors.fill: parent
|
||||
contentWidth: parent.width
|
||||
contentHeight: childrenRect.height
|
||||
|
||||
Column {
|
||||
id: outputPanel
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: childrenRect.height
|
||||
Layout.fillWidth: true
|
||||
spacing: 12
|
||||
|
||||
StyledTextLabel {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 8
|
||||
height: 40
|
||||
font: ui.theme.bodyBoldFont
|
||||
text: "MIDI output"
|
||||
}
|
||||
|
||||
StyledTextLabel {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 8
|
||||
height: 40
|
||||
width: parent.width
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
font: ui.theme.bodyBoldFont
|
||||
text: "Devices:"
|
||||
text: "MIDI output devices:"
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: childrenRect.height
|
||||
StyledListView {
|
||||
width: parent.width
|
||||
height: contentHeight
|
||||
|
||||
Repeater {
|
||||
id: outputDevicesRepeater
|
||||
model: midiModel.outputDevices()
|
||||
delegate: Item {
|
||||
model: midiModel.outputDevices
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 8
|
||||
anchors.rightMargin: 8
|
||||
delegate: RowLayout {
|
||||
width: ListView.view.width
|
||||
height: 40
|
||||
spacing: 12
|
||||
|
||||
StyledTextLabel {
|
||||
id: label
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
width: 240
|
||||
Layout.minimumWidth: 240
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
text: modelData.id + " " + modelData.name
|
||||
}
|
||||
|
||||
FlatButton {
|
||||
id: connBtn
|
||||
anchors.left: label.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
height: 30
|
||||
text: modelData.action
|
||||
onClicked: midiModel.outputDeviceAction(modelData.id, modelData.action)
|
||||
onClicked: {
|
||||
midiModel.outputDeviceAction(modelData.id, modelData.action)
|
||||
}
|
||||
}
|
||||
|
||||
StyledTextLabel {
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: connBtn.right
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 8
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
text: modelData.error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
id: inputPanel
|
||||
anchors.top: outputPanel.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.topMargin: 16
|
||||
height: childrenRect.height
|
||||
Layout.fillWidth: true
|
||||
spacing: 12
|
||||
|
||||
StyledTextLabel {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 8
|
||||
height: 40
|
||||
font: ui.theme.bodyBoldFont
|
||||
text: "MIDI input"
|
||||
}
|
||||
|
||||
StyledTextLabel {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 8
|
||||
height: 40
|
||||
width: parent.width
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
font: ui.theme.bodyBoldFont
|
||||
text: "Devices:"
|
||||
text: "MIDI input devices:"
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: childrenRect.height
|
||||
StyledListView {
|
||||
width: parent.width
|
||||
height: contentHeight
|
||||
|
||||
Repeater {
|
||||
id: inputDevicesRepeater
|
||||
model: midiModel.inputDevices()
|
||||
delegate: Item {
|
||||
model: midiModel.inputDevices
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 8
|
||||
anchors.rightMargin: 8
|
||||
delegate: RowLayout {
|
||||
width: ListView.view.width
|
||||
height: 40
|
||||
spacing: 12
|
||||
|
||||
StyledTextLabel {
|
||||
id: ilabel
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
width: 240
|
||||
Layout.minimumWidth: 240
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
text: modelData.id + " " + modelData.name
|
||||
}
|
||||
|
||||
FlatButton {
|
||||
id: iconnBtn
|
||||
anchors.left: ilabel.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
height: 30
|
||||
text: modelData.action
|
||||
onClicked: midiModel.inputDeviceAction(modelData.id, modelData.action)
|
||||
onClicked: {
|
||||
midiModel.inputDeviceAction(modelData.id, modelData.action)
|
||||
}
|
||||
}
|
||||
|
||||
StyledTextLabel {
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: iconnBtn.right
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 8
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
text: modelData.error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.top: inputPanel.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.topMargin: 16
|
||||
height: childrenRect.height
|
||||
|
||||
FlatButton {
|
||||
text: "generate MIDI2.0"
|
||||
text: "Generate MIDI2.0"
|
||||
onClicked: midiModel.generateMIDI20();
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: inputEventsRepeator
|
||||
model: midiModel.inputEvents()
|
||||
StyledListView {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
model: midiModel.inputEvents
|
||||
|
||||
delegate: StyledTextLabel {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 8
|
||||
anchors.rightMargin: 8
|
||||
width: ListView.view.width
|
||||
height: 20
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
text: modelData
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,14 @@ MidiPortDevModel::MidiPortDevModel(QObject* parent)
|
|||
m_inputEvents.prepend(str);
|
||||
emit inputEventsChanged();
|
||||
});
|
||||
|
||||
midiInPort()->devicesChanged().onNotify(this, [this]() {
|
||||
emit inputDevicesChanged();
|
||||
});
|
||||
|
||||
midiOutPort()->devicesChanged().onNotify(this, [this]() {
|
||||
emit outputDevicesChanged();
|
||||
});
|
||||
}
|
||||
|
||||
QVariantList MidiPortDevModel::outputDevices() const
|
||||
|
@ -202,8 +210,3 @@ void MidiPortDevModel::generateMIDI20()
|
|||
}
|
||||
emit inputEventsChanged();
|
||||
}
|
||||
|
||||
bool MidiPortDevModel::isInputConnected() const
|
||||
{
|
||||
return midiInPort()->isConnected();
|
||||
}
|
||||
|
|
|
@ -38,27 +38,26 @@ class MidiPortDevModel : public QObject, public async::Asyncable
|
|||
INJECT(midi, IMidiOutPort, midiOutPort)
|
||||
INJECT(midi, IMidiInPort, midiInPort)
|
||||
|
||||
Q_PROPERTY(bool isInputConnected READ isInputConnected NOTIFY isInputConnectedChanged)
|
||||
Q_PROPERTY(QVariantList outputDevices READ outputDevices NOTIFY outputDevicesChanged)
|
||||
Q_PROPERTY(QVariantList inputDevices READ inputDevices NOTIFY inputDevicesChanged)
|
||||
Q_PROPERTY(QVariantList inputEvents READ inputEvents NOTIFY inputEventsChanged)
|
||||
|
||||
public:
|
||||
explicit MidiPortDevModel(QObject* parent = nullptr);
|
||||
|
||||
bool isInputConnected() const;
|
||||
|
||||
Q_INVOKABLE QVariantList outputDevices() const;
|
||||
QVariantList outputDevices() const;
|
||||
Q_INVOKABLE void outputDeviceAction(const QString& deviceID, const QString& action);
|
||||
|
||||
Q_INVOKABLE QVariantList inputDevices() const;
|
||||
QVariantList inputDevices() const;
|
||||
Q_INVOKABLE void inputDeviceAction(const QString& deviceID, const QString& action);
|
||||
|
||||
Q_INVOKABLE QVariantList inputEvents() const;
|
||||
QVariantList inputEvents() const;
|
||||
Q_INVOKABLE void generateMIDI20();
|
||||
|
||||
signals:
|
||||
void outputDevicesChanged();
|
||||
void inputDevicesChanged();
|
||||
void inputEventsChanged();
|
||||
void isInputConnectedChanged();
|
||||
|
||||
private:
|
||||
QMap<QString, QString> m_connectionErrors;
|
||||
|
|
Loading…
Reference in a new issue