#include <config.h>
#include "KeySymbol.h"
+#include "GuiApplication.h"
#include "qt_helpers.h"
if (str == "Escape") return Qt::Key_Escape;
if (str == "Tab") return Qt::Key_Tab;
- if (str == "ISO_Left_Tab") return Qt::Key_Tab;
+ if (str == "ISO_Left_Tab") return Qt::Key_Backtab;
if (str == "BackSpace") return Qt::Key_Backspace;
if (str == "Return") return Qt::Key_Return;
if (str == "KP_Enter") return Qt::Key_Enter; // correct ?
#endif
-void setKeySymbol(KeySymbol * sym, QKeyEvent * ev)
+void setKeySymbol(KeySymbol * sym, QKeyEvent const * ev)
{
sym->setKey(ev->key());
if (ev->text().isNull()) {
LYXERR(Debug::KEY, "Getting key " << ev->key() << ", with text '"
<< ev->text() << "'");
// This is unsafe because ev->text() is the unicode representation of the
- // key, not the name of the key. For example, Ctrl-x and Alt-x produce
+ // key, not the name of the key. For example, Ctrl-x and Alt-x produce
// different texts.
sym->setText(qstring_to_ucs4(ev->text()));
LYXERR(Debug::KEY, "Setting key to " << sym->key() << ", "
if (forgui)
str = seq.toString(QKeySequence::NativeText);
else {
-#ifdef Q_WS_MACX
+#ifdef Q_OS_MAC
// Qt/Mac does not use Command and friends in the
// portable case, but the windows-like Control+x (bug 5421).
str = seq.toString(QKeySequence::NativeText);
str.replace(QChar(0x2325), qt_("Option-"));
str.replace(QChar(0x2318), qt_("Command-"));
#else
- str = seq.toString(QKeySequence::PortableText);
+ str = seq.toString(QKeySequence::PortableText);
#endif
}
KeyModifier q_key_state(Qt::KeyboardModifiers state)
{
KeyModifier k = NoModifier;
- if (state & Qt::ControlModifier)
+#if defined(Q_OS_MAC) && QT_VERSION > 0x050000
+ /// Additional check for Control and Meta modifier swap state.
+ /// Starting with Qt 5 the modifiers aren't reported correctly.
+ /// Until this is fixed a correction is required.
+ const bool dontSwapCtrlAndMeta =
+ frontend::theGuiApp()->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
+#else
+ const bool dontSwapCtrlAndMeta = false;
+#endif
+
+ if (state & (dontSwapCtrlAndMeta ? Qt::MetaModifier : Qt::ControlModifier))
k |= ControlModifier;
if (state & Qt::ShiftModifier)
k |= ShiftModifier;
if (state & Qt::AltModifier)
k |= AltModifier;
#if defined(USE_MACOSX_PACKAGING) || defined(USE_META_KEYBINDING)
- if (state & Qt::MetaModifier)
+ if (state & (dontSwapCtrlAndMeta ? Qt::ControlModifier : Qt::MetaModifier))
k |= MetaModifier;
#else
if (state & Qt::MetaModifier)