]> git.lyx.org Git - features.git/commitdiff
Add CB for Meta/Control key swap on Mac OS X.
authorPavel Sanda <sanda@lyx.org>
Sun, 19 Sep 2010 22:00:25 +0000 (22:00 +0000)
committerPavel Sanda <sanda@lyx.org>
Sun, 19 Sep 2010 22:00:25 +0000 (22:00 +0000)
Patch by Jens Noeckel.
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg160177.html

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35453 a592a061-630c-0410-9148-cb99ea01b6c8

src/LyXRC.cpp
src/LyXRC.h
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/ui/PrefInputUi.ui

index 252bbfb36d4c3c28c8a1a3feaa9f3355dfa2d296..5727c3267e931c7aab15b26068f869900606411e 100644 (file)
@@ -126,6 +126,7 @@ LexerKeyword lyxrcTags[] = {
        { "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
        { "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
        { "\\load_session", LyXRC::RC_LOADSESSION },
+       { "\\mac_dontswap_ctrl_meta", LyXRC::RC_MAC_DONTSWAP_CTRL_META },
        { "\\mac_like_word_movement", LyXRC::RC_MAC_LIKE_WORD_MOVEMENT },
        { "\\macro_edit_style", LyXRC::RC_MACRO_EDIT_STYLE },
        { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
@@ -324,6 +325,7 @@ void LyXRC::setDefaults()
        scroll_below_document = false;
        scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_CTRL;
        paragraph_markers = false;
+       mac_dontswap_ctrl_meta = false;
        mac_like_word_movement = false;
        macro_edit_style = MACRO_EDIT_INLINE_BOX;
        dialogs_iconify_with_main = false;
@@ -891,6 +893,10 @@ int LyXRC::read(Lexer & lexrc)
                        lexrc >> paragraph_markers;
                        break;
 
+               case RC_MAC_DONTSWAP_CTRL_META:
+                       lexrc >> mac_dontswap_ctrl_meta;
+                       break;
+
                case RC_MAC_LIKE_WORD_MOVEMENT:
                        lexrc >> mac_like_word_movement;
                        break;
@@ -1736,6 +1742,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                }
                if (tag != RC_LAST)
                        break;
+       case RC_MAC_DONTSWAP_CTRL_META:
+               if (ignore_system_lyxrc ||
+                   mac_dontswap_ctrl_meta
+                   != system_lyxrc.mac_dontswap_ctrl_meta) {
+                       os << "\\mac_dontswap_ctrl_meta "
+                          << convert<string>(mac_dontswap_ctrl_meta) << '\n';
+               }
+               if (tag != RC_LAST)
+                       break;
        case RC_MAC_LIKE_WORD_MOVEMENT:
                if (ignore_system_lyxrc ||
                    mac_like_word_movement
@@ -3049,6 +3064,10 @@ string const LyXRC::getDescription(LyXRCTags tag)
                str = _("LyX normally doesn't allow the user to scroll further than the bottom of the document. Set to true if you prefer to scroll the bottom of the document to the top of the screen");
                break;
 
+       case RC_MAC_DONTSWAP_CTRL_META:
+               str = _("Make Apple key act as Meta and Control key as Ctrl.");
+               break;
+
        case RC_MAC_LIKE_WORD_MOVEMENT:
                str = _("Use the Mac OS X conventions for the word-level cursor movement");
                break;
index ffcf3f650c10703218c5c96d75cee43652516e21..3567bae6ea4e196b0b07844a60443b020cd1dfc4 100644 (file)
@@ -110,6 +110,7 @@ public:
                RC_LANGUAGE_USE_BABEL,
                RC_LOADSESSION,
                RC_MACRO_EDIT_STYLE,
+               RC_MAC_DONTSWAP_CTRL_META,
                RC_MAC_LIKE_WORD_MOVEMENT,
                RC_MAKE_BACKUP,
                RC_MARK_FOREIGN_LANGUAGE,
@@ -411,6 +412,8 @@ public:
        /// all available editors
        Alternatives editor_alternatives;
        ///
+       bool mac_dontswap_ctrl_meta;
+       ///
        bool mac_like_word_movement;
        ///
        bool cursor_follows_scrollbar;
index 9f5232f1570bf11687f1de968d811550e3cd2127..f42c099df3e83584fc5e6b4f681628e037b90651 100644 (file)
@@ -786,8 +786,6 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
        // FIXME: Do we need a lyxrc setting for this on Mac? This behaviour
        // seems to be the default case for applications like LyX.
        setQuitOnLastWindowClosed(false);
-       // setAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
-
        // This allows to translate the strings that appear in the LyX menu.
        /// A translator suitable for the entries in the LyX menu.
        /// Only needed with Qt/Mac.
@@ -1988,6 +1986,9 @@ void GuiApplication::execBatchCommands()
                return;
 
 #ifdef Q_WS_MACX
+#if QT_VERSION > 0x040600
+       setAttribute(Qt::AA_MacDontSwapCtrlAndMeta,lyxrc.mac_dontswap_ctrl_meta);
+#endif
        // Create the global default menubar which is shown for the dialogs
        // and if no GuiView is visible.
        // This must be done after the session was recovered to know the "last files".
index 2a35c759d0b8c492d35151a33c60d807b245c1ce..41a6304ff05d23604d3808b0b86eaa73b65a9388 100644 (file)
@@ -461,9 +461,20 @@ PrefInput::PrefInput(GuiPreferences * form)
        connect(mouseWheelSpeedSB, SIGNAL(valueChanged(double)),
                this, SIGNAL(changed()));
        connect(scrollzoomEnableCB, SIGNAL(clicked()),
-                       this, SIGNAL(changed()));
+               this, SIGNAL(changed()));
        connect(scrollzoomValueCO, SIGNAL(activated(int)),
-                       this, SIGNAL(changed()));
+               this, SIGNAL(changed()));
+       connect(dontswapCB, SIGNAL(toggled(bool)),
+               this, SIGNAL(changed()));
+
+       // reveal checkbox for switching Ctrl and Meta on Mac:
+       bool swapcb = false;
+#ifdef Q_WS_MACX
+#if QT_VERSION > 0x040600
+       swapcb = true;
+#endif
+#endif
+       dontswapCB->setVisible(swapcb);
 }
 
 
@@ -489,6 +500,7 @@ void PrefInput::apply(LyXRC & rc) const
        } else {
                rc.scroll_wheel_zoom = LyXRC::SCROLL_WHEEL_ZOOM_OFF;
        }
+       rc.mac_dontswap_ctrl_meta  = dontswapCB->isChecked();
 }
 
 
@@ -516,6 +528,7 @@ void PrefInput::update(LyXRC const & rc)
                scrollzoomValueCO->setCurrentIndex(2);
                break;
        }
+       dontswapCB->setChecked(rc.mac_dontswap_ctrl_meta);
 }
 
 
index 75857b953f69d97a9281a5034e066083e2e8e024..4f8d0fdd1c0ccc3972cddc9947f000c5e29f540e 100644 (file)
         </property>
        </widget>
       </item>
+      <item row="3" column="0" colspan="3" >
+       <widget class="QCheckBox" name="dontswapCB" >
+        <property name="toolTip">
+         <string>Mac OS X specific setting for use with emacs bindings. Takes effect next time LyX is launched.</string>
+        </property>
+        <property name="text" >
+         <string>Do not swap Apple and Control keys</string>
+        </property>
+        <property name="checked" >
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>