diff --git a/apps/opencs/model/prefs/shortcutsetting.cpp b/apps/opencs/model/prefs/shortcutsetting.cpp index cd2c1fcf5..211aead55 100644 --- a/apps/opencs/model/prefs/shortcutsetting.cpp +++ b/apps/opencs/model/prefs/shortcutsetting.cpp @@ -93,7 +93,7 @@ namespace CSMPrefs const int MaxKeys = 4; // A limitation of QKeySequence // Modifiers are handled differently - const int Blacklist[] + const int Blacklist[] = { Qt::Key_Shift, Qt::Key_Control, diff --git a/apps/opencs/model/prefs/state.cpp b/apps/opencs/model/prefs/state.cpp index 4b5ddffd1..89491e8dc 100644 --- a/apps/opencs/model/prefs/state.cpp +++ b/apps/opencs/model/prefs/state.cpp @@ -268,6 +268,25 @@ void CSMPrefs::State::declare() declareShortcut ("document-debug-shutdown", "Stop Debug", QKeySequence()); declareShortcut ("document-debug-runlog", "Run Log", QKeySequence()); + declareSeparator (); + declareShortcut ("table-edit", "Edit record", QKeySequence()); + declareShortcut ("table-add", "Add row/record", QKeySequence(Qt::ControlModifier | Qt::Key_N)); + declareShortcut ("table-clone", "Clone record", QKeySequence()); + declareShortcut ("table-revert", "Revert record", QKeySequence()); + declareShortcut ("table-remove", "Remove record", QKeySequence(Qt::Key_Delete)); + declareShortcut ("table-moveup", "Move record up", QKeySequence()); + declareShortcut ("table-movedown", "Move record down", QKeySequence()); + declareShortcut ("table-view", "View record", QKeySequence()); + declareShortcut ("table-preview", "Preview record", QKeySequence()); + declareShortcut ("table-extendeddelete", "Extended record deletion", QKeySequence()); + declareShortcut ("table-extendedrevert", "Extended record revertion", QKeySequence()); + + declareSeparator (); + declareShortcut ("reporttable-show", "Show report", QKeySequence()); + declareShortcut ("reporttable-remove", "Remove report", QKeySequence(Qt::Key_Delete)); + declareShortcut ("reporttable-replace", "Replace report", QKeySequence()); + declareShortcut ("reporttable-refresh", "Refresh report", QKeySequence()); + declareSeparator (); declareShortcut ("free-forward", "Free camera forward", QKeySequence(Qt::Key_W), Qt::Key_Shift); declareShortcut ("free-backward", "Free camera backward", QKeySequence(Qt::Key_S)); diff --git a/apps/opencs/view/tools/reporttable.cpp b/apps/opencs/view/tools/reporttable.cpp index bfc002933..58feda7c9 100644 --- a/apps/opencs/view/tools/reporttable.cpp +++ b/apps/opencs/view/tools/reporttable.cpp @@ -15,6 +15,7 @@ #include "../../model/tools/reportmodel.hpp" #include "../../model/prefs/state.hpp" +#include "../../model/prefs/shortcut.hpp" #include "../../view/world/idtypedelegate.hpp" @@ -171,14 +172,20 @@ CSVTools::ReportTable::ReportTable (CSMDoc::Document& document, mShowAction = new QAction (tr ("Show"), this); connect (mShowAction, SIGNAL (triggered()), this, SLOT (showSelection())); addAction (mShowAction); + CSMPrefs::Shortcut* showShortcut = new CSMPrefs::Shortcut("reporttable-show", this); + showShortcut->associateAction(mShowAction); mRemoveAction = new QAction (tr ("Remove from list"), this); connect (mRemoveAction, SIGNAL (triggered()), this, SLOT (removeSelection())); addAction (mRemoveAction); + CSMPrefs::Shortcut* removeShortcut = new CSMPrefs::Shortcut("reporttable-remove", this); + removeShortcut->associateAction(mRemoveAction); mReplaceAction = new QAction (tr ("Replace"), this); connect (mReplaceAction, SIGNAL (triggered()), this, SIGNAL (replaceRequest())); addAction (mReplaceAction); + CSMPrefs::Shortcut* replaceShortcut = new CSMPrefs::Shortcut("reporttable-replace", this); + replaceShortcut->associateAction(mReplaceAction); if (mRefreshState) { @@ -186,6 +193,8 @@ CSVTools::ReportTable::ReportTable (CSMDoc::Document& document, mRefreshAction->setEnabled (!(mDocument.getState() & mRefreshState)); connect (mRefreshAction, SIGNAL (triggered()), this, SIGNAL (refreshRequest())); addAction (mRefreshAction); + CSMPrefs::Shortcut* refreshShortcut = new CSMPrefs::Shortcut("reporttable-refresh", this); + refreshShortcut->associateAction(mRefreshAction); } mDoubleClickActions.insert (std::make_pair (Qt::NoModifier, Action_Edit)); diff --git a/apps/opencs/view/world/nestedtable.cpp b/apps/opencs/view/world/nestedtable.cpp index d791377b8..02bd93920 100644 --- a/apps/opencs/view/world/nestedtable.cpp +++ b/apps/opencs/view/world/nestedtable.cpp @@ -5,6 +5,8 @@ #include #include +#include "../../model/prefs/shortcut.hpp" + #include "../../model/world/nestedtableproxymodel.hpp" #include "../../model/world/universalid.hpp" #include "../../model/world/commands.hpp" @@ -60,14 +62,16 @@ CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document, if (!fixedRows) { mAddNewRowAction = new QAction (tr ("Add new row"), this); - connect(mAddNewRowAction, SIGNAL(triggered()), this, SLOT(addNewRowActionTriggered())); + CSMPrefs::Shortcut* addRowShortcut = new CSMPrefs::Shortcut("table-add", this); + addRowShortcut->associateAction(mAddNewRowAction); mRemoveRowAction = new QAction (tr ("Remove rows"), this); - connect(mRemoveRowAction, SIGNAL(triggered()), this, SLOT(removeRowActionTriggered())); + CSMPrefs::Shortcut* removeRowShortcut = new CSMPrefs::Shortcut("table-remove", this); + removeRowShortcut->associateAction(mRemoveRowAction); } mEditIdAction = new TableEditIdAction(*this, this); diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 45e50dba7..07db5b477 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -21,6 +21,7 @@ #include "../../model/world/commanddispatcher.hpp" #include "../../model/prefs/state.hpp" +#include "../../model/prefs/shortcut.hpp" #include "tableeditidaction.hpp" #include "util.hpp" @@ -283,49 +284,72 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, mEditAction = new QAction (tr ("Edit Record"), this); connect (mEditAction, SIGNAL (triggered()), this, SLOT (editRecord())); addAction (mEditAction); + CSMPrefs::Shortcut* editShortcut = new CSMPrefs::Shortcut("table-edit", this); + editShortcut->associateAction(mEditAction); if (createAndDelete) { mCreateAction = new QAction (tr ("Add Record"), this); connect (mCreateAction, SIGNAL (triggered()), this, SIGNAL (createRequest())); addAction (mCreateAction); + CSMPrefs::Shortcut* createShortcut = new CSMPrefs::Shortcut("table-add", this); + createShortcut->associateAction(mCreateAction); mCloneAction = new QAction (tr ("Clone Record"), this); connect(mCloneAction, SIGNAL (triggered()), this, SLOT (cloneRecord())); addAction(mCloneAction); + CSMPrefs::Shortcut* cloneShortcut = new CSMPrefs::Shortcut("table-clone", this); + cloneShortcut->associateAction(mCloneAction); } mRevertAction = new QAction (tr ("Revert Record"), this); connect (mRevertAction, SIGNAL (triggered()), mDispatcher, SLOT (executeRevert())); addAction (mRevertAction); + CSMPrefs::Shortcut* revertShortcut = new CSMPrefs::Shortcut("table-revert", this); + revertShortcut->associateAction(mRevertAction); mDeleteAction = new QAction (tr ("Delete Record"), this); connect (mDeleteAction, SIGNAL (triggered()), mDispatcher, SLOT (executeDelete())); addAction (mDeleteAction); + CSMPrefs::Shortcut* deleteShortcut = new CSMPrefs::Shortcut("table-remove", this); + deleteShortcut->associateAction(mDeleteAction); + mMoveUpAction = new QAction (tr ("Move Up"), this); connect (mMoveUpAction, SIGNAL (triggered()), this, SLOT (moveUpRecord())); addAction (mMoveUpAction); + CSMPrefs::Shortcut* moveUpShortcut = new CSMPrefs::Shortcut("table-moveup", this); + moveUpShortcut->associateAction(mMoveUpAction); mMoveDownAction = new QAction (tr ("Move Down"), this); connect (mMoveDownAction, SIGNAL (triggered()), this, SLOT (moveDownRecord())); addAction (mMoveDownAction); + CSMPrefs::Shortcut* moveDownShortcut = new CSMPrefs::Shortcut("table-movedown", this); + moveDownShortcut->associateAction(mMoveDownAction); mViewAction = new QAction (tr ("View"), this); connect (mViewAction, SIGNAL (triggered()), this, SLOT (viewRecord())); addAction (mViewAction); + CSMPrefs::Shortcut* viewShortcut = new CSMPrefs::Shortcut("table-view", this); + viewShortcut->associateAction(mViewAction); mPreviewAction = new QAction (tr ("Preview"), this); connect (mPreviewAction, SIGNAL (triggered()), this, SLOT (previewRecord())); addAction (mPreviewAction); + CSMPrefs::Shortcut* previewShortcut = new CSMPrefs::Shortcut("table-preview", this); + previewShortcut->associateAction(mPreviewAction); mExtendedDeleteAction = new QAction (tr ("Extended Delete Record"), this); connect (mExtendedDeleteAction, SIGNAL (triggered()), this, SLOT (executeExtendedDelete())); addAction (mExtendedDeleteAction); + CSMPrefs::Shortcut* extendedDeleteShortcut = new CSMPrefs::Shortcut("table-extendeddelete", this); + extendedDeleteShortcut->associateAction(mExtendedDeleteAction); mExtendedRevertAction = new QAction (tr ("Extended Revert Record"), this); connect (mExtendedRevertAction, SIGNAL (triggered()), this, SLOT (executeExtendedRevert())); addAction (mExtendedRevertAction); + CSMPrefs::Shortcut* extendedRevertShortcut = new CSMPrefs::Shortcut("table-extendedrevert", this); + extendedRevertShortcut->associateAction(mExtendedRevertAction); mEditIdAction = new TableEditIdAction (*this, this); connect (mEditIdAction, SIGNAL (triggered()), this, SLOT (editCell()));