]> git.lyx.org Git - features.git/commitdiff
List currently used shortcuts in the shortcuts panel of the preference dialog
authorBo Peng <bpeng@lyx.org>
Tue, 16 Oct 2007 17:48:37 +0000 (17:48 +0000)
committerBo Peng <bpeng@lyx.org>
Tue, 16 Oct 2007 17:48:37 +0000 (17:48 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20991 a592a061-630c-0410-9148-cb99ea01b6c8

src/KeyMap.h
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/ui/PrefShortcutsUi.ui

index bb28d37433e4df7c23d0fef004cef112628cff5d..c3ff0820e0ac0feefd0e6c195d896c1900ba5c3e 100644 (file)
@@ -90,7 +90,6 @@ public:
 
        typedef std::pair<KeyModifier, KeyModifier> ModifierPair;
 
-private:
        ///
        struct Key {
                /// Keysym
@@ -106,6 +105,13 @@ private:
                FuncRequest func;
        };
 
+       ///
+       typedef std::vector<Key> 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<Key> Table;
-       ///
        Table table;
 };
 
index a6d42c34c57616ffb5d9b043309b613467e53a61..a983f406027e526effa857eeef91245c92655168 100644 (file)
@@ -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 <QPushButton>
 #include <QSpinBox>
 #include <QString>
+#include <QTreeWidget>
+#include <QTreeWidgetItem>
 #include <QValidator>
 #include <QCloseEvent>
 
@@ -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);
+       }
 }
 
 
index 57810409c62ab076e0cae143f4e34554335f8398..d303c650de42ea8557ba9e633473d0ca05da435d 100644 (file)
    <property name="spacing" >
     <number>6</number>
    </property>
-   <item row="1" column="2" >
-    <widget class="QPushButton" name="bindFilePB" >
+   <item row="3" column="2" >
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType" >
+      <enum>QSizePolicy::Expanding</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>20</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="2" column="2" >
+    <widget class="QPushButton" name="editPB" >
      <property name="text" >
-      <string>B&amp;rowse...</string>
+      <string>Edit</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0" colspan="2" >
+    <widget class="QLabel" name="shortcutsLBL" >
+     <property name="text" >
+      <string>Shortcuts:</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="0" >
+   <item row="0" column="1" >
+    <widget class="QLineEdit" name="bindFileED" />
+   </item>
+   <item row="0" column="0" >
     <widget class="QLabel" name="bindFileLA" >
      <property name="text" >
       <string>&amp;Bind file:</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="1" >
-    <widget class="QLineEdit" name="bindFileED" />
-   </item>
-   <item row="5" column="1" >
-    <spacer>
-     <property name="orientation" >
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeHint" >
-      <size>
-       <width>20</width>
-       <height>40</height>
-      </size>
+   <item row="0" column="2" >
+    <widget class="QPushButton" name="bindFilePB" >
+     <property name="text" >
+      <string>B&amp;rowse...</string>
      </property>
-    </spacer>
+    </widget>
+   </item>
+   <item rowspan="2" row="2" column="0" colspan="2" >
+    <widget class="QTreeWidget" name="shortcutsTW" />
    </item>
   </layout>
  </widget>