Remove input plugin menu dependency

This commit is contained in:
Atlante45 2016-06-03 11:51:35 -07:00
parent 6f75fab298
commit 24bbb8db3f
3 changed files with 17 additions and 22 deletions

View file

@ -198,7 +198,6 @@ static const float PHYSICS_READY_RANGE = 3.0f; // how far from avatar to check f
static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
static const QString INPUT_DEVICE_MENU_PREFIX = "Device: ";
Setting::Handle<int> maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS);
const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensions {
@ -1000,7 +999,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
RenderableWebEntityItem* webEntity = dynamic_cast<RenderableWebEntityItem*>(entity.get());
if (webEntity) {
webEntity->setProxyWindow(_window->windowHandle());
if (Menu::getInstance()->isOptionChecked(INPUT_DEVICE_MENU_PREFIX + KeyboardMouseDevice::NAME)) {
if (_keyboardMouseDevice->isActive()) {
_keyboardMouseDevice->pluginFocusOutEvent();
}
_keyboardFocusedItem = entityItemID;
@ -1153,9 +1152,7 @@ void Application::aboutToQuit() {
emit beforeAboutToQuit();
foreach(auto inputPlugin, PluginManager::getInstance()->getInputPlugins()) {
QString name = INPUT_DEVICE_MENU_PREFIX + inputPlugin->getName();
QAction* action = Menu::getInstance()->getActionForOption(name);
if (action->isChecked()) {
if (inputPlugin->isActive()) {
inputPlugin->deactivate();
}
}
@ -2024,7 +2021,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
}
if (hasFocus()) {
if (Menu::getInstance()->isOptionChecked(INPUT_DEVICE_MENU_PREFIX + KeyboardMouseDevice::NAME)) {
if (_keyboardMouseDevice->isActive()) {
_keyboardMouseDevice->keyPressEvent(event);
}
@ -2358,7 +2355,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
return;
}
if (Menu::getInstance()->isOptionChecked(INPUT_DEVICE_MENU_PREFIX + KeyboardMouseDevice::NAME)) {
if (_keyboardMouseDevice->isActive()) {
_keyboardMouseDevice->keyReleaseEvent(event);
}
@ -2390,9 +2387,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
void Application::focusOutEvent(QFocusEvent* event) {
auto inputPlugins = PluginManager::getInstance()->getInputPlugins();
foreach(auto inputPlugin, inputPlugins) {
QString name = INPUT_DEVICE_MENU_PREFIX + inputPlugin->getName();
QAction* action = Menu::getInstance()->getActionForOption(name);
if (action && action->isChecked()) {
if (inputPlugin->isActive()) {
inputPlugin->pluginFocusOutEvent();
}
}
@ -2477,7 +2472,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) {
return;
}
if (Menu::getInstance()->isOptionChecked(INPUT_DEVICE_MENU_PREFIX + KeyboardMouseDevice::NAME)) {
if (_keyboardMouseDevice->isActive()) {
_keyboardMouseDevice->mouseMoveEvent(event);
}
@ -2514,7 +2509,7 @@ void Application::mousePressEvent(QMouseEvent* event) {
if (hasFocus()) {
if (Menu::getInstance()->isOptionChecked(INPUT_DEVICE_MENU_PREFIX + KeyboardMouseDevice::NAME)) {
if (_keyboardMouseDevice->isActive()) {
_keyboardMouseDevice->mousePressEvent(event);
}
@ -2559,7 +2554,7 @@ void Application::mouseReleaseEvent(QMouseEvent* event) {
}
if (hasFocus()) {
if (Menu::getInstance()->isOptionChecked(INPUT_DEVICE_MENU_PREFIX + KeyboardMouseDevice::NAME)) {
if (_keyboardMouseDevice->isActive()) {
_keyboardMouseDevice->mouseReleaseEvent(event);
}
@ -2586,7 +2581,7 @@ void Application::touchUpdateEvent(QTouchEvent* event) {
return;
}
if (Menu::getInstance()->isOptionChecked(INPUT_DEVICE_MENU_PREFIX + KeyboardMouseDevice::NAME)) {
if (_keyboardMouseDevice->isActive()) {
_keyboardMouseDevice->touchUpdateEvent(event);
}
}
@ -2604,7 +2599,7 @@ void Application::touchBeginEvent(QTouchEvent* event) {
return;
}
if (Menu::getInstance()->isOptionChecked(INPUT_DEVICE_MENU_PREFIX + KeyboardMouseDevice::NAME)) {
if (_keyboardMouseDevice->isActive()) {
_keyboardMouseDevice->touchBeginEvent(event);
}
@ -2621,7 +2616,7 @@ void Application::touchEndEvent(QTouchEvent* event) {
return;
}
if (Menu::getInstance()->isOptionChecked(INPUT_DEVICE_MENU_PREFIX + KeyboardMouseDevice::NAME)) {
if (_keyboardMouseDevice->isActive()) {
_keyboardMouseDevice->touchEndEvent(event);
}
@ -2637,7 +2632,7 @@ void Application::wheelEvent(QWheelEvent* event) const {
return;
}
if (Menu::getInstance()->isOptionChecked(INPUT_DEVICE_MENU_PREFIX + KeyboardMouseDevice::NAME)) {
if (_keyboardMouseDevice->isActive()) {
_keyboardMouseDevice->wheelEvent(event);
}
}
@ -2770,9 +2765,7 @@ void Application::idle(float nsecsElapsed) {
getActiveDisplayPlugin()->idle();
auto inputPlugins = PluginManager::getInstance()->getInputPlugins();
foreach(auto inputPlugin, inputPlugins) {
QString name = INPUT_DEVICE_MENU_PREFIX + inputPlugin->getName();
QAction* action = Menu::getInstance()->getActionForOption(name);
if (action && action->isChecked()) {
if (inputPlugin->isActive()) {
inputPlugin->idle();
}
}

View file

@ -25,7 +25,6 @@ InputPluginList getInputPlugins() {
for (int i = 0; PLUGIN_POOL[i]; ++i) {
InputPlugin* plugin = PLUGIN_POOL[i];
if (plugin->isSupported()) {
plugin->init();
result.push_back(InputPluginPointer(plugin));
}
}

View file

@ -164,7 +164,9 @@ const InputPluginList& PluginManager::getInputPlugins() {
InputProvider* inputProvider = qobject_cast<InputProvider*>(loader->instance());
if (inputProvider) {
for (auto inputPlugin : inputProvider->getInputPlugins()) {
inputPlugins.push_back(inputPlugin);
if (inputPlugin->isSupported()) {
inputPlugins.push_back(inputPlugin);
}
}
}
}
@ -173,6 +175,7 @@ const InputPluginList& PluginManager::getInputPlugins() {
for (auto plugin : inputPlugins) {
plugin->setContainer(&container);
plugin->init();
plugin->activate();
}
});
return inputPlugins;