|
From: Tapio V. <aa...@us...> - 2011-01-17 09:19:22
|
Module: editor
Branch: master
Commit: 4f8f804fc531f0de8806b6b8bac31df5d97f9344
Author: Tapio Vierros <tap...@gm...>
Date: Mon Jan 17 11:07:37 2011 +0200
Undo menu becomes disabled when undo is not available.
---
editor.ui | 3 +++
editorapp.cc | 14 ++++++++++++--
editorapp.hh | 1 +
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/editor.ui b/editor.ui
index c43993b..58c840a 100644
--- a/editor.ui
+++ b/editor.ui
@@ -413,6 +413,9 @@
</property>
</action>
<action name="actionUndo">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="text">
<string>&Undo</string>
</property>
diff --git a/editorapp.cc b/editorapp.cc
index 03591a7..84fddc8 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -64,6 +64,7 @@ void EditorApp::operationDone(const Operation &op)
{
//std::cout << "Push op: " << op.dump() << std::endl;
opStack.push(op);
+ updateMenuStates();
}
void EditorApp::doOpStack()
@@ -79,6 +80,14 @@ void EditorApp::doOpStack()
noteGraph->doOperation(*opit, Operation::NO_EMIT);
} catch (std::exception& e) { std::cout << e.what() << std::endl; }
}
+ updateMenuStates();
+}
+
+void EditorApp::updateMenuStates()
+{
+ if (opStack.isEmpty() || opStack.top().op() == "BLOCK")
+ ui.actionUndo->setEnabled(false);
+ else ui.actionUndo->setEnabled(true);
}
void EditorApp::updateNoteInfo(NoteLabel *note)
@@ -278,9 +287,10 @@ void EditorApp::on_actionUndo_triggered()
{
if (opStack.isEmpty())
return;
- if (opStack.top().op() == "BLOCK")
+ if (opStack.top().op() == "BLOCK") {
+ updateMenuStates();
return;
- else if (opStack.top().op() == "COMBINER") {
+ } else if (opStack.top().op() == "COMBINER") {
int count = opStack.top().i(1);
for (int i = 0; i < count; ++i) opStack.pop();
// TODO: Redo handling
diff --git a/editorapp.hh b/editorapp.hh
index 23bf8be..310f470 100644
--- a/editorapp.hh
+++ b/editorapp.hh
@@ -17,6 +17,7 @@ public:
void updateSongMeta(bool readFromSongToUI = false);
void saveProject(QString fileName);
void doOpStack();
+ void updateMenuStates();
public slots:
void operationDone(const Operation &op);
|