diff options
author | Tim E. Real <termtech@rogers.com> | 2011-10-09 23:49:15 +0000 |
---|---|---|
committer | Tim E. Real <termtech@rogers.com> | 2011-10-09 23:49:15 +0000 |
commit | e160c228beaee36519fb210891006f7b40a46b4a (patch) | |
tree | 2d56abcbeddd7775cc6511d7ebc9f4921cc6c9f7 /muse2/muse | |
parent | 80d1f99cbad08ee6b0d7076f8df80ae71857c9f3 (diff) |
Fixed track list midi port popup menu - too many ports listed.
Seperated empty ports into submenu.
Diffstat (limited to 'muse2/muse')
-rw-r--r-- | muse2/muse/arranger/tlist.cpp | 2 | ||||
-rw-r--r-- | muse2/muse/midiport.cpp | 36 |
2 files changed, 30 insertions, 8 deletions
diff --git a/muse2/muse/arranger/tlist.cpp b/muse2/muse/arranger/tlist.cpp index 98c4a595..87179575 100644 --- a/muse2/muse/arranger/tlist.cpp +++ b/muse2/muse/arranger/tlist.cpp @@ -602,7 +602,7 @@ void TList::portsPopupMenu(MusECore::Track* t, int x, int y) else port = track->outPort(); - QMenu* p = MusECore::midiPortsPopup(0, port); + QMenu* p = MusECore::midiPortsPopup(this, port); // 0, port); QAction* act = p->exec(mapToGlobal(QPoint(x, y)), 0); if (act) { int n = act->data().toInt(); diff --git a/muse2/muse/midiport.cpp b/muse2/muse/midiport.cpp index a8a248cb..49934d7b 100644 --- a/muse2/muse/midiport.cpp +++ b/muse2/muse/midiport.cpp @@ -37,6 +37,7 @@ #include "synth.h" #include "app.h" #include "song.h" +#include "menutitleitem.h" //#ifdef DSSI_SUPPORT //#include "dssihost.h" @@ -316,20 +317,41 @@ int MidiPort::portno() const // midiPortsPopup //--------------------------------------------------------- -//QPopupMenu* midiPortsPopup(QWidget* parent) QMenu* midiPortsPopup(QWidget* parent, int checkPort) { QMenu* p = new QMenu(parent); + p->addAction(new MusEGui::MenuTitleItem("Port / Device", p)); + QMenu* subp = 0; + QAction *act = 0; + QString name; for (int i = 0; i < MIDI_PORTS; ++i) { MidiPort* port = &MusEGlobal::midiPorts[i]; - QString name; name.sprintf("%d:%s", port->portno()+1, port->portname().toLatin1().constData()); - QAction *act = p->addAction(name); - act->setData(i); - - if(i == checkPort) - act->setChecked(true); + if(port->device() || (i == checkPort)) + { + act = p->addAction(name); + act->setData(i); + act->setCheckable(true); + act->setChecked(i == checkPort); + } + + if(!port->device()) + { + if(!subp) // No submenu yet? Create it now. + { + subp = new QMenu(p); + subp->setTitle(subp->tr("Empty")); + subp->addAction(new MusEGui::MenuTitleItem("Empty Ports", subp)); + } + //act = subp->addAction(name); // No need for all those "<None>" names. + act = subp->addAction(QString().setNum(i+1)); + act->setData(i); + act->setCheckable(true); + act->setChecked(i == checkPort); + } } + if(subp) + p->addMenu(subp); return p; } |