mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 09:59:20 +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 <QMainWindow>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QShortcut>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <PairingHandler.h>
|
#include <PairingHandler.h>
|
||||||
|
@ -483,6 +484,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
_myAvatar.setChatMessage(_chatEntry.getContents());
|
_myAvatar.setChatMessage(_chatEntry.getContents());
|
||||||
_chatEntry.clear();
|
_chatEntry.clear();
|
||||||
_chatEntryOn = false;
|
_chatEntryOn = false;
|
||||||
|
setMenuShortcutsEnabled(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -607,6 +609,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
_chatEntryOn = true;
|
_chatEntryOn = true;
|
||||||
_myAvatar.setKeyState(NO_KEY_DOWN);
|
_myAvatar.setKeyState(NO_KEY_DOWN);
|
||||||
_myAvatar.setChatMessage(string());
|
_myAvatar.setChatMessage(string());
|
||||||
|
setMenuShortcutsEnabled(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
|
@ -1852,6 +1855,25 @@ void Application::resetSensors() {
|
||||||
_myAvatar.reset();
|
_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) {
|
void Application::attachNewHeadToAgent(Agent *newAgent) {
|
||||||
if (newAgent->getLinkedData() == NULL) {
|
if (newAgent->getLinkedData() == NULL) {
|
||||||
newAgent->setLinkedData(new Avatar(false));
|
newAgent->setLinkedData(new Avatar(false));
|
||||||
|
|
|
@ -110,6 +110,8 @@ private:
|
||||||
|
|
||||||
void resetSensors();
|
void resetSensors();
|
||||||
|
|
||||||
|
void setMenuShortcutsEnabled(bool enabled);
|
||||||
|
|
||||||
static void attachNewHeadToAgent(Agent *newAgent);
|
static void attachNewHeadToAgent(Agent *newAgent);
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
static void audioMixerUpdate(in_addr_t newMixerAddress, in_port_t newMixerPort);
|
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 - 165);
|
||||||
glVertex2f(20 + width, screenHeight - 150);
|
glVertex2f(20 + width, screenHeight - 150);
|
||||||
glEnd();
|
glEnd();
|
||||||
glEnable(GL_LINE_SMOOTH);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue