diff --git a/src/KeyMap.h b/src/KeyMap.h index bb28d37433..c3ff0820e0 100644 --- a/src/KeyMap.h +++ b/src/KeyMap.h @@ -90,7 +90,6 @@ public: typedef std::pair ModifierPair; -private: /// struct Key { /// Keysym @@ -106,6 +105,13 @@ private: FuncRequest func; }; + /// + typedef std::vector Table; + + Table::const_iterator begin() const { return table.begin(); } + Table::const_iterator end() const { return table.end(); } + +private: /** * Define an action for a key sequence. * @param r internal recursion level @@ -124,8 +130,6 @@ private: /// is the table empty ? bool empty() const { return table.empty(); } /// - typedef std::vector Table; - /// Table table; }; diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index a6d42c34c5..a983f40602 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -24,6 +24,8 @@ #include "FuncRequest.h" #include "gettext.h" #include "GuiFontExample.h" +#include "KeyMap.h" +#include "LyXAction.h" #include "PanelStack.h" #include "paper.h" #include "Session.h" @@ -45,6 +47,8 @@ #include #include #include +#include +#include #include #include @@ -1682,6 +1686,12 @@ PrefShortcuts::PrefShortcuts(GuiPreferences * form, QWidget * parent) { setupUi(this); + shortcutsTW->setColumnCount(3); + shortcutsTW->headerItem()->setText(0, qt_("")); + shortcutsTW->headerItem()->setText(1, qt_("Function")); + shortcutsTW->headerItem()->setText(2, qt_("Shortcut")); + shortcutsTW->setSortingEnabled(false); + connect(bindFilePB, SIGNAL(clicked()), this, SLOT(select_bind())); connect(bindFileED, SIGNAL(textChanged(const QString &)), @@ -1698,6 +1708,23 @@ void PrefShortcuts::apply(LyXRC & rc) const void PrefShortcuts::update(LyXRC const & rc) { bindFileED->setText(toqstr(external_path(rc.bind_file))); + + KeyMap & km = theTopLevelKeymap(); + KeyMap::Table::const_iterator it = km.begin(); + KeyMap::Table::const_iterator it_end = km.end(); + for (; it != it_end; ++it) { + QTreeWidgetItem * newItem = new QTreeWidgetItem(shortcutsTW); + string const action = lyxaction.getActionName(it->func.action); + if (action == "self-insert") + continue; + QString const lfun = toqstr(from_utf8(action) + " " + it->func.argument()); + QString const shortcut = toqstr(it->code.print(it->mod.first, true)); + newItem->setText(1, lfun); + newItem->setText(2, shortcut); + // FIXME: TreeItem can not be user-checkable? + newItem->setFlags(newItem->flags() | Qt::ItemIsEditable + | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable); + } } diff --git a/src/frontends/qt4/ui/PrefShortcutsUi.ui b/src/frontends/qt4/ui/PrefShortcutsUi.ui index 57810409c6..d303c650de 100644 --- a/src/frontends/qt4/ui/PrefShortcutsUi.ui +++ b/src/frontends/qt4/ui/PrefShortcutsUi.ui @@ -27,14 +27,40 @@ 6 - - + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + - B&rowse... + Edit - + + + + Shortcuts: + + + + + + + &Bind file: @@ -44,21 +70,15 @@ - - + + + + B&rowse... + + - - - - Qt::Vertical - - - - 20 - 40 - - - + +