From baf21362e165ce642c47d2a312336e28a16e32f3 Mon Sep 17 00:00:00 2001 From: Doc West Date: Wed, 4 Jul 2018 21:47:16 +0200 Subject: [PATCH 1/3] Fixed undo / redo actions losing their shortcuts --- apps/opencs/view/doc/view.cpp | 22 +++++++++++++++++++++- apps/opencs/view/doc/view.hpp | 4 ++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 10de46e06..f4d9b8ede 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 46aa87891..5418b7720 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(); From 5d381602390458bc1242d2a2412a4e6143bbf8ee Mon Sep 17 00:00:00 2001 From: Doc West Date: Wed, 4 Jul 2018 22:03:42 +0200 Subject: [PATCH 2/3] Updated change log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55442586b..3cb7c8073 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ Bug #4475: Scripted animations should not cause movement Bug #4479: "Game" category on Advanced page is getting too long Bug #4480: Segfalt in QuickKeysMenu when item no longer in inventory + Bug #4110: Fixed undo / redo menu text losing the assigned shortcuts Feature #3276: Editor: Search- Show number of (remaining) search results and indicate a search without any results Feature #4222: 360° screenshots Feature #4256: Implement ToggleBorders (TB) console command From f9b565a46e6e146391b295455cb5d7f6d25c4737 Mon Sep 17 00:00:00 2001 From: Doc West Date: Thu, 5 Jul 2018 17:29:58 +0200 Subject: [PATCH 3/3] Removed QDebug include, moved updateUndoRedoAction to an anonymous namespace --- apps/opencs/view/doc/view.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index f4d9b8ede..9e87e9a3a 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -102,11 +101,16 @@ void CSVDoc::View::setupFileMenu() file->addAction(exit); } -static void updateUndoRedoAction(QAction *action, const std::string &settingsKey) +namespace { - QKeySequence seq; - CSMPrefs::State::get().getShortcutManager().getSequence(settingsKey, seq); - action->setShortcut(seq); + + void updateUndoRedoAction(QAction *action, const std::string &settingsKey) + { + QKeySequence seq; + CSMPrefs::State::get().getShortcutManager().getSequence(settingsKey, seq); + action->setShortcut(seq); + } + } void CSVDoc::View::undoActionChanged()