]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiKeySymbol.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiKeySymbol.cpp
index 99aee838c327003e4c4ee101bc6ad188ad6f0fcf..e5d3d796d96133e6329c32a3d39208da9837177b 100644 (file)
@@ -3,7 +3,7 @@
  * 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.
  */
@@ -14,6 +14,7 @@
 
 #include "qt_helpers.h"
 
+#include "support/lassert.h"
 #include "support/debug.h"
 
 #include "Encoding.h"
@@ -24,8 +25,6 @@
 #include <QEvent>
 #include <QTextCodec>
 
-#include "boost/assert.hpp"
-
 #include <map>
 #include <string>
 
@@ -403,7 +402,9 @@ static std::string const qkey_to_string(int lkey)
        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_Insert: return "Insert";
        case Qt::Key_Delete: return "Delete";
@@ -596,7 +597,7 @@ static char encode(string const & encoding, QString const & str)
                return 0;
        }
 
-       LYXERR(Debug::KEY, "Using codec " << fromqstr(codec->name()));
+       LYXERR(Debug::KEY, "Using codec " << codec->name());
 
        if (!codec->canEncode(str)) {
                LYXERR(Debug::KEY, "Oof. Can't encode the text !");
@@ -617,7 +618,7 @@ void setKeySymbol(KeySymbol * sym, QKeyEvent * ev)
                return;
        }
        LYXERR(Debug::KEY, "Getting key " << ev->key() << ", with text '"
-               << fromqstr(ev->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 
        // different texts.
@@ -637,7 +638,7 @@ void KeySymbol::init(string const & symbolname)
 
 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;
 }
@@ -669,7 +670,7 @@ char_type KeySymbol::getUCSEncoded() const
                return 0;
 
        // UTF16 has a maximum of two characters.
-       BOOST_ASSERT(text_.size() <= 2);
+       LASSERT(text_.size() <= 2, /**/);
 
        if (lyxerr.debugging() && text_.size() > 1) {
                // We don't know yet how well support the full ucs4 range.
@@ -694,9 +695,25 @@ docstring const KeySymbol::print(KeyModifier mod, bool forgui) const
                tmpkey += Qt::AltModifier;
 
        QKeySequence seq(tmpkey);
+       QString str;
+       
+       if (forgui)
+               str = seq.toString(QKeySequence::NativeText);
+       else {
+#ifdef Q_WS_MACX
+               // 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(0x21E7), qt_("Shift-"));
+               str.replace(QChar(0x2303), qt_("Control-"));
+               str.replace(QChar(0x2325), qt_("Option-"));
+               str.replace(QChar(0x2318), qt_("Command-"));
+#else
+               str = seq.toString(QKeySequence::PortableText); 
+#endif
+       }
 
-       return qstring_to_ucs4(seq.toString(forgui ? QKeySequence::NativeText
-                                           : QKeySequence::PortableText));
+       return qstring_to_ucs4(str);
 }