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
This commit is contained in:
Pavel Sanda 2010-09-19 22:00:25 +00:00
parent 1291b07c05
commit 59ce20acde
5 changed files with 53 additions and 4 deletions

View 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;

View 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;

View 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".

View File

@ -464,6 +464,17 @@ PrefInput::PrefInput(GuiPreferences * form)
this, SIGNAL(changed()));
connect(scrollzoomValueCO, SIGNAL(activated(int)),
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);
}

View File

@ -114,6 +114,19 @@
</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>