From 80e2025ebf187b3684e1ae01ee27459feaee7ecb Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Wed, 16 Mar 2016 18:12:59 -0700 Subject: [PATCH] Allow display plugin switching by keyboard --- interface/src/Application.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2ac9eda38c..bd2a43a678 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1899,6 +1899,28 @@ void Application::keyPressEvent(QKeyEvent* event) { } break; + case Qt::Key_1: + case Qt::Key_2: + case Qt::Key_3: + case Qt::Key_4: + case Qt::Key_5: + case Qt::Key_6: + case Qt::Key_7: + if (isMeta || isOption) { + unsigned int index = static_cast(event->key() - Qt::Key_1); + auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins(); + if (index <= displayPlugins.size()) { + auto targetPlugin = displayPlugins.at(index); + QString targetName = targetPlugin->getName(); + auto menu = Menu::getInstance(); + QAction* action = menu->getActionForOption(targetName); + if (action && !action->isChecked()) { + action->trigger(); + } + } + } + break; + case Qt::Key_X: if (isShifted && isMeta) { auto offscreenUi = DependencyManager::get();