From edd3eb6d5b73b2868398bef6ae7fbb6fd92c5800 Mon Sep 17 00:00:00 2001 From: "Tim E. Real" Date: Mon, 17 Sep 2012 22:29:46 +0000 Subject: 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, .."). --- muse2/muse/undo.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'muse2/muse/undo.cpp') 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; } -- cgit v1.2.1