diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d6d829f834..432f47c58f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -483,6 +484,7 @@ void Application::keyPressEvent(QKeyEvent* event) { _myAvatar.setChatMessage(_chatEntry.getContents()); _chatEntry.clear(); _chatEntryOn = false; + setMenuShortcutsEnabled(true); } return; } @@ -607,6 +609,7 @@ void Application::keyPressEvent(QKeyEvent* event) { _chatEntryOn = true; _myAvatar.setKeyState(NO_KEY_DOWN); _myAvatar.setChatMessage(string()); + setMenuShortcutsEnabled(false); break; case Qt::Key_Up: @@ -1852,6 +1855,25 @@ void Application::resetSensors() { _myAvatar.reset(); } +static void setShortcutsEnabled(QWidget* widget, bool enabled) { + foreach (QAction* action, widget->actions()) { + QKeySequence shortcut = action->shortcut(); + if (!shortcut.isEmpty() && (shortcut[0] & (Qt::CTRL | Qt::ALT | Qt::META)) == 0) { + // it's a shortcut that may coincide with a "regular" key, so switch its context + action->setShortcutContext(enabled ? Qt::WindowShortcut : Qt::WidgetShortcut); + } + } + foreach (QObject* child, widget->children()) { + if (child->isWidgetType()) { + setShortcutsEnabled(static_cast(child), enabled); + } + } +} + +void Application::setMenuShortcutsEnabled(bool enabled) { + setShortcutsEnabled(_window->menuBar(), enabled); +} + void Application::attachNewHeadToAgent(Agent *newAgent) { if (newAgent->getLinkedData() == NULL) { newAgent->setLinkedData(new Avatar(false)); diff --git a/interface/src/Application.h b/interface/src/Application.h index 422b6302e6..011e1a94e5 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -110,6 +110,8 @@ private: void resetSensors(); + void setMenuShortcutsEnabled(bool enabled); + static void attachNewHeadToAgent(Agent *newAgent); #ifndef _WIN32 static void audioMixerUpdate(in_addr_t newMixerAddress, in_port_t newMixerPort); diff --git a/interface/src/ui/ChatEntry.cpp b/interface/src/ui/ChatEntry.cpp index d83bd5d657..ad4cf70ab0 100644 --- a/interface/src/ui/ChatEntry.cpp +++ b/interface/src/ui/ChatEntry.cpp @@ -85,5 +85,4 @@ void ChatEntry::render(int screenWidth, int screenHeight) { glVertex2f(20 + width, screenHeight - 165); glVertex2f(20 + width, screenHeight - 150); glEnd(); - glEnable(GL_LINE_SMOOTH); }