diff options
-rw-r--r-- | muse/doc/man/de/midirecording.tex | 1 | ||||
-rw-r--r-- | muse/muse/arranger/arranger.cpp | 3 | ||||
-rw-r--r-- | muse/muse/midiedit/drumedit.cpp | 27 | ||||
-rw-r--r-- | muse/muse/midiedit/ecanvas.cpp | 2 | ||||
-rw-r--r-- | muse/muse/midiedit/pianoroll.cpp | 22 | ||||
-rw-r--r-- | muse/muse/muse.cpp | 25 | ||||
-rw-r--r-- | muse/muse/shortcuts.cpp | 781 | ||||
-rw-r--r-- | muse/muse/shortcuts.h | 223 | ||||
-rw-r--r-- | muse/muse/transport.cpp | 2 | ||||
-rw-r--r-- | muse/muse/widgets/shortcutcapturedialog.cpp | 105 | ||||
-rw-r--r-- | muse/muse/widgets/shortcutcapturedialog.h | 18 | ||||
-rw-r--r-- | muse/muse/widgets/shortcutcapturedialog.ui | 135 | ||||
-rw-r--r-- | muse/muse/widgets/shortcutconfig.cpp | 85 | ||||
-rw-r--r-- | muse/muse/widgets/shortcutconfig.h | 17 | ||||
-rw-r--r-- | muse/muse/widgets/shortcutconfig.ui | 24 |
15 files changed, 691 insertions, 779 deletions
diff --git a/muse/doc/man/de/midirecording.tex b/muse/doc/man/de/midirecording.tex index 63af45a1..8036ba66 100644 --- a/muse/doc/man/de/midirecording.tex +++ b/muse/doc/man/de/midirecording.tex @@ -35,5 +35,4 @@ Zunächst erzeugen wir einen ''MidiInput'' Track und checken, ob das Keyboard richtig angeschlossen ist: - \Fig{add_miditrack} diff --git a/muse/muse/arranger/arranger.cpp b/muse/muse/arranger/arranger.cpp index 8215028f..d3d2b560 100644 --- a/muse/muse/arranger/arranger.cpp +++ b/muse/muse/arranger/arranger.cpp @@ -1226,6 +1226,7 @@ void Arranger::moveTrack(Track* src, Track* dst) void Arranger::keyPressEvent(QKeyEvent* e) { +#if 0 //TODOB int key = e->key(); bool keypress_handled = false; @@ -1313,6 +1314,8 @@ void Arranger::keyPressEvent(QKeyEvent* e) if (!keypress_handled) { e->ignore(); } +#endif + e->ignore(); } diff --git a/muse/muse/midiedit/drumedit.cpp b/muse/muse/midiedit/drumedit.cpp index 344af693..61537069 100644 --- a/muse/muse/midiedit/drumedit.cpp +++ b/muse/muse/midiedit/drumedit.cpp @@ -123,7 +123,7 @@ DrumEdit::DrumEdit(PartList* pl, bool init) QToolBar* transport = addToolBar(tr("Transport")); muse->setupTransportToolbar(transport); - // dont´t show pitch value in toolbar + // dont´how pitch value in toolbar addToolBarBreak(); toolbar = new Toolbar1(initRaster, initQuant, false); addToolBar(toolbar); @@ -354,6 +354,10 @@ static int rasterTable[] = { void DrumEdit::keyPressEvent(QKeyEvent* event) { + event->ignore(); + return; +#if 0 +//TODOB DrumCanvas* dc = canvas(); int index = 0; int n = sizeof(rasterTable); @@ -393,13 +397,6 @@ void DrumEdit::keyPressEvent(QKeyEvent* event) tools2->set(RubberTool); return; } - - /* - else if (key == shortcuts[SHRT_INSERT_AT_LOCATION].key) { - pc->pianoCmd(CMD_INSERT); - return; - } - */ else if (key == shortcuts[SHRT_SET_QUANT_1].key) val = rasterTable[8 + off]; else if (key == shortcuts[SHRT_SET_QUANT_2].key) @@ -416,17 +413,6 @@ void DrumEdit::keyPressEvent(QKeyEvent* event) val = rasterTable[2 + off]; else if (key == shortcuts[SHRT_TOGGLE_TRIOL].key) val = rasterTable[index + ((off == 0) ? 9 : 0)]; - /* - else if (key == shortcuts[SHRT_EVENT_COLOR].key) { - if (colorMode == 0) - colorMode = 1; - else if (colorMode == 1) - colorMode = 2; - else - colorMode = 0; - setEventColorMode(colorMode); - return; - }*/ else if (key == shortcuts[SHRT_TOGGLE_PUNCT].key) val = rasterTable[index + ((off == 18) ? 9 : 18)]; @@ -448,6 +434,7 @@ void DrumEdit::keyPressEvent(QKeyEvent* event) setRaster(val); toolbar->setQuant(quant()); toolbar->setRaster(raster()); +#endif } //--------------------------------------------------------- @@ -456,6 +443,7 @@ void DrumEdit::keyPressEvent(QKeyEvent* event) void DrumEdit::initShortcuts() { +#if 0 //TODOB cutAction->setShortcut(shortcuts[SHRT_CUT].key); copyAction->setShortcut(shortcuts[SHRT_COPY].key); pasteAction->setShortcut(shortcuts[SHRT_PASTE].key); @@ -468,6 +456,7 @@ void DrumEdit::initShortcuts() cmdActions[DrumCanvas::CMD_SELECT_INVERT]->setShortcut(shortcuts[SHRT_SELECT_INVERT].key); cmdActions[DrumCanvas::CMD_SELECT_ILOOP]->setShortcut(shortcuts[SHRT_SELECT_ILOOP].key); cmdActions[DrumCanvas::CMD_SELECT_OLOOP]->setShortcut(shortcuts[SHRT_SELECT_OLOOP].key); +#endif } //--------------------------------------------------------- diff --git a/muse/muse/midiedit/ecanvas.cpp b/muse/muse/midiedit/ecanvas.cpp index 4c60a792..8a855ef3 100644 --- a/muse/muse/midiedit/ecanvas.cpp +++ b/muse/muse/midiedit/ecanvas.cpp @@ -204,6 +204,7 @@ MidiTrack* EventCanvas::track() const void EventCanvas::keyPress(QKeyEvent* event) { +#if 0 // TODOB int key = event->key(); if (event->modifiers() & Qt::ShiftModifier) key += Qt::SHIFT; @@ -302,6 +303,7 @@ void EventCanvas::keyPress(QKeyEvent* event) modifySelected(NoteInfo::VAL_TIME, 0 - editor->raster()); } else +#endif event->ignore(); } diff --git a/muse/muse/midiedit/pianoroll.cpp b/muse/muse/midiedit/pianoroll.cpp index b7def4d9..f7adad32 100644 --- a/muse/muse/midiedit/pianoroll.cpp +++ b/muse/muse/midiedit/pianoroll.cpp @@ -252,6 +252,7 @@ PianoRoll::PianoRoll(PartList* pl, bool init) // // install misc shortcuts // +#if 0 //TODOB QShortcut* sc; sc = new QShortcut(shortcuts[SHRT_POS_INC].key, this); sc->setContext(Qt::WindowShortcut); @@ -265,6 +266,8 @@ PianoRoll::PianoRoll(PartList* pl, bool init) sc->setContext(Qt::WindowShortcut); connect(sc, SIGNAL(activated()), SLOT(close())); +#endif + connect(song, SIGNAL(songChanged(int)), canvas(), SLOT(songChanged(int))); connect(followSongAction, SIGNAL(toggled(bool)), canvas(), SLOT(setFollow(bool))); canvas()->selectFirst(); @@ -435,19 +438,20 @@ void PianoRoll::soloChanged(bool flag) song->setSolo(canvas()->track(), flag); } -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 - }; - //--------------------------------------------------------- // viewKeyPressEvent //--------------------------------------------------------- void PianoRoll::keyPressEvent(QKeyEvent* event) { +#if 0 //TODOB + 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 + }; + if (info->hasFocus()) { event->ignore(); return; @@ -544,6 +548,8 @@ void PianoRoll::keyPressEvent(QKeyEvent* event) setRaster(val); toolbar->setQuant(quant()); toolbar->setRaster(raster()); +#endif + event->ignore(); } //--------------------------------------------------------- @@ -583,6 +589,7 @@ void PianoRoll::setEventColorMode(int mode) void PianoRoll::initShortcuts() { +#if 0 //TODOB cmdActions[PianoCanvas::CMD_SELECT_NONE]->setShortcut(shortcuts[SHRT_SELECT_ALL].key); cmdActions[PianoCanvas::CMD_SELECT_NONE]->setShortcut(shortcuts[SHRT_SELECT_NONE].key); cmdActions[PianoCanvas::CMD_SELECT_INVERT]->setShortcut(shortcuts[SHRT_SELECT_INVERT].key); @@ -609,6 +616,7 @@ void PianoRoll::initShortcuts() cmdActions[PianoCanvas::CMD_CREATE_MEASURE]->setShortcut(shortcuts[SHRT_CREATE_MEASURE].key); menu_ids[CMD_CONFIG_QUANT]->setShortcut(shortcuts[SHRT_CONFIG_QUANT].key); +#endif } //--------------------------------------------------------- diff --git a/muse/muse/muse.cpp b/muse/muse/muse.cpp index 6fe2f662..e5135990 100644 --- a/muse/muse/muse.cpp +++ b/muse/muse/muse.cpp @@ -471,11 +471,16 @@ MusE::MusE() projectPropsDialog = 0; listEditor = 0; - startAction = new QAction(QIcon(":/xpm/start.xpm"), "start", this); - rewindAction = new QAction(QIcon(":/xpm/frewind.xpm"), "rewind", this); + startAction = getAction("play", this); + startAction->setIcon(QIcon(":/xpm/start.xpm")); + startAction->setText(tr("start")); + connect(startAction, SIGNAL(triggered()), song, SLOT(rewindStart())); + + rewindAction = new QAction(QIcon(":/xpm/frewind.xpm"), "rewind", this); forwardAction = new QAction(QIcon(":/xpm/fforward.xpm"), "forward", this); - stopAction = new QAction(QIcon(":/xpm/stop.xpm"), "stop", this); - playAction = new QAction(QIcon(":/xpm/play.xpm"), "play", this); + stopAction = new QAction(QIcon(":/xpm/stop.xpm"), "stop", this); + playAction = new QAction(QIcon(":/xpm/play.xpm"), "play", this); + playAction->setCheckable(true); stopAction->setCheckable(true); @@ -519,9 +524,6 @@ MusE::MusE() punchoutAction->setCheckable(true); connect(punchoutAction, SIGNAL(toggled(bool)), song, SLOT(setPunchout(bool))); - startAction->setWhatsThis(tr(infoStartButton)); - connect(startAction, SIGNAL(triggered()), song, SLOT(rewindStart())); - rewindAction->setWhatsThis(tr(infoRewindButton)); forwardAction->setWhatsThis(tr(infoForwardButton)); @@ -1690,6 +1692,7 @@ void MusE::selectProject(QAction* a) void MusE::kbAccel(int key) { +#if 0 //TODOB if (key == shortcuts[SHRT_TOGGLE_METRO].key) { song->setClick(!song->click()); } @@ -1739,6 +1742,7 @@ void MusE::kbAccel(int key) if (debugMsg) printf("unknown kbAccel 0x%x\n", key); } +#endif } //--------------------------------------------------------- @@ -1759,7 +1763,8 @@ class MuseApplication : public QApplication { muse = m; } - bool notify(QObject* receiver, QEvent* event) { + bool notify(QObject* receiver, QEvent* event) + { bool flag = QApplication::notify(receiver, event); if (event->type() == QEvent::KeyPress) { QKeyEvent* ke = (QKeyEvent*)event; @@ -2499,6 +2504,7 @@ void MusE::startEditInstrument() void MusE::updateConfiguration() { +#if 0 //TODOB fileOpenAction->setShortcut(shortcuts[SHRT_OPEN].key); fileSaveAction->setShortcut(shortcuts[SHRT_SAVE].key); @@ -2567,6 +2573,8 @@ void MusE::updateConfiguration() // menu_ids[CMD_OPEN_HOMEPAGE]->setShortcut(shortcuts[SHRT_OPEN_HOMEPAGE].key); // menu_ids[CMD_OPEN_BUG]->setShortcut(shortcuts[SHRT_OPEN_BUG].key); menu_ids[CMD_START_WHATSTHIS]->setShortcut(shortcuts[SHRT_START_WHATSTHIS].key); +#endif + #if 0 //TD menuEdit->setShortcut(shortcuts[SHRT_OPEN_MIDI_TRANSFORM].key, menu_ids[CMD_OPEN_MIDI_TRANSFORM]); @@ -2853,6 +2861,7 @@ int main(int argc, char* argv[]) initMidiController(); initMidiInstruments(); MuseApplication app(argc, argv); + initShortcuts(); config.fonts[0] = QFont(QString("helvetica"), 10, QFont::Normal); config.fonts[1] = QFont(QString("helvetica"), 6, QFont::Normal); diff --git a/muse/muse/shortcuts.cpp b/muse/muse/shortcuts.cpp index 9ef9b0ae..8ba4e862 100644 --- a/muse/muse/shortcuts.cpp +++ b/muse/muse/shortcuts.cpp @@ -42,743 +42,751 @@ const shortcut_cg ShortcutConfig::shortcut_category[] = { { ALL_SHRT , QT_TR_NOOP("All categories") } }; -Shortcut shortcuts[SHRT_NUM_OF_ELEMENTS] = { - { +QMap<QString, Shortcut*> shortcuts; + +static Shortcut sc[] = { + Shortcut( "play", QT_TR_NOOP("Transport: Start playback from current location"), GLOBAL_SHRT, - Qt::Key_Enter, - }, - { + QKeySequence(Qt::Key_Enter) + ), + Shortcut( "toggle_metro", QT_TR_NOOP("Transport: Toggle metronome"), GLOBAL_SHRT, - Qt::Key_C, - }, - { + QKeySequence(Qt::Key_C) + ), + Shortcut( "stop", QT_TR_NOOP("Transport: Stop Playback"), GLOBAL_SHRT, - Qt::Key_Insert, - }, - { + Qt::Key_Insert + ), + Shortcut( "play_toggle", QT_TR_NOOP("Transport: Play, Stop, Rewind"), GLOBAL_SHRT, - Qt::Key_Space, - }, - { + Qt::Key_Space + ), + Shortcut( "goto_left", QT_TR_NOOP("Transport: Goto left marker"), GLOBAL_SHRT, - Qt::Key_End, - }, - { + Qt::Key_End + ), + Shortcut( "goto_right", QT_TR_NOOP("Transport: Goto right marker"), GLOBAL_SHRT, - Qt::Key_PageDown, - }, - { + Qt::Key_PageDown + ), + Shortcut( "toggle_loop", QT_TR_NOOP("Transport: Toggle Loop section"), GLOBAL_SHRT, - Qt::Key_Slash, - }, - { + Qt::Key_Slash + ), + Shortcut( "toggle_rec", QT_TR_NOOP("Transport: Toggle Record"), GLOBAL_SHRT, - Qt::Key_Asterisk, - }, - { + Qt::Key_Asterisk + ), + Shortcut( "copy", QT_TR_NOOP("Edit: Copy"), INVIS_SHRT, - Qt::CTRL + Qt::Key_C, - }, - { + Qt::CTRL + Qt::Key_C + ), + Shortcut( "undo", QT_TR_NOOP("Edit: Undo"), INVIS_SHRT, - Qt::CTRL + Qt::Key_Z, - }, - { + Qt::CTRL + Qt::Key_Z + ), + Shortcut( "redo", QT_TR_NOOP("Edit: Redo"), INVIS_SHRT, - Qt::CTRL + Qt::Key_Y, - }, - { + Qt::CTRL + Qt::Key_Y + ), + Shortcut( "cut", QT_TR_NOOP("Edit: Cut" ), INVIS_SHRT, - Qt::CTRL + Qt::Key_X, - }, - { + Qt::CTRL + Qt::Key_X + ), + Shortcut( "paste", QT_TR_NOOP("Edit: Paste,"), INVIS_SHRT, - Qt::CTRL + Qt::Key_V, - }, - { + Qt::CTRL + Qt::Key_V + ), + Shortcut( "delete", QT_TR_NOOP("Edit: Delete" ), INVIS_SHRT, - Qt::Key_Delete, - }, - { + Qt::Key_Delete + ), + Shortcut( "open_project", QT_TR_NOOP("File: Open from disk"), ARRANG_SHRT + DEDIT_SHRT, - Qt::CTRL + Qt::Key_O, - }, - { + Qt::CTRL + Qt::Key_O + ), + Shortcut( "save_project", QT_TR_NOOP("File: Save project"), ARRANG_SHRT + DEDIT_SHRT, - Qt::CTRL + Qt::Key_S, - }, - { + Qt::CTRL + Qt::Key_S + ), + Shortcut( "open_recent", QT_TR_NOOP("File: Open recent file"), ARRANG_SHRT, - Qt::CTRL + Qt::Key_1, - }, - { + Qt::CTRL + Qt::Key_1 + ), + Shortcut( "import_midi", QT_TR_NOOP("File: Import midi file"), - ARRANG_SHRT, - 0 , - }, - { + ARRANG_SHRT, + 0 + ), + Shortcut( "export_midi", QT_TR_NOOP("File: Export midi file"), ARRANG_SHRT, - 0 , - }, - { + 0 + ), + Shortcut( "import_audio", QT_TR_NOOP("File: Import audio file"), ARRANG_SHRT, - 0 , - }, - { + 0 + ), + Shortcut( "quit", QT_TR_NOOP("File: Quit MusE"), ARRANG_SHRT, - Qt::CTRL + Qt::Key_Q, - }, - { + Qt::CTRL + Qt::Key_Q + ), + Shortcut( "select_parts_on_track", QT_TR_NOOP("Edit: Select parts on track"), ARRANG_SHRT, - Qt::CTRL+ Qt::ALT + Qt::Key_P, - }, - { + Qt::CTRL+ Qt::ALT + Qt::Key_P + ), + Shortcut( "open_pianoroll", QT_TR_NOOP("Open pianoroll"), ARRANG_SHRT, - Qt::CTRL + Qt::Key_E, - }, - { + Qt::CTRL + Qt::Key_E + ), + Shortcut( "open_drumedit", QT_TR_NOOP("Open drumeditor"), ARRANG_SHRT, - Qt::CTRL + Qt::Key_D, - }, - { + Qt::CTRL + Qt::Key_D + ), + Shortcut( "open_listedit", QT_TR_NOOP("Open listeditor"), ARRANG_SHRT, - Qt::CTRL + Qt::Key_L, - }, - { + Qt::CTRL + Qt::Key_L + ), + Shortcut( "open_graph_master", QT_TR_NOOP("Open graphical mastertrack editor"), ARRANG_SHRT, - Qt::CTRL + Qt::Key_M, - }, - { + Qt::CTRL + Qt::Key_M + ), + Shortcut( "open_list_master", QT_TR_NOOP("Open list mastertrack editor"), ARRANG_SHRT, - Qt::CTRL + Qt::SHIFT + Qt::Key_M, - }, - { + Qt::CTRL + Qt::SHIFT + Qt::Key_M + ), + Shortcut( "add_midi_track", QT_TR_NOOP("Add midi track"), ARRANG_SHRT, - Qt::CTRL + Qt::Key_J, - }, - { + Qt::CTRL + Qt::Key_J + ), + Shortcut( "add_drum_track", QT_TR_NOOP("Add drum track"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "add_wave_track", QT_TR_NOOP("Add wave track"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "add_audio_output", QT_TR_NOOP("Add audio output"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "add_audio_group", QT_TR_NOOP("Add audio group"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "add_audio_input", QT_TR_NOOP("Add audio input"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "global_cut", QT_TR_NOOP("Structure: Global cut"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "global_insert", QT_TR_NOOP("Structure: Global insert"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "global_split", QT_TR_NOOP("Structure: Global split"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "copy_range", QT_TR_NOOP("Structure: Copy range"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "cut_events", QT_TR_NOOP("Structure: Cut events"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "toggle_mixer", QT_TR_NOOP("View: Open mixer window"), ARRANG_SHRT, - Qt::Key_F10, - }, - { + Qt::Key_F10 + ), + Shortcut( "toggle_transport", QT_TR_NOOP("View: Toggle transport window"), ARRANG_SHRT, - Qt::Key_F11, - }, - { + Qt::Key_F11 + ), + Shortcut( "toggle_bigtime", QT_TR_NOOP("View: Toggle bigtime window"), ARRANG_SHRT, - Qt::Key_F12, - }, - { + Qt::Key_F12 + ), + Shortcut( "marker_window", QT_TR_NOOP("View: Open marker window"), ARRANG_SHRT, - Qt::Key_F9, - }, - { + Qt::Key_F9 + ), + Shortcut( "follow_jump", QT_TR_NOOP("Settings: Follow song by page"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "follow_no", QT_TR_NOOP("Settings: Follow song off"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "follow_continuous", QT_TR_NOOP("Settings: Follow song continuous"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "configure_shortcuts", QT_TR_NOOP("Settings: Configure shortcuts"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "configure_metronome", QT_TR_NOOP("Settings: Configure metronome"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "configure_midi_sync", QT_TR_NOOP("Settings: Midi sync configuration"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "configure_midi_file", QT_TR_NOOP("Settings: Midi file export configuration"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "configure_midi_ports", QT_TR_NOOP("Settings: Midi ports / Soft Synth"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "configure_audio_ports", QT_TR_NOOP("Settings: Audio subsystem configuration"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_edit_instruments", QT_TR_NOOP("Midi: Edit midi instruments"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_remote_control", QT_TR_NOOP("Midi: Midi remote control"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_reset", QT_TR_NOOP("Midi: Reset midi"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_init", QT_TR_NOOP("Midi: Init midi"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_local_off", QT_TR_NOOP("Midi: Midi local off"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "audio_bounce_to_track", QT_TR_NOOP("Audio: Bounce audio to track"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "audio_bounce_to_file", QT_TR_NOOP("Audio: Bounce audio to file"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "audio_restart", QT_TR_NOOP("Audio: Restart audio"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "open_help", QT_TR_NOOP("Help: Open Manual"), ARRANG_SHRT, - Qt::Key_F1, - }, - { + Qt::Key_F1 + ), + Shortcut( "toggle_whatsthis", QT_TR_NOOP("Help: Toggle whatsthis mode"), ARRANG_SHRT, - Qt::SHIFT + Qt::Key_F1, - }, - { + Qt::SHIFT + Qt::Key_F1 + ), + Shortcut( "edit_selected_part", QT_TR_NOOP("Edit: Edit selected part"), ARRANG_SHRT, - Qt::Key_Return, - }, - { + Qt::Key_Return + ), + Shortcut( "sel_part_above", QT_TR_NOOP("Edit: Select nearest part on track above"), ARRANG_SHRT, - Qt::Key_Up, - }, - { + Qt::Key_Up + ), + Shortcut( "sel_part_above_add", QT_TR_NOOP("Edit: Add nearest part on track above"), ARRANG_SHRT, - Qt::SHIFT + Qt::Key_Up, - }, - { + Qt::SHIFT + Qt::Key_Up + ), + Shortcut( "sel_part_below", QT_TR_NOOP("Edit: Select nearest part on track below"), ARRANG_SHRT, - Qt::Key_Down, - }, - { + Qt::Key_Down + ), + Shortcut( "sel_part_below_add", QT_TR_NOOP("Edit: Add nearest part on track below"), ARRANG_SHRT, - Qt::SHIFT + Qt::Key_Down, - }, - { + Qt::SHIFT + Qt::Key_Down + ), + Shortcut( "midi_transpose", QT_TR_NOOP("Midi: Transpose"), ARRANG_SHRT + PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "sel_all", QT_TR_NOOP("Edit: Select all"), ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, - Qt::CTRL + Qt::Key_A, - }, - { + Qt::CTRL + Qt::Key_A + ), + Shortcut( "sel_none", QT_TR_NOOP("Edit: Select none"), ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, - Qt::CTRL + Qt::SHIFT + Qt::Key_A, - }, - { + Qt::CTRL + Qt::SHIFT + Qt::Key_A + ), + Shortcut( "sel_inv", QT_TR_NOOP("Edit: Invert selection"), ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, - Qt::CTRL + Qt::Key_I, - }, - { + Qt::CTRL + Qt::Key_I + ), + Shortcut( "sel_ins_loc", QT_TR_NOOP("Edit: Select events/parts inside locators"), ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "sel_out_loc", QT_TR_NOOP("Edit: Select events/parts outside locators"), ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "sel_left", QT_TR_NOOP("Edit: Select nearest part/event to the left"), ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, - Qt::Key_Left, - }, - { + Qt::Key_Left + ), + Shortcut( "sel_left_add", QT_TR_NOOP("Edit: Add nearest part/event to the left to selection"), PROLL_SHRT + DEDIT_SHRT, - Qt::Key_Left + Qt::SHIFT, - }, - { + Qt::Key_Left + Qt::SHIFT + ), + Shortcut( "sel_right", QT_TR_NOOP("Edit: Select nearest part/event to the left"), ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, - Qt::Key_Right, - }, - { + Qt::Key_Right + ), + Shortcut( "sel_right_add", QT_TR_NOOP("Edit: Add nearest part/event to the right to selection"), PROLL_SHRT + DEDIT_SHRT, - Qt::Key_Right + Qt::SHIFT, - }, - { + Qt::Key_Right + Qt::SHIFT + ), + Shortcut( "loc_to_sel", QT_TR_NOOP("Edit: Set locators to selection"), ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, - Qt::ALT + Qt::Key_P, - }, - { + Qt::ALT + Qt::Key_P + ), + Shortcut( "sel_inc_pitch", QT_TR_NOOP("Edit: Increase pitch"), PROLL_SHRT + DEDIT_SHRT, - Qt::CTRL + Qt::Key_Up, - }, - { + Qt::CTRL + Qt::Key_Up + ), + Shortcut( "sel_dec_pitch", QT_TR_NOOP("Edit: Decrease pitch"), PROLL_SHRT + DEDIT_SHRT, - Qt::CTRL + Qt::Key_Down, - }, - { + Qt::CTRL + Qt::Key_Down + ), + Shortcut( "midi_fixed_len", QT_TR_NOOP("Edit: Set fixed length on midi events"), DEDIT_SHRT, - Qt::ALT + Qt::Key_L, - }, - { + Qt::ALT + Qt::Key_L + ), + Shortcut( "midi_over_quant", QT_TR_NOOP("Quantize: Over Quantize"), PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_quant_noteon", QT_TR_NOOP("Quantize: Note On Quantize"), PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_quant_noteoff", QT_TR_NOOP("Quantize: Note On/Off Quantize"), PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_quant_iterative", QT_TR_NOOP("Quantize: Iterative Quantize"), PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "config_quant", QT_TR_NOOP("Quantize: Configure quant"), PROLL_SHRT, - Qt::CTRL + Qt::ALT + Qt::Key_Q, - }, - { + Qt::CTRL + Qt::ALT + Qt::Key_Q + ), + Shortcut( "midi_mod_gate_time", QT_TR_NOOP("Quantize: Modify Gate Time"), PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_mod_velo", QT_TR_NOOP("Quantize: Modify Velocity"), PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_crescendo", QT_TR_NOOP("Edit: Crescendo"), PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_thin_out", QT_TR_NOOP("Edit: Thin Out"), PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_erase_event", QT_TR_NOOP("Edit: Erase Event"), PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_note_shift", QT_TR_NOOP("Edit: Note Shift"), PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_move_clock", QT_TR_NOOP("Edit: Move Clock"), PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_copy_measure", QT_TR_NOOP("Edit: Copy Measure"), PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_erase_measure", QT_TR_NOOP("Edit: Erase Measure"), PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_delete_measure", QT_TR_NOOP("Edit: Delete Measure"), PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "midi_create_measure", QT_TR_NOOP("Edit: Create Measure"), PROLL_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "change_event_color", QT_TR_NOOP("Edit: Change event color"), PROLL_SHRT, - Qt::Key_E, - }, - { + Qt::Key_E + ), + Shortcut( "pointer_tool", QT_TR_NOOP("Tool: Pointer"), ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, - Qt::Key_A, - }, - { + Qt::Key_A + ), + Shortcut( "pencil_tool", QT_TR_NOOP("Tool: Pencil"), ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, - Qt::Key_D, - }, - { + Qt::Key_D + ), + Shortcut( "eraser_tool", QT_TR_NOOP("Tool: Eraser"), ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, - Qt::Key_R, - }, - { + Qt::Key_R + ), + Shortcut( "line_draw_tool", QT_TR_NOOP("Tool: Line Draw"), PROLL_SHRT + DEDIT_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "scissor_tool", QT_TR_NOOP("Tool: Scissor"), ARRANG_SHRT, - Qt::Key_S, - }, - { + Qt::Key_S + ), + Shortcut( "glue_tool", QT_TR_NOOP("Tool: Glue"), ARRANG_SHRT, - Qt::Key_G, - }, - { + Qt::Key_G + ), + Shortcut( "mute_tool", QT_TR_NOOP("Tool: Mute"), ARRANG_SHRT, - 0, - }, - { + 0 + ), + Shortcut( "curpos_increase", QT_TR_NOOP("Transport: Increase current position"), GLOBAL_SHRT, - Qt::Key_Plus, - }, - { + Qt::Key_Plus + ), + Shortcut( "curpos_decrease", QT_TR_NOOP("Transport: Decrease current position"), GLOBAL_SHRT, - Qt::Key_Minus, - }, - { + Qt::Key_Minus + ), + Shortcut( "midi_quant_1", QT_TR_NOOP("Quantize: Set quantize to 1/1 note"), PROLL_SHRT, - Qt::Key_1, - }, - { + Qt::Key_1 + ), + Shortcut( "midi_quant_2", QT_TR_NOOP("Quantize: Set quantize to 1/2 note"), PROLL_SHRT, - Qt::Key_2, - }, - { + Qt::Key_2 + ), + Shortcut( "midi_quant_3", QT_TR_NOOP("Quantize: Set quantize to 1/4 note"), PROLL_SHRT, - Qt::Key_3, - }, - { + Qt::Key_3 + ), + Shortcut( "midi_quant_4", QT_TR_NOOP("Quantize: Set quantize to 1/8 note"), PROLL_SHRT, - Qt::Key_4, - }, - { + Qt::Key_4 + ), + Shortcut( "midi_quant_5", QT_TR_NOOP("Quantize: Set quantize to 1/16 note"), PROLL_SHRT, - Qt::Key_5, - }, - { + Qt::Key_5 + ), + Shortcut( "midi_quant_6", QT_TR_NOOP("Quantize: Set quantize to 1/32 note"), PROLL_SHRT, - Qt::Key_6, - }, - { + Qt::Key_6 + ), + Shortcut( "midi_quant_7", QT_TR_NOOP("Quantize: Set quantize to 1/64 note"), PROLL_SHRT, - Qt::Key_7, - }, - { + Qt::Key_7 + ), + Shortcut( "midi_quant_triol", QT_TR_NOOP("Quantize: Toggle triol quantization"), PROLL_SHRT, - Qt::Key_T, - }, - { + Qt::Key_T + ), + Shortcut( "midi_quant_punct", QT_TR_NOOP("Quantize: Toggle punctuation quantization"), PROLL_SHRT, - Qt::Key_Period, - }, - { + Qt::Key_Period + ), + Shortcut( "midi_quant_punct2", QT_TR_NOOP("Quantize: Toggle punctuation quantization (2)"), PROLL_SHRT, - Qt::Key_Comma, - }, - { + Qt::Key_Comma + ), + Shortcut( "lm_ins_tempo", QT_TR_NOOP("Insert Tempo"), LMEDIT_SHRT, - Qt::CTRL + Qt::Key_T, - }, - { + Qt::CTRL + Qt::Key_T + ), + Shortcut( "lm_ins_sig", QT_TR_NOOP("Insert Signature"), LMEDIT_SHRT, - Qt::CTRL + Qt::Key_R, - }, - { + Qt::CTRL + Qt::Key_R + ), + Shortcut( "lm_edit_beat", QT_TR_NOOP("Change Event Position"), LMEDIT_SHRT, - Qt::CTRL + Qt::SHIFT + Qt::Key_E, - }, - { + Qt::CTRL + Qt::SHIFT + Qt::Key_E + ), + Shortcut( "lm_edit_val", QT_TR_NOOP("Edit Event Value"), LMEDIT_SHRT, - Qt::CTRL + Qt::Key_E, - }, + Qt::CTRL + Qt::Key_E + ), }; KeyboardMovementIndicator shortcutsKbdMovement; //for keeping track of active part selected by kbd //--------------------------------------------------------- -// getShrtByTag +// initShortcuts //--------------------------------------------------------- -int getShrtByTag(const char* xml) +void initShortcuts() { - for (int i=0; i<SHRT_NUM_OF_ELEMENTS; i++) { - if (shortcuts[i].xml) { - if (strcmp(shortcuts[i].xml, xml) == 0) - return i; + for (unsigned i = 0; i < sizeof(sc)/sizeof(*sc); ++i) { + shortcuts[sc[i].xml] = &sc[i]; } } + +//--------------------------------------------------------- +// getShrtByTag +//--------------------------------------------------------- + +QKeySequence getShrtByTag(const char* xml) + { + return shortcuts[xml]->key; return -1; } @@ -789,10 +797,9 @@ int getShrtByTag(const char* xml) void writeShortCuts(Xml& xml) { xml.tag("shortcuts"); - for (int i=0; i < SHRT_NUM_OF_ELEMENTS; i++) { - if (shortcuts[i].xml != NULL && shortcuts[i].type != INVIS_SHRT) //Avoid nullptr & hardcoded shortcuts - xml.intTag(shortcuts[i].xml, shortcuts[i].key); - } + foreach(Shortcut* s, shortcuts) + if (s->xml && s->type != INVIS_SHRT) //Avoid nullptr & hardcoded shortcuts + xml.strTag(s->xml, s->key.toString(QKeySequence::PortableText)); xml.etag("shortcuts"); } @@ -802,16 +809,32 @@ void writeShortCuts(Xml& xml) void readShortCuts(QDomNode node) { - while (!node.isNull()) { + for (;!node.isNull(); node = node.nextSibling()) { QDomElement e = node.toElement(); - int index = getShrtByTag(e.tagName().toLatin1().data()); - if (index != -1) { - shortcuts[index].key = e.text().toInt(); - //printf("shortcuts[%d].key = %d, %s\n",index, shortcuts[index].key, shortcuts[index].descr); - } + Shortcut* s = shortcuts.value(e.tagName()); + if (s) + s->key = QKeySequence::fromString(e.text(), QKeySequence::PortableText); else printf("MusE:readShortCuts: unknown tag %s\n", e.tagName().toLatin1().data()); - node = node.nextSibling(); } } +//--------------------------------------------------------- +// getAction +// returns action for shortcut +//--------------------------------------------------------- + +QAction* getAction(const char* id, QObject* parent) + { + Shortcut* s = shortcuts.value(id); + if (s == 0) + return 0; + if (s->action == 0 || s->action->parent() != parent) { + s->action = new QAction(parent); + s->action->setShortcut(s->key); + s->action->setToolTip(s->descr); + s->action->setWhatsThis(s->descr); + } + return s->action; + } + diff --git a/muse/muse/shortcuts.h b/muse/muse/shortcuts.h index 8cc4d0b5..0a35c882 100644 --- a/muse/muse/shortcuts.h +++ b/muse/muse/shortcuts.h @@ -53,10 +53,20 @@ using AL::Xml; struct Shortcut { - const char* xml; /*! xml tag name for configuration file */ - QString descr; /*! Description of the shortcut, shown in editor. Mapped against ls[] in shortcuts.cpp */ - int type; /*! Bitmask category value mapped against PROLL_SHRT, DEDIT_SHRT etc. One shortcut can be a member of many categories */ - QKeySequence key; /*! shortcut key */ + const char* xml; /*! xml tag name for configuration file */ + QString descr; /*! Description of the shortcut, shown in editor. Mapped against ls[] in shortcuts.cpp */ + int type; /*! Bitmask category value mapped against PROLL_SHRT, DEDIT_SHRT etc. One shortcut can be a member of many categories */ + QKeySequence key; /*! shortcut key */ + QAction* action; + + Shortcut() { + xml = 0; + type = 0; + key = 0; + action = 0; + } + Shortcut(const char* x, const QString& d, int t, const QKeySequence& k) + : xml(x), descr(d), type(t), key(k) { action = 0; } }; //! Describes a shortcut category @@ -98,209 +108,10 @@ class KeyboardMovementIndicator { bool isValid() { return (lastSelectedPart && lastSelectedTrack); } }; -//! Enumeration of the configurable shortcuts -enum { - //Transport/Positioning - SHRT_PLAY_SONG, // enter - SHRT_PLAY_TOGGLE, // space - SHRT_STOP, //Insert - SHRT_GOTO_LEFT, //End-keypad - SHRT_GOTO_RIGHT, //Cursordown-keypad - SHRT_POS_INC, // Plus - SHRT_POS_DEC, // Minus - SHRT_TOGGLE_LOOP, // Slash - SHRT_TOGGLE_METRO, // C - SHRT_START_REC, // *(keypad) - - //Main + Drumeditor - SHRT_OPEN, //Ctrl+O - SHRT_SAVE, //Ctrl+S - - //Used throughout the app: - SHRT_UNDO, //Ctrl+Z - SHRT_REDO, //Ctrl+Y - SHRT_COPY, //Ctrl+C - SHRT_CUT, //Ctrl+X - SHRT_PASTE, //Ctrl+V - SHRT_DELETE,//Delete - - - //Main: - SHRT_OPEN_RECENT, //Ctrl+1 - SHRT_LOAD_TEMPLATE, //Default: undefined - SHRT_CONFIG_PRINTER, //Ctrl+P - SHRT_IMPORT_MIDI, //Default: undefined - SHRT_EXPORT_MIDI, //Default: undefined - SHRT_IMPORT_AUDIO, //Default: undefined - SHRT_QUIT, //Default: Ctrl+Q - - SHRT_DESEL_PARTS, //Ctrl+B - SHRT_SELECT_PRTSTRACK, //Default: undefined - SHRT_OPEN_PIANO, //Ctrl+E - SHRT_OPEN_TRACKER, //Ctrl+T - SHRT_OPEN_SCORE, //Ctrl+R - SHRT_OPEN_DRUMS, //Ctrl+D - SHRT_OPEN_LIST, //Ctrl+L - SHRT_OPEN_GRAPHIC_MASTER, //Ctrl+M - SHRT_OPEN_LIST_MASTER, //Ctrl+Shift+M - SHRT_OPEN_MIDI_TRANSFORM, //Ctrl+T - - SHRT_GLOBAL_CUT, //Default: undefined - SHRT_GLOBAL_INSERT, //Default: undefined - SHRT_GLOBAL_SPLIT, //Default: undefined - SHRT_COPY_RANGE, //Default: undefined - SHRT_CUT_EVENTS, //Default: undefined - - SHRT_OPEN_TRANSPORT, //F11 - SHRT_OPEN_BIGTIME, //F12 - SHRT_OPEN_MIXER, //Ctrl+* - SHRT_OPEN_MARKER, // F9 - SHRT_OPEN_CLIPS, //Default: undefined - - SHRT_FOLLOW_JUMP, //Default: undefined - SHRT_FOLLOW_NO, //Default: undefined - SHRT_FOLLOW_CONTINUOUS, //Default: undefined - -// SHRT_GLOBAL_CONFIG, //Default: undefined - SHRT_CONFIG_SHORTCUTS, //Default: undefined - SHRT_CONFIG_METRONOME, //Default: undefined - SHRT_CONFIG_MIDISYNC, //Default: undefined - SHRT_MIDI_FILE_CONFIG, //Default: undefined -// SHRT_APPEARANCE_SETTINGS, //Default: undefined - SHRT_CONFIG_MIDI_PORTS, //Default: undefined - SHRT_CONFIG_AUDIO_PORTS, //Default: undefined - //SHRT_SAVE_GLOBAL_CONFIG, //Default: undefined - - SHRT_MIDI_EDIT_INSTRUMENTS, //Default: undefined - SHRT_MIDI_INPUT_TRANSFORM, //Default: undefined - SHRT_MIDI_INPUT_FILTER, //Default: undefined - SHRT_MIDI_INPUT_TRANSPOSE, //Default: undefined - SHRT_MIDI_REMOTE_CONTROL, //Default: undefined - SHRT_RANDOM_RHYTHM_GENERATOR, //Default: undefined - SHRT_MIDI_RESET, //Default: undefined - SHRT_MIDI_INIT, //Default: undefined - SHRT_MIDI_LOCAL_OFF, //Default: undefined - - SHRT_AUDIO_BOUNCE_TO_TRACK, //Default: undefined - SHRT_AUDIO_BOUNCE_TO_FILE, //Default: undefined - SHRT_AUDIO_RESTART, //Default: undefined - -// SHRT_MIXER_AUTOMATION, //Default: undefined - SHRT_MIXER_SNAPSHOT, //Default: undefined - SHRT_MIXER_AUTOMATION_CLEAR, //Default: undefined - - SHRT_ADD_MIDI_TRACK, //Default: Ctrl+J - SHRT_ADD_DRUM_TRACK, //Default: undefined - SHRT_ADD_WAVE_TRACK, //Default: undefined - SHRT_ADD_AUDIO_OUTPUT, //Default: undefined - SHRT_ADD_AUDIO_GROUP, //Default: undefined - SHRT_ADD_AUDIO_INPUT, //Default: undefined - SHRT_RESET_MIDI, //Ctrl+Alt+Z - - SHRT_OPEN_HELP, //F1 - SHRT_START_WHATSTHIS, //Shift-F1 - - //Arranger, parts: - SHRT_EDIT_PART, //Enter - SHRT_SEL_ABOVE, //Up - SHRT_SEL_ABOVE_ADD, //move up and add to selection - SHRT_SEL_BELOW, //Down - SHRT_SEL_BELOW_ADD, //move down and add to selection - - //To be in arranger, pianoroll & drumeditor - SHRT_SELECT_ALL, //Ctrl+A - SHRT_SELECT_NONE, //Ctrl+Shift+A - SHRT_SELECT_INVERT, //Ctrl+I - SHRT_SELECT_ILOOP, //Default: Undefined - SHRT_SELECT_OLOOP, //Default: Undefined - SHRT_SEL_LEFT, //left - SHRT_SEL_LEFT_ADD, //move left and add to selection - SHRT_SEL_RIGHT, //Right - SHRT_SEL_RIGHT_ADD, //move right and add to selection - SHRT_INC_PITCH, - SHRT_DEC_PITCH, - SHRT_INC_POS, - SHRT_DEC_POS, - SHRT_LOCATORS_TO_SELECTION, //Alt+P, currently in arranger & pianoroll - SHRT_ZOOM_IN, //H - pianoroll - SHRT_ZOOM_OUT, //G - pianoroll - SHRT_INSERT_AT_LOCATION, //Shift+CrsrRight - - SHRT_TOOL_1,//Shift+1 Pointer - SHRT_TOOL_2,//Shift+2 Pen - SHRT_TOOL_3,//Shift+3 Rubber - SHRT_TOOL_4,//Shift+4 - SHRT_TOOL_5,//Shift+5 - SHRT_TOOL_6,//Shift+6 - SHRT_TRANSPOSE, //Default: undefined - - //Shortcuts to be in pianoroll & drumeditor - SHRT_FIXED_LEN, //Alt+L, currently only drumeditor - SHRT_QUANTIZE, //q - SHRT_OVER_QUANTIZE, //Default: undefined - SHRT_ON_QUANTIZE, //Default: undefined - SHRT_ONOFF_QUANTIZE, //Default: undefined - SHRT_ITERATIVE_QUANTIZE, //Default: undefined - SHRT_CONFIG_QUANT, //Default: Ctrl+Alt+Q - SHRT_MODIFY_GATE_TIME, //Default: undefined - SHRT_MODIFY_VELOCITY, - SHRT_CRESCENDO, - - SHRT_THIN_OUT, - SHRT_ERASE_EVENT, - SHRT_NOTE_SHIFT, - SHRT_MOVE_CLOCK, - SHRT_COPY_MEASURE, - SHRT_ERASE_MEASURE, - SHRT_DELETE_MEASURE, - SHRT_CREATE_MEASURE, - SHRT_SET_QUANT_1, //1 - pianoroll - SHRT_SET_QUANT_2, //2 - pianoroll - SHRT_SET_QUANT_3, //3 - pianoroll - SHRT_SET_QUANT_4, //4 - pianoroll - SHRT_SET_QUANT_5, //5 - pianoroll - SHRT_SET_QUANT_6, //6 - pianoroll - SHRT_SET_QUANT_7, //7 - pianoroll - SHRT_TOGGLE_TRIOL, //t - SHRT_TOGGLE_PUNCT, //.-keypad - SHRT_TOGGLE_PUNCT2, // , - - SHRT_EVENT_COLOR, //e - - // Shortcuts for tools - // global - SHRT_TOOL_POINTER, // - SHRT_TOOL_PENCIL, - SHRT_TOOL_RUBBER, - - // pianoroll and drum editor - SHRT_TOOL_LINEDRAW, - - // arranger - SHRT_TOOL_SCISSORS, - SHRT_TOOL_GLUE, - SHRT_TOOL_MUTE, - - - //Listeditor: - SHRT_LE_INS_NOTES, //Ctrl+N - SHRT_LE_INS_SYSEX, //Ctrl+S - SHRT_LE_INS_CTRL, //Ctrl+T - SHRT_LE_INS_META, //Default: undefined - SHRT_LE_INS_CHAN_AFTERTOUCH,//Ctrl+A - SHRT_LE_INS_POLY_AFTERTOUCH,//Ctrl+P - - //List master editor: - SHRT_LM_INS_TEMPO, // Ctrl+T - SHRT_LM_INS_SIG, // Ctrl+R - SHRT_LM_EDIT_BEAT, // Ctrl+Shift+E - SHRT_LM_EDIT_VALUE,// Ctrl+E - - SHRT_NUM_OF_ELEMENTS // must be last - }; - -extern Shortcut shortcuts[SHRT_NUM_OF_ELEMENTS]; //size of last entry +extern QMap<QString, Shortcut*> shortcuts; extern KeyboardMovementIndicator shortcutsKbdMovement; extern void writeShortCuts(Xml& xml); extern void readShortCuts(QDomNode); +extern QAction* getAction(const char*, QObject* parent); +extern void initShortcuts(); #endif diff --git a/muse/muse/transport.cpp b/muse/muse/transport.cpp index 3f34db8f..aa8fcc7c 100644 --- a/muse/muse/transport.cpp +++ b/muse/muse/transport.cpp @@ -103,7 +103,7 @@ Transport::Transport() // AQ - Click - Sync //----------------------------------------------------- - clickButton->setShortcut(shortcuts[SHRT_TOGGLE_METRO].key); +//TODOB clickButton->setShortcut(shortcuts[SHRT_TOGGLE_METRO].key); connect(quantizeButton, SIGNAL(clicked(bool)), song, SLOT(setQuantize(bool))); connect(clickButton, SIGNAL(clicked(bool)), song, SLOT(setClick(bool))); diff --git a/muse/muse/widgets/shortcutcapturedialog.cpp b/muse/muse/widgets/shortcutcapturedialog.cpp index 30740516..dab3330f 100644 --- a/muse/muse/widgets/shortcutcapturedialog.cpp +++ b/muse/muse/widgets/shortcutcapturedialog.cpp @@ -21,78 +21,77 @@ #include "shortcutcapturedialog.h" #include "shortcuts.h" -ShortcutCaptureDialog::ShortcutCaptureDialog(QWidget* parent, int index) +//--------------------------------------------------------- +// ShortcutCaptureDialog +//--------------------------------------------------------- + +ShortcutCaptureDialog::ShortcutCaptureDialog(Shortcut* _s, QWidget* parent) : QDialog(parent) { setupUi(this); - QKeySequence q = QKeySequence(shortcuts[index].key); - oshrtLabel->setText(q); - connect(okButton, SIGNAL( clicked() ), this, SLOT( apply() ) ); - connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancel())); - shortcutindex = index; + s = _s; + + oshrtLabel->setText(s->key.toString(QKeySequence::NativeText)); + connect(clearButton, SIGNAL(clicked()), SLOT(clearClicked())); + clearClicked(); grabKeyboard(); - okButton->setText(tr("Ok")); - cancelButton->setText(tr("Cancel")); } +//--------------------------------------------------------- +// ShortcutCaptureDialog +//--------------------------------------------------------- + ShortcutCaptureDialog::~ShortcutCaptureDialog() { releaseKeyboard(); } +//--------------------------------------------------------- +// keyPressEvent +//--------------------------------------------------------- + void ShortcutCaptureDialog::keyPressEvent(QKeyEvent* e) { -#if 0 //TODOB - bool shift, alt, ctrl, conflict = false, realkey = false; - QString msgString = ""; - int temp_key; - shift = e->modifiers() & Qt::ShiftModifier; - ctrl = e->modifiers() & Qt::ControlModifier; - alt = e->modifiers() & Qt::AltModifier; - - //printf("Key total: %d, alt: %d, ctrl: %d shift: %d\n",e->key(), alt, ctrl, shift); - temp_key = e->key(); - if (shift) - temp_key += Qt::SHIFT; - if (ctrl) - temp_key += Qt::CTRL; - if (alt) - temp_key += Qt::ALT; - //printf("Final key assembled: %d\n",temp_key); - - // Check if this is a "real" key that completes a valid shortcut: + if (key.count() >= 4) + return; int k = e->key(); - if (k < 256 || k == Qt::Key_Enter || k == Qt::Key_Return || k >= Qt::Key_F1 && k <= Qt::Key_F12 || k == Qt::Key_Home || k == Qt::Key_PageUp - || k == Qt::Key_PageDown || k == Qt::Key_End || k == Qt::Key_Insert || k == Qt::Key_Delete) { - key = temp_key; - realkey = true; - QKeySequence q = QKeySequence(key); - QString keyString = q; - if (keyString != QString::null) - nshrtLabel->setText(q); + if (k == 0 || k == Qt::Key_Shift || k == Qt::Key_Control || + k == Qt::Key_Meta || k == Qt::Key_Alt || k == Qt::Key_AltGr + || k == Qt::Key_CapsLock || k == Qt::Key_NumLock + || k == Qt::Key_ScrollLock) + return; - // Check against conflicting shortcuts - for (int i=0; i < SHRT_NUM_OF_ELEMENTS; i++) { - if (i != shortcutindex) { //check all other than current shortcut - if (shortcuts[i].key == key && (shortcuts[i].type & (shortcuts[shortcutindex].type | GLOBAL_SHRT | INVIS_SHRT))) { - msgString = tr("Shortcut conflicts with ") + QString(shortcuts[i].descr); - conflict = true; - break; - } - } - } + k += e->modifiers(); + switch(key.count()) { + case 0: key = QKeySequence(k); break; + case 1: key = QKeySequence(key[0], k); break; + case 2: key = QKeySequence(key[0], key[1], k); break; + case 3: key = QKeySequence(key[0], key[1], key[2], k); break; } - messageLabel->setText(msgString); - okButton->setEnabled(conflict == false && realkey); - if (!realkey) - nshrtLabel->setText(tr("Undefined")); -#endif + // Check against conflicting shortcuts + bool conflict = false; + QString msgString; + foreach (Shortcut* ss, shortcuts) { + if ((s != ss) && (ss->key == key) + && (ss->type & (s->type | GLOBAL_SHRT | INVIS_SHRT))) { + msgString = tr("Shortcut conflicts with ") + ss->descr; + conflict = true; + break; + } + } + messageLabel->setText(msgString); + okButton->setEnabled(conflict == false); + nshrtLabel->setText(key.toString(QKeySequence::NativeText)); } -void ShortcutCaptureDialog::apply() +//--------------------------------------------------------- +// clearClicked +//--------------------------------------------------------- + +void ShortcutCaptureDialog::clearClicked() { - //return the shortcut to configurator widget: - done(key); + nshrtLabel->setText(tr("Undefined")); + key = 0; } diff --git a/muse/muse/widgets/shortcutcapturedialog.h b/muse/muse/widgets/shortcutcapturedialog.h index 2ddc696e..4c2b5b6c 100644 --- a/muse/muse/widgets/shortcutcapturedialog.h +++ b/muse/muse/widgets/shortcutcapturedialog.h @@ -29,20 +29,24 @@ #include "filedialog.h" #include "ui_shortcutcapturedialog.h" +//--------------------------------------------------------- +// ShortcutCaptureDialog +//--------------------------------------------------------- + class ShortcutCaptureDialog : public QDialog, public Ui::ShortcutCaptureDialogBase { Q_OBJECT private: - int shortcutindex; + Shortcut* s; void keyPressEvent(QKeyEvent* e); - int key; + QKeySequence key; - private slots: - void apply(); - void cancel() { reject(); }; + private slots: + void clearClicked(); - public: - ShortcutCaptureDialog(QWidget* parent = 0, int index = 0); + public: + ShortcutCaptureDialog(Shortcut* s = 0, QWidget* parent = 0); ~ShortcutCaptureDialog(); + QKeySequence getKey() const { return key; } }; diff --git a/muse/muse/widgets/shortcutcapturedialog.ui b/muse/muse/widgets/shortcutcapturedialog.ui index 8b7c4b97..0df2338f 100644 --- a/muse/muse/widgets/shortcutcapturedialog.ui +++ b/muse/muse/widgets/shortcutcapturedialog.ui @@ -1,7 +1,4 @@ <ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> <class>ShortcutCaptureDialogBase</class> <widget class="QDialog" name="ShortcutCaptureDialogBase" > <property name="geometry" > @@ -25,6 +22,51 @@ <property name="spacing" > <number>6</number> </property> + <item row="0" column="0" colspan="2" > + <widget class="QLabel" name="descrLabel" > + <property name="text" > + <string>Press up to 4 keys to enter shortcut sequence!</string> + </property> + <property name="alignment" > + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2" > + <widget class="QLabel" name="messageLabel" > + <property name="text" > + <string/> + </property> + </widget> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="oshrtTextLabel" > + <property name="text" > + <string>Old shortcut:</string> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QLineEdit" name="oshrtLabel" > + <property name="readOnly" > + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="0" > + <widget class="QLabel" name="nshrtTextLabel" > + <property name="text" > + <string>New shortcut:</string> + </property> + </widget> + </item> + <item row="3" column="1" > + <widget class="QLineEdit" name="nshrtLabel" > + <property name="readOnly" > + <bool>true</bool> + </property> + </widget> + </item> <item row="4" column="0" colspan="2" > <layout class="QHBoxLayout" > <property name="margin" > @@ -34,6 +76,13 @@ <number>6</number> </property> <item> + <widget class="QToolButton" name="clearButton" > + <property name="text" > + <string>Clear</string> + </property> + </widget> + </item> + <item> <spacer> <property name="orientation" > <enum>Qt::Horizontal</enum> @@ -71,55 +120,43 @@ </item> </layout> </item> - <item row="3" column="0" > - <widget class="QLabel" name="nshrtTextLabel" > - <property name="text" > - <string>New shortcut:</string> - </property> - </widget> - </item> - <item row="2" column="1" > - <widget class="QLineEdit" name="oshrtLabel" > - <property name="readOnly" > - <bool>true</bool> - </property> - </widget> - </item> - <item row="0" column="0" colspan="2" > - <widget class="QLabel" name="descrLabel" > - <property name="text" > - <string>Press keys to enter shortcut sequence!</string> - </property> - <property name="alignment" > - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="2" column="0" > - <widget class="QLabel" name="oshrtTextLabel" > - <property name="text" > - <string>Old shortcut:</string> - </property> - </widget> - </item> - <item row="3" column="1" > - <widget class="QLineEdit" name="nshrtLabel" > - <property name="readOnly" > - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2" > - <widget class="QLabel" name="messageLabel" > - <property name="text" > - <string/> - </property> - </widget> - </item> </layout> </widget> <layoutdefault spacing="6" margin="11" /> <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> <resources/> - <connections/> + <connections> + <connection> + <sender>okButton</sender> + <signal>clicked()</signal> + <receiver>ShortcutCaptureDialogBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>337</x> + <y>189</y> + </hint> + <hint type="destinationlabel" > + <x>242</x> + <y>194</y> + </hint> + </hints> + </connection> + <connection> + <sender>cancelButton</sender> + <signal>clicked()</signal> + <receiver>ShortcutCaptureDialogBase</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>425</x> + <y>194</y> + </hint> + <hint type="destinationlabel" > + <x>350</x> + <y>153</y> + </hint> + </hints> + </connection> + </connections> </ui> diff --git a/muse/muse/widgets/shortcutconfig.cpp b/muse/muse/widgets/shortcutconfig.cpp index 23b7f4c5..f797e8eb 100644 --- a/muse/muse/widgets/shortcutconfig.cpp +++ b/muse/muse/widgets/shortcutconfig.cpp @@ -22,6 +22,10 @@ #include "shortcutcapturedialog.h" #include "shortcuts.h" +//--------------------------------------------------------- +// ShortcutConfig +//--------------------------------------------------------- + ShortcutConfig::ShortcutConfig(QWidget* parent) : QDialog(parent) { @@ -42,86 +46,103 @@ ShortcutConfig::ShortcutConfig(QWidget* parent) for (int i=0; i < SHRT_NUM_OF_CATEGORIES; i++) { QTreeWidgetItem* newItem = new QTreeWidgetItem; newItem->setText(SHRT_CATEGORY_COL, tr(shortcut_category[i].name)); - newItem->setData(0, 1, i); + newItem->setData(0, Qt::UserRole, i); cgListView->addTopLevelItem(newItem); } updateSCListView(); } +//--------------------------------------------------------- +// updateSCListView +//--------------------------------------------------------- + void ShortcutConfig::updateSCListView(int category) { scListView->clear(); - for (int i=0; i < SHRT_NUM_OF_ELEMENTS; i++) { - if (shortcuts[i].type & category) { + foreach (Shortcut* s, shortcuts) { + if (s && (s->type & category)) { QTreeWidgetItem* newItem; newItem = new QTreeWidgetItem; - newItem->setText(SHRT_DESCR_COL, shortcuts[i].descr); - QKeySequence key = QKeySequence(shortcuts[i].key); - newItem->setText(SHRT_SHRTCUT_COL, key); - newItem->setData(0, 1, i); + newItem->setText(SHRT_DESCR_COL, s->descr); + QKeySequence seq = s->key; + newItem->setText(SHRT_SHRTCUT_COL, s->key.toString(QKeySequence::NativeText)); + newItem->setData(0, Qt::UserRole, s->xml); scListView->addTopLevelItem(newItem); } } } +//--------------------------------------------------------- +// assignShortcut +//--------------------------------------------------------- + void ShortcutConfig::assignShortcut() { QTreeWidgetItem* active = scListView->currentItem(); - int shortcutindex = active->data(0, 1).toInt(); - ShortcutCaptureDialog* sc = new ShortcutCaptureDialog(this, shortcutindex); - int key = sc->exec(); - delete(sc); - if (key != Rejected) { - shortcuts[shortcutindex].key = key; - QKeySequence keySequence = QKeySequence(key); - active->setText(SHRT_SHRTCUT_COL, keySequence); + Shortcut* s = shortcuts[active->data(0, Qt::UserRole).toString()]; + ShortcutCaptureDialog sc(s, this); + if (sc.exec()) { + s->key = sc.getKey(); + active->setText(SHRT_SHRTCUT_COL, s->key.toString(QKeySequence::NativeText)); _config_changed = true; } clearButton->setEnabled(true); - defineButton->setDown(false); } +//--------------------------------------------------------- +// clearShortcut +//--------------------------------------------------------- + void ShortcutConfig::clearShortcut() { QTreeWidgetItem* active = scListView->currentItem(); - int shortcutindex = active->data(0, 1).toInt(); - shortcuts[shortcutindex].key = 0; //Cleared + Shortcut* s = shortcuts[active->data(0, Qt::UserRole).toString()]; + s->key = 0; active->setText(SHRT_SHRTCUT_COL, ""); - clearButton->setDown(false); clearButton->setEnabled(false); _config_changed = true; } +//--------------------------------------------------------- +// categorySelChanged +//--------------------------------------------------------- + void ShortcutConfig::categorySelChanged(QTreeWidgetItem* i) { - int idx = i->data(0, 1).toInt(); + int idx = i->data(0, Qt::UserRole).toInt(); current_category = shortcut_category[idx].id_flag; updateSCListView(current_category); } +//--------------------------------------------------------- +// shortcutSelChanged +//--------------------------------------------------------- + void ShortcutConfig::shortcutSelChanged(QTreeWidgetItem* active) { - defineButton->setEnabled(true); - int index = active->data(0, 1).toInt(); - if (!shortcuts[index].key.isEmpty()) - clearButton->setEnabled(true); - else + defineButton->setEnabled(active != 0); + if (active == 0) { clearButton->setEnabled(false); + return; + } + Shortcut* s = shortcuts[active->data(0, Qt::UserRole).toString()]; + clearButton->setEnabled(s && !s->key.isEmpty()); } +//--------------------------------------------------------- +// closeEvent +//--------------------------------------------------------- + void ShortcutConfig::closeEvent(QCloseEvent*) { done(_config_changed); } +//--------------------------------------------------------- +// assignAll +//--------------------------------------------------------- + void ShortcutConfig::assignAll() { - applyButton->setDown(false); done(_config_changed); } - -QString ShortcutConfig::Translate(const char* locstr) - { - //printf("In: %s - Trans1: %s\n", locstr, tr(locstr).toLatin1().data()); - return tr(locstr); - } diff --git a/muse/muse/widgets/shortcutconfig.h b/muse/muse/widgets/shortcutconfig.h index c3b14381..0e9e24b2 100644 --- a/muse/muse/widgets/shortcutconfig.h +++ b/muse/muse/widgets/shortcutconfig.h @@ -16,12 +16,15 @@ #include "shortcuts.h" #define SHRT_CATEGORY_COL 0 -enum - { +enum { SHRT_DESCR_COL = 0, SHRT_SHRTCUT_COL }; +//--------------------------------------------------------- +// ShortcutConfig +//--------------------------------------------------------- + class ShortcutConfig : public QDialog, public Ui::ShortcutConfigBase { Q_OBJECT private: @@ -30,20 +33,18 @@ class ShortcutConfig : public QDialog, public Ui::ShortcutConfigBase { void updateSCListView() { updateSCListView(current_category); } void closeEvent(QCloseEvent *e); - private slots: + private slots: void categorySelChanged(QTreeWidgetItem*); void shortcutSelChanged(QTreeWidgetItem*); void assignShortcut(); void clearShortcut(); void assignAll(); - - public: + public: ShortcutConfig(QWidget* parent = 0); - static QString Translate(const char*); bool _config_changed; - static const char* ls[]; static const shortcut_cg shortcut_category[]; -}; + }; #endif + diff --git a/muse/muse/widgets/shortcutconfig.ui b/muse/muse/widgets/shortcutconfig.ui index 26dfbd41..92b82dd7 100644 --- a/muse/muse/widgets/shortcutconfig.ui +++ b/muse/muse/widgets/shortcutconfig.ui @@ -1,14 +1,11 @@ <ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> <class>ShortcutConfigBase</class> <widget class="QDialog" name="ShortcutConfigBase" > <property name="geometry" > <rect> <x>0</x> <y>0</y> - <width>466</width> + <width>537</width> <height>403</height> </rect> </property> @@ -59,12 +56,12 @@ <property name="rootIsDecorated" > <bool>false</bool> </property> - <property name="columnCount" > - <number>1</number> - </property> <property name="sortingEnabled" > <bool>true</bool> </property> + <property name="columnCount" > + <number>1</number> + </property> <column> <property name="text" > <string>Category</string> @@ -88,18 +85,27 @@ <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="columnCount" > - <number>2</number> + <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> |