diff options
author | Tim E. Real <termtech@rogers.com> | 2012-09-17 22:29:46 +0000 |
---|---|---|
committer | Tim E. Real <termtech@rogers.com> | 2012-09-17 22:29:46 +0000 |
commit | edd3eb6d5b73b2868398bef6ae7fbb6fd92c5800 (patch) | |
tree | e2da58edd541ce359fa513a9332d7a37965efef5 /muse2/muse | |
parent | ef0a06629a9d4652b3a91d85af768e7e5797fe2a (diff) |
Info text on Undo/Redo buttons/menu text/tooltips ("Undo AddTrack" etc).
In cases of multiple items in one operation, the first is shown,
with ", .." ("Undo AddTrack, ..").
Diffstat (limited to 'muse2/muse')
-rw-r--r-- | muse2/muse/song.cpp | 4 | ||||
-rw-r--r-- | muse2/muse/song.h | 1 | ||||
-rw-r--r-- | muse2/muse/undo.cpp | 48 |
3 files changed, 52 insertions, 1 deletions
diff --git a/muse2/muse/song.cpp b/muse2/muse/song.cpp index 9781116f..026ec1a9 100644 --- a/muse2/muse/song.cpp +++ b/muse2/muse/song.cpp @@ -1778,6 +1778,7 @@ void Song::endMsgCmd() redoList->clearDelete(); MusEGlobal::undoAction->setEnabled(true); MusEGlobal::redoAction->setEnabled(false); + setUndoRedoText(); emit songChanged(updateFlags); } } @@ -1795,6 +1796,7 @@ void Song::undo() doUndo3(); MusEGlobal::redoAction->setEnabled(true); MusEGlobal::undoAction->setEnabled(!undoList->empty()); + setUndoRedoText(); if(updateFlags && (SC_TRACK_REMOVED | SC_TRACK_INSERTED)) MusEGlobal::audio->msgUpdateSoloStates(); @@ -1815,6 +1817,7 @@ void Song::redo() doRedo3(); MusEGlobal::undoAction->setEnabled(true); MusEGlobal::redoAction->setEnabled(!redoList->empty()); + setUndoRedoText(); if(updateFlags && (SC_TRACK_REMOVED | SC_TRACK_INSERTED)) MusEGlobal::audio->msgUpdateSoloStates(); @@ -2102,6 +2105,7 @@ void Song::clear(bool signal, bool clear_all) MusEGlobal::undoAction->setEnabled(false); if(MusEGlobal::redoAction) MusEGlobal::redoAction->setEnabled(false); + setUndoRedoText(); _markerList->clear(); pos[0].setTick(0); diff --git a/muse2/muse/song.h b/muse2/muse/song.h index 8777fb2c..9a314533 100644 --- a/muse2/muse/song.h +++ b/muse2/muse/song.h @@ -358,6 +358,7 @@ class Song : public QObject { void doRedo3(); void addUndo(UndoOp i); + void setUndoRedoText(); //----------------------------------------- // Configuration diff --git a/muse2/muse/undo.cpp b/muse2/muse/undo.cpp index 45642652..65ca04bf 100644 --- a/muse2/muse/undo.cpp +++ b/muse2/muse/undo.cpp @@ -214,6 +214,7 @@ void Song::startUndo() { redoList->clearDelete(); // redo must be invalidated when a new undo is started MusEGlobal::redoAction->setEnabled(false); + setUndoRedoText(); undoList->push_back(Undo()); updateFlags = 0; @@ -231,6 +232,49 @@ void Song::endUndo(SongChangedFlags_t flags) undoMode = false; } +//--------------------------------------------------------- +// setUndoRedoText +//--------------------------------------------------------- + +void Song::setUndoRedoText() +{ + if(MusEGlobal::undoAction) + { + QString s = tr("Und&o"); + if(MusEGlobal::undoAction->isEnabled()) + { + if(!undoList->empty() && !undoList->back().empty()) + { + int sz = undoList->back().size(); + //if(sz >= 2) + // s += QString(" (%1)").arg(sz); + s += QString(" ") + undoList->back().front().typeName(); + if(sz >= 2) + s += ", .."; // Hm, the tooltip will not show three dots "..." + } + } + MusEGlobal::undoAction->setText(s); + } + + if(MusEGlobal::redoAction) + { + QString s = tr("Re&do"); + if(MusEGlobal::redoAction->isEnabled()) + { + if(!redoList->empty() && !redoList->back().empty()) + { + int sz = redoList->back().size(); + //if(sz >= 2) + // s += QString(" (%1)").arg(sz); + s += QString(" ") + redoList->back().front().typeName(); + if(sz >= 2) + s += ", .."; + } + } + MusEGlobal::redoAction->setText(s); + } +} + void cleanOperationGroup(Undo& group) { @@ -277,12 +321,14 @@ bool Song::applyOperationGroup(Undo& group, bool doUndo) { undoList->pop_back(); MusEGlobal::undoAction->setEnabled(!undoList->empty()); + setUndoRedoText(); } else { redoList->clearDelete(); // redo must be invalidated when a new undo is started MusEGlobal::redoAction->setEnabled(false); - } + setUndoRedoText(); + } return doUndo; } |