mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-07 20:24:11 +02:00
Disable the menu shortcuts for "regular" keys when the chat entry is showing.
This commit is contained in:
parent
1e99389a4b
commit
31b94203ff
3 changed files with 24 additions and 1 deletions
|
@ -24,6 +24,7 @@
|
|||
#include <QMainWindow>
|
||||
#include <QMenuBar>
|
||||
#include <QMouseEvent>
|
||||
#include <QShortcut>
|
||||
#include <QTimer>
|
||||
#include <QtDebug>
|
||||
#include <PairingHandler.h>
|
||||
|
@ -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<QWidget*>(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));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue