Fixed undo / redo actions losing their shortcuts

This commit is contained in:
Doc West 2018-07-04 21:47:16 +02:00
parent aa5ddd6b28
commit baf21362e1
2 changed files with 25 additions and 1 deletions

View file

@ -4,6 +4,7 @@
#include <stdexcept> #include <stdexcept>
#include <QCloseEvent> #include <QCloseEvent>
#include <QDebug>
#include <QMenuBar> #include <QMenuBar>
#include <QMdiArea> #include <QMdiArea>
#include <QDockWidget> #include <QDockWidget>
@ -101,15 +102,34 @@ void CSVDoc::View::setupFileMenu()
file->addAction(exit); 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() void CSVDoc::View::setupEditMenu()
{ {
QMenu *edit = menuBar()->addMenu (tr ("Edit")); QMenu *edit = menuBar()->addMenu (tr ("Edit"));
mUndo = mDocument->getUndoStack().createUndoAction (this, tr("Undo")); mUndo = mDocument->getUndoStack().createUndoAction (this, tr("Undo"));
setupShortcut("document-edit-undo", mUndo); setupShortcut("document-edit-undo", mUndo);
connect(mUndo, SIGNAL (changed ()), this, SLOT (undoActionChanged ()));
edit->addAction (mUndo); 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); setupShortcut("document-edit-redo", mRedo);
edit->addAction (mRedo); edit->addAction (mRedo);

View file

@ -152,6 +152,10 @@ namespace CSVDoc
void settingChanged (const CSMPrefs::Setting *setting); void settingChanged (const CSMPrefs::Setting *setting);
void undoActionChanged();
void redoActionChanged();
void newView(); void newView();
void save(); void save();