From: <ms...@us...> - 2009-08-30 15:09:27
|
Revision: 10785 http://rosegarden.svn.sourceforge.net/rosegarden/?rev=10785&view=rev Author: msjulie Date: 2009-08-30 15:09:19 +0000 (Sun, 30 Aug 2009) Log Message: ----------- * Basic Rest / Note functionality restored via NoteRestInserter * Proper tool selected on NotationView open based whether there are Note events. Have notes choose Select Tool, else choose draw Tool (NoteRestInserter) ToDo: Consider refactoring code related to notes/rests toolbars, and other slot actions now that NoteRestInserter does not need to communicate with each other like RestInserter / NoteInserter did. There is a lot of glue code and hack trick to pass information back and forth and set up toolbars, etc. It is all so much simpler now with the new tool. Modified Paths: -------------- branches/notation_toolbar_2/src/gui/editors/notation/NotationView.cpp branches/notation_toolbar_2/src/gui/editors/notation/NotationWidget.cpp branches/notation_toolbar_2/src/gui/editors/notation/NoteRestInserter.cpp branches/notation_toolbar_2/src/gui/editors/notation/NoteRestInserter.h Modified: branches/notation_toolbar_2/src/gui/editors/notation/NotationView.cpp =================================================================== --- branches/notation_toolbar_2/src/gui/editors/notation/NotationView.cpp 2009-08-30 14:28:14 UTC (rev 10784) +++ branches/notation_toolbar_2/src/gui/editors/notation/NotationView.cpp 2009-08-30 15:09:19 UTC (rev 10785) @@ -147,15 +147,27 @@ connect(m_notationWidget->getScene(), SIGNAL(selectionChanged()), this, SLOT(slotUpdateMenuStates())); - // Default tool is a note inserter; if we have some notes already, - // make the selector the default (c.f. MatrixView also). - if (m_notationWidget->segmentsContainNotes()) { - findAction("select")->trigger(); - } - // Either way, start off with plain durations as the visible notes toolbar morphDurationMonobar(InsertingNotes); + // Determine default action stolen from MatrixView.cpp + // Toggle the desired tool off and then trigger it on again, to + // make sure its signal is called at least once (as would not + // happen if the tool was on by default otherwise) + QAction *toolAction = 0; + if (!m_notationWidget->segmentsContainNotes()) { + toolAction = findAction("draw"); + } else { + toolAction = findAction("select"); + } + if (toolAction) { + NOTATION_DEBUG << "initial state for action '" << toolAction->objectName() << "' is " << toolAction->isChecked() << endl; + if (toolAction->isChecked()) toolAction->toggle(); + NOTATION_DEBUG << "newer state for action '" << toolAction->objectName() << "' is " << toolAction->isChecked() << endl; + toolAction->trigger(); + NOTATION_DEBUG << "newest state for action '" << toolAction->objectName() << "' is " << toolAction->isChecked() << endl; + } + // Set display configuration bool visible; QSettings settings; @@ -1930,10 +1942,13 @@ NewNotationView::slotToggleDot() { if (m_notationWidget) { - NoteRestInserter *currentInserter = dynamic_cast<NoteRestInserter *> (m_notationWidget->getCurrentTool()); + NoteRestInserter *currentInserter = dynamic_cast<NoteRestInserter *> + (m_notationWidget->getCurrentTool()); if (!currentInserter) { /* was sorry QMessageBox::warning(this, "", tr("No note duration selected")); */ + NOTATION_DEBUG << "NewNotationView::slotToggleDat : expected " + << "NoteRestInserter as current tool. Silent exit."; return ; } Note note = currentInserter->getCurrentNote(); @@ -1969,7 +1984,9 @@ morphDurationMonobar(currentMode); findAction(noteToolbarName)->setChecked(true); + // Show we always open the duration tool bar? Yuck! findAction(durationMenuName)->setChecked(true); + slotUpdateMenuStates(); } Modified: branches/notation_toolbar_2/src/gui/editors/notation/NotationWidget.cpp =================================================================== --- branches/notation_toolbar_2/src/gui/editors/notation/NotationWidget.cpp 2009-08-30 14:28:14 UTC (rev 10784) +++ branches/notation_toolbar_2/src/gui/editors/notation/NotationWidget.cpp 2009-08-30 15:09:19 UTC (rev 10785) @@ -392,7 +392,7 @@ { NoteRestInserter *noteRestInserter = dynamic_cast<NoteRestInserter *> (m_toolBox->getTool(NoteRestInserter::ToolName)); - noteRestInserter->setToRestInserter(false); // set to insert notes. + noteRestInserter->setToRestInserter(true); // set to insert notes. slotSetTool(NoteRestInserter::ToolName); } Modified: branches/notation_toolbar_2/src/gui/editors/notation/NoteRestInserter.cpp =================================================================== --- branches/notation_toolbar_2/src/gui/editors/notation/NoteRestInserter.cpp 2009-08-30 14:28:14 UTC (rev 10784) +++ branches/notation_toolbar_2/src/gui/editors/notation/NoteRestInserter.cpp 2009-08-30 15:09:19 UTC (rev 10785) @@ -87,6 +87,7 @@ createAction("select", SLOT(slotSelectSelected())); createAction("erase", SLOT(slotEraseSelected())); createAction("rests", SLOT(slotRestsSelected())); + createAction("notes", SLOT(slotNotesSelected())); connect(m_widget, SIGNAL(changeAccidental(Accidental, bool)), this, SLOT(slotSetAccidental(Accidental, bool))); @@ -491,7 +492,8 @@ const Note ¬e, int pitch, Accidental accidental) { NOTATION_DEBUG << "doAddCommand: time " << time << ", endTime " << endTime - << ", pitch " << pitch << endl; + << ", pitch " << pitch << ",isaRestInserter " + << isaRestInserter() << endl; Command *activeCommand = 0; //Used in rest / note mode code NoteInsertionCommand *insertionCommand = 0; //Used in rest / note mode code @@ -698,10 +700,29 @@ if (!action) { std::cerr << "WARNING: No such action as " << actionName << std::endl; } else { + setToRestInserter(true); + action->setChecked(true); action->trigger(); } } +void NoteRestInserter::slotNotesSelected() +{ + Note note(m_noteType, m_noteDots); + QString actionName(NotationStrings::getReferenceName(note)); + actionName.replace(QRegExp("-"), "_"); + + QAction *action = findActionInParentView(actionName); + + if (!action) { + std::cerr << "WARNING: No such action as " << actionName << std::endl; + } else { + setToRestInserter(false); + action->setChecked(true); + action->trigger(); + } +} + const char* NoteRestInserter::m_actionsAccidental[][4] = { { "1slotNoAccidental()", "no_accidental" }, Modified: branches/notation_toolbar_2/src/gui/editors/notation/NoteRestInserter.h =================================================================== --- branches/notation_toolbar_2/src/gui/editors/notation/NoteRestInserter.h 2009-08-30 14:28:14 UTC (rev 10784) +++ branches/notation_toolbar_2/src/gui/editors/notation/NoteRestInserter.h 2009-08-30 15:09:19 UTC (rev 10785) @@ -92,9 +92,6 @@ protected: NoteRestInserter(NotationWidget *); -// RestInserter(NotationWidget *); // From RestInserter (delete) - - /// this ctor is used by RestInserter (delete) NoteRestInserter(QString rcFileName, QString menuName, NotationWidget *); timeT getOffsetWithinRest(NotationStaff *, @@ -122,12 +119,14 @@ void slotNatural(); void slotDoubleSharp(); void slotDoubleFlat(); - void slotToggleDot(); //Same code as RestInserter + void slotToggleDot(); void slotToggleAutoBeam(); void slotEraseSelected(); void slotSelectSelected(); - void slotRestsSelected(); + // Consider a slotToggleNoteRest() instead + void slotRestsSelected(); //Check real need for this + void slotNotesSelected(); //Check real need for this protected: //--------------- Data members --------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |