diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 10de46e064..f4d9b8eded 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -101,15 +102,34 @@ void CSVDoc::View::setupFileMenu() file->addAction(exit); } +static void updateUndoRedoAction(QAction *action, const std::string &settingsKey) +{ + QKeySequence seq; + CSMPrefs::State::get().getShortcutManager().getSequence(settingsKey, seq); + action->setShortcut(seq); +} + +void CSVDoc::View::undoActionChanged() +{ + updateUndoRedoAction(mUndo, "document-edit-undo"); +} + +void CSVDoc::View::redoActionChanged() +{ + updateUndoRedoAction(mRedo, "document-edit-redo"); +} + void CSVDoc::View::setupEditMenu() { QMenu *edit = menuBar()->addMenu (tr ("Edit")); mUndo = mDocument->getUndoStack().createUndoAction (this, tr("Undo")); setupShortcut("document-edit-undo", mUndo); + connect(mUndo, SIGNAL (changed ()), this, SLOT (undoActionChanged ())); edit->addAction (mUndo); - mRedo= mDocument->getUndoStack().createRedoAction (this, tr("Redo")); + mRedo = mDocument->getUndoStack().createRedoAction (this, tr("Redo")); + connect(mRedo, SIGNAL (changed ()), this, SLOT (redoActionChanged ())); setupShortcut("document-edit-redo", mRedo); edit->addAction (mRedo); diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index 46aa87891a..5418b7720a 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -152,6 +152,10 @@ namespace CSVDoc void settingChanged (const CSMPrefs::Setting *setting); + void undoActionChanged(); + + void redoActionChanged(); + void newView(); void save();