GUI: Ctrl+Arrows allow selection of different script languages

This commit is contained in:
mrexodia 2016-06-26 12:57:02 +02:00
parent a542c434bb
commit f616d7d0f8
No known key found for this signature in database
GPG Key ID: D72F9A4FAA0073B4
2 changed files with 57 additions and 31 deletions

View File

@ -3771,7 +3771,7 @@
"mnem": "jnc"
},
{
"description": "jump short if not equal (zf=0)",
"description": "jump short if not equal/not zero (zf=0)",
"mnem": "jne"
},
{

View File

@ -29,14 +29,9 @@ CommandLineEdit::CommandLineEdit(QWidget* parent)
void CommandLineEdit::keyPressEvent(QKeyEvent* event)
{
// We only want key-press events for TAB
if(event->type() != QEvent::KeyPress || event->key() != Qt::Key_Tab)
if(event->type() == QEvent::KeyPress && event->key() == Qt::Key_Tab)
{
HistoryLineEdit::keyPressEvent(event);
return;
}
// Tab autocompletes the command
// TAB autocompletes the command
QStringList stringList = mCompleterModel->stringList();
if(stringList.size())
@ -69,6 +64,37 @@ void CommandLineEdit::keyPressEvent(QKeyEvent* event)
popup->hide();
}
}
else if(event->type() == QEvent::KeyPress && event->modifiers() == Qt::ControlModifier)
{
int index = mCmdScriptType->currentIndex(), count = mCmdScriptType->count();
if(event->key() == Qt::Key_Up)
{
// Ctrl + Up selects the previous language
if(index > 0)
index--;
else
index = count - 1;
}
else if(event->key() == Qt::Key_Down)
{
// Ctrl + Down selects the next language
index = (index + 1) % count;
}
else if(event->key() == Qt::Key_Left)
{
// Ctrl + Left selects the first language
index = 0;
}
else if(event->key() == Qt::Key_Right)
{
// Ctrl + Right selects the last language
index = count - 1;
}
mCmdScriptType->setCurrentIndex(index);
}
else
HistoryLineEdit::keyPressEvent(event);
}
// Disables moving to Prev/Next child when pressing tab
bool CommandLineEdit::focusNextPrevChild(bool next)