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