* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
- * \author Asger & Jürgen
+ * \author Asger & Jürgen
*
* Full author contact details are available in file CREDITS.
*/
#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 ?
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;
case Qt::Key_Y: return "y";
case Qt::Key_Z: return "z";
+ case Qt::Key_Return: return "Return";
case Qt::Key_Escape: return "Escape";
case Qt::Key_Tab: return "Tab";
case Qt::Key_Backspace: return "BackSpace";
case Qt::Key_THORN: return "THORN";
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 ...
case Qt::Key_Hyper_L: return "Hyper_L";
case Qt::Key_Hyper_R: return "Hyper_R";
case Qt::Key_Help: return "Help";
- case Qt::Key_Bar: return "Bar";
case Qt::Key_Backtab: return "BackTab";
default:
bool KeySymbol::isOK() const
{
- bool const ok = !(text_.empty() && key_ == Qt::Key_unknown);
+ bool const ok = !(text_.empty() && qkey_to_string(key_).empty());
LYXERR(Debug::KEY, "isOK is " << ok);
return ok;
}
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.
{
int tmpkey = key_;
- if (mod & ShiftModifier)
+ if (mod & ShiftModifier && !(tmpkey == Qt::Key_Shift))
tmpkey += Qt::ShiftModifier;
- if (mod & ControlModifier)
+ if (mod & ControlModifier && !(tmpkey == Qt::Key_Control))
tmpkey += Qt::ControlModifier;
- if (mod & AltModifier)
+ if (mod & AltModifier && !(tmpkey == Qt::Key_Alt))
tmpkey += Qt::AltModifier;
+ if (mod & MetaModifier && !(tmpkey == Qt::Key_Meta))
+ tmpkey += Qt::MetaModifier;
QKeySequence seq(tmpkey);
QString str;
-
+
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);
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 || state & Qt::MetaModifier)
+ if (state & Qt::AltModifier)
k |= AltModifier;
+#if defined(USE_MACOSX_PACKAGING) || defined(USE_META_KEYBINDING)
+ if (state & (dontSwapCtrlAndMeta ? Qt::ControlModifier : Qt::MetaModifier))
+ k |= MetaModifier;
+#else
+ if (state & Qt::MetaModifier)
+ k |= AltModifier;
+#endif
return k;
}