mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Change the way modifiers are handled so they can be shared.
This commit is contained in:
parent
faea33b888
commit
bf2ab4ed45
10 changed files with 145 additions and 90 deletions
|
@ -21,9 +21,8 @@ namespace CSMPrefs
|
||||||
|
|
||||||
std::pair<QWidget*, QWidget*> ModifierSetting::makeWidgets(QWidget* parent)
|
std::pair<QWidget*, QWidget*> ModifierSetting::makeWidgets(QWidget* parent)
|
||||||
{
|
{
|
||||||
QKeySequence sequence;
|
|
||||||
int modifier = 0;
|
int modifier = 0;
|
||||||
State::get().getShortcutManager().getSequence(getKey(), sequence, modifier);
|
State::get().getShortcutManager().getModifier(getKey(), modifier);
|
||||||
|
|
||||||
QString text = QString::fromUtf8(State::get().getShortcutManager().convertToString(modifier).c_str());
|
QString text = QString::fromUtf8(State::get().getShortcutManager().convertToString(modifier).c_str());
|
||||||
|
|
||||||
|
@ -111,13 +110,10 @@ namespace CSMPrefs
|
||||||
|
|
||||||
void ModifierSetting::storeValue(int modifier)
|
void ModifierSetting::storeValue(int modifier)
|
||||||
{
|
{
|
||||||
QKeySequence sequence;
|
State::get().getShortcutManager().setModifier(getKey(), modifier);
|
||||||
int ignored;
|
|
||||||
State::get().getShortcutManager().getSequence(getKey(), sequence, ignored);
|
|
||||||
State::get().getShortcutManager().setSequence(getKey(), sequence, modifier);
|
|
||||||
|
|
||||||
// Convert to string and assign
|
// Convert to string and assign
|
||||||
std::string value = State::get().getShortcutManager().convertToString(sequence, modifier);
|
std::string value = State::get().getShortcutManager().convertToString(modifier);
|
||||||
|
|
||||||
{
|
{
|
||||||
QMutexLocker lock(getMutex());
|
QMutexLocker lock(getMutex());
|
||||||
|
@ -133,9 +129,8 @@ namespace CSMPrefs
|
||||||
mEditorActive = false;
|
mEditorActive = false;
|
||||||
|
|
||||||
// Button text
|
// Button text
|
||||||
QKeySequence sequence;
|
|
||||||
int modifier = 0;
|
int modifier = 0;
|
||||||
State::get().getShortcutManager().getSequence(getKey(), sequence, modifier);
|
State::get().getShortcutManager().getModifier(getKey(), modifier);
|
||||||
|
|
||||||
QString text = QString::fromUtf8(State::get().getShortcutManager().convertToString(modifier).c_str());
|
QString text = QString::fromUtf8(State::get().getShortcutManager().convertToString(modifier).c_str());
|
||||||
mButton->setText(text);
|
mButton->setText(text);
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace CSMPrefs
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, mEnabled(true)
|
, mEnabled(true)
|
||||||
, mName(name)
|
, mName(name)
|
||||||
|
, mModName("")
|
||||||
, mSecondaryMode(SM_Ignore)
|
, mSecondaryMode(SM_Ignore)
|
||||||
, mModifier(0)
|
, mModifier(0)
|
||||||
, mCurrentPos(0)
|
, mCurrentPos(0)
|
||||||
|
@ -25,13 +26,34 @@ namespace CSMPrefs
|
||||||
assert (parent);
|
assert (parent);
|
||||||
|
|
||||||
State::get().getShortcutManager().addShortcut(this);
|
State::get().getShortcutManager().addShortcut(this);
|
||||||
State::get().getShortcutManager().getSequence(name, mSequence, mModifier);
|
State::get().getShortcutManager().getSequence(name, mSequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut::Shortcut(const std::string& name, SecondaryMode secMode, QWidget* parent)
|
Shortcut::Shortcut(const std::string& name, const std::string& modName, QWidget* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, mEnabled(true)
|
, mEnabled(true)
|
||||||
, mName(name)
|
, mName(name)
|
||||||
|
, mModName(modName)
|
||||||
|
, mSecondaryMode(SM_Ignore)
|
||||||
|
, mModifier(0)
|
||||||
|
, mCurrentPos(0)
|
||||||
|
, mLastPos(0)
|
||||||
|
, mActivationStatus(AS_Inactive)
|
||||||
|
, mModifierStatus(false)
|
||||||
|
, mAction(0)
|
||||||
|
{
|
||||||
|
assert (parent);
|
||||||
|
|
||||||
|
State::get().getShortcutManager().addShortcut(this);
|
||||||
|
State::get().getShortcutManager().getSequence(name, mSequence);
|
||||||
|
State::get().getShortcutManager().getModifier(modName, mModifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
Shortcut::Shortcut(const std::string& name, const std::string& modName, SecondaryMode secMode, QWidget* parent)
|
||||||
|
: QObject(parent)
|
||||||
|
, mEnabled(true)
|
||||||
|
, mName(name)
|
||||||
|
, mModName(modName)
|
||||||
, mSecondaryMode(secMode)
|
, mSecondaryMode(secMode)
|
||||||
, mModifier(0)
|
, mModifier(0)
|
||||||
, mCurrentPos(0)
|
, mCurrentPos(0)
|
||||||
|
@ -43,7 +65,8 @@ namespace CSMPrefs
|
||||||
assert (parent);
|
assert (parent);
|
||||||
|
|
||||||
State::get().getShortcutManager().addShortcut(this);
|
State::get().getShortcutManager().addShortcut(this);
|
||||||
State::get().getShortcutManager().getSequence(name, mSequence, mModifier);
|
State::get().getShortcutManager().getSequence(name, mSequence);
|
||||||
|
State::get().getShortcutManager().getModifier(modName, mModifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut::~Shortcut()
|
Shortcut::~Shortcut()
|
||||||
|
@ -61,6 +84,11 @@ namespace CSMPrefs
|
||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& Shortcut::getModifierName() const
|
||||||
|
{
|
||||||
|
return mModName;
|
||||||
|
}
|
||||||
|
|
||||||
Shortcut::SecondaryMode Shortcut::getSecondaryMode() const
|
Shortcut::SecondaryMode Shortcut::getSecondaryMode() const
|
||||||
{
|
{
|
||||||
return mSecondaryMode;
|
return mSecondaryMode;
|
||||||
|
|
|
@ -34,13 +34,16 @@ namespace CSMPrefs
|
||||||
};
|
};
|
||||||
|
|
||||||
Shortcut(const std::string& name, QWidget* parent);
|
Shortcut(const std::string& name, QWidget* parent);
|
||||||
Shortcut(const std::string& name, SecondaryMode secMode, QWidget* parent);
|
Shortcut(const std::string& name, const std::string& modName, QWidget* parent);
|
||||||
|
Shortcut(const std::string& name, const std::string& modName, SecondaryMode secMode, QWidget* parent);
|
||||||
|
|
||||||
~Shortcut();
|
~Shortcut();
|
||||||
|
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
|
|
||||||
const std::string& getName() const;
|
const std::string& getName() const;
|
||||||
|
const std::string& getModifierName() const;
|
||||||
|
|
||||||
SecondaryMode getSecondaryMode() const;
|
SecondaryMode getSecondaryMode() const;
|
||||||
|
|
||||||
const QKeySequence& getSequence() const;
|
const QKeySequence& getSequence() const;
|
||||||
|
@ -82,6 +85,7 @@ namespace CSMPrefs
|
||||||
bool mEnabled;
|
bool mEnabled;
|
||||||
|
|
||||||
std::string mName;
|
std::string mName;
|
||||||
|
std::string mModName;
|
||||||
SecondaryMode mSecondaryMode;
|
SecondaryMode mSecondaryMode;
|
||||||
QKeySequence mSequence;
|
QKeySequence mSequence;
|
||||||
int mModifier;
|
int mModifier;
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace CSMPrefs
|
||||||
void ShortcutManager::addShortcut(Shortcut* shortcut)
|
void ShortcutManager::addShortcut(Shortcut* shortcut)
|
||||||
{
|
{
|
||||||
mShortcuts.insert(std::make_pair(shortcut->getName(), shortcut));
|
mShortcuts.insert(std::make_pair(shortcut->getName(), shortcut));
|
||||||
|
mShortcuts.insert(std::make_pair(shortcut->getModifierName(), shortcut));
|
||||||
mEventHandler->addShortcut(shortcut);
|
mEventHandler->addShortcut(shortcut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,13 +42,12 @@ namespace CSMPrefs
|
||||||
mEventHandler->removeShortcut(shortcut);
|
mEventHandler->removeShortcut(shortcut);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShortcutManager::getSequence(const std::string& name, QKeySequence& sequence, int& modifier) const
|
bool ShortcutManager::getSequence(const std::string& name, QKeySequence& sequence) const
|
||||||
{
|
{
|
||||||
SequenceMap::const_iterator item = mSequences.find(name);
|
SequenceMap::const_iterator item = mSequences.find(name);
|
||||||
if (item != mSequences.end())
|
if (item != mSequences.end())
|
||||||
{
|
{
|
||||||
sequence = item->second.first;
|
sequence = item->second;
|
||||||
modifier = item->second.second;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -55,17 +55,17 @@ namespace CSMPrefs
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShortcutManager::setSequence(const std::string& name, const QKeySequence& sequence, int modifier)
|
void ShortcutManager::setSequence(const std::string& name, const QKeySequence& sequence)
|
||||||
{
|
{
|
||||||
// Add to map/modify
|
// Add to map/modify
|
||||||
SequenceMap::iterator item = mSequences.find(name);
|
SequenceMap::iterator item = mSequences.find(name);
|
||||||
if (item != mSequences.end())
|
if (item != mSequences.end())
|
||||||
{
|
{
|
||||||
item->second = std::make_pair(sequence, modifier);
|
item->second = sequence;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mSequences.insert(std::make_pair(name, std::make_pair(sequence, modifier)));
|
mSequences.insert(std::make_pair(name, sequence));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change active shortcuts
|
// Change active shortcuts
|
||||||
|
@ -74,6 +74,40 @@ namespace CSMPrefs
|
||||||
for (ShortcutMap::iterator it = rangeS.first; it != rangeS.second; ++it)
|
for (ShortcutMap::iterator it = rangeS.first; it != rangeS.second; ++it)
|
||||||
{
|
{
|
||||||
it->second->setSequence(sequence);
|
it->second->setSequence(sequence);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ShortcutManager::getModifier(const std::string& name, int& modifier) const
|
||||||
|
{
|
||||||
|
ModifierMap::const_iterator item = mModifiers.find(name);
|
||||||
|
if (item != mModifiers.end())
|
||||||
|
{
|
||||||
|
modifier = item->second;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShortcutManager::setModifier(const std::string& name, int modifier)
|
||||||
|
{
|
||||||
|
// Add to map/modify
|
||||||
|
ModifierMap::iterator item = mModifiers.find(name);
|
||||||
|
if (item != mModifiers.end())
|
||||||
|
{
|
||||||
|
item->second = modifier;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mModifiers.insert(std::make_pair(name, modifier));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Change active shortcuts
|
||||||
|
std::pair<ShortcutMap::iterator, ShortcutMap::iterator> rangeS = mShortcuts.equal_range(name);
|
||||||
|
|
||||||
|
for (ShortcutMap::iterator it = rangeS.first; it != rangeS.second; ++it)
|
||||||
|
{
|
||||||
it->second->setModifier(modifier);
|
it->second->setModifier(modifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,7 +290,6 @@ namespace CSMPrefs
|
||||||
{
|
{
|
||||||
const QChar SequenceStart = '{';
|
const QChar SequenceStart = '{';
|
||||||
const QChar SequenceEnd = '}';
|
const QChar SequenceEnd = '}';
|
||||||
const QString ModifierSequence = QString::fromUtf8(":mod");
|
|
||||||
|
|
||||||
QStringList substrings;
|
QStringList substrings;
|
||||||
|
|
||||||
|
@ -277,33 +310,22 @@ namespace CSMPrefs
|
||||||
startIndex += 1; // '{' character
|
startIndex += 1; // '{' character
|
||||||
count = endIndex - startIndex;
|
count = endIndex - startIndex;
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
|
||||||
// Check if looking for modifier
|
|
||||||
int separatorIndex = toolTip.indexOf(ModifierSequence, startIndex);
|
|
||||||
if (separatorIndex != -1 && separatorIndex < endIndex)
|
|
||||||
{
|
|
||||||
count = separatorIndex - startIndex;
|
|
||||||
|
|
||||||
QString settingName = toolTip.mid(startIndex, count);
|
|
||||||
|
|
||||||
QKeySequence ignored;
|
|
||||||
int modifier = 0;
|
|
||||||
getSequence(settingName.toUtf8().data(), ignored, modifier);
|
|
||||||
|
|
||||||
QString value = QString::fromUtf8(convertToString(modifier).c_str());
|
|
||||||
substrings.push_back(value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
QString settingName = toolTip.mid(startIndex, count);
|
QString settingName = toolTip.mid(startIndex, count);
|
||||||
|
|
||||||
QKeySequence sequence;
|
QKeySequence sequence;
|
||||||
int ignored = 0;
|
int modifier;
|
||||||
getSequence(settingName.toUtf8().data(), sequence, ignored);
|
|
||||||
|
|
||||||
|
if (getSequence(settingName.toUtf8().data(), sequence))
|
||||||
|
{
|
||||||
QString value = QString::fromUtf8(convertToString(sequence).c_str());
|
QString value = QString::fromUtf8(convertToString(sequence).c_str());
|
||||||
substrings.push_back(value);
|
substrings.push_back(value);
|
||||||
}
|
}
|
||||||
|
else if (getModifier(settingName.toUtf8().data(), modifier))
|
||||||
|
{
|
||||||
|
QString value = QString::fromUtf8(convertToString(modifier).c_str());
|
||||||
|
substrings.push_back(value);
|
||||||
|
}
|
||||||
|
|
||||||
prevIndex = endIndex + 1; // '}' character
|
prevIndex = endIndex + 1; // '}' character
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,11 @@ namespace CSMPrefs
|
||||||
/// The shortcut class will do this automatically
|
/// The shortcut class will do this automatically
|
||||||
void removeShortcut(Shortcut* shortcut);
|
void removeShortcut(Shortcut* shortcut);
|
||||||
|
|
||||||
bool getSequence(const std::string& name, QKeySequence& sequence, int& modifier) const;
|
bool getSequence(const std::string& name, QKeySequence& sequence) const;
|
||||||
void setSequence(const std::string& name, const QKeySequence& sequence, int modifier);
|
void setSequence(const std::string& name, const QKeySequence& sequence);
|
||||||
|
|
||||||
|
bool getModifier(const std::string& name, int& modifier) const;
|
||||||
|
void setModifier(const std::string& name, int modifier);
|
||||||
|
|
||||||
std::string convertToString(const QKeySequence& sequence) const;
|
std::string convertToString(const QKeySequence& sequence) const;
|
||||||
std::string convertToString(int modifier) const;
|
std::string convertToString(int modifier) const;
|
||||||
|
@ -40,22 +43,21 @@ namespace CSMPrefs
|
||||||
|
|
||||||
void convertFromString(const std::string& data, QKeySequence& sequence, int& modifier) const;
|
void convertFromString(const std::string& data, QKeySequence& sequence, int& modifier) const;
|
||||||
|
|
||||||
/// Replaces "{sequence-name}" or "{sequence-name:mod}" with the appropriate text
|
/// Replaces "{sequence-name}" or "{modifier-name}" with the appropriate text
|
||||||
QString processToolTip(const QString& toolTip) const;
|
QString processToolTip(const QString& toolTip) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/// Key Sequence, Modifier (for secondary signal)
|
|
||||||
typedef std::pair<QKeySequence, int> SequenceData;
|
|
||||||
|
|
||||||
// Need a multimap in case multiple shortcuts share the same name
|
// Need a multimap in case multiple shortcuts share the same name
|
||||||
typedef std::multimap<std::string, Shortcut*> ShortcutMap;
|
typedef std::multimap<std::string, Shortcut*> ShortcutMap;
|
||||||
typedef std::map<std::string, SequenceData> SequenceMap;
|
typedef std::map<std::string, QKeySequence> SequenceMap;
|
||||||
|
typedef std::map<std::string, int> ModifierMap;
|
||||||
typedef std::map<int, std::string> NameMap;
|
typedef std::map<int, std::string> NameMap;
|
||||||
typedef std::map<std::string, int> KeyMap;
|
typedef std::map<std::string, int> KeyMap;
|
||||||
|
|
||||||
ShortcutMap mShortcuts;
|
ShortcutMap mShortcuts;
|
||||||
SequenceMap mSequences;
|
SequenceMap mSequences;
|
||||||
|
ModifierMap mModifiers;
|
||||||
|
|
||||||
NameMap mNames;
|
NameMap mNames;
|
||||||
KeyMap mKeys;
|
KeyMap mKeys;
|
||||||
|
|
|
@ -29,8 +29,7 @@ namespace CSMPrefs
|
||||||
std::pair<QWidget*, QWidget*> ShortcutSetting::makeWidgets(QWidget* parent)
|
std::pair<QWidget*, QWidget*> ShortcutSetting::makeWidgets(QWidget* parent)
|
||||||
{
|
{
|
||||||
QKeySequence sequence;
|
QKeySequence sequence;
|
||||||
int ignored = 0;
|
State::get().getShortcutManager().getSequence(getKey(), sequence);
|
||||||
State::get().getShortcutManager().getSequence(getKey(), sequence, ignored);
|
|
||||||
|
|
||||||
QString text = QString::fromUtf8(State::get().getShortcutManager().convertToString(sequence).c_str());
|
QString text = QString::fromUtf8(State::get().getShortcutManager().convertToString(sequence).c_str());
|
||||||
|
|
||||||
|
@ -156,13 +155,10 @@ namespace CSMPrefs
|
||||||
|
|
||||||
void ShortcutSetting::storeValue(const QKeySequence& sequence)
|
void ShortcutSetting::storeValue(const QKeySequence& sequence)
|
||||||
{
|
{
|
||||||
QKeySequence ignored;
|
State::get().getShortcutManager().setSequence(getKey(), sequence);
|
||||||
int modifier;
|
|
||||||
State::get().getShortcutManager().getSequence(getKey(), ignored, modifier);
|
|
||||||
State::get().getShortcutManager().setSequence(getKey(), sequence, modifier);
|
|
||||||
|
|
||||||
// Convert to string and assign
|
// Convert to string and assign
|
||||||
std::string value = State::get().getShortcutManager().convertToString(sequence, modifier);
|
std::string value = State::get().getShortcutManager().convertToString(sequence);
|
||||||
|
|
||||||
{
|
{
|
||||||
QMutexLocker lock(getMutex());
|
QMutexLocker lock(getMutex());
|
||||||
|
@ -184,8 +180,7 @@ namespace CSMPrefs
|
||||||
|
|
||||||
// Button text
|
// Button text
|
||||||
QKeySequence sequence;
|
QKeySequence sequence;
|
||||||
int modifier = 0;
|
State::get().getShortcutManager().getSequence(getKey(), sequence);
|
||||||
State::get().getShortcutManager().getSequence(getKey(), sequence, modifier);
|
|
||||||
|
|
||||||
QString text = QString::fromUtf8(State::get().getShortcutManager().convertToString(sequence).c_str());
|
QString text = QString::fromUtf8(State::get().getShortcutManager().convertToString(sequence).c_str());
|
||||||
mButton->setText(text);
|
mButton->setText(text);
|
||||||
|
|
|
@ -287,27 +287,6 @@ void CSMPrefs::State::declare()
|
||||||
declareShortcut ("reporttable-replace", "Replace Report", QKeySequence());
|
declareShortcut ("reporttable-replace", "Replace Report", QKeySequence());
|
||||||
declareShortcut ("reporttable-refresh", "Refresh Report", QKeySequence());
|
declareShortcut ("reporttable-refresh", "Refresh Report", QKeySequence());
|
||||||
|
|
||||||
declareSubcategory ("1st/Free Camera");
|
|
||||||
declareShortcut ("free-forward", "Forward", QKeySequence(Qt::Key_W), Qt::Key_Shift);
|
|
||||||
declareShortcut ("free-backward", "Backward", QKeySequence(Qt::Key_S));
|
|
||||||
declareShortcut ("free-left", "Left", QKeySequence(Qt::Key_A));
|
|
||||||
declareShortcut ("free-right", "Right", QKeySequence(Qt::Key_D));
|
|
||||||
declareModifier ("free-forward", "Speed Modifier");
|
|
||||||
declareShortcut ("free-roll-left", "Roll Left", QKeySequence(Qt::Key_Q));
|
|
||||||
declareShortcut ("free-roll-right", "Roll Right", QKeySequence(Qt::Key_E));
|
|
||||||
declareShortcut ("free-speed-mode", "Toggle Speed Mode", QKeySequence(Qt::Key_F));
|
|
||||||
|
|
||||||
declareSubcategory ("Orbit Camera");
|
|
||||||
declareShortcut ("orbit-up", "Up", QKeySequence(Qt::Key_W), Qt::Key_Shift);
|
|
||||||
declareShortcut ("orbit-down", "Down", QKeySequence(Qt::Key_S));
|
|
||||||
declareShortcut ("orbit-left", "Left", QKeySequence(Qt::Key_A));
|
|
||||||
declareShortcut ("orbit-right", "Right", QKeySequence(Qt::Key_D));
|
|
||||||
declareModifier ("orbit-up", "Speed Modifier");
|
|
||||||
declareShortcut ("orbit-roll-left", "Roll Left", QKeySequence(Qt::Key_Q));
|
|
||||||
declareShortcut ("orbit-roll-right", "Roll Right", QKeySequence(Qt::Key_E));
|
|
||||||
declareShortcut ("orbit-speed-mode", "Toggle Speed Mode", QKeySequence(Qt::Key_F));
|
|
||||||
declareShortcut ("orbit-center-selection", "Center On Selected", QKeySequence(Qt::Key_C));
|
|
||||||
|
|
||||||
declareSubcategory ("Scene");
|
declareSubcategory ("Scene");
|
||||||
declareShortcut ("scene-navi-primary", "Camera Rotation From Mouse Movement", QKeySequence(Qt::LeftButton));
|
declareShortcut ("scene-navi-primary", "Camera Rotation From Mouse Movement", QKeySequence(Qt::LeftButton));
|
||||||
declareShortcut ("scene-navi-secondary", "Camera Translation From Mouse Movement",
|
declareShortcut ("scene-navi-secondary", "Camera Translation From Mouse Movement",
|
||||||
|
@ -318,6 +297,7 @@ void CSMPrefs::State::declare()
|
||||||
declareShortcut ("scene-select-primary", "Primary Select", QKeySequence(Qt::MiddleButton));
|
declareShortcut ("scene-select-primary", "Primary Select", QKeySequence(Qt::MiddleButton));
|
||||||
declareShortcut ("scene-select-secondary", "Secondary Select",
|
declareShortcut ("scene-select-secondary", "Secondary Select",
|
||||||
QKeySequence(Qt::ControlModifier | (int)Qt::MiddleButton));
|
QKeySequence(Qt::ControlModifier | (int)Qt::MiddleButton));
|
||||||
|
declareModifier ("scene-speed-modifier", "Speed Modifier", Qt::Key_Shift);
|
||||||
declareShortcut ("scene-load-cam-cell", "Load Camera Cell", QKeySequence(Qt::KeypadModifier | Qt::Key_5));
|
declareShortcut ("scene-load-cam-cell", "Load Camera Cell", QKeySequence(Qt::KeypadModifier | Qt::Key_5));
|
||||||
declareShortcut ("scene-load-cam-eastcell", "Load East Cell", QKeySequence(Qt::KeypadModifier | Qt::Key_6));
|
declareShortcut ("scene-load-cam-eastcell", "Load East Cell", QKeySequence(Qt::KeypadModifier | Qt::Key_6));
|
||||||
declareShortcut ("scene-load-cam-northcell", "Load North Cell", QKeySequence(Qt::KeypadModifier | Qt::Key_8));
|
declareShortcut ("scene-load-cam-northcell", "Load North Cell", QKeySequence(Qt::KeypadModifier | Qt::Key_8));
|
||||||
|
@ -326,6 +306,25 @@ void CSMPrefs::State::declare()
|
||||||
declareShortcut ("scene-edit-abort", "Abort", QKeySequence(Qt::Key_Escape));
|
declareShortcut ("scene-edit-abort", "Abort", QKeySequence(Qt::Key_Escape));
|
||||||
declareShortcut ("scene-focus-toolbar", "Toggle Toolbar Focus", QKeySequence(Qt::Key_T));
|
declareShortcut ("scene-focus-toolbar", "Toggle Toolbar Focus", QKeySequence(Qt::Key_T));
|
||||||
declareShortcut ("scene-render-stats", "Debug Rendering Stats", QKeySequence(Qt::Key_F3));
|
declareShortcut ("scene-render-stats", "Debug Rendering Stats", QKeySequence(Qt::Key_F3));
|
||||||
|
|
||||||
|
declareSubcategory ("1st/Free Camera");
|
||||||
|
declareShortcut ("free-forward", "Forward", QKeySequence(Qt::Key_W));
|
||||||
|
declareShortcut ("free-backward", "Backward", QKeySequence(Qt::Key_S));
|
||||||
|
declareShortcut ("free-left", "Left", QKeySequence(Qt::Key_A));
|
||||||
|
declareShortcut ("free-right", "Right", QKeySequence(Qt::Key_D));
|
||||||
|
declareShortcut ("free-roll-left", "Roll Left", QKeySequence(Qt::Key_Q));
|
||||||
|
declareShortcut ("free-roll-right", "Roll Right", QKeySequence(Qt::Key_E));
|
||||||
|
declareShortcut ("free-speed-mode", "Toggle Speed Mode", QKeySequence(Qt::Key_F));
|
||||||
|
|
||||||
|
declareSubcategory ("Orbit Camera");
|
||||||
|
declareShortcut ("orbit-up", "Up", QKeySequence(Qt::Key_W));
|
||||||
|
declareShortcut ("orbit-down", "Down", QKeySequence(Qt::Key_S));
|
||||||
|
declareShortcut ("orbit-left", "Left", QKeySequence(Qt::Key_A));
|
||||||
|
declareShortcut ("orbit-right", "Right", QKeySequence(Qt::Key_D));
|
||||||
|
declareShortcut ("orbit-roll-left", "Roll Left", QKeySequence(Qt::Key_Q));
|
||||||
|
declareShortcut ("orbit-roll-right", "Roll Right", QKeySequence(Qt::Key_E));
|
||||||
|
declareShortcut ("orbit-speed-mode", "Toggle Speed Mode", QKeySequence(Qt::Key_F));
|
||||||
|
declareShortcut ("orbit-center-selection", "Center On Selected", QKeySequence(Qt::Key_C));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::State::declareCategory (const std::string& key)
|
void CSMPrefs::State::declareCategory (const std::string& key)
|
||||||
|
@ -443,20 +442,19 @@ CSMPrefs::ColourSetting& CSMPrefs::State::declareColour (const std::string& key,
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMPrefs::ShortcutSetting& CSMPrefs::State::declareShortcut (const std::string& key, const std::string& label,
|
CSMPrefs::ShortcutSetting& CSMPrefs::State::declareShortcut (const std::string& key, const std::string& label,
|
||||||
const QKeySequence& default_, int modifier_)
|
const QKeySequence& default_)
|
||||||
{
|
{
|
||||||
if (mCurrentCategory==mCategories.end())
|
if (mCurrentCategory==mCategories.end())
|
||||||
throw std::logic_error ("no category for setting");
|
throw std::logic_error ("no category for setting");
|
||||||
|
|
||||||
std::string seqStr = getShortcutManager().convertToString(default_, modifier_);
|
std::string seqStr = getShortcutManager().convertToString(default_);
|
||||||
setDefault (key, seqStr);
|
setDefault (key, seqStr);
|
||||||
|
|
||||||
// Setup with actual data
|
// Setup with actual data
|
||||||
QKeySequence sequence;
|
QKeySequence sequence;
|
||||||
int mod;
|
|
||||||
|
|
||||||
getShortcutManager().convertFromString(mSettings.getString(key, mCurrentCategory->second.getKey()), sequence, mod);
|
getShortcutManager().convertFromString(mSettings.getString(key, mCurrentCategory->second.getKey()), sequence);
|
||||||
getShortcutManager().setSequence(key, sequence, mod);
|
getShortcutManager().setSequence(key, sequence);
|
||||||
|
|
||||||
CSMPrefs::ShortcutSetting *setting = new CSMPrefs::ShortcutSetting (&mCurrentCategory->second, &mSettings, &mMutex,
|
CSMPrefs::ShortcutSetting *setting = new CSMPrefs::ShortcutSetting (&mCurrentCategory->second, &mSettings, &mMutex,
|
||||||
key, label);
|
key, label);
|
||||||
|
@ -465,11 +463,21 @@ CSMPrefs::ShortcutSetting& CSMPrefs::State::declareShortcut (const std::string&
|
||||||
return *setting;
|
return *setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMPrefs::ModifierSetting& CSMPrefs::State::declareModifier(const std::string& key, const std::string& label)
|
CSMPrefs::ModifierSetting& CSMPrefs::State::declareModifier(const std::string& key, const std::string& label,
|
||||||
|
int default_)
|
||||||
{
|
{
|
||||||
if (mCurrentCategory==mCategories.end())
|
if (mCurrentCategory==mCategories.end())
|
||||||
throw std::logic_error ("no category for setting");
|
throw std::logic_error ("no category for setting");
|
||||||
|
|
||||||
|
std::string modStr = getShortcutManager().convertToString(default_);
|
||||||
|
setDefault (key, modStr);
|
||||||
|
|
||||||
|
// Setup with actual data
|
||||||
|
int modifier;
|
||||||
|
|
||||||
|
getShortcutManager().convertFromString(mSettings.getString(key, mCurrentCategory->second.getKey()), modifier);
|
||||||
|
getShortcutManager().setModifier(key, modifier);
|
||||||
|
|
||||||
CSMPrefs::ModifierSetting *setting = new CSMPrefs::ModifierSetting (&mCurrentCategory->second, &mSettings, &mMutex,
|
CSMPrefs::ModifierSetting *setting = new CSMPrefs::ModifierSetting (&mCurrentCategory->second, &mSettings, &mMutex,
|
||||||
key, label);
|
key, label);
|
||||||
mCurrentCategory->second.addSetting (setting);
|
mCurrentCategory->second.addSetting (setting);
|
||||||
|
|
|
@ -76,9 +76,9 @@ namespace CSMPrefs
|
||||||
ColourSetting& declareColour (const std::string& key, const std::string& label, QColor default_);
|
ColourSetting& declareColour (const std::string& key, const std::string& label, QColor default_);
|
||||||
|
|
||||||
ShortcutSetting& declareShortcut (const std::string& key, const std::string& label,
|
ShortcutSetting& declareShortcut (const std::string& key, const std::string& label,
|
||||||
const QKeySequence& default_, int modifier_=0);
|
const QKeySequence& default_);
|
||||||
|
|
||||||
ModifierSetting& declareModifier(const std::string& key, const std::string& label);
|
ModifierSetting& declareModifier(const std::string& key, const std::string& label, int modifier_);
|
||||||
|
|
||||||
void declareSeparator();
|
void declareSeparator();
|
||||||
|
|
||||||
|
|
|
@ -189,8 +189,8 @@ namespace CSVRender
|
||||||
|
|
||||||
addShortcut(naviSecondaryShortcut);
|
addShortcut(naviSecondaryShortcut);
|
||||||
|
|
||||||
CSMPrefs::Shortcut* forwardShortcut = new CSMPrefs::Shortcut("free-forward", CSMPrefs::Shortcut::SM_Detach,
|
CSMPrefs::Shortcut* forwardShortcut = new CSMPrefs::Shortcut("free-forward", "scene-speed-modifier",
|
||||||
widget);
|
CSMPrefs::Shortcut::SM_Detach, widget);
|
||||||
forwardShortcut->enable(false);
|
forwardShortcut->enable(false);
|
||||||
connect(forwardShortcut, SIGNAL(activated(bool)), this, SLOT(forward(bool)));
|
connect(forwardShortcut, SIGNAL(activated(bool)), this, SLOT(forward(bool)));
|
||||||
connect(forwardShortcut, SIGNAL(secondary(bool)), this, SLOT(alternateFast(bool)));
|
connect(forwardShortcut, SIGNAL(secondary(bool)), this, SLOT(alternateFast(bool)));
|
||||||
|
@ -476,7 +476,8 @@ namespace CSVRender
|
||||||
|
|
||||||
addShortcut(naviSecondaryShortcut);
|
addShortcut(naviSecondaryShortcut);
|
||||||
|
|
||||||
CSMPrefs::Shortcut* upShortcut = new CSMPrefs::Shortcut("orbit-up", CSMPrefs::Shortcut::SM_Detach, widget);
|
CSMPrefs::Shortcut* upShortcut = new CSMPrefs::Shortcut("orbit-up", "scene-speed-modifier",
|
||||||
|
CSMPrefs::Shortcut::SM_Detach, widget);
|
||||||
upShortcut->enable(false);
|
upShortcut->enable(false);
|
||||||
connect(upShortcut, SIGNAL(activated(bool)), this, SLOT(up(bool)));
|
connect(upShortcut, SIGNAL(activated(bool)), this, SLOT(up(bool)));
|
||||||
connect(upShortcut, SIGNAL(secondary(bool)), this, SLOT(alternateFast(bool)));
|
connect(upShortcut, SIGNAL(secondary(bool)), this, SLOT(alternateFast(bool)));
|
||||||
|
|
|
@ -168,7 +168,7 @@ CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector (
|
||||||
"<li>Movement keys: {free-forward}(forward), {free-left}(left), {free-backward}(back), {free-right}(right)</li>"
|
"<li>Movement keys: {free-forward}(forward), {free-left}(left), {free-backward}(back), {free-right}(right)</li>"
|
||||||
"<li>Strafing (also vertically) by holding {scene-navi-secondary}</li>"
|
"<li>Strafing (also vertically) by holding {scene-navi-secondary}</li>"
|
||||||
"<li>Mouse wheel moves the camera forward/backward</li>"
|
"<li>Mouse wheel moves the camera forward/backward</li>"
|
||||||
"<li>Hold {free-forward:mod} to speed up movement</li>"
|
"<li>Hold {scene-speed-modifier} to speed up movement</li>"
|
||||||
"</ul>");
|
"</ul>");
|
||||||
tool->addButton (":scenetoolbar/free-camera", "free",
|
tool->addButton (":scenetoolbar/free-camera", "free",
|
||||||
"Free Camera"
|
"Free Camera"
|
||||||
|
@ -188,7 +188,7 @@ CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector (
|
||||||
"<li>Roll camera with {orbit-roll-left} and {orbit-roll-right} keys</li>"
|
"<li>Roll camera with {orbit-roll-left} and {orbit-roll-right} keys</li>"
|
||||||
"<li>Strafing (also vertically) by holding {scene-navi-secondary} (includes relocation of the centre point)</li>"
|
"<li>Strafing (also vertically) by holding {scene-navi-secondary} (includes relocation of the centre point)</li>"
|
||||||
"<li>Mouse wheel moves camera away or towards centre point but can not pass through it</li>"
|
"<li>Mouse wheel moves camera away or towards centre point but can not pass through it</li>"
|
||||||
"<li>Hold {orbit-up:mod} to speed up movement</li>"
|
"<li>Hold {scene-speed-modifier} to speed up movement</li>"
|
||||||
"</ul>", tool),
|
"</ul>", tool),
|
||||||
"orbit");
|
"orbit");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue