]> git.lyx.org Git - lyx.git/commitdiff
Make the InsetInfo dialog a bit less esoteric.
authorJuergen Spitzmueller <spitz@lyx.org>
Thu, 26 Jul 2018 14:02:03 +0000 (16:02 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Thu, 26 Jul 2018 14:02:03 +0000 (16:02 +0200)
src/frontends/qt4/GuiInfo.cpp
src/frontends/qt4/ui/InfoUi.ui

index 8994b9431e8fdb54fbe41fafb3b325a5356a2c1b..2ba2ec645b9e06bab55665d199f3d63921194ddb 100644 (file)
@@ -43,8 +43,33 @@ char const * info_types[] =
 { "unknown", "shortcut", "shortcuts", "lyxrc", "package", "textclass", "menu", "icon", "buffer", "lyxinfo", "" };
 
 char const * info_types_gui[] =
-{ N_("unknown"), N_("shortcut"), N_("shortcuts"), N_("lyxrc"), N_("package"), N_("textclass"),
-  N_("menu"), N_("icon"), N_("buffer"), N_("lyxinfo"), ""};
+{ N_("Unknown"), N_("Last Assigned Keyboard Shortcut"), N_("All Keyboard Shortcuts"),
+  N_("LyX Preferences Entry"),  N_("LaTeX Package Availability"), N_("LaTeX Class Availability"),
+  N_("LyX Menu Location"), N_("LyX Toolbar Icon"), N_("Document Information"), N_("LyX Application Information"), ""};
+
+char const * info_name_gui[] =
+{ N_("Not Applicable"), N_("LyX Function"), N_("LyX Function"), N_("Preferences Key"),  N_("Package Name"),
+  N_("Class Name"), N_("LyX Function"), N_("LyX Function"), N_("Information Type"), N_("Information Type"), ""};
+
+char const * info_tooltip[] =
+{ N_("Please select a valid type above"),
+  N_("Enter a function name such as 'math-insert \\alpha'. Please refer to Help > LyX Functions for a comprehensive list of functions. "
+     "The output is the most recently assigned keyboard shortcut for this function"),
+  N_("Enter a function name such as 'math-insert \\alpha'. Please refer to Help > LyX Functions for a comprehensive list of functions. "
+     "The output lists all possible keyboard shortcuts for this function"),
+  N_("Enter a LyX preferences key such as 'bind_file'. Please refer to src/LyXRC.h for available entries. "
+     "The output is the current setting of this preference."),
+  N_("Enter a LaTeX package name such as 'hyperref' (extension is optional). "
+     "The output will be 'Yes' (package available) or 'No' (package unavailable)."),
+  N_("Enter a LaTeX class name such as 'article' (extension is optional). "
+     "The output will be 'Yes' (class available) or 'No' (class unavailable)."),
+  N_("Enter a function name such as 'math-insert \\alpha'. Please refer to Help > LyX Functions for a comprehensive list of functions. "
+     "The output is the path to the function in the menu (using the current localization)."),
+  N_("Enter a function name such as 'math-insert \\alpha'. Please refer to Help > LyX Functions for a comprehensive list of functions. "
+     "The output is the toolbar icon for this function (using the active icon theme)."),
+  N_("Enter either 'name' (outputs the filename of the current document), 'path' (outputs the file path), or 'class' (outputs the text class)."),
+  N_("Currently supported information type: 'version' (outputs the current LyX version)."),
+  ""};
 
 
 GuiInfo::GuiInfo(QWidget * parent) : InsetParamsWidget(parent)
@@ -53,7 +78,7 @@ GuiInfo::GuiInfo(QWidget * parent) : InsetParamsWidget(parent)
 
        typeCO->blockSignals(true);
        for (int n = 0; info_types[n][0]; ++n)
-               typeCO->addItem(qt_(info_types_gui[n]));
+               typeCO->addItem(qt_(info_types_gui[n]), info_types[n]);
        typeCO->blockSignals(false);
 
        connect(typeCO, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
@@ -68,8 +93,8 @@ void GuiInfo::paramsToDialog(Inset const * inset)
        QString const name = toqstr(ii->infoName());
        typeCO->blockSignals(true);
        nameLE->blockSignals(true);
-       int type_index = findToken(info_types, fromqstr(type));
-       typeCO->setCurrentIndex(type_index >= 0 ? type_index : 0);
+       int const i = typeCO->findData(type);
+       typeCO->setCurrentIndex(i);
        // Without this test, 'math-insert' (name) will replace 'math-insert '
        // in nameLE and effectively disallow the input of spaces after a LFUN.
        if (nameLE->text().trimmed() != name)
@@ -81,10 +106,8 @@ void GuiInfo::paramsToDialog(Inset const * inset)
 
 docstring GuiInfo::dialogToParams() const
 {
-       int type_index = typeCO->currentIndex();
-       QString type;
-       if (type_index != -1)
-               type = info_types[type_index];
+       QString type =
+               typeCO->itemData(typeCO->currentIndex()).toString();
        QString const name = nameLE->text();
        return qstring_to_ucs4(type + ' ' + name);
 }
@@ -94,6 +117,13 @@ bool GuiInfo::checkWidgets(bool readonly) const
 {
        nameLE->setReadOnly(readonly);
        typeCO->setEnabled(!readonly);
+       nameLA->setText(qt_(info_name_gui[typeCO->currentIndex()]) + toqstr(":"));
+       bool const type_enabled =
+               typeCO->itemData(typeCO->currentIndex()).toString() != "unknown";
+       nameLA->setEnabled(type_enabled);
+       nameLE->setEnabled(type_enabled);
+       nameLE->setToolTip(qt_(info_tooltip[typeCO->currentIndex()]));
+
        if (!InsetParamsWidget::checkWidgets())
                return false;
        return !nameLE->text().isEmpty();
index 297d16360282e0e67af3954a45222ef0d4b69bfd..39cb57c8bfffb0af60c68e1499e0ea70a84fc5a2 100644 (file)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
  <class>InfoUi</class>
  <widget class="QWidget" name="InfoUi">
@@ -6,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>320</width>
-    <height>75</height>
+    <height>90</height>
    </rect>
   </property>
   <property name="windowTitle">
    <item>
     <layout class="QGridLayout">
      <item row="0" column="0">
-      <widget class="QLabel" name="typeLBL">
+      <widget class="QLabel" name="typeLA">
        <property name="text">
         <string>Information Type:</string>
        </property>
       </widget>
      </item>
      <item row="0" column="1">
-      <widget class="QComboBox" name="typeCO"/>
+      <widget class="QComboBox" name="typeCO">
+       <property name="toolTip">
+        <string>Select the type of information to be output. Then specify the requested information below.</string>
+       </property>
+      </widget>
      </item>
      <item row="1" column="0">
-      <widget class="QLabel" name="nameLBL">
+      <widget class="QLabel" name="nameLA">
        <property name="text">
         <string>Information Name:</string>
        </property>