]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiKeySymbol.cpp
Fix the tab ordering of GuiDocument components.
[lyx.git] / src / frontends / qt4 / GuiKeySymbol.cpp
index 81839db48b59b3726a50bdf9bdd37184bccba7f5..b3184304cfbed55876023ecc6819befd141601d0 100644 (file)
@@ -402,6 +402,7 @@ 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";
@@ -557,6 +558,7 @@ static std::string const qkey_to_string(int lkey)
        case Qt::Key_THORN: return "THORN";
        case Qt::Key_ssharp: return "ssharp";
        case Qt::Key_ydiaeresis: return "ydiaeresis";
+       case Qt::Key_Bar: return "bar";
 
        // FIXME: these ones I don't know the names of ... help !
        // what's here is basically guesses ...
@@ -566,7 +568,6 @@ static std::string const qkey_to_string(int lkey)
        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:
@@ -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;
 }
@@ -686,16 +687,18 @@ docstring const KeySymbol::print(KeyModifier mod, bool forgui) const
 {
        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 {
@@ -743,8 +746,15 @@ KeyModifier q_key_state(Qt::KeyboardModifiers state)
                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 & Qt::MetaModifier)
+               k |= MetaModifier;
+#else
+       if (state & Qt::MetaModifier)
                k |= AltModifier;
+#endif
        return k;
 }