From 59ce20acde4c94f336302881783729f026d1e350 Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Sun, 19 Sep 2010 22:00:25 +0000 Subject: [PATCH] Add CB for Meta/Control key swap on Mac OS X. 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 | 19 +++++++++++++++++++ src/LyXRC.h | 3 +++ src/frontends/qt4/GuiApplication.cpp | 5 +++-- src/frontends/qt4/GuiPrefs.cpp | 17 +++++++++++++++-- src/frontends/qt4/ui/PrefInputUi.ui | 13 +++++++++++++ 5 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 252bbfb36d..5727c3267e 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -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(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; diff --git a/src/LyXRC.h b/src/LyXRC.h index ffcf3f650c..3567bae6ea 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -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; diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 9f5232f157..f42c099df3 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -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". diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 2a35c759d0..41a6304ff0 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -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); } diff --git a/src/frontends/qt4/ui/PrefInputUi.ui b/src/frontends/qt4/ui/PrefInputUi.ui index 75857b953f..4f8d0fdd1c 100644 --- a/src/frontends/qt4/ui/PrefInputUi.ui +++ b/src/frontends/qt4/ui/PrefInputUi.ui @@ -114,6 +114,19 @@ + + + + Mac OS X specific setting for use with emacs bindings. Takes effect next time LyX is launched. + + + Do not swap Apple and Control keys + + + false + + + -- 2.39.5