mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 11:39:49 -06:00
Added keybinding warning for number keys
This commit is contained in:
@@ -66,6 +66,7 @@ public slots:
|
||||
void listItemCancelSave();
|
||||
void transitionToEditMode();
|
||||
void parseSelections();
|
||||
void keySelected(int index);
|
||||
|
||||
private:
|
||||
void transitionFromEditMode();
|
||||
|
||||
@@ -176,6 +176,10 @@ KeybindingsDialog::KeybindingsDialog(openspace::Profile& profile, QWidget *paren
|
||||
}
|
||||
}
|
||||
_keyCombo->addItems(comboKeysStringList);
|
||||
connect(
|
||||
_keyCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, &KeybindingsDialog::keySelected
|
||||
);
|
||||
box->addWidget(_keyCombo, 1, 1);
|
||||
|
||||
|
||||
@@ -294,6 +298,25 @@ void KeybindingsDialog::listItemSelected(void) {
|
||||
transitionToEditMode();
|
||||
}
|
||||
|
||||
void KeybindingsDialog::keySelected(int index) {
|
||||
const QString numKeyWarning = "Warning: using a number key may conflict with the "
|
||||
"keybindings for simulation time increments. ";
|
||||
QString errorContents = _errorMsg->text();
|
||||
bool alreadyContainsWarning = (errorContents.length() >= numKeyWarning.length() &&
|
||||
errorContents.left(numKeyWarning.length()) == numKeyWarning);
|
||||
if (_mapKeyComboBoxIndexToKeyValue[index] >= static_cast<int>(openspace::Key::Num0)
|
||||
&& _mapKeyComboBoxIndexToKeyValue[index] <= static_cast<int>(openspace::Key::Num9))
|
||||
{
|
||||
if (!alreadyContainsWarning) {
|
||||
errorContents = numKeyWarning + errorContents;
|
||||
_errorMsg->setText(errorContents);
|
||||
}
|
||||
}
|
||||
else if (alreadyContainsWarning) {
|
||||
_errorMsg->setText(errorContents.mid(numKeyWarning.length()));
|
||||
}
|
||||
}
|
||||
|
||||
int KeybindingsDialog::indexInKeyMapping(std::vector<int>& mapVector, int keyInt) {
|
||||
auto it = std::find(mapVector.begin(), mapVector.end(), keyInt);
|
||||
return std::distance(mapVector.begin(), it);
|
||||
|
||||
Reference in New Issue
Block a user