X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiKeySymbol.cpp;h=ef9425deb1c72bcf0a7098b08804c35393f3dab5;hb=1f10969bb5c5f36017bf5ba8671381b09945cf57;hp=da975a5732883a1be67902934604e7cf67e00dd7;hpb=e9d943aeb8bbe5fb211977c84160813cfcbecb34;p=lyx.git diff --git a/src/frontends/qt4/GuiKeySymbol.cpp b/src/frontends/qt4/GuiKeySymbol.cpp index da975a5732..ef9425deb1 100644 --- a/src/frontends/qt4/GuiKeySymbol.cpp +++ b/src/frontends/qt4/GuiKeySymbol.cpp @@ -11,6 +11,7 @@ #include #include "KeySymbol.h" +#include "GuiApplication.h" #include "qt_helpers.h" @@ -64,7 +65,7 @@ static int string_to_qkey(std::string const & str) 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 ? @@ -341,6 +342,7 @@ static int string_to_qkey(std::string const & str) if (str == "yacute") return Qt::Key_Yacute; if (str == "thorn") return Qt::Key_THORN; if (str == "ydiaeresis") return Qt::Key_ydiaeresis; + if (str == "Dead_Caron") return Qt::Key_Dead_Caron; // FIXME, correct for all these ? if (str == "Super_L") return Qt::Key_Super_L; @@ -559,6 +561,7 @@ static std::string const qkey_to_string(int lkey) case Qt::Key_ssharp: return "ssharp"; case Qt::Key_ydiaeresis: return "ydiaeresis"; case Qt::Key_Bar: return "bar"; + case Qt::Key_Dead_Caron: return "Dead_Caron"; // FIXME: these ones I don't know the names of ... help ! // what's here is basically guesses ... @@ -609,7 +612,7 @@ static char encode(string const & encoding, QString const & str) #endif -void setKeySymbol(KeySymbol * sym, QKeyEvent * ev) +void setKeySymbol(KeySymbol * sym, QKeyEvent const * ev) { sym->setKey(ev->key()); if (ev->text().isNull()) { @@ -670,7 +673,7 @@ char_type KeySymbol::getUCSEncoded() const return 0; // UTF16 has a maximum of two characters. - LASSERT(text_.size() <= 2, /**/); + LASSERT(text_.size() <= 2, return 0); if (lyxerr.debugging() && text_.size() > 1) { // We don't know yet how well support the full ucs4 range. @@ -702,7 +705,7 @@ docstring const KeySymbol::print(KeyModifier mod, bool forgui) const 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); @@ -742,14 +745,24 @@ bool KeySymbol::operator==(KeySymbol const & ks) const 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; -#ifdef USE_MACOSX_PACKAGING || defined(USE_META_KEYBINDING) - if (state & Qt::MetaModifier) +#if defined(USE_MACOSX_PACKAGING) || defined(USE_META_KEYBINDING) + if (state & (dontSwapCtrlAndMeta ? Qt::ControlModifier : Qt::MetaModifier)) k |= MetaModifier; #else if (state & Qt::MetaModifier)