Remove QShortcut usage,

Add a lot of shortcuts,
Remove debug messages
pull/29/head
Aesylwinn 9 years ago
parent 08af82e1bd
commit 3edc77a32b

@ -137,7 +137,10 @@ namespace CSMPrefs
{
if (mAction)
{
disconnect(this, SLOT(actionDeleted()));
mAction->setText(mActionText);
disconnect(this, SIGNAL(activated()), mAction, SLOT(trigger()));
disconnect(mAction, SIGNAL(destroyed()), this, SLOT(actionDeleted()));
}
mAction = action;
@ -147,6 +150,7 @@ namespace CSMPrefs
mActionText = mAction->text();
mAction->setText(mActionText + "\t" + State::get().getShortcutManager().convertToString(mSequence).data());
connect(this, SIGNAL(activated()), mAction, SLOT(trigger()));
connect(mAction, SIGNAL(destroyed()), this, SLOT(actionDeleted()));
}
}

@ -2,7 +2,6 @@
#include <algorithm>
#include <sstream>
#include <iostream>
#include <QApplication>
#include <QMetaEnum>
@ -141,9 +140,6 @@ namespace CSMPrefs
std::string ShortcutManager::convertToString(const QKeySequence& sequence, int modifier) const
{
std::string concat = convertToString(sequence) + ";" + convertToString(modifier);
std::cout << sequence[0] << "." << sequence[1] << "."<< sequence[2] << "."<< sequence[3] << "." << modifier << std::endl;
std::cout << concat << std::endl;
return concat;
}

@ -1,7 +1,5 @@
#include "shortcutsetting.hpp"
#include <iostream>
#include <QEvent>
#include <QKeyEvent>
#include <QLabel>

@ -168,16 +168,6 @@ void CSMPrefs::State::declare()
"list go to the first/last item");
declareCategory ("3D Scene Input");
EnumValue left ("Left Mouse-Button");
EnumValue cLeft ("Ctrl-Left Mouse-Button");
EnumValue right ("Right Mouse-Button");
EnumValue cRight ("Ctrl-Right Mouse-Button");
EnumValue middle ("Middle Mouse-Button");
EnumValue cMiddle ("Ctrl-Middle Mouse-Button");
EnumValues inputButtons;
inputButtons.add (left).add (cLeft).add (right).add (cRight).add (middle).add (cMiddle);
declareEnum ("p-navi", "Primary Camera Navigation Button", left).addValues (inputButtons);
declareEnum ("s-navi", "Secondary Camera Navigation Button", cLeft).addValues (inputButtons);
declareDouble ("p-navi-free-sensitivity", "Free Camera Sensitivity", 1/650.).setPrecision(5).setRange(0.0, 1.0);
declareBool ("p-navi-free-invert", "Invert Free Camera Mouse Input", false);
declareDouble ("p-navi-orbit-sensitivity", "Orbit Camera Sensitivity", 1/650.).setPrecision(5).setRange(0.0, 1.0);
@ -189,10 +179,6 @@ void CSMPrefs::State::declare()
declareDouble ("navi-free-speed-mult", "Free Camera Speed Multiplier (from Modifier)", 8).setRange(0.001, 1000.0);
declareDouble ("navi-orbit-rot-speed", "Orbital Camera Rotational Speed", 3.14 / 4).setRange(0.001, 6.28);
declareDouble ("navi-orbit-speed-mult", "Orbital Camera Speed Multiplier (from Modifier)", 4).setRange(0.001, 1000.0);
declareEnum ("p-edit", "Primary Editing Button", right).addValues (inputButtons);
declareEnum ("s-edit", "Secondary Editing Button", cRight).addValues (inputButtons);
declareEnum ("p-select", "Primary Selection Button", middle).addValues (inputButtons);
declareEnum ("s-select", "Secondary Selection Button", cMiddle).addValues (inputButtons);
declareSeparator();
declareBool ("context-select", "Context Sensitive Selection", false);
declareDouble ("drag-factor", "Mouse sensitivity during drag operations", 1.0).
@ -230,7 +216,57 @@ void CSMPrefs::State::declare()
declareCategory ("Key Bindings");
declareShortcut ("document-save", "Save", QKeySequence(Qt::ControlModifier | Qt::Key_S));
declareShortcut ("document-file-newgame", "Create new game", QKeySequence());
declareShortcut ("document-file-newaddon", "Create new addon", QKeySequence());
declareShortcut ("document-file-open", "Open", QKeySequence());
declareShortcut ("document-file-save", "Save", QKeySequence(Qt::ControlModifier | Qt::Key_S));
declareShortcut ("document-file-verify", "Verify", QKeySequence(Qt::ControlModifier | Qt::Key_V));
declareShortcut ("document-file-merge", "Merge", QKeySequence());
declareShortcut ("document-file-errorlog", "Load error log", QKeySequence());
declareShortcut ("document-file-metadata", "Meta Data", QKeySequence());
declareShortcut ("document-file-close", "Close", QKeySequence());
declareShortcut ("document-file-exit", "Exit", QKeySequence());
declareShortcut ("document-edit-undo", "Undo", QKeySequence(Qt::ControlModifier | Qt::Key_Z));
declareShortcut ("document-edit-redo", "Redo", QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Z));
declareShortcut ("document-edit-preferences", "Show Preferences", QKeySequence());
declareShortcut ("document-edit-search", "Show Search", QKeySequence());
declareShortcut ("document-view-newview", "New View", QKeySequence());
declareShortcut ("document-view-statusbar", "Show Status Bar", QKeySequence());
declareShortcut ("document-view-filters", "Show Filters", QKeySequence());
declareShortcut ("document-world-regions", "Show Regions", QKeySequence());
declareShortcut ("document-world-cells", "Show Cells", QKeySequence());
declareShortcut ("document-world-referencables", "Show Referencables", QKeySequence());
declareShortcut ("document-world-references", "Show References", QKeySequence());
declareShortcut ("document-world-pathgrid", "Show Pathgrids", QKeySequence());
declareShortcut ("document-world-regionmap", "Show Region Map", QKeySequence());
declareShortcut ("document-mechanics-globals", "Show Globals", QKeySequence());
declareShortcut ("document-mechanics-gamesettings", "Show Game Settings", QKeySequence());
declareShortcut ("document-mechanics-scripts", "Show Scripts", QKeySequence());
declareShortcut ("document-mechanics-spells", "Show Spells", QKeySequence());
declareShortcut ("document-mechanics-enchantments", "Show Enchantments", QKeySequence());
declareShortcut ("document-mechanics-magiceffects", "Show Magic Effects", QKeySequence());
declareShortcut ("document-mechanics-startscripts", "Show Start Scripts", QKeySequence());
declareShortcut ("document-character-skills", "Show Skills", QKeySequence());
declareShortcut ("document-character-classes", "Show Classes", QKeySequence());
declareShortcut ("document-character-factions", "Show Factions", QKeySequence());
declareShortcut ("document-character-races", "Show Races", QKeySequence());
declareShortcut ("document-character-birthsigns", "Show Birthsigns", QKeySequence());
declareShortcut ("document-character-topics", "Show Topics", QKeySequence());
declareShortcut ("document-character-journals", "Show Journals", QKeySequence());
declareShortcut ("document-character-topicinfos", "Show Topic Infos", QKeySequence());
declareShortcut ("document-character-journalinfos", "Show Journal Infos", QKeySequence());
declareShortcut ("document-character-bodyparts", "Show Body Parts", QKeySequence());
declareShortcut ("document-assets-sounds", "Show Sound Assets", QKeySequence());
declareShortcut ("document-assets-soundgens", "Show Sound Generators", QKeySequence());
declareShortcut ("document-assets-meshes", "Show Mesh Assets", QKeySequence());
declareShortcut ("document-assets-icons", "Show Icon Assets", QKeySequence());
declareShortcut ("document-assets-music", "Show Music Assets", QKeySequence());
declareShortcut ("document-assets-soundres", "Show Sound Files", QKeySequence());
declareShortcut ("document-assets-textures", "TShow exture Assets", QKeySequence());
declareShortcut ("document-assets-videos", "Show Video Assets", QKeySequence());
declareShortcut ("document-debug-run", "Run Debug", QKeySequence());
declareShortcut ("document-debug-shutdown", "Stop Debug", QKeySequence());
declareShortcut ("document-debug-runlog", "Run Log", QKeySequence());
declareSeparator ();
declareShortcut ("free-forward", "Free camera forward", QKeySequence(Qt::Key_W), Qt::Key_Shift);

@ -49,47 +49,54 @@ void CSVDoc::View::setupFileMenu()
QAction *newGame = new QAction (tr ("New Game"), this);
connect (newGame, SIGNAL (triggered()), this, SIGNAL (newGameRequest()));
setupShortcut("document-file-newgame", newGame);
file->addAction (newGame);
QAction *newAddon = new QAction (tr ("New Addon"), this);
connect (newAddon, SIGNAL (triggered()), this, SIGNAL (newAddonRequest()));
setupShortcut("document-file-newaddon", newAddon);
file->addAction (newAddon);
QAction *open = new QAction (tr ("&Open"), this);
connect (open, SIGNAL (triggered()), this, SIGNAL (loadDocumentRequest()));
setupShortcut("document-file-open", open);
file->addAction (open);
mSave = new QAction (tr ("&Save"), this);
connect (mSave, SIGNAL (triggered()), this, SLOT (save()));
setupShortcut("document-file-save", mSave);
file->addAction (mSave);
CSMPrefs::Shortcut* saveShortcut = new CSMPrefs::Shortcut("document-save", this);
saveShortcut->associateAction(mSave);
connect (saveShortcut, SIGNAL(activated()), this, SLOT(save()));
mVerify = new QAction (tr ("&Verify"), this);
connect (mVerify, SIGNAL (triggered()), this, SLOT (verify()));
setupShortcut("document-file-verify", mVerify);
file->addAction (mVerify);
mMerge = new QAction (tr ("Merge"), this);
connect (mMerge, SIGNAL (triggered()), this, SLOT (merge()));
setupShortcut("document-file-merge", mMerge);
file->addAction (mMerge);
QAction *loadErrors = new QAction (tr ("Load Error Log"), this);
connect (loadErrors, SIGNAL (triggered()), this, SLOT (loadErrorLog()));
setupShortcut("document-file-errorlog", loadErrors);
file->addAction (loadErrors);
QAction *meta = new QAction (tr ("Meta Data"), this);
connect (meta, SIGNAL (triggered()), this, SLOT (addMetaDataSubView()));
setupShortcut("document-file-metadata", meta);
file->addAction (meta);
QAction *close = new QAction (tr ("&Close"), this);
connect (close, SIGNAL (triggered()), this, SLOT (close()));
setupShortcut("document-file-close", close);
file->addAction(close);
QAction *exit = new QAction (tr ("&Exit"), this);
connect (exit, SIGNAL (triggered()), this, SLOT (exit()));
connect (this, SIGNAL(exitApplicationRequest(CSVDoc::View *)), &mViewManager, SLOT(exitApplication(CSVDoc::View *)));
setupShortcut("document-file-exit", exit);
file->addAction(exit);
}
@ -99,19 +106,21 @@ void CSVDoc::View::setupEditMenu()
QMenu *edit = menuBar()->addMenu (tr ("&Edit"));
mUndo = mDocument->getUndoStack().createUndoAction (this, tr("&Undo"));
mUndo->setShortcuts (QKeySequence::Undo);
setupShortcut("document-edit-undo", mUndo);
edit->addAction (mUndo);
mRedo= mDocument->getUndoStack().createRedoAction (this, tr("&Redo"));
mRedo->setShortcuts (QKeySequence::Redo);
setupShortcut("document-edit-redo", mRedo);
edit->addAction (mRedo);
QAction *userSettings = new QAction (tr ("&Preferences"), this);
connect (userSettings, SIGNAL (triggered()), this, SIGNAL (editSettingsRequest()));
setupShortcut("document-edit-preferences", userSettings);
edit->addAction (userSettings);
QAction *search = new QAction (tr ("Search"), this);
connect (search, SIGNAL (triggered()), this, SLOT (addSearchSubView()));
setupShortcut("document-edit-search", search);
edit->addAction (search);
}
@ -121,11 +130,13 @@ void CSVDoc::View::setupViewMenu()
QAction *newWindow = new QAction (tr ("&New View"), this);
connect (newWindow, SIGNAL (triggered()), this, SLOT (newView()));
setupShortcut("document-view-newview", newWindow);
view->addAction (newWindow);
mShowStatusBar = new QAction (tr ("Show Status Bar"), this);
mShowStatusBar->setCheckable (true);
connect (mShowStatusBar, SIGNAL (toggled (bool)), this, SLOT (toggleShowStatusBar (bool)));
setupShortcut("document-view-statusbar", mShowStatusBar);
mShowStatusBar->setChecked (CSMPrefs::get()["Windows"]["show-statusbar"].isTrue());
@ -133,6 +144,7 @@ void CSVDoc::View::setupViewMenu()
QAction *filters = new QAction (tr ("Filters"), this);
connect (filters, SIGNAL (triggered()), this, SLOT (addFiltersSubView()));
setupShortcut("document-view-filters", filters);
view->addAction (filters);
}
@ -142,28 +154,34 @@ void CSVDoc::View::setupWorldMenu()
QAction *regions = new QAction (tr ("Regions"), this);
connect (regions, SIGNAL (triggered()), this, SLOT (addRegionsSubView()));
setupShortcut("document-world-regions", regions);
world->addAction (regions);
QAction *cells = new QAction (tr ("Cells"), this);
connect (cells, SIGNAL (triggered()), this, SLOT (addCellsSubView()));
setupShortcut("document-world-cells", cells);
world->addAction (cells);
QAction *referenceables = new QAction (tr ("Objects"), this);
connect (referenceables, SIGNAL (triggered()), this, SLOT (addReferenceablesSubView()));
setupShortcut("document-world-referencables", referenceables);
world->addAction (referenceables);
QAction *references = new QAction (tr ("Instances"), this);
connect (references, SIGNAL (triggered()), this, SLOT (addReferencesSubView()));
setupShortcut("document-world-references", references);
world->addAction (references);
QAction *grid = new QAction (tr ("Pathgrid"), this);
connect (grid, SIGNAL (triggered()), this, SLOT (addPathgridSubView()));
setupShortcut("document-world-pathgrid", grid);
world->addAction (grid);
world->addSeparator(); // items that don't represent single record lists follow here
QAction *regionMap = new QAction (tr ("Region Map"), this);
connect (regionMap, SIGNAL (triggered()), this, SLOT (addRegionMapSubView()));
setupShortcut("document-world-regionmap", regionMap);
world->addAction (regionMap);
}
@ -173,30 +191,37 @@ void CSVDoc::View::setupMechanicsMenu()
QAction *globals = new QAction (tr ("Globals"), this);
connect (globals, SIGNAL (triggered()), this, SLOT (addGlobalsSubView()));
setupShortcut("document-mechanics-globals", globals);
mechanics->addAction (globals);
QAction *gmsts = new QAction (tr ("Game settings"), this);
connect (gmsts, SIGNAL (triggered()), this, SLOT (addGmstsSubView()));
setupShortcut("document-mechanics-gamesettings", gmsts);
mechanics->addAction (gmsts);
QAction *scripts = new QAction (tr ("Scripts"), this);
connect (scripts, SIGNAL (triggered()), this, SLOT (addScriptsSubView()));
setupShortcut("document-mechanics-scripts", scripts);
mechanics->addAction (scripts);
QAction *spells = new QAction (tr ("Spells"), this);
connect (spells, SIGNAL (triggered()), this, SLOT (addSpellsSubView()));
setupShortcut("document-mechanics-spells", spells);
mechanics->addAction (spells);
QAction *enchantments = new QAction (tr ("Enchantments"), this);
connect (enchantments, SIGNAL (triggered()), this, SLOT (addEnchantmentsSubView()));
setupShortcut("document-mechanics-enchantments", enchantments);
mechanics->addAction (enchantments);
QAction *effects = new QAction (tr ("Magic Effects"), this);
connect (effects, SIGNAL (triggered()), this, SLOT (addMagicEffectsSubView()));
setupShortcut("document-mechanics-magiceffects", effects);
mechanics->addAction (effects);
QAction *startScripts = new QAction (tr ("Start Scripts"), this);
connect (startScripts, SIGNAL (triggered()), this, SLOT (addStartScriptsSubView()));
setupShortcut("document-mechanics-startscripts", startScripts);
mechanics->addAction (startScripts);
}
@ -206,42 +231,52 @@ void CSVDoc::View::setupCharacterMenu()
QAction *skills = new QAction (tr ("Skills"), this);
connect (skills, SIGNAL (triggered()), this, SLOT (addSkillsSubView()));
setupShortcut("document-character-skills", skills);
characters->addAction (skills);
QAction *classes = new QAction (tr ("Classes"), this);
connect (classes, SIGNAL (triggered()), this, SLOT (addClassesSubView()));
setupShortcut("document-character-classes", classes);
characters->addAction (classes);
QAction *factions = new QAction (tr ("Factions"), this);
connect (factions, SIGNAL (triggered()), this, SLOT (addFactionsSubView()));
setupShortcut("document-character-factions", factions);
characters->addAction (factions);
QAction *races = new QAction (tr ("Races"), this);
connect (races, SIGNAL (triggered()), this, SLOT (addRacesSubView()));
setupShortcut("document-character-races", races);
characters->addAction (races);
QAction *birthsigns = new QAction (tr ("Birthsigns"), this);
connect (birthsigns, SIGNAL (triggered()), this, SLOT (addBirthsignsSubView()));
setupShortcut("document-character-birthsigns", birthsigns);
characters->addAction (birthsigns);
QAction *topics = new QAction (tr ("Topics"), this);
connect (topics, SIGNAL (triggered()), this, SLOT (addTopicsSubView()));
setupShortcut("document-character-topics", topics);
characters->addAction (topics);
QAction *journals = new QAction (tr ("Journals"), this);
connect (journals, SIGNAL (triggered()), this, SLOT (addJournalsSubView()));
setupShortcut("document-character-journals", journals);
characters->addAction (journals);
QAction *topicInfos = new QAction (tr ("Topic Infos"), this);
connect (topicInfos, SIGNAL (triggered()), this, SLOT (addTopicInfosSubView()));
setupShortcut("document-character-topicinfos", topicInfos);
characters->addAction (topicInfos);
QAction *journalInfos = new QAction (tr ("Journal Infos"), this);
connect (journalInfos, SIGNAL (triggered()), this, SLOT (addJournalInfosSubView()));
setupShortcut("document-character-journalinfos", journalInfos);
characters->addAction (journalInfos);
QAction *bodyParts = new QAction (tr ("Body Parts"), this);
connect (bodyParts, SIGNAL (triggered()), this, SLOT (addBodyPartsSubView()));
setupShortcut("document-character-bodyparts", bodyParts);
characters->addAction (bodyParts);
}
@ -251,36 +286,44 @@ void CSVDoc::View::setupAssetsMenu()
QAction *sounds = new QAction (tr ("Sounds"), this);
connect (sounds, SIGNAL (triggered()), this, SLOT (addSoundsSubView()));
setupShortcut("document-assets-sounds", sounds);
assets->addAction (sounds);
QAction *soundGens = new QAction (tr ("Sound Generators"), this);
connect (soundGens, SIGNAL (triggered()), this, SLOT (addSoundGensSubView()));
setupShortcut("document-assets-soundgens", soundGens);
assets->addAction (soundGens);
assets->addSeparator(); // resources follow here
QAction *meshes = new QAction (tr ("Meshes"), this);
connect (meshes, SIGNAL (triggered()), this, SLOT (addMeshesSubView()));
setupShortcut("document-assets-meshes", meshes);
assets->addAction (meshes);
QAction *icons = new QAction (tr ("Icons"), this);
connect (icons, SIGNAL (triggered()), this, SLOT (addIconsSubView()));
setupShortcut("document-assets-icons", icons);
assets->addAction (icons);
QAction *musics = new QAction (tr ("Music"), this);
connect (musics, SIGNAL (triggered()), this, SLOT (addMusicsSubView()));
setupShortcut("document-assets-music", musics);
assets->addAction (musics);
QAction *soundsRes = new QAction (tr ("Sound Files"), this);
connect (soundsRes, SIGNAL (triggered()), this, SLOT (addSoundsResSubView()));
setupShortcut("document-assets-soundres", soundsRes);
assets->addAction (soundsRes);
QAction *textures = new QAction (tr ("Textures"), this);
connect (textures, SIGNAL (triggered()), this, SLOT (addTexturesSubView()));
setupShortcut("document-assets-textures", textures);
assets->addAction (textures);
QAction *videos = new QAction (tr ("Videos"), this);
connect (videos, SIGNAL (triggered()), this, SLOT (addVideosSubView()));
setupShortcut("document-assets-videos", videos);
assets->addAction (videos);
}
@ -304,12 +347,16 @@ void CSVDoc::View::setupDebugMenu()
QAction *runDebug = debug->addMenu (mGlobalDebugProfileMenu);
runDebug->setText (tr ("Run OpenMW"));
setupShortcut("document-debug-run", runDebug);
mStopDebug = new QAction (tr ("Shutdown OpenMW"), this);
connect (mStopDebug, SIGNAL (triggered()), this, SLOT (stop()));
setupShortcut("document-debug-shutdown", mStopDebug);
debug->addAction (mStopDebug);
QAction *runLog = new QAction (tr ("Run Log"), this);
connect (runLog, SIGNAL (triggered()), this, SLOT (addRunLogSubView()));
setupShortcut("document-debug-runlog", runLog);
debug->addAction (runLog);
}
@ -325,6 +372,12 @@ void CSVDoc::View::setupUi()
setupDebugMenu();
}
void CSVDoc::View::setupShortcut(const char* name, QAction* action)
{
CSMPrefs::Shortcut* shortcut = new CSMPrefs::Shortcut(name, this);
shortcut->associateAction(action);
}
void CSVDoc::View::updateTitle()
{
std::ostringstream stream;

@ -84,6 +84,8 @@ namespace CSVDoc
void setupUi();
void setupShortcut(const char* name, QAction* action);
void updateActions();
void exitApplication();

@ -3,7 +3,6 @@
#include <QEvent>
#include <QResizeEvent>
#include <QTimer>
#include <QShortcut>
#include <QLayout>
#include <extern/osgQt/GraphicsWindowQt>

@ -1,7 +1,8 @@
#include "scenetoolbar.hpp"
#include <QVBoxLayout>
#include <QShortcut>
#include "../../model/prefs/shortcut.hpp"
#include "scenetool.hpp"
@ -25,9 +26,8 @@ CSVWidget::SceneToolbar::SceneToolbar (int buttonSize, QWidget *parent)
setLayout (mLayout);
/// \todo make shortcut configurable
QShortcut *focusScene = new QShortcut (Qt::Key_T, this, 0, 0, Qt::WidgetWithChildrenShortcut);
connect (focusScene, SIGNAL (activated()), this, SIGNAL (focusSceneRequest()));
CSMPrefs::Shortcut* focusSceneShortcut = new CSMPrefs::Shortcut("scene-focus-toolbar", this);
connect(focusSceneShortcut, SIGNAL(activated()), this, SIGNAL(focusSceneRequest()));
}
void CSVWidget::SceneToolbar::addTool (SceneTool *tool, SceneTool *insertPoint)

Loading…
Cancel
Save