From 3a911929ba263a23eba0c343a4f7b343e7aa9af6 Mon Sep 17 00:00:00 2001 From: "Tim E. Real" Date: Sun, 5 Dec 2010 04:34:35 +0000 Subject: Some work on shortcuts. See ChangeLog. --- muse2/ChangeLog | 7 +++ muse2/muse/app.cpp | 33 ++++++----- muse2/muse/midiedit/drumedit.cpp | 81 ++++++++++++++------------- muse2/muse/midiedit/ecanvas.cpp | 6 +- muse2/muse/midiedit/pianoroll.cpp | 17 +++--- muse2/muse/shortcuts.cpp | 14 +++-- muse2/muse/shortcuts.h | 7 ++- muse2/muse/widgets/canvas.cpp | 6 +- muse2/muse/widgets/filedialog.cpp | 83 +++++++++++++++------------- muse2/muse/widgets/shortcutcapturedialog.cpp | 13 +++-- muse2/muse/widgets/shortcutconfig.cpp | 12 ++++ muse2/muse/widgets/tb1.cpp | 4 +- 12 files changed, 162 insertions(+), 121 deletions(-) diff --git a/muse2/ChangeLog b/muse2/ChangeLog index f9656cf5..02224ed3 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -4,6 +4,13 @@ - Ported scldiv. Things seem to work as before. Maybe needs more testing. (Orcan) - Removed fontsel, and synthwizardbase from the project. (Orcan) - Feature: In waveedit, the mousewheel controls the vertical slider. (Orcan) + - Completed porting shortcutcapturedialog, filedialog. Added paste clone, 2track, clone2track, + insert empty, insert, to configurable shortcuts. Changed all arr/pianoroll/drumedit hard-wired + keys to refer to shortcut table. (TODO: Other windows?) (Tim) + - Correction: Convert all state() to QInputEvent::modifiers() and stateAfter() to modifiers() + (I forced a downcast to QInputEvent if required). Is correct? QT Help says: + QInputEvent::modifiers() "Returns the keyb. mod. flags that existed imm. before the event occurred." + QKeyEvent::modifiers() "Returns the keyb. mod. flags that existed imm. after the event occurred." 03.12.2010 - Ported all copy/paste/drag/drop coding. Including pianoroll, drumedit, pcanvas, prcanvas, dcanvas, and effect rack. Test OK cut, copy, paste, also drag n drop various files to arranger and rack. (Tim) diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index e589e855..91ede963 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -1278,7 +1278,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow() // Miscellaneous shortcuts //-------------------------------------------------- - QShortcut* sc = new QShortcut(Qt::Key_Delete, this); + QShortcut* sc = new QShortcut(shortcuts[SHRT_DELETE].key, this); sc->setContext(Qt::WindowShortcut); connect(sc, SIGNAL(activated()), editSignalMapper, SLOT(map())); editSignalMapper->setMapping(sc, CMD_DELETE); @@ -3552,13 +3552,16 @@ class MuseApplication : public QApplication { if (!accepted) { int key = ke->key(); ///if (ke->state() & Qt::ShiftModifier) - if (globalKeyState & Qt::ShiftModifier) + //if (globalKeyState & Qt::ShiftModifier) + if (((QInputEvent*)ke)->modifiers() & Qt::ShiftModifier) key += Qt::SHIFT; ///if (ke->state() & Qt::AltModifier) - if (globalKeyState & Qt::AltModifier) + //if (globalKeyState & Qt::AltModifier) + if (((QInputEvent*)ke)->modifiers() & Qt::AltModifier) key += Qt::ALT; ///if (ke->state() & Qt::ControlModifier) - if (globalKeyState & Qt::ControlModifier) + //if (globalKeyState & Qt::ControlModifier) + if (((QInputEvent*)ke)->modifiers() & Qt::ControlModifier) key+= Qt::CTRL; muse->kbAccel(key); return true; @@ -5016,17 +5019,17 @@ void MusE::updateConfiguration() //menu_file->setShortcut(shortcuts[SHRT_LOAD_TEMPLATE].key, menu_ids[CMD_LOAD_TEMPLATE]); // Not used. - undoAction->setShortcut(Qt::CTRL+Qt::Key_Z); - redoAction->setShortcut(Qt::CTRL+Qt::Key_Y); - - editCutAction->setShortcut(Qt::CTRL+Qt::Key_X); - editCopyAction->setShortcut(Qt::CTRL+Qt::Key_C); - editPasteAction->setShortcut(Qt::CTRL+Qt::Key_V); - editInsertAction->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_I); - editPasteCloneAction->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_V); - editPaste2TrackAction->setShortcut(Qt::CTRL+Qt::Key_B); - editPasteC2TAction->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_B); - editInsertEMAction->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_X); + undoAction->setShortcut(shortcuts[SHRT_UNDO].key); + redoAction->setShortcut(shortcuts[SHRT_REDO].key); + + editCutAction->setShortcut(shortcuts[SHRT_CUT].key); + editCopyAction->setShortcut(shortcuts[SHRT_COPY].key); + editPasteAction->setShortcut(shortcuts[SHRT_PASTE].key); + editInsertAction->setShortcut(shortcuts[SHRT_INSERT].key); + editPasteCloneAction->setShortcut(shortcuts[SHRT_PASTE_CLONE].key); + editPaste2TrackAction->setShortcut(shortcuts[SHRT_PASTE_TO_TRACK].key); + editPasteC2TAction->setShortcut(shortcuts[SHRT_PASTE_CLONE_TO_TRACK].key); + editInsertEMAction->setShortcut(shortcuts[SHRT_INSERTMEAS].key); //editDeleteSelectedAction has no acceleration diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp index 62241b10..100f4c5d 100644 --- a/muse2/muse/midiedit/drumedit.cpp +++ b/muse2/muse/midiedit/drumedit.cpp @@ -152,6 +152,7 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini selPart = 0; _to = _toInit; QSignalMapper *signalMapper = new QSignalMapper(this); + //---------Pulldown Menu---------------------------- menuFile = new QMenu(tr("&File")); menuBar()->addMenu(menuFile); @@ -172,14 +173,11 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini menuBar()->addMenu(menuEdit); menuEdit->addActions(undoRedo->actions()); - ///Q3Accel* qa = new Q3Accel(this); - ///qa->connectItem(qa->addAction(Qt::CTRL+Qt::Key_Z), song, SLOT(undo())); - - menuEdit->insertSeparator(); + menuEdit->addSeparator(); cutAction = menuEdit->addAction(QIcon(*editcutIconSet), tr("Cut")); copyAction = menuEdit->addAction(QIcon(*editcopyIconSet), tr("Copy")); pasteAction = menuEdit->addAction(QIcon(*editpasteIconSet), tr("Paste")); - menuEdit->insertSeparator(); + menuEdit->addSeparator(); deleteAction = menuEdit->addAction(tr("Delete Events")); connect(cutAction, SIGNAL(triggered()), signalMapper, SLOT(map())); @@ -197,11 +195,11 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini sallAction = menuSelect->addAction(QIcon(*select_allIcon), tr("Select All")); snoneAction = menuSelect->addAction(QIcon(*select_deselect_allIcon), tr("Select None")); invAction = menuSelect->addAction(QIcon(*select_invert_selectionIcon), tr("Invert")); - menuSelect->insertSeparator(); + menuSelect->addSeparator(); inAction = menuSelect->addAction(QIcon(*select_inside_loopIcon), tr("Inside Loop")); outAction = menuSelect->addAction(QIcon(*select_outside_loopIcon), tr("Outside Loop")); - menuSelect->insertSeparator(); + menuSelect->addSeparator(); prevAction = menuSelect->addAction(QIcon(*select_all_parts_on_trackIcon), tr("Previous Part")); nextAction = menuSelect->addAction(QIcon(*select_all_parts_on_trackIcon), tr("Next Part")); @@ -225,7 +223,9 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini // Functions menuFunctions = new QMenu(tr("&Functions")); menuBar()->addMenu(menuFunctions); - menuFunctions->insertTearOffHandle(); + + menuFunctions->setTearOffEnabled(true); + fixedAction = menuFunctions->addAction(tr("Set fixed length")); veloAction = menuFunctions->addAction(tr("Modify Velocity")); @@ -301,6 +301,7 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini split1 = new Splitter(Qt::Vertical, mainw, "split1"); QPushButton* ctrl = new QPushButton(tr("ctrl"), mainw); + ctrl->setObjectName("Ctrl"); ctrl->setFont(config.fonts[3]); hscroll = new ScrollScale(-25, -2, xscale, 20000, Qt::Horizontal, mainw); ctrl->setFixedSize(40, hscroll->sizeHint().height()); @@ -652,24 +653,24 @@ void DrumEdit::readStatus(Xml& xml) if (tag == "steprec") { int val = xml.parseInt(); canvas->setSteprec(val); - srec->setOn(val); + srec->setChecked(val); } else if (tag == "midiin") { int val = xml.parseInt(); canvas->setMidiin(val); - midiin->setOn(val); + midiin->setChecked(val); } else if (tag == "ctrledit") { CtrlEdit* ctrl = addCtrl(); ctrl->readStatus(xml); } - else if (tag == split1->name()) + else if (tag == split1->objectName()) split1->readStatus(xml); - else if (tag == split2->name()) + else if (tag == split2->objectName()) split2->readStatus(xml); else if (tag == "midieditor") MidiEditor::readStatus(xml); - else if (tag == header->name()) + else if (tag == header->objectName()) header->readStatus(xml); else if (tag == "xmag") hscroll->setMag(xml.parseInt()); @@ -844,7 +845,7 @@ void DrumEdit::reset() { if(QMessageBox::warning(this, tr("Drum map"), tr("Reset the drum map with GM defaults?"), - QMessageBox::Ok | QMessageBox::Default, QMessageBox::Cancel | QMessageBox::Escape, Qt::NoButton) == QMessageBox::Ok) + QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok) == QMessageBox::Ok) { resetGMDrumMap(); dlist->redraw(); @@ -923,7 +924,8 @@ CtrlEdit* DrumEdit::addCtrl() if(split1w1) { - split2->setCollapsible(split1w1, false); + ///split2->setCollapsible(split1w1, false); + split2->setCollapsible(split2->indexOf(split1w1), false); split1w1->setMinimumWidth(CTRL_PANEL_FIXED_WIDTH); } ctrlEdit->setCanvasWidth(canvas->width()); @@ -952,7 +954,8 @@ void DrumEdit::removeCtrl(CtrlEdit* ctrl) if(ctrlEditList.empty()) { split1w1->setMinimumWidth(0); - split2->setCollapsible(split1w1, true); + ///split2->setCollapsible(split1w1, true); + split2->setCollapsible(split2->indexOf(split1w1), true); } } } @@ -1022,11 +1025,11 @@ void DrumEdit::keyPressEvent(QKeyEvent* event) int val; int key = event->key(); - if (event->state() & Qt::ShiftButton) + if (((QInputEvent*)event)->modifiers() & Qt::ShiftModifier) key += Qt::SHIFT; - if (event->state() & Qt::AltButton) + if (((QInputEvent*)event)->modifiers() & Qt::AltModifier) key += Qt::ALT; - if (event->state() & Qt::ControlButton) + if (((QInputEvent*)event)->modifiers() & Qt::ControlModifier) key+= Qt::CTRL; if (key == Qt::Key_Escape) { @@ -1168,25 +1171,25 @@ void DrumEdit::keyPressEvent(QKeyEvent* event) void DrumEdit::initShortcuts() { - loadAction->setAccel(shortcuts[SHRT_OPEN].key); - saveAction->setAccel(shortcuts[SHRT_SAVE].key); - - cutAction->setAccel(shortcuts[SHRT_CUT].key); - copyAction->setAccel(shortcuts[SHRT_COPY].key); - pasteAction->setAccel(shortcuts[SHRT_PASTE].key); - deleteAction->setAccel(shortcuts[SHRT_DELETE].key); - - fixedAction->setAccel(shortcuts[SHRT_FIXED_LEN].key); - veloAction->setAccel(shortcuts[SHRT_MODIFY_VELOCITY].key); - - sallAction->setAccel(shortcuts[SHRT_SELECT_ALL].key); - snoneAction->setAccel(shortcuts[SHRT_SELECT_NONE].key); - invAction->setAccel(shortcuts[SHRT_SELECT_INVERT].key); - inAction->setAccel(shortcuts[SHRT_SELECT_ILOOP].key); - outAction->setAccel(shortcuts[SHRT_SELECT_OLOOP].key); + loadAction->setShortcut(shortcuts[SHRT_OPEN].key); + saveAction->setShortcut(shortcuts[SHRT_SAVE].key); + + cutAction->setShortcut(shortcuts[SHRT_CUT].key); + copyAction->setShortcut(shortcuts[SHRT_COPY].key); + pasteAction->setShortcut(shortcuts[SHRT_PASTE].key); + deleteAction->setShortcut(shortcuts[SHRT_DELETE].key); + + fixedAction->setShortcut(shortcuts[SHRT_FIXED_LEN].key); + veloAction->setShortcut(shortcuts[SHRT_MODIFY_VELOCITY].key); + + sallAction->setShortcut(shortcuts[SHRT_SELECT_ALL].key); + snoneAction->setShortcut(shortcuts[SHRT_SELECT_NONE].key); + invAction->setShortcut(shortcuts[SHRT_SELECT_INVERT].key); + inAction->setShortcut(shortcuts[SHRT_SELECT_ILOOP].key); + outAction->setShortcut(shortcuts[SHRT_SELECT_OLOOP].key); - prevAction->setAccel(shortcuts[SHRT_SELECT_PREV_PART].key); - nextAction->setAccel(shortcuts[SHRT_SELECT_NEXT_PART].key); + prevAction->setShortcut(shortcuts[SHRT_SELECT_PREV_PART].key); + nextAction->setShortcut(shortcuts[SHRT_SELECT_NEXT_PART].key); } //--------------------------------------------------------- @@ -1196,7 +1199,7 @@ void DrumEdit::execDeliveredScript(int id) { //QString scriptfile = QString(INSTPREFIX) + SCRIPTSSUFFIX + deliveredScriptNames[id]; QString scriptfile = song->getScriptPath(id, true); - song->executeScript(scriptfile.latin1(), parts(), quant(), true); + song->executeScript(scriptfile.toLatin1().data(), parts(), quant(), true); } //--------------------------------------------------------- @@ -1205,6 +1208,6 @@ void DrumEdit::execDeliveredScript(int id) void DrumEdit::execUserScript(int id) { QString scriptfile = song->getScriptPath(id, false); - song->executeScript(scriptfile.latin1(), parts(), quant(), true); + song->executeScript(scriptfile.toLatin1().data(), parts(), quant(), true); } diff --git a/muse2/muse/midiedit/ecanvas.cpp b/muse2/muse/midiedit/ecanvas.cpp index c790d8c0..bb99035d 100644 --- a/muse2/muse/midiedit/ecanvas.cpp +++ b/muse2/muse/midiedit/ecanvas.cpp @@ -262,13 +262,13 @@ void EventCanvas::keyPress(QKeyEvent* event) { int key = event->key(); ///if (event->state() & Qt::ShiftButton) - if (event->modifiers() & Qt::ShiftButton) + if (((QInputEvent*)event)->modifiers() & Qt::ShiftModifier) key += Qt::SHIFT; ///if (event->state() & Qt::AltButton) - if (event->modifiers() & Qt::AltButton) + if (((QInputEvent*)event)->modifiers() & Qt::AltModifier) key += Qt::ALT; ///if (event->state() & Qt::ControlButton) - if (event->modifiers() & Qt::ControlButton) + if (((QInputEvent*)event)->modifiers() & Qt::ControlModifier) key+= Qt::CTRL; // diff --git a/muse2/muse/midiedit/pianoroll.cpp b/muse2/muse/midiedit/pianoroll.cpp index 2dc1cbde..fa51b792 100644 --- a/muse2/muse/midiedit/pianoroll.cpp +++ b/muse2/muse/midiedit/pianoroll.cpp @@ -94,24 +94,20 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i editCutAction = menuEdit->addAction(QIcon(*editcutIconSet), tr("C&ut")); mapper->setMapping(editCutAction, PianoCanvas::CMD_CUT); - editCutAction->setShortcut(QKeySequence::Cut); connect(editCutAction, SIGNAL(triggered()), mapper, SLOT(map())); editCopyAction = menuEdit->addAction(QIcon(*editcopyIconSet), tr("&Copy")); mapper->setMapping(editCopyAction, PianoCanvas::CMD_COPY); - editCopyAction->setShortcut(QKeySequence::Copy); connect(editCopyAction, SIGNAL(triggered()), mapper, SLOT(map())); editPasteAction = menuEdit->addAction(QIcon(*editpasteIconSet), tr("&Paste")); mapper->setMapping(editPasteAction, PianoCanvas::CMD_PASTE); - editPasteAction->setShortcut(QKeySequence::Paste); connect(editPasteAction, SIGNAL(triggered()), mapper, SLOT(map())); menuEdit->addSeparator(); editDelEventsAction = menuEdit->addAction(tr("Delete &Events")); mapper->setMapping(editDelEventsAction, PianoCanvas::CMD_DEL); - editDelEventsAction->setShortcut(QKeySequence::Delete); connect(editDelEventsAction, SIGNAL(triggered()), mapper, SLOT(map())); menuEdit->addSeparator(); @@ -863,7 +859,7 @@ void PianoRoll::readStatus(Xml& xml) CtrlEdit* ctrl = addCtrl(); ctrl->readStatus(xml); } - else if (tag == splitter->name()) + else if (tag == splitter->objectName()) splitter->readStatus(xml); else if (tag == "quantStrength") _quantStrength = xml.parseInt(); @@ -938,13 +934,13 @@ void PianoRoll::keyPressEvent(QKeyEvent* event) int key = event->key(); //if (event->state() & Qt::ShiftButton) - if (event->state() & Qt::ShiftModifier) + if (((QInputEvent*)event)->modifiers() & Qt::ShiftModifier) key += Qt::SHIFT; //if (event->state() & Qt::AltButton) - if (event->state() & Qt::AltModifier) + if (((QInputEvent*)event)->modifiers() & Qt::AltModifier) key += Qt::ALT; //if (event->state() & Qt::ControlButton) - if (event->state() & Qt::ControlModifier) + if (((QInputEvent*)event)->modifiers() & Qt::ControlModifier) key+= Qt::CTRL; if (key == Qt::Key_Escape) { @@ -1178,6 +1174,11 @@ void PianoRoll::resizeEvent(QResizeEvent* ev) void PianoRoll::initShortcuts() { + editCutAction->setShortcut(shortcuts[SHRT_CUT].key); + editCopyAction->setShortcut(shortcuts[SHRT_COPY].key); + editPasteAction->setShortcut(shortcuts[SHRT_PASTE].key); + editDelEventsAction->setShortcut(shortcuts[SHRT_DELETE].key); + selectAllAction->setShortcut(shortcuts[SHRT_SELECT_ALL].key); selectNoneAction->setShortcut(shortcuts[SHRT_SELECT_NONE].key); selectInvertAction->setShortcut(shortcuts[SHRT_SELECT_INVERT].key); diff --git a/muse2/muse/shortcuts.cpp b/muse2/muse/shortcuts.cpp index 6f0e51f9..68a538e9 100644 --- a/muse2/muse/shortcuts.cpp +++ b/muse2/muse/shortcuts.cpp @@ -10,7 +10,8 @@ // // #include "shortcuts.h" -#include +#include +#include ShortCut shortcuts[SHRT_NUM_OF_ELEMENTS]; @@ -36,11 +37,12 @@ void initShortCuts() defShrt(SHRT_TOGGLE_LOOP, Qt::Key_Slash, "Transport: Toggle Loop section", GLOBAL_SHRT, "toggle_loop"); defShrt(SHRT_START_REC, Qt::Key_Asterisk, "Transport: Toggle Record", GLOBAL_SHRT, "toggle_rec"); defShrt(SHRT_REC_CLEAR, Qt::Key_Backspace, "Transport: Clear all rec enabled tracks", GLOBAL_SHRT, "rec_clear"); + defShrt(SHRT_COPY, Qt::CTRL + Qt::Key_C, "Edit: Copy", INVIS_SHRT, "copy"); defShrt(SHRT_UNDO, Qt::CTRL + Qt::Key_Z, "Edit: Undo", INVIS_SHRT, "undo"); defShrt(SHRT_REDO, Qt::CTRL + Qt::Key_Y, "Edit: Redo", INVIS_SHRT, "redo"); defShrt(SHRT_CUT, Qt::CTRL + Qt::Key_X, "Edit: Cut", INVIS_SHRT, "cut"); - defShrt(SHRT_PASTE, Qt::CTRL + Qt::Key_V, "Edit: Paste,", INVIS_SHRT, "paste"); + defShrt(SHRT_PASTE, Qt::CTRL + Qt::Key_V, "Edit: Paste", INVIS_SHRT, "paste"); defShrt(SHRT_DELETE, Qt::Key_Delete, "Edit: Delete", INVIS_SHRT, "delete"); //----------------------------------------------------------- @@ -131,9 +133,13 @@ void initShortCuts() defShrt(SHRT_SEL_BELOW, Qt::Key_Down, "Edit: Select nearest part on track below", ARRANG_SHRT, "sel_part_below"); defShrt(SHRT_SEL_BELOW_ADD, Qt::SHIFT + Qt::Key_Down, "Edit: Add nearest part on track below", ARRANG_SHRT, "sel_part_below_add"); -// defShrt(SHRT_INSERT, Qt::CTRL+Qt::SHIFT+ Qt::Key_I, "Edit: Insert parts, moving time", ARRANG_SHRT, "insert_parts"); -// defShrt(SHRT_INSERTMEAS, Qt::CTRL+Qt::SHIFT+ Qt::Key_M, "Edit: Insert empty measure", ARRANG_SHRT, "insert_measure"); + defShrt(SHRT_INSERT, Qt::CTRL+Qt::SHIFT+ Qt::Key_I, "Edit: Insert parts, moving time", ARRANG_SHRT, "insert_parts"); + defShrt(SHRT_INSERTMEAS, Qt::CTRL+Qt::SHIFT+ Qt::Key_M, "Edit: Insert empty measure", ARRANG_SHRT, "insert_measure"); + defShrt(SHRT_PASTE_CLONE, Qt::CTRL+Qt::SHIFT+Qt::Key_V, "Edit: Paste clone", ARRANG_SHRT, "paste_clone"); + defShrt(SHRT_PASTE_TO_TRACK, Qt::CTRL+Qt::Key_B, "Edit: Paste to track", ARRANG_SHRT, "paste_to_track"); + defShrt(SHRT_PASTE_CLONE_TO_TRACK, Qt::CTRL+Qt::SHIFT+Qt::Key_B, "Edit: Paste clone to track", ARRANG_SHRT, "paste_clone_to_track"); + defShrt(SHRT_SEL_TRACK_ABOVE, Qt::CTRL + Qt::Key_Up, "Select track above", ARRANG_SHRT, "sel_track_above"); defShrt(SHRT_SEL_TRACK_BELOW, Qt::CTRL + Qt::Key_Down, "Select track below", ARRANG_SHRT, "sel_track_below"); diff --git a/muse2/muse/shortcuts.h b/muse2/muse/shortcuts.h index 0e2121f9..d39532de 100644 --- a/muse2/muse/shortcuts.h +++ b/muse2/muse/shortcuts.h @@ -164,10 +164,13 @@ enum { SHRT_SEL_BELOW, //Down SHRT_SEL_BELOW_ADD, //move down and add to selection - /* SHRT_INSERT, //Ctrl+Shift+I - insert parts instead of pasting SHRT_INSERTMEAS, //Ctrl+Shift+M - insert measures - */ + + SHRT_PASTE_CLONE, //CTRL+SHIFT+Key_V + SHRT_PASTE_TO_TRACK, //CTRL+Key_B + SHRT_PASTE_CLONE_TO_TRACK, //CTRL+SHIFT+Key_B + //Arranger tracks SHRT_SEL_TRACK_BELOW, SHRT_SEL_TRACK_ABOVE, diff --git a/muse2/muse/widgets/canvas.cpp b/muse2/muse/widgets/canvas.cpp index 7533b2ad..ec138af5 100644 --- a/muse2/muse/widgets/canvas.cpp +++ b/muse2/muse/widgets/canvas.cpp @@ -341,7 +341,7 @@ void Canvas::wheelEvent(QWheelEvent* ev) int scrollstep = WHEEL_STEPSIZE * (-delta); ///if (ev->state() == Qt::ShiftModifier) - if (ev->modifiers() == Qt::ShiftModifier) + if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier) scrollstep = scrollstep / 10; int newYpos = ypos + ypixelscale * scrollstep; @@ -453,7 +453,7 @@ void Canvas::viewKeyPressEvent(QKeyEvent* event) void Canvas::viewMousePressEvent(QMouseEvent* event) { ///keyState = event->state(); - keyState = event->modifiers(); + keyState = ((QInputEvent*)event)->modifiers(); button = event->button(); //printf("viewMousePressEvent buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button()); @@ -1063,7 +1063,7 @@ void Canvas::viewMouseReleaseEvent(QMouseEvent* event) QPoint pos = event->pos(); ///bool shift = event->state() & Qt::ShiftModifier; - bool shift = event->modifiers() & Qt::ShiftModifier; + bool shift = ((QInputEvent*)event)->modifiers() & Qt::ShiftModifier; bool redrawFlag = false; switch (drag) { diff --git a/muse2/muse/widgets/filedialog.cpp b/muse2/muse/widgets/filedialog.cpp index 00cc136f..c6c1f9ae 100644 --- a/muse2/muse/widgets/filedialog.cpp +++ b/muse2/muse/widgets/filedialog.cpp @@ -29,7 +29,7 @@ QString MFileDialog::lastGlobalDir = ""; static bool createDir(const QString& s) { QString sl("/"); - QStringList l = QStringList::split(sl, s); + QStringList l = s.split(sl, QString::SkipEmptyParts); QString path(sl); QDir dir; for (QStringList::Iterator it = l.begin(); it != l.end(); ++it) { @@ -37,7 +37,7 @@ static bool createDir(const QString& s) if (!QDir(path + sl + *it).exists()) { if (!dir.mkdir(*it)) { printf("mkdir failed: %s %s\n", - path.latin1(), (*it).latin1()); + path.toLatin1().data(), (*it).toLatin1().data()); return true; } } @@ -53,30 +53,27 @@ static bool createDir(const QString& s) //--------------------------------------------------------- static bool testDirCreate(QWidget* parent, const QString& path) - { +{ QDir dir(path); - if (!dir.exists()) { - int n = QMessageBox::information(parent, - QWidget::tr("MusE: get file name"), - QWidget::tr("the directory\n") + path - + QWidget::tr("\ndoes not exist\ncreate?"), - QWidget::tr("&Create"), - QWidget::tr("Cancel"), - QString::null, 1, 1); - if (n == 0) { - if (createDir(path)) { - QMessageBox::critical(parent, - QWidget::tr("MusE: create directory"), - QWidget::tr("creating dir failed") - ); - return true; - } - return false; - } + if (!dir.exists()) + { + if(QMessageBox::information(parent, + QWidget::tr("MusE: get file name"), + QWidget::tr("The directory\n") + path + + QWidget::tr("\ndoes not exist.\nCreate it?"), + QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok) != QMessageBox::Ok) + return true; + + if (createDir(path)) + { + QMessageBox::critical(parent, + QWidget::tr("MusE: create directory"), + QWidget::tr("creating dir failed")); return true; - } - return false; + } } + return false; +} //--------------------------------------------------------- // globalToggled @@ -227,7 +224,8 @@ void MFileDialog::directoryChanged(const QString&) { ViewType currentView = GLOBAL_VIEW; QDir ndir = directory(); - QString newdir = ndir.absPath().latin1(); + ///QString newdir = ndir.absolutePath().latin1(); + QString newdir = ndir.absolutePath(); if (buttons.projectButton->isChecked()) currentView = PROJECT_VIEW; else if (buttons.userButton->isChecked()) @@ -289,7 +287,7 @@ QString getFilterExtension(const QString &filter) // Return the first extension found. Must contain at least one * character. // - int pos = filter.find('*'); + int pos = filter.indexOf('*'); if(pos == -1) return QString(); @@ -314,10 +312,10 @@ QString getOpenFileName(const QString &startWith, //const char** filters, QWidget* parent, const QString& name, bool* all) const QStringList& filters, QWidget* parent, const QString& name, bool* all) { - QString initialSelection; + QString initialSelection; // FIXME Tim. MFileDialog *dlg = new MFileDialog(startWith, QString::null, parent, false); dlg->setNameFilters(filters); - dlg->setCaption(name); + dlg->setWindowTitle(name); if (all) { dlg->buttons.loadAllGroup->setVisible(true); //dlg->buttons.globalButton->setVisible(false); @@ -349,7 +347,7 @@ QString getSaveFileName(const QString &startWith, { MFileDialog *dlg = new MFileDialog(startWith, QString::null, parent, true); dlg->setNameFilters(filters); - dlg->setCaption(name); + dlg->setWindowTitle(name); dlg->setFileMode(QFileDialog::AnyFile); QStringList files; QString result; @@ -384,7 +382,7 @@ QString getSaveFileName(const QString &startWith, // but only if there are no errors in the list of filters. fileOpen() will act as a 'catchall'. // // Force the filter list to the first one (the preferred one), and then get the filter. - dlg->selectNameFilter(dlg->filters().at(0)); + dlg->selectNameFilter(dlg->nameFilters().at(0)); filt = dlg->selectedNameFilter(); filt = getFilterExtension(filt); @@ -413,7 +411,7 @@ QString getImageFileName(const QString& startWith, const QStringList& filters, QWidget* parent, const QString& name) { QString initialSelection; - QString* workingDirectory = new QString(QDir::currentDirPath()); + QString* workingDirectory = new QString(QDir::currentPath()); if (!startWith.isEmpty() ) { QFileInfo fi(startWith); if (fi.exists() && fi.isDir()) { @@ -434,7 +432,7 @@ QString getImageFileName(const QString& startWith, dlg->setContentsPreview(preview, preview); dlg->setPreviewMode(QFileDialog::Contents); */ - dlg->setCaption(name); + dlg->setWindowTitle(name); dlg->setNameFilters(filters); dlg->setFileMode(QFileDialog::ExistingFile); QStringList files; @@ -473,32 +471,39 @@ FILE* fileOpen(QWidget* parent, QString name, const QString& ext, QString zip; popenFlag = false; - if (info.extension(true) == "") { + if (info.completeSuffix() == "") { name += ext; info.setFile(name); } - else if (info.extension(false) == "gz") { + else if (info.suffix() == "gz") { popenFlag = true; zip = QString("gzip"); } - else if (info.extension(false) == "bz2") { + else if (info.suffix() == "bz2") { popenFlag = true; zip = QString("bzip2"); } if (strcmp(mode,"w") == 0 && overwriteWarning && info.exists()) { - QString s(QWidget::tr("File\n") + name + QWidget::tr("\nexists")); + QString s(QWidget::tr("File\n") + name + QWidget::tr("\nexists. Overwrite?")); + /* int rv = QMessageBox::warning(parent, QWidget::tr("MusE: write"), s, - QWidget::tr("Overwrite"), - QWidget::tr("Quit"), QString::null, 0, 1); + QMessageBox::Save | QMessageBox::Cancel, QMessageBox::Save); switch(rv) { case 0: // overwrite break; case 1: // quit return 0; } + */ + if(QMessageBox::warning(parent, + QWidget::tr("MusE: write"), s, + QMessageBox::Save | QMessageBox::Cancel, QMessageBox::Save) + != QMessageBox::Save) + return 0; + } FILE* fp = 0; if (popenFlag) { @@ -507,10 +512,10 @@ FILE* fileOpen(QWidget* parent, QString name, const QString& ext, else zip += QString(" > "); zip += name; - fp = popen(zip.ascii(), mode); + fp = popen(zip.toAscii().data(), mode); } else { - fp = fopen(name.ascii(), mode); + fp = fopen(name.toAscii().data(), mode); } if (fp == 0 && !noError) { QString s(QWidget::tr("Open File\n") + name + QWidget::tr("\nfailed: ") diff --git a/muse2/muse/widgets/shortcutcapturedialog.cpp b/muse2/muse/widgets/shortcutcapturedialog.cpp index 07482bbd..ef2bc33e 100644 --- a/muse2/muse/widgets/shortcutcapturedialog.cpp +++ b/muse2/muse/widgets/shortcutcapturedialog.cpp @@ -14,6 +14,7 @@ #include #include +#include ShortcutCaptureDialog::ShortcutCaptureDialog(QWidget* parent, int index) : QDialog(parent) @@ -39,14 +40,14 @@ void ShortcutCaptureDialog::keyPressEvent(QKeyEvent* e) bool shift, alt, ctrl, conflict = false, realkey = false; QString msgString = ""; int temp_key; - shift = e->state() & Qt::ShiftModifier; - ctrl = e->state() & Qt::ControlModifier; - alt = e->state() & Qt::AltModifier; + shift = ((QInputEvent*)e)->modifiers() & Qt::ShiftModifier; + ctrl = ((QInputEvent*)e)->modifiers() & Qt::ControlModifier; + alt = ((QInputEvent*)e)->modifiers() & Qt::AltModifier; //printf("Key total: %d, alt: %d, ctrl: %d shift: %d\n",e->key(), alt, ctrl, shift); temp_key = e->key(); - temp_key += (shift ? Qt::SHIFT : 0); - temp_key += (ctrl ? Qt::CTRL : 0); - temp_key += (alt ? Qt::ALT : 0); + temp_key += (shift ? (int)Qt::SHIFT : 0); // (int) Tim + temp_key += (ctrl ? (int)Qt::CTRL : 0); // + temp_key += (alt ? (int)Qt::ALT : 0); // //printf("Final key assembled: %d\n",temp_key); // Check if this is a "real" key that completes a valid shortcut: diff --git a/muse2/muse/widgets/shortcutconfig.cpp b/muse2/muse/widgets/shortcutconfig.cpp index b41250e1..78162f50 100644 --- a/muse2/muse/widgets/shortcutconfig.cpp +++ b/muse2/muse/widgets/shortcutconfig.cpp @@ -11,6 +11,7 @@ // #include #include +#include #include "shortcutconfig.h" #include "shortcutcapturedialog.h" @@ -35,10 +36,15 @@ ShortcutConfig::ShortcutConfig(QWidget* parent) //Fill up category listview: SCListViewItem* newItem; + SCListViewItem* selItem = 0; for (int i=0; i < SHRT_NUM_OF_CATEGORIES; i++) { newItem = new SCListViewItem(cgListView, i); newItem->setText(SHRT_CATEGORY_COL, shortcut_category[i].name); + if(shortcut_category[i].id_flag == current_category) + selItem = newItem; } + if(selItem) + cgListView->setCurrentItem(selItem); // Tim updateSCListView(); } @@ -46,10 +52,16 @@ void ShortcutConfig::updateSCListView(int category) { scListView->clear(); SCListViewItem* newItem; + //QString catpre; for (int i=0; i < SHRT_NUM_OF_ELEMENTS; i++) { if (shortcuts[i].type & category) { newItem = new SCListViewItem(scListView, i); newItem->setText(SHRT_DESCR_COL, tr(shortcuts[i].descr)); + //if(category == ALL_SHRT) + // catpre = QString(shortcut_category[shortcuts[i].type].name) + QString(": "); + //else + // catpre.clear(); + //newItem->setText(SHRT_DESCR_COL, catpre + tr(shortcuts[i].descr)); // Tim QKeySequence key = QKeySequence(shortcuts[i].key); newItem->setText(SHRT_SHRTCUT_COL, key); } diff --git a/muse2/muse/widgets/tb1.cpp b/muse2/muse/widgets/tb1.cpp index ab4961cc..41f2ed41 100644 --- a/muse2/muse/widgets/tb1.cpp +++ b/muse2/muse/widgets/tb1.cpp @@ -155,7 +155,7 @@ Toolbar1::Toolbar1(QWidget* parent, int r, int q, bool sp) // rasterChanged //--------------------------------------------------------- -void Toolbar1::_rasterChanged(int i) +void Toolbar1::_rasterChanged(int /*i*/) //void Toolbar1::_rasterChanged(int r, int c) { emit rasterChanged(rasterTable[rlist->currentRow() + rlist->currentColumn() * 10]); @@ -166,7 +166,7 @@ void Toolbar1::_rasterChanged(int i) // quantChanged //--------------------------------------------------------- -void Toolbar1::_quantChanged(int i) +void Toolbar1::_quantChanged(int /*i*/) //void Toolbar1::_quantChanged(int r, int c) { emit quantChanged(quantTable[qlist->currentRow() + qlist->currentColumn() * 8]); -- cgit v1.2.3