]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt/GuiKeySymbol.cpp
Make code a bit easier to read
[lyx.git] / src / frontends / qt / GuiKeySymbol.cpp
index c1882f70d5ce10ce40cb588fdf089db92280ac98..083bc5f8848cda5f3031e3ff614154c772ef77b7 100644 (file)
@@ -11,7 +11,7 @@
 #include <config.h>
 
 #include "GuiKeySymbol.h"
-#if defined(Q_OS_MAC) && QT_VERSION > 0x050000
+#if defined(Q_OS_MAC)
 #include "GuiApplication.h"
 #endif
 #include "qt_helpers.h"
@@ -25,7 +25,6 @@
 #include <QKeyEvent>
 #include <QKeySequence>
 #include <QEvent>
-#include <QTextCodec>
 
 #include <map>
 #include <string>
@@ -692,39 +691,6 @@ static std::string const qkey_to_string(int lkey)
 }
 
 
-#if 0
-static char encode(string const & encoding, QString const & str)
-{
-       typedef map<string, QTextCodec *> EncodingMap;
-       EncodingMap encoding_map;
-
-       QTextCodec * codec = 0;
-
-       EncodingMap::const_iterator cit = encoding_map.find(encoding);
-       if (cit == encoding_map.end()) {
-               LYXERR(Debug::KEY, "Unrecognised encoding '" << encoding << "'.");
-               codec = encoding_map.find("")->second;
-       } else {
-               codec = cit->second;
-       }
-
-       if (!codec) {
-               LYXERR(Debug::KEY, "No codec for encoding '" << encoding << "' found.");
-               return 0;
-       }
-
-       LYXERR(Debug::KEY, "Using codec " << codec->name());
-
-       if (!codec->canEncode(str)) {
-               LYXERR(Debug::KEY, "Oof. Can't encode the text !");
-               return 0;
-       }
-
-       return codec->fromUnicode(str).data()[0];
-}
-#endif
-
-
 void setKeySymbol(KeySymbol * sym, QKeyEvent const * ev)
 {
        sym->setKey(ev->key());
@@ -752,6 +718,14 @@ void KeySymbol::init(string const & symbolname)
 }
 
 
+void KeySymbol::init(int key)
+{
+       key_ = key;
+       text_ = from_utf8(qkey_to_string(key));
+       LYXERR(Debug::KEY, "Init key to " << key_ << ", " << to_utf8(text_));
+}
+
+
 bool KeySymbol::isOK() const
 {
        bool const ok = !(text_.empty() && qkey_to_string(key_).empty());
@@ -859,10 +833,11 @@ bool KeySymbol::operator==(KeySymbol const & ks) const
 KeyModifier q_key_state(Qt::KeyboardModifiers state)
 {
        KeyModifier k = NoModifier;
-#if defined(Q_OS_MAC) && QT_VERSION > 0x050000
+#if defined(Q_OS_MAC) && (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))
        /// 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.
+       /// AFAIK it is fixed at least with Qt 5.12.0
        const bool dontSwapCtrlAndMeta =
                frontend::theGuiApp()->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
 #else