mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +00:00
make bindings appear in LyX/Mac menus
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8836 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
db3c256d2a
commit
d3ab333b14
@ -1,3 +1,8 @@
|
||||
2004-06-24 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* kbmap.C (find1keybinding): new method, only used by LyX/Mac with
|
||||
Qt frontend
|
||||
|
||||
2004-07-05 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* BufferView_pimpl.C (setBuffer): set the layout combox value only
|
||||
|
@ -1,3 +1,11 @@
|
||||
2004-07-05 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* QLyXKeySym.C (qprint): like print, but return a QString
|
||||
(print): use qprint.
|
||||
|
||||
* QLPopupMenu.C (getLabel): do not add the binding here anymore
|
||||
(populate): changes to make bindings work on Qt/Mac.
|
||||
|
||||
2004-06-09 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* lyx_gui.C (getStatus): under Mac OS X, disable the
|
||||
|
@ -22,6 +22,12 @@
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#ifdef Q_WS_MACX
|
||||
#include "kbmap.h"
|
||||
#include "QLyXKeySym.h"
|
||||
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
||||
#endif
|
||||
|
||||
using std::distance;
|
||||
using std::make_pair;
|
||||
using std::string;
|
||||
@ -46,13 +52,6 @@ string const getLabel(MenuItem const & mi)
|
||||
label.insert(pos, 1, '&');
|
||||
}
|
||||
|
||||
if (mi.kind() == MenuItem::Command) {
|
||||
string const binding(mi.binding());
|
||||
if (!binding.empty()) {
|
||||
label += '\t' + binding;
|
||||
}
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
@ -107,7 +106,30 @@ void QLPopupMenu::populate(Menu * menu)
|
||||
funcs_.insert(funcs_.end(), m->func());
|
||||
int const index = distance(funcs_.begin(), fit);
|
||||
|
||||
insertItem(toqstr(getLabel(*m)), index);
|
||||
QString label = toqstr(getLabel(*m));
|
||||
#ifdef Q_WS_MACX
|
||||
/* There are two constraints on Qt/Mac: (1)
|
||||
the bindings require a unicode string to be
|
||||
represented meaningfully and std::string
|
||||
does not work (2) only 1-key bindings can
|
||||
be represented in menus.
|
||||
|
||||
This is why the unpleasant hack bellow is
|
||||
needed (JMarc)
|
||||
*/
|
||||
pair<LyXKeySym const *, key_modifier::state>
|
||||
binding = toplevel_keymap->find1keybinding(m->func());
|
||||
if (binding.first) {
|
||||
QLyXKeySym const *key = static_cast<QLyXKeySym const *>(binding.first);
|
||||
label += '\t' + key->qprint(binding.second);
|
||||
}
|
||||
#else
|
||||
string const binding(m->binding());
|
||||
if (!binding.empty()) {
|
||||
label += '\t' + toqstr(binding);
|
||||
}
|
||||
#endif
|
||||
insertItem(label, index);
|
||||
setItemEnabled(index, status.enabled());
|
||||
setItemChecked(index, status.onoff(true));
|
||||
}
|
||||
|
@ -169,11 +169,10 @@ char QLyXKeySym::getISOEncoded(string const & encoding) const
|
||||
}
|
||||
|
||||
|
||||
string const QLyXKeySym::print(key_modifier::state mod) const
|
||||
QString const QLyXKeySym::qprint(key_modifier::state mod) const
|
||||
{
|
||||
int tmpkey = key_;
|
||||
|
||||
|
||||
if (mod & key_modifier::shift)
|
||||
tmpkey += Qt::SHIFT;
|
||||
if (mod & key_modifier::ctrl)
|
||||
@ -181,7 +180,13 @@ string const QLyXKeySym::print(key_modifier::state mod) const
|
||||
if (mod & key_modifier::alt)
|
||||
tmpkey += Qt::ALT;
|
||||
|
||||
return fromqstr(QAccel::keyToString(tmpkey));
|
||||
return QAccel::keyToString(tmpkey);
|
||||
}
|
||||
|
||||
|
||||
string const QLyXKeySym::print(key_modifier::state mod) const
|
||||
{
|
||||
return fromqstr(qprint(mod));
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,9 +55,12 @@ public:
|
||||
*/
|
||||
virtual char getISOEncoded(std::string const & encoding) const;
|
||||
|
||||
///
|
||||
/// Return a human-readable version of a key+modifier pair.
|
||||
virtual std::string const print(key_modifier::state mod) const;
|
||||
|
||||
///
|
||||
QString const qprint(key_modifier::state mod) const;
|
||||
|
||||
///
|
||||
int key() const {
|
||||
return key_;
|
||||
|
14
src/kbmap.C
14
src/kbmap.C
@ -325,3 +325,17 @@ kb_keymap::findbindings(FuncRequest const & func,
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
std::pair<LyXKeySym const *, key_modifier::state>
|
||||
kb_keymap::find1keybinding(FuncRequest const & func) const
|
||||
{
|
||||
Table::const_iterator end = table.end();
|
||||
for (Table::const_iterator cit = table.begin();
|
||||
cit != end; ++cit) {
|
||||
if (!cit->table.get() && cit->func == func)
|
||||
return std::make_pair(cit->code.get(), cit->mod.first);
|
||||
}
|
||||
|
||||
return std::make_pair<LyXKeySym const *, key_modifier::state>(0, key_modifier::none);
|
||||
}
|
||||
|
@ -65,6 +65,15 @@ public:
|
||||
/// Given an action, print the keybindings.
|
||||
std::string const printbindings(FuncRequest const & func) const;
|
||||
|
||||
/**
|
||||
* Given an action, find the first 1-key binding (if it exists).
|
||||
* The LyXKeySym pointer is 0 is no key is found.
|
||||
* [only used by the Qt/Mac frontend]
|
||||
*/
|
||||
std::pair<LyXKeySym const *, key_modifier::state>
|
||||
find1keybinding(FuncRequest const & func) const;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a string of the given keysym, with modifiers.
|
||||
* @param key the key as a keysym
|
||||
|
Loading…
Reference in New Issue
Block a user