Dear all,

The attached patch creates a Shortcuts panel in the Prefs dialog, and
moves bind file related controls to this panel. It does not add or
remove any existing feature.

I plan to

1. add a scrollable two-column list that displays LFUN and Shortcut.
2. allow insertion and edition of each item.
3. save added or modified shortcuts to user preference.

This will yield a simple usable shortcut display/edit interface. At
this stage, users have to know the string representation of LFUN and
shortcuts, which can be made easier latter.

I will commit if there is no objection.

Cheers,
Bo

PS: I have not forgotten Embedding.
Index: development/scons/scons_manifest.py
===================================================================
--- development/scons/scons_manifest.py	(revision 20977)
+++ development/scons/scons_manifest.py	(working copy)
@@ -974,6 +974,7 @@
     PrefPlaintextUi.ui
     PrefPrinterUi.ui
     PrefScreenFontsUi.ui
+    PrefShortcutsUi.ui
     PrefSpellcheckerUi.ui
     PrefUi.ui
     PrefsUi.ui
Index: src/frontends/qt4/GuiPrefs.cpp
===================================================================
--- src/frontends/qt4/GuiPrefs.cpp	(revision 20977)
+++ src/frontends/qt4/GuiPrefs.cpp	(working copy)
@@ -1583,12 +1583,8 @@
 		TextLabel1, SLOT(setEnabled(bool)));
 	connect(uiFilePB, SIGNAL(clicked()),
 		this, SLOT(select_ui()));
-	connect(bindFilePB, SIGNAL(clicked()),
-		this, SLOT(select_bind()));
 	connect(uiFileED, SIGNAL(textChanged(const QString &)),
 		this, SIGNAL(changed()));
-	connect(bindFileED, SIGNAL(textChanged(const QString &)),
-		this, SIGNAL(changed()));
 	connect(restoreCursorCB, SIGNAL(clicked()),
 		this, SIGNAL(changed()));
 	connect(loadSessionCB, SIGNAL(clicked()),
@@ -1616,7 +1612,6 @@
 void PrefUserInterface::apply(LyXRC & rc) const
 {
 	rc.ui_file = internal_path(fromqstr(uiFileED->text()));
-	rc.bind_file = internal_path(fromqstr(bindFileED->text()));
 	rc.use_lastfilepos = restoreCursorCB->isChecked();
 	rc.load_session = loadSessionCB->isChecked();
 	if (loadWindowSizeCB->isChecked()) {
@@ -1637,7 +1632,6 @@
 void PrefUserInterface::update(LyXRC const & rc)
 {
 	uiFileED->setText(toqstr(external_path(rc.ui_file)));
-	bindFileED->setText(toqstr(external_path(rc.bind_file)));
 	restoreCursorCB->setChecked(rc.use_lastfilepos);
 	loadSessionCB->setChecked(rc.load_session);
 	bool loadWindowSize = rc.geometry_width == 0 && rc.geometry_height == 0;
@@ -1668,8 +1662,47 @@
 }
 
 
-void PrefUserInterface::select_bind()
+void PrefUserInterface::on_loadWindowSizeCB_toggled(bool loadwindowsize)
 {
+	windowWidthLA->setDisabled(loadwindowsize);
+	windowHeightLA->setDisabled(loadwindowsize);
+	windowWidthSB->setDisabled(loadwindowsize);
+	windowHeightSB->setDisabled(loadwindowsize);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefShortcuts
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefShortcuts::PrefShortcuts(GuiPreferences * form, QWidget * parent)
+	: PrefModule(_("Shortcuts"), form, parent)
+{
+	setupUi(this);
+
+	connect(bindFilePB, SIGNAL(clicked()),
+		this, SLOT(select_bind()));
+	connect(bindFileED, SIGNAL(textChanged(const QString &)),
+		this, SIGNAL(changed()));
+}
+
+
+void PrefShortcuts::apply(LyXRC & rc) const
+{
+	rc.bind_file = internal_path(fromqstr(bindFileED->text()));
+}
+
+
+void PrefShortcuts::update(LyXRC const & rc)
+{
+	bindFileED->setText(toqstr(external_path(rc.bind_file)));
+}
+
+
+void PrefShortcuts::select_bind()
+{
 	docstring const name =
 		from_utf8(internal_path(fromqstr(bindFileED->text())));
 	docstring file = form_->browsebind(name);
@@ -1678,15 +1711,6 @@
 }
 
 
-void PrefUserInterface::on_loadWindowSizeCB_toggled(bool loadwindowsize)
-{
-	windowWidthLA->setDisabled(loadwindowsize);
-	windowHeightLA->setDisabled(loadwindowsize);
-	windowWidthSB->setDisabled(loadwindowsize);
-	windowHeightSB->setDisabled(loadwindowsize);
-}
-
-
 PrefIdentity::PrefIdentity(QWidget * parent)
 	: PrefModule(_("Identity"), 0, parent)
 {
@@ -1734,6 +1758,7 @@
 	connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
 
 	add(new PrefUserInterface(this));
+	add(new PrefShortcuts(this));
 	add(new PrefScreenFonts(this));
 	add(new PrefColors(this));
 	add(new PrefDisplay);
Index: src/frontends/qt4/ui/PrefUi.ui
===================================================================
--- src/frontends/qt4/ui/PrefUi.ui	(revision 20977)
+++ src/frontends/qt4/ui/PrefUi.ui	(working copy)
@@ -163,13 +163,6 @@
      </layout>
     </widget>
    </item>
-   <item row="1" column="2" >
-    <widget class="QPushButton" name="bindFilePB" >
-     <property name="text" >
-      <string>B&amp;rowse...</string>
-     </property>
-    </widget>
-   </item>
    <item row="0" column="0" >
     <widget class="QLabel" name="uiFileLA" >
      <property name="text" >
@@ -180,16 +173,6 @@
      </property>
     </widget>
    </item>
-   <item row="1" column="0" >
-    <widget class="QLabel" name="bindFileLA" >
-     <property name="text" >
-      <string>&amp;Bind file:</string>
-     </property>
-     <property name="buddy" >
-      <cstring>bindFileED</cstring>
-     </property>
-    </widget>
-   </item>
    <item row="0" column="1" >
     <widget class="QLineEdit" name="uiFileED" />
    </item>
@@ -200,9 +183,6 @@
      </property>
     </widget>
    </item>
-   <item row="1" column="1" >
-    <widget class="QLineEdit" name="bindFileED" />
-   </item>
    <item row="2" column="0" colspan="3" >
     <widget class="QGroupBox" name="GeometryGB" >
      <property name="sizePolicy" >
@@ -378,8 +358,6 @@
  <tabstops>
   <tabstop>uiFileED</tabstop>
   <tabstop>uiFilePB</tabstop>
-  <tabstop>bindFileED</tabstop>
-  <tabstop>bindFilePB</tabstop>
   <tabstop>loadWindowSizeCB</tabstop>
   <tabstop>windowWidthSB</tabstop>
   <tabstop>windowHeightSB</tabstop>
Index: src/frontends/qt4/ui/PrefShortcutsUi.ui
===================================================================
--- src/frontends/qt4/ui/PrefShortcutsUi.ui	(revision 0)
+++ src/frontends/qt4/ui/PrefShortcutsUi.ui	(revision 0)
@@ -0,0 +1,74 @@
+<ui version="4.0" >
+ <class>PrefShortcuts</class>
+ <widget class="QWidget" name="PrefShortcuts" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>398</width>
+    <height>418</height>
+   </rect>
+  </property>
+  <property name="sizePolicy" >
+   <sizepolicy>
+    <hsizetype>1</hsizetype>
+    <vsizetype>1</vsizetype>
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="windowTitle" >
+   <string/>
+  </property>
+  <layout class="QGridLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item row="1" column="2" >
+    <widget class="QPushButton" name="bindFilePB" >
+     <property name="text" >
+      <string>B&amp;rowse...</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0" >
+    <widget class="QLabel" name="bindFileLA" >
+     <property name="text" >
+      <string>&amp;Bind file:</string>
+     </property>
+     <property name="buddy" >
+      <cstring>bindFileED</cstring>
+     </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>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>bindFileED</tabstop>
+  <tabstop>bindFilePB</tabstop>
+ </tabstops>
+ <includes>
+  <include location="local" >qt_helpers.h</include>
+ </includes>
+ <resources/>
+ <connections/>
+</ui>
Index: src/frontends/qt4/GuiPrefs.h
===================================================================
--- src/frontends/qt4/GuiPrefs.h	(revision 20977)
+++ src/frontends/qt4/GuiPrefs.h	(working copy)
@@ -30,6 +30,7 @@
 #include "ui_PrefColorsUi.h"
 #include "ui_PrefDisplayUi.h"
 #include "ui_PrefPathsUi.h"
+#include "ui_PrefShortcutsUi.h"
 #include "ui_PrefSpellcheckerUi.h"
 #include "ui_PrefConvertersUi.h"
 #include "ui_PrefFileformatsUi.h"
@@ -338,12 +339,26 @@
 
 public Q_SLOTS:
 	void select_ui();
-	void select_bind();
 	void on_loadWindowSizeCB_toggled(bool);
 
 };
 
 
+class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts
+{
+	Q_OBJECT
+public:
+	PrefShortcuts(GuiPreferences * form, QWidget * parent = 0);
+
+	void apply(LyXRC & rc) const;
+	void update(LyXRC const & rc);
+
+public Q_SLOTS:
+	void select_bind();
+
+};
+
+
 class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi
 {
 	Q_OBJECT

Reply via email to