diff options
Diffstat (limited to 'muse/muse')
| -rw-r--r-- | muse/muse/event.h | 39 | ||||
| -rw-r--r-- | muse/muse/eventlist.cpp | 14 | ||||
| -rw-r--r-- | muse/muse/midiedit/drumedit.cpp | 104 | ||||
| -rw-r--r-- | muse/muse/midiedit/drumedit.h | 3 | ||||
| -rw-r--r-- | muse/muse/midiedit/pianoroll.cpp | 112 | ||||
| -rw-r--r-- | muse/muse/midiedit/pianoroll.h | 5 | ||||
| -rw-r--r-- | muse/muse/part.cpp | 41 | ||||
| -rw-r--r-- | muse/muse/shortcuts.cpp | 11 | ||||
| -rw-r--r-- | muse/muse/widgets/shortcutconfig.cpp | 21 | ||||
| -rw-r--r-- | muse/muse/widgets/shortcutconfig.ui | 194 |
10 files changed, 252 insertions, 292 deletions
diff --git a/muse/muse/event.h b/muse/muse/event.h index 9352eb38..c44ca622 100644 --- a/muse/muse/event.h +++ b/muse/muse/event.h @@ -120,20 +120,16 @@ typedef std::pair <iEvent, iEvent> EventRange; // tick sorted list of events //--------------------------------------------------------- -class EventList : public EL { - int ref; // number of references to this EventList +class EventListData : public EL, public QSharedData { int aref; // number of active references (exclude undo list) void deselect(); public: - EventList() { ref = 0; aref = 0; } - ~EventList() {} + EventListData() { aref = 0; } + ~EventListData() {} - void incRef(int n) { ref += n; } - int refCount() const { return ref; } void incARef(int n) { aref += n; } int arefCount() const { return aref; } - iEvent find(const Event&); iEvent add(Event& event); iEvent add(Event& event, unsigned tick); @@ -142,5 +138,34 @@ class EventList : public EL { void read(QDomNode, bool midi); }; +class EventList { + QSharedDataPointer<EventListData> d; + + public: + EventList() { d = new EventListData(); } + void incARef(int n) { d->incARef(n); } + int arefCount() const { return d->arefCount(); } + iEvent find(const Event& event) { return d->find(event); } + iEvent add(Event& event) { return d->add(event); } + iEvent add(Event& event, unsigned tick) { return d->add(event, tick); } + void move(Event& event, unsigned tick) { d->move(event, tick); } + void dump() const { d->dump(); } + void read(QDomNode n, bool midi) { d->read(n, midi); } + iEvent begin() { return d->begin(); } + iEvent end() { return d->end(); } + ciEvent begin() const { return d->begin(); } + ciEvent end() const { return d->end(); } + iEvent lower_bound(unsigned n) { return d->lower_bound(n); } + ciEvent lower_bound(unsigned n) const { return d->lower_bound(n); } + iEvent upper_bound(unsigned n) { return d->upper_bound(n); } + ciEvent upper_bound(unsigned n) const { return d->upper_bound(n); } + EventRange equal_range(unsigned n) { return d->equal_range(n); } + void clear() { d->clear(); } + bool empty() const { return d->empty(); } + void erase(iEvent i) { d->erase(i); } + void erase(iEvent i, iEvent k) { d->erase(i, k); } + unsigned size() const { return d->size(); } + }; + #endif diff --git a/muse/muse/eventlist.cpp b/muse/muse/eventlist.cpp index 0ba0ee57..9ce2930a 100644 --- a/muse/muse/eventlist.cpp +++ b/muse/muse/eventlist.cpp @@ -25,7 +25,7 @@ // readEventList //--------------------------------------------------------- -void EventList::read(QDomNode node, bool midi) +void EventListData::read(QDomNode node, bool midi) { for (; !node.isNull(); node = node.nextSibling()) { QDomElement e = node.toElement(); @@ -38,7 +38,7 @@ void EventList::read(QDomNode node, bool midi) add(e); } else - printf("EventList:read(): unknown tag %s\n", tag.toAscii().data()); + printf("EventListData:read(): unknown tag %s\n", tag.toAscii().data()); } } @@ -46,12 +46,12 @@ void EventList::read(QDomNode node, bool midi) // add //--------------------------------------------------------- -iEvent EventList::add(Event& event, unsigned tick) +iEvent EventListData::add(Event& event, unsigned tick) { return std::multimap<unsigned, Event, std::less<unsigned> >::insert(std::pair<const unsigned, Event> (tick, event)); } -iEvent EventList::add(Event& event) +iEvent EventListData::add(Event& event) { return add(event, event.tick()); } @@ -60,7 +60,7 @@ iEvent EventList::add(Event& event) // move //--------------------------------------------------------- -void EventList::move(Event& event, unsigned tick) +void EventListData::move(Event& event, unsigned tick) { iEvent i = find(event); erase(i); @@ -71,7 +71,7 @@ void EventList::move(Event& event, unsigned tick) // find //--------------------------------------------------------- -iEvent EventList::find(const Event& event) +iEvent EventListData::find(const Event& event) { EventRange range = equal_range(event.tick()); for (iEvent i = range.first; i != range.second; ++i) { @@ -85,7 +85,7 @@ iEvent EventList::find(const Event& event) // dump //--------------------------------------------------------- -void EventList::dump() const +void EventListData::dump() const { for (ciEvent i = begin(); i != end(); ++i) i->second.dump(); diff --git a/muse/muse/midiedit/drumedit.cpp b/muse/muse/midiedit/drumedit.cpp index f4370e36..04a5766a 100644 --- a/muse/muse/midiedit/drumedit.cpp +++ b/muse/muse/midiedit/drumedit.cpp @@ -51,17 +51,10 @@ DrumEdit::DrumEdit(PartList* pl, bool init) deltaMode = false; drumMap = &noDrumMap; -#if 0 //TODOB - cutAction->setShortcut(shortcuts[SHRT_CUT].key); - copyAction->setShortcut(shortcuts[SHRT_COPY].key); - pasteAction->setShortcut(shortcuts[SHRT_PASTE].key); -#endif - //---------Pulldown Menu---------------------------- QMenuBar* mb = menuBar(); menuEdit->addSeparator(); - menuEdit->addAction(getAction("delete", this)); // Functions @@ -109,7 +102,6 @@ DrumEdit::DrumEdit(PartList* pl, bool init) QToolBar* transport = addToolBar(tr("Transport")); muse->setupTransportToolbar(transport); - // dontīch value in toolbar addToolBarBreak(); toolbar = new Toolbar1(initRaster, initQuant, false); addToolBar(toolbar); @@ -160,6 +152,23 @@ DrumEdit::DrumEdit(PartList* pl, bool init) sc->setContext(Qt::WindowShortcut); connect(sc, SIGNAL(activated()), SLOT(close())); + QSignalMapper* cmdMap = new QSignalMapper(this); + static const char* actions[] = { + "curpos_increase", "curpos_decrease", + "pointer", "pencil", "eraser", + "midi_quant_1", "midi_quant_2", "midi_quant_3", "midi_quant_4", + "midi_quant_5", "midi_quant_6", "midi_quant_7", + "midi_quant_triol", "midi_quant_punct", "midi_quant_punct2" + }; + for (unsigned i = 0; i < sizeof(actions)/sizeof(*actions); ++i) { + QAction* a = getAction(actions[i], this); + addAction(a); + cmdMap->setMapping(a, a); + connect(a, SIGNAL(triggered()), cmdMap, SLOT(map())); + } + connect(cmdMap, SIGNAL(mapped(QObject*)), SLOT(drumCmd(QObject*))); + + connect(song, SIGNAL(songChanged(int)), canvas(), SLOT(songChanged(int))); connect(followSongAction, SIGNAL(toggled(bool)), canvas(), SLOT(setFollow(bool))); canvas()->selectFirst(); @@ -318,32 +327,21 @@ void DrumEdit::cmd(QAction* a) } //--------------------------------------------------------- -// configChanged +// keyPressEvent //--------------------------------------------------------- -void DrumEdit::configChanged() +void DrumEdit::drumCmd(QObject* object) { - } + QAction* a = (QAction*)object; + QString cmd(a->data().toString()); -#if 0 -static int rasterTable[] = { - //-9----8- 7 6 5 4 3(1/4) 2 1 - 4, 8, 16, 32, 64, 128, 256, 512, 1024, // triple - 6, 12, 24, 48, 96, 192, 384, 768, 1536, - 9, 18, 36, 72, 144, 288, 576, 1152, 2304 // dot - }; -#endif + static const int rasterTable[] = { + //-9----8- 7 6 5 4 3(1/4) 2 1 + 4, 8, 16, 32, 64, 128, 256, 512, 1024, // triple + 6, 12, 24, 48, 96, 192, 384, 768, 1536, + 9, 18, 36, 72, 144, 288, 576, 1152, 2304 // dot + }; -//--------------------------------------------------------- -// keyPressEvent -//--------------------------------------------------------- - -void DrumEdit::keyPressEvent(QKeyEvent* event) - { - event->ignore(); - return; -#if 0 -//TODOB DrumCanvas* dc = canvas(); int index = 0; int n = sizeof(rasterTable); @@ -353,56 +351,47 @@ void DrumEdit::keyPressEvent(QKeyEvent* event) int off = (index / 9) * 9; index = index % 9; int val; - int key = event->key(); - if (event->modifiers() & Qt::ShiftModifier) - key += Qt::SHIFT; - if (event->modifiers() & Qt::AltModifier) - key += Qt::ALT; - if (event->modifiers() & Qt::ControlModifier) - key+= Qt::CTRL; - - if (key == shortcuts[SHRT_POS_INC].key) { - dc->cmd(DrumCanvas::CMD_RIGHT); + if (cmd == "curpos_increase") { + dc->cmd(a); return; } - else if (key == shortcuts[SHRT_POS_DEC].key) { - dc->cmd(DrumCanvas::CMD_LEFT); + else if (cmd == "curpos_decrease") { + dc->cmd(a); return; } - - else if (key == shortcuts[SHRT_TOOL_POINTER].key) { + else if (cmd == "pointer") { tools2->set(PointerTool); return; } - else if (key == shortcuts[SHRT_TOOL_PENCIL].key) { + else if (cmd == "pencil") { tools2->set(PencilTool); return; } - else if (key == shortcuts[SHRT_TOOL_RUBBER].key) { + else if (cmd == "eraser") { tools2->set(RubberTool); return; } - else if (key == shortcuts[SHRT_SET_QUANT_1].key) + else if (cmd == "midi_quant_1") val = rasterTable[8 + off]; - else if (key == shortcuts[SHRT_SET_QUANT_2].key) + else if (cmd == "midi_quant_2") val = rasterTable[7 + off]; - else if (key == shortcuts[SHRT_SET_QUANT_3].key) + else if (cmd == "midi_quant_3") val = rasterTable[6 + off]; - else if (key == shortcuts[SHRT_SET_QUANT_4].key) + else if (cmd == "midi_quant_4") val = rasterTable[5 + off]; - else if (key == shortcuts[SHRT_SET_QUANT_5].key) + else if (cmd == "midi_quant_5") val = rasterTable[4 + off]; - else if (key == shortcuts[SHRT_SET_QUANT_6].key) + else if (cmd == "midi_quant_6") val = rasterTable[3 + off]; - else if (key == shortcuts[SHRT_SET_QUANT_7].key) + else if (cmd == "midi_quant_7") val = rasterTable[2 + off]; - else if (key == shortcuts[SHRT_TOGGLE_TRIOL].key) + else if (cmd == "midi_quant_triol") val = rasterTable[index + ((off == 0) ? 9 : 0)]; - else if (key == shortcuts[SHRT_TOGGLE_PUNCT].key) + else if (cmd == "midi_quant_punct") val = rasterTable[index + ((off == 18) ? 9 : 18)]; - else if (key == shortcuts[SHRT_TOGGLE_PUNCT2].key) {//CDW + else if (cmd == "midi_quant_punct2") { if ((off == 18) && (index > 2)) { val = rasterTable[index + 9 - 1]; } @@ -412,15 +401,14 @@ void DrumEdit::keyPressEvent(QKeyEvent* event) else return; } - else { //Default: - event->ignore(); + else { + printf("DrumEdit::drumCmd: unknown cmd <%s>\n", cmd.toLatin1().data()); return; } setQuant(val); setRaster(val); toolbar->setQuant(quant()); toolbar->setRaster(raster()); -#endif } //--------------------------------------------------------- diff --git a/muse/muse/midiedit/drumedit.h b/muse/muse/midiedit/drumedit.h index 0283f508..20cf99f6 100644 --- a/muse/muse/midiedit/drumedit.h +++ b/muse/muse/midiedit/drumedit.h @@ -55,13 +55,12 @@ class DrumEdit : public MidiEditor { virtual void closeEvent(QCloseEvent*); QWidget* genToolbar(QWidget* parent); - virtual void keyPressEvent(QKeyEvent*); DrumCanvas* canvas() { return (DrumCanvas*)tcanvas; } private slots: void noteinfoChanged(NoteInfo::ValType type, int val); virtual void cmd(QAction*); - void configChanged(); + void drumCmd(QObject* object); public slots: void setSelection(int, Event&, Part*); diff --git a/muse/muse/midiedit/pianoroll.cpp b/muse/muse/midiedit/pianoroll.cpp index 649c4955..e709bf45 100644 --- a/muse/muse/midiedit/pianoroll.cpp +++ b/muse/muse/midiedit/pianoroll.cpp @@ -72,7 +72,6 @@ PianoRoll::PianoRoll(PartList* pl, bool init) QAction* a = getAction("delete", this); menuEdit->addAction(a); -//TD? a->setData(PianoCanvas::CMD_DEL); menuEdit->addSeparator(); @@ -210,22 +209,26 @@ PianoRoll::PianoRoll(PartList* pl, bool init) // // install misc shortcuts // - - a = getAction("curpos_increase", this); - a->setShortcutContext(Qt::WindowShortcut); - addAction(a); - connect(a, SIGNAL(triggered()), SLOT(cmdRight())); - - a = getAction("curpos_decrease", this); - a->setShortcutContext(Qt::WindowShortcut); - addAction(a); - connect(a, SIGNAL(triggered()), SLOT(cmdLeft())); - QShortcut* sc = new QShortcut(Qt::Key_Escape, this); sc->setContext(Qt::WindowShortcut); - connect(sc, SIGNAL(activated()), SLOT(close())); + QSignalMapper* cmdMap = new QSignalMapper(this); + static const char* actions[] = { + "curpos_increase", "curpos_decrease", + "midi_insert_at_loc", + "midi_quant_1", "midi_quant_2", "midi_quant_3", "midi_quant_4", + "midi_quant_5", "midi_quant_6", "midi_quant_7", + "midi_quant_punct", "midi_quant_punct2", "midi_quant_triol", + }; + for (unsigned i = 0; i < sizeof(actions)/sizeof(*actions); ++i) { + a = getAction(actions[i], this); + addAction(a); + cmdMap->setMapping(a, a); + connect(a, SIGNAL(triggered()), cmdMap, SLOT(map())); + } + connect(cmdMap, SIGNAL(mapped(QObject*)), SLOT(pianoCmd(QObject*))); + connect(song, SIGNAL(songChanged(int)), canvas(), SLOT(songChanged(int))); connect(followSongAction, SIGNAL(toggled(bool)), canvas(), SLOT(setFollow(bool))); canvas()->selectFirst(); @@ -243,32 +246,6 @@ PianoRoll::PianoRoll(PartList* pl, bool init) } //--------------------------------------------------------- -// cmdLeft -//--------------------------------------------------------- - -void PianoRoll::cmdLeft() - { - canvas()->pianoCmd(MCMD_LEFT); - } - -//--------------------------------------------------------- -// cmdRight -//--------------------------------------------------------- - -void PianoRoll::cmdRight() - { - canvas()->pianoCmd(MCMD_RIGHT); - } - -//--------------------------------------------------------- -// configChanged -//--------------------------------------------------------- - -void PianoRoll::configChanged() - { - } - -//--------------------------------------------------------- // cmd // pulldown menu commands //--------------------------------------------------------- @@ -395,12 +372,14 @@ void PianoRoll::soloChanged(bool flag) } //--------------------------------------------------------- -// viewKeyPressEvent +// pianoCmd //--------------------------------------------------------- -void PianoRoll::keyPressEvent(QKeyEvent* event) +void PianoRoll::pianoCmd(QObject* object) { -#if 0 //TODOB + QAction* a = (QAction*)object; + QString cmd(a->data().toString()); + static int rasterTable[] = { //-9----8- 7 6 5 4 3(1/4) 2 1 4, 8, 16, 32, 64, 128, 256, 512, 1024, // triple @@ -408,11 +387,6 @@ void PianoRoll::keyPressEvent(QKeyEvent* event) 9, 18, 36, 72, 144, 288, 576, 1152, 2304 // dot }; - if (info->hasFocus()) { - event->ignore(); - return; - } - int index; int n = sizeof(rasterTable)/sizeof(*rasterTable); for (index = 0; index < n; ++index) @@ -428,42 +402,39 @@ void PianoRoll::keyPressEvent(QKeyEvent* event) int val = 0; PianoCanvas* pc = canvas(); - int key = event->key(); - if (key == shortcuts[SHRT_INSERT_AT_LOCATION].key) { + if (cmd == "curpos_increase") + canvas()->pianoCmd(MCMD_LEFT); + else if (cmd == "curpos_decrease") + canvas()->pianoCmd(MCMD_RIGHT); + else if (cmd == "midi_insert_at_loc") { pc->pianoCmd(MCMD_INSERT); return; } - else if (key == Qt::Key_Delete) { - pc->pianoCmd(MCMD_DELETE); - return; - } - else if (key == shortcuts[SHRT_SET_QUANT_1].key) + else if (cmd == "midi_quant_1") val = rasterTable[8 + off]; - else if (key == shortcuts[SHRT_SET_QUANT_2].key) + else if (cmd == "midi_quant_2") val = rasterTable[7 + off]; - else if (key == shortcuts[SHRT_SET_QUANT_3].key) + else if (cmd == "midi_quant_3") val = rasterTable[6 + off]; - else if (key == shortcuts[SHRT_SET_QUANT_4].key) + else if (cmd == "midi_quant_4") val = rasterTable[5 + off]; - else if (key == shortcuts[SHRT_SET_QUANT_5].key) + else if (cmd == "midi_quant_5") val = rasterTable[4 + off]; - else if (key == shortcuts[SHRT_SET_QUANT_6].key) + else if (cmd == "midi_quant_6") val = rasterTable[3 + off]; - else if (key == shortcuts[SHRT_SET_QUANT_7].key) + else if (cmd == "midi_quant_7") val = rasterTable[2 + off]; - else if (key == shortcuts[SHRT_TOGGLE_TRIOL].key) + else if (cmd == "midi_quant_triol") val = rasterTable[index + ((off == 0) ? 9 : 0)]; - - else if (key == shortcuts[SHRT_EVENT_COLOR].key) { + else if (cmd == "change_event_color") { _colorMode = (_colorMode + 1) % 3; setEventColorMode(_colorMode); return; } - else if (key == shortcuts[SHRT_TOGGLE_PUNCT].key) + else if (cmd == "midi_quant_punct") val = rasterTable[index + ((off == 18) ? 9 : 18)]; - - else if (key == shortcuts[SHRT_TOGGLE_PUNCT2].key) { + else if (cmd == "midi_quant_punct2") { if ((off == 18) && (index > 2)) { val = rasterTable[index + 9 - 1]; } @@ -473,17 +444,12 @@ void PianoRoll::keyPressEvent(QKeyEvent* event) else return; } - else { //Default: - event->ignore(); - return; - } - + else + printf("unknown cmd <%s>\n", cmd.toLatin1().data()); setQuant(val); setRaster(val); toolbar->setQuant(quant()); toolbar->setRaster(raster()); -#endif - event->ignore(); } //--------------------------------------------------------- diff --git a/muse/muse/midiedit/pianoroll.h b/muse/muse/midiedit/pianoroll.h index 3d9a9ae1..e510408c 100644 --- a/muse/muse/midiedit/pianoroll.h +++ b/muse/muse/midiedit/pianoroll.h @@ -70,7 +70,6 @@ class PianoRoll : public MidiEditor { QuantConfig* quantConfig; QWidget* genToolbar(QWidget* parent); - virtual void keyPressEvent(QKeyEvent*); void setEventColorMode(int); PianoCanvas* canvas() { return (PianoCanvas*)tcanvas; } const PianoCanvas* canvas() const { return (PianoCanvas*)tcanvas; } @@ -83,9 +82,7 @@ class PianoRoll : public MidiEditor { virtual void cmd(QAction*); void setEventColorMode(QAction*); - void configChanged(); - void cmdLeft(); - void cmdRight(); + void pianoCmd(QObject*); public: PianoRoll(PartList*, bool); diff --git a/muse/muse/part.cpp b/muse/muse/part.cpp index ea8ca457..fa199036 100644 --- a/muse/muse/part.cpp +++ b/muse/muse/part.cpp @@ -27,23 +27,23 @@ #include "al/tempo.h" const char* partColorNames[] = { - "Default", - "Refrain", - "Bridge", - "Intro", - "Coda", - "Chorus", - "Solo", - "Brass", - "Percussion", - "Drums", - "Guitar", - "Bass", - "Flute", - "Strings", - "Keyboard", - "Piano", - "Saxophon", + QT_TR_NOOP("Default"), + QT_TR_NOOP("Refrain"), + QT_TR_NOOP("Bridge"), + QT_TR_NOOP("Intro"), + QT_TR_NOOP("Coda"), + QT_TR_NOOP("Chorus"), + QT_TR_NOOP("Solo"), + QT_TR_NOOP("Brass"), + QT_TR_NOOP("Percussion"), + QT_TR_NOOP("Drums"), + QT_TR_NOOP("Guitar"), + QT_TR_NOOP("Bass"), + QT_TR_NOOP("Flute"), + QT_TR_NOOP("Strings"), + QT_TR_NOOP("Keyboard"), + QT_TR_NOOP("Piano"), + QT_TR_NOOP("Saxophon"), }; CloneList cloneList; @@ -62,7 +62,6 @@ void Part::init() _mute = false; _colorIndex = 0; _fillLen = 0; - _events->incRef(1); _events->incARef(1); if (_track->type() == Track::WAVE) setType(AL::FRAMES); @@ -92,7 +91,6 @@ Part::Part(const Part& p) _raster = p._raster; _xmag = p._xmag; _fillLen = p._fillLen; - _events->incRef(1); } Part::Part(const Part& p, EventList* el) @@ -108,7 +106,6 @@ Part::Part(const Part& p, EventList* el) _xmag = p._xmag; _fillLen = p._fillLen; _events = el; - _events->incRef(1); _events->incARef(1); } @@ -129,9 +126,6 @@ Part::Part(Track* t, EventList* el) Part::~Part() { - _events->incRef(-1); - if (_events->refCount() <= 0) - delete _events; } //--------------------------------------------------------- @@ -386,7 +380,6 @@ void Part::read(QDomNode node) if (i->id == id) { delete _events; _events = (EventList*)(i->el); - _events->incRef(1); _events->incARef(1); break; } diff --git a/muse/muse/shortcuts.cpp b/muse/muse/shortcuts.cpp index 4381baa7..0df5f43e 100644 --- a/muse/muse/shortcuts.cpp +++ b/muse/muse/shortcuts.cpp @@ -117,7 +117,6 @@ Shortcut MuseApplication::sc[] = { ":/xpm/recordOn.svg", ":/xpm/recordOff.svg" ), -//------ Shortcut( "punchin", QT_TR_NOOP("Transport: Punch In"), @@ -163,8 +162,6 @@ Shortcut MuseApplication::sc[] = { QT_TR_NOOP("send note off to all midi channels"), ":/xpm/panic.xpm" ), - - Shortcut( "copy", QT_TR_NOOP("Edit: Copy"), @@ -942,6 +939,12 @@ Shortcut MuseApplication::sc[] = { Qt::Key_Comma ), Shortcut( + "midi_insert_at_loc", + QT_TR_NOOP("Insert"), + PROLL_SHRT, + Qt::SHIFT + Qt::Key_Right + ), + Shortcut( "lm_ins_tempo", QT_TR_NOOP("Insert Tempo"), LMEDIT_SHRT, @@ -1011,7 +1014,7 @@ QAction* getAction(const char* id, QObject* parent) printf("interanl error: shortcut <%s> not found\n", id); return 0; } - if (s->action == 0 || s->action->parent() != parent) { + if (s->action == 0 || (s->action->parent() != parent)) { s->action = new QAction(s->xml, parent); s->action->setData(s->xml); s->action->setShortcut(s->key); diff --git a/muse/muse/widgets/shortcutconfig.cpp b/muse/muse/widgets/shortcutconfig.cpp index da8390b4..025f1494 100644 --- a/muse/muse/widgets/shortcutconfig.cpp +++ b/muse/muse/widgets/shortcutconfig.cpp @@ -37,6 +37,7 @@ ShortcutConfig::ShortcutConfig(QWidget* parent) connect(defineButton, SIGNAL(pressed()), this, SLOT(assignShortcut())); connect(clearButton, SIGNAL(pressed()), this, SLOT(clearShortcut())); connect(applyButton, SIGNAL(pressed()), this, SLOT(assignAll())); + connect(scListView, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(assignShortcut())); current_category = ALL_SHRT; //TD cgListView->setSorting(SHRT_CATEGORY_COL, -1); @@ -84,8 +85,6 @@ void ShortcutConfig::assignShortcut() if (sc.exec()) { s->key = sc.getKey(); active->setText(SHRT_SHRTCUT_COL, s->key.toString(QKeySequence::NativeText)); - if (s->action) - s->action->setShortcut(s->key); _config_changed = true; } clearButton->setEnabled(true); @@ -146,5 +145,23 @@ void ShortcutConfig::closeEvent(QCloseEvent*) void ShortcutConfig::assignAll() { + foreach(QWidget* w, QApplication::allWidgets()) { + foreach(QAction* a, w->actions()) { + QVariant v(a->data()); + if (v.type() == QVariant::String) { + QString name = v.toString(); + foreach (Shortcut* s, shortcuts) { + if (s->xml == name) { + if (a->shortcut() != s->key) { + printf("shortcut <%s> changed\n", s->xml); + a->setShortcuts(QList<QKeySequence>()); + a->setShortcut(s->key); + } + } + } + } + } + } done(_config_changed); } + diff --git a/muse/muse/widgets/shortcutconfig.ui b/muse/muse/widgets/shortcutconfig.ui index 92b82dd7..901e2cac 100644 --- a/muse/muse/widgets/shortcutconfig.ui +++ b/muse/muse/widgets/shortcutconfig.ui @@ -5,7 +5,7 @@ <rect> <x>0</x> <y>0</y> - <width>537</width> + <width>661</width> <height>403</height> </rect> </property> @@ -17,108 +17,96 @@ </property> <layout class="QVBoxLayout" > <property name="margin" > - <number>11</number> + <number>9</number> </property> <property name="spacing" > <number>6</number> </property> <item> - <widget class="QGroupBox" name="groupBox3" > - <property name="title" > - <string/> + <widget class="QSplitter" name="splitter" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> </property> - <layout class="QHBoxLayout" > - <property name="margin" > + <widget class="QTreeWidget" name="cgListView" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize" > + <size> + <width>105</width> + <height>200</height> + </size> + </property> + <property name="indentation" > + <number>0</number> + </property> + <property name="rootIsDecorated" > + <bool>false</bool> + </property> + <property name="sortingEnabled" > + <bool>true</bool> + </property> + <property name="columnCount" > + <number>1</number> + </property> + <column> + <property name="text" > + <string>Category</string> + </property> + </column> + </widget> + <widget class="QTreeWidget" name="scListView" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>2</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize" > + <size> + <width>170</width> + <height>230</height> + </size> + </property> + <property name="alternatingRowColors" > + <bool>true</bool> + </property> + <property name="indentation" > <number>0</number> </property> - <property name="spacing" > - <number>3</number> + <property name="rootIsDecorated" > + <bool>false</bool> + </property> + <property name="uniformRowHeights" > + <bool>true</bool> + </property> + <property name="sortingEnabled" > + <bool>true</bool> </property> - <item> - <widget class="QTreeWidget" name="cgListView" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>5</hsizetype> - <vsizetype>7</vsizetype> - <horstretch>1</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize" > - <size> - <width>105</width> - <height>200</height> - </size> - </property> - <property name="indentation" > - <number>0</number> - </property> - <property name="rootIsDecorated" > - <bool>false</bool> - </property> - <property name="sortingEnabled" > - <bool>true</bool> - </property> - <property name="columnCount" > - <number>1</number> - </property> - <column> - <property name="text" > - <string>Category</string> - </property> - </column> - </widget> - </item> - <item> - <widget class="QTreeWidget" name="scListView" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>7</vsizetype> - <horstretch>2</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize" > - <size> - <width>170</width> - <height>230</height> - </size> - </property> - <property name="alternatingRowColors" > - <bool>true</bool> - </property> - <property name="indentation" > - <number>0</number> - </property> - <property name="rootIsDecorated" > - <bool>false</bool> - </property> - <property name="uniformRowHeights" > - <bool>true</bool> - </property> - <property name="sortingEnabled" > - <bool>true</bool> - </property> - <property name="allColumnsShowFocus" > - <bool>true</bool> - </property> - <property name="columnCount" > - <number>2</number> - </property> - <column> - <property name="text" > - <string>Description</string> - </property> - </column> - <column> - <property name="text" > - <string>Shortcut</string> - </property> - </column> - </widget> - </item> - </layout> + <property name="allColumnsShowFocus" > + <bool>true</bool> + </property> + <property name="columnCount" > + <number>2</number> + </property> + <column> + <property name="text" > + <string>Description</string> + </property> + </column> + <column> + <property name="text" > + <string>Shortcut</string> + </property> + </column> + </widget> </widget> </item> <item> @@ -130,22 +118,6 @@ <number>6</number> </property> <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>150</width> - <height>21</height> - </size> - </property> - </spacer> - </item> - <item> <widget class="QPushButton" name="clearButton" > <property name="enabled" > <bool>false</bool> @@ -190,7 +162,7 @@ <item> <widget class="QPushButton" name="applyButton" > <property name="text" > - <string>&Apply</string> + <string>Ok</string> </property> <property name="shortcut" > <string>Alt+A</string> |
