]> git.lyx.org Git - features.git/commitdiff
Migrate GuiHSPace to InsetParamsDialog.
authorAbdelrazak Younes <younes@lyx.org>
Sun, 21 Feb 2010 09:28:33 +0000 (09:28 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 21 Feb 2010 09:28:33 +0000 (09:28 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33525 a592a061-630c-0410-9148-cb99ea01b6c8

12 files changed:
src/frontends/qt4/GuiHSpace.cpp
src/frontends/qt4/GuiHSpace.h
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/InsetParamsDialog.cpp
src/frontends/qt4/InsetParamsWidget.h
src/frontends/qt4/ui/HSpaceUi.ui
src/insets/Inset.cpp
src/insets/InsetSpace.cpp
src/insets/InsetSpace.h
src/mathed/InsetMathNest.cpp
src/mathed/InsetMathSpace.cpp
src/mathed/InsetMathSpace.h

index 07b98aee23b6064f0734e0a9d6f7bf30fe52215c..4271ab5318bcfefd887d9053941894eaecf775ff 100644 (file)
@@ -21,6 +21,8 @@
 
 #include "insets/InsetSpace.h"
 
+#include "mathed/InsetMathSpace.h"
+
 #include "support/gettext.h"
 #include "support/lstrings.h"
 
@@ -34,133 +36,89 @@ using namespace std;
 namespace lyx {
 namespace frontend {
 
-GuiHSpace::GuiHSpace(GuiView & lv, bool math)
-       : GuiDialog(lv, math ? "mathspace" : "space", qt_("Horizontal Space Settings"))
+GuiHSpace::GuiHSpace(bool math_mode, QWidget * parent)
+       : InsetParamsWidget(parent), math_mode_(math_mode)
 {
-       params_.math = math;
        setupUi(this);
 
-       connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
-       connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
-       connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
+       spacingCO->clear();
+       if (math_mode_) {
+               spacingCO->addItem(qt_("Thin space"));
+               spacingCO->addItem(qt_("Medium space"));
+               spacingCO->addItem(qt_("Thick space"));
+               spacingCO->addItem(qt_("Negative thin space"));
+               spacingCO->addItem(qt_("Negative medium space"));
+               spacingCO->addItem(qt_("Negative thick space"));
+               spacingCO->addItem(qt_("Half Quad (0.5 em)"));
+               spacingCO->addItem(qt_("Quad (1 em)"));
+               spacingCO->addItem(qt_("Double Quad (2 em)"));
+               spacingCO->addItem(qt_("Custom"));
+       } else {
+               spacingCO->addItem(qt_("Inter-word space"));
+               spacingCO->addItem(qt_("Thin space"));
+               spacingCO->addItem(qt_("Negative thin space"));
+               spacingCO->addItem(qt_("Half Quad (0.5 em)"));
+               spacingCO->addItem(qt_("Quad (1 em)"));
+               spacingCO->addItem(qt_("Double Quad (2 em)"));
+               spacingCO->addItem(qt_("Horizontal Fill"));
+               spacingCO->addItem(qt_("Custom"));
+       }
 
        connect(spacingCO, SIGNAL(highlighted(QString)),
-               this, SLOT(change_adaptor()));
+               this, SLOT(changedSlot()));
        connect(valueLE, SIGNAL(textChanged(QString)),
-               this, SLOT(change_adaptor()));
+               this, SLOT(changedSlot()));
        connect(spacingCO, SIGNAL(activated(int)),
-               this, SLOT(enableWidgets(int)));
+               this, SLOT(changedSlot()));
        connect(keepCB, SIGNAL(clicked()),
-               this, SLOT(change_adaptor()));
+               this, SLOT(changedSlot()));
        connect(unitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
-               this, SLOT(change_adaptor()));
+               this, SLOT(changedSlot()));
        connect(fillPatternCO, SIGNAL(activated(int)),
-               this, SLOT(patternChanged()));
+               this, SLOT(changedSlot()));
 
-       if (params_.math)
+       if (math_mode_)
                valueLE->setValidator(unsignedLengthValidator(valueLE));
        else
                valueLE->setValidator(unsignedGlueLengthValidator(valueLE));
 
-       // Manage the ok, apply, restore and cancel/close buttons
-       bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
-       bc().setOK(okPB);
-       bc().setApply(applyPB);
-       bc().setCancel(closePB);
-
-       // disable for read-only documents
-       bc().addReadOnly(spacingCO);
-       bc().addReadOnly(valueLE);
-       bc().addReadOnly(unitCO);
-       bc().addReadOnly(keepCB);
-       bc().addReadOnly(fillPatternCO);
-
        // initialize the length validator
-       bc().addCheckedLineEdit(valueLE, valueL);
+       addCheckedWidget(valueLE, valueL);
 }
 
 
-void GuiHSpace::change_adaptor()
+void GuiHSpace::changedSlot()
 {
+       enableWidgets();
        changed();
 }
 
 
-void GuiHSpace::setMath(bool custom)
+void GuiHSpace::enableWidgets()
 {
+       int const selection = spacingCO->currentIndex();
+       bool const custom = (selection == spacingCO->count() - 1);
        valueLE->setEnabled(custom);
        unitCO->setEnabled(custom);
-       fillPatternCO->setEnabled(false);
-       keepCB->setToolTip(qt_("Insert the spacing even after a line break"));
-       keepCB->setEnabled(false);
-}
-
-
-void GuiHSpace::enableWidgets(int selection)
-{
-       if (params_.math) {
-               setMath(selection == 9);
-               changed();
+       if (math_mode_) {
+               fillPatternCO->setEnabled(false);
+               keepCB->setEnabled(false);
                return;
        }
-       valueLE->setEnabled(selection == 7);
-       unitCO->setEnabled(selection == 7);
        fillPatternCO->setEnabled(selection == 6);
-       int pattern = fillPatternCO->currentIndex();
+       bool const no_pattern = fillPatternCO->currentIndex() == 0;
        bool const enable_keep =
                selection == 0 || selection == 3  ||
-               (selection == 6 && pattern == 0) || selection == 7;
+               (selection == 6 && no_pattern) || custom;
        keepCB->setEnabled(enable_keep);
-       if (selection == 3)
-               keepCB->setToolTip(qt_("Insert the spacing even after a line break.\n"
-                                      "Note that a protected Half Quad will be turned into\n"
-                                      "a vertical space if used at the beginning of a paragraph!"));
-       else
-               keepCB->setToolTip(qt_("Insert the spacing even after a line break"));
-       changed();
-}
-
-
-void GuiHSpace::patternChanged()
-{
-       enableWidgets(spacingCO->currentIndex());
-       changed();
 }
 
 
-static void setWidgetsFromHSpace(InsetSpaceParams const & params,
-                         QComboBox * spacing,
-                         QLineEdit * value,
-                         LengthCombo * unit,
-                         QCheckBox * keep,
-                         QComboBox * fillPattern)
+void GuiHSpace::paramsToDialog(Inset const * inset)
 {
-       spacing->clear();
-       if (params.math) {
-               spacing->addItem(qt_("Thin space"));
-               spacing->addItem(qt_("Medium space"));
-               spacing->addItem(qt_("Thick space"));
-               spacing->addItem(qt_("Negative thin space"));
-               spacing->addItem(qt_("Negative medium space"));
-               spacing->addItem(qt_("Negative thick space"));
-               spacing->addItem(qt_("Half Quad (0.5 em)"));
-               spacing->addItem(qt_("Quad (1 em)"));
-               spacing->addItem(qt_("Double Quad (2 em)"));
-               spacing->addItem(qt_("Custom"));
-               keep->setEnabled(false);
-               fillPattern->setEnabled(false);
-       } else {
-               spacing->addItem(qt_("Inter-word space"));
-               spacing->addItem(qt_("Thin space"));
-               spacing->addItem(qt_("Negative thin space"));
-               spacing->addItem(qt_("Half Quad (0.5 em)"));
-               spacing->addItem(qt_("Quad (1 em)"));
-               spacing->addItem(qt_("Double Quad (2 em)"));
-               spacing->addItem(qt_("Horizontal Fill"));
-               spacing->addItem(qt_("Custom"));
-               keep->setEnabled(true);
-               fillPattern->setEnabled(true);
-       }
+       InsetSpaceParams const params = math_mode_
+               ? static_cast<InsetMathSpace const *>(inset)->params()
+               : static_cast<InsetSpace const *>(inset)->params();
 
        int item = 0;
        int pattern = 0;
@@ -243,45 +201,61 @@ static void setWidgetsFromHSpace(InsetSpaceParams const & params,
                        protect = !params.math;
                        break;
        }
-       spacing->setCurrentIndex(item);
-       fillPattern->setCurrentIndex(pattern);
-       keep->setChecked(protect);
-
+       spacingCO->setCurrentIndex(item);
+       fillPatternCO->setCurrentIndex(pattern);
+       keepCB->setChecked(protect);
+       if (math_mode_) {
+               keepCB->setToolTip(qt_("Insert the spacing even after a line break"));
+       } else if (item == 3) {
+               keepCB->setToolTip(qt_("Insert the spacing even after a line break.\n"
+                                      "Note that a protected Half Quad will be turned into\n"
+                                      "a vertical space if used at the beginning of a paragraph!"));
+       } else {
+               keepCB->setToolTip(qt_("Insert the spacing even after a line break"));
+       }
        Length::UNIT const default_unit = Length::defaultUnit();
        if (item == (params.math ? 9 : 7)) {
                string length = params.length.asString();
-               lengthToWidgets(value, unit, length, default_unit);
+               lengthToWidgets(valueLE, unitCO, length, default_unit);
        } else
-               lengthToWidgets(value, unit, "", default_unit);
+               lengthToWidgets(valueLE, unitCO, "", default_unit);
+
+       enableWidgets();
 }
 
 
-static InsetSpaceParams setHSpaceFromWidgets(int spacing,
-       QLineEdit * value, LengthCombo * unit, bool keep, int fill, bool math)
+docstring GuiHSpace::dialogToMathParams() const
 {
-       InsetSpaceParams params(math);
-       if (math) {
-               switch (spacing) {
-               case 0: params.kind = InsetSpaceParams::THIN;      break;
-               case 1: params.kind = InsetSpaceParams::MEDIUM;    break;
-               case 2: params.kind = InsetSpaceParams::THICK;     break;
-               case 3: params.kind = InsetSpaceParams::NEGTHIN;   break;
-               case 4: params.kind = InsetSpaceParams::NEGMEDIUM; break;
-               case 5: params.kind = InsetSpaceParams::NEGTHICK;  break;
-               case 6: params.kind = InsetSpaceParams::ENSKIP;    break;
-               case 7: params.kind = InsetSpaceParams::QUAD;      break;
-               case 8: params.kind = InsetSpaceParams::QQUAD;     break;
-               case 9:
-                       params.kind = InsetSpaceParams::CUSTOM;
-                       params.length = GlueLength(widgetsToLength(value, unit));
-                       break;
-               }
-               return params;
+       InsetSpaceParams params(true);
+       switch (spacingCO->currentIndex()) {
+       case 0: params.kind = InsetSpaceParams::THIN;      break;
+       case 1: params.kind = InsetSpaceParams::MEDIUM;    break;
+       case 2: params.kind = InsetSpaceParams::THICK;     break;
+       case 3: params.kind = InsetSpaceParams::NEGTHIN;   break;
+       case 4: params.kind = InsetSpaceParams::NEGMEDIUM; break;
+       case 5: params.kind = InsetSpaceParams::NEGTHICK;  break;
+       case 6: params.kind = InsetSpaceParams::ENSKIP;    break;
+       case 7: params.kind = InsetSpaceParams::QUAD;      break;
+       case 8: params.kind = InsetSpaceParams::QQUAD;     break;
+       case 9:
+               params.kind = InsetSpaceParams::CUSTOM;
+               params.length = GlueLength(widgetsToLength(valueLE, unitCO));
+               break;
        }
+       return from_ascii(InsetSpace::params2string(params));
+}
+
+
+docstring GuiHSpace::dialogToParams() const
+{
+       if (math_mode_)
+               return dialogToMathParams();
 
-       switch (spacing) {
+       InsetSpaceParams params(false);
+
+       switch (spacingCO->currentIndex()) {
                case 0:
-                       if (keep)
+                       if (keepCB->isChecked())
                                params.kind = InsetSpaceParams::PROTECTED;
                        else
                                params.kind = InsetSpaceParams::NORMAL;
@@ -293,7 +267,7 @@ static InsetSpaceParams setHSpaceFromWidgets(int spacing,
                        params.kind = InsetSpaceParams::NEGTHIN;
                        break;
                case 3:
-                       if (keep)
+                       if (keepCB->isChecked())
                                params.kind = InsetSpaceParams::ENSPACE;
                        else
                                params.kind = InsetSpaceParams::ENSKIP;
@@ -305,88 +279,53 @@ static InsetSpaceParams setHSpaceFromWidgets(int spacing,
                        params.kind = InsetSpaceParams::QQUAD;
                        break;
                case 6:
-                       if (fill == 1)
+                       switch (fillPatternCO->currentIndex()) {
+                       case 1:
                                params.kind = InsetSpaceParams::DOTFILL;
-                       else if (fill == 2)
+                               break;
+                       case 2:
                                params.kind = InsetSpaceParams::HRULEFILL;
-                       else if (fill == 3)
+                               break;
+                       case 3:
                                params.kind = InsetSpaceParams::LEFTARROWFILL;
-                       else if (fill == 4)
+                               break;
+                       case 4:
                                params.kind = InsetSpaceParams::RIGHTARROWFILL;
-                       else if (fill == 5)
+                               break;
+                       case 5:
                                params.kind = InsetSpaceParams::UPBRACEFILL;
-                       else if (fill == 6)
+                               break;
+                       case 6:
                                params.kind = InsetSpaceParams::DOWNBRACEFILL;
-                       else if (keep)
-                               params.kind = InsetSpaceParams::HFILL_PROTECTED;
-                       else
-                               params.kind = InsetSpaceParams::HFILL;
+                               break;
+                       default:
+                               if (keepCB->isChecked())
+                                       params.kind = InsetSpaceParams::HFILL_PROTECTED;
+                               else
+                                       params.kind = InsetSpaceParams::HFILL;
+                               break;
+                       }
                        break;
                case 7:
-                       if (keep)
+                       if (keepCB->isChecked())
                                params.kind = InsetSpaceParams::CUSTOM_PROTECTED;
                        else
                                params.kind = InsetSpaceParams::CUSTOM;
-                       params.length = GlueLength(widgetsToLength(value, unit));
+                       params.length = GlueLength(widgetsToLength(valueLE, unitCO));
                        break;
        }
-       return params;
-}
-
-
-void GuiHSpace::applyView()
-{
-       params_ = setHSpaceFromWidgets(spacingCO->currentIndex(),
-                       valueLE, unitCO, keepCB->isChecked(),
-                       fillPatternCO->currentIndex(), params_.math);
-}
-
-
-void GuiHSpace::updateContents()
-{
-       setWidgetsFromHSpace(params_, spacingCO, valueLE, unitCO, keepCB,
-               fillPatternCO);
-       enableWidgets(spacingCO->currentIndex());
+       return from_ascii(InsetSpace::params2string(params));
 }
 
 
-bool GuiHSpace::initialiseParams(string const & data)
+bool GuiHSpace::checkWidgets() const
 {
-       bool const math = params_.math;
-       InsetSpace::string2params(data, params_);
-       params_.math = math;
-       if (params_.math)
-               setMath(params_.kind == InsetSpaceParams::CUSTOM);
-       setButtonsValid(true);
-       return true;
-}
-
-
-void GuiHSpace::clearParams()
-{
-       params_ = InsetSpaceParams(params_.math);
-}
-
-
-void GuiHSpace::dispatchParams()
-{
-       dispatch(FuncRequest(getLfun(), InsetSpace::params2string(params_)));
-}
-
-
-bool GuiHSpace::isValid()
-{
-       return spacingCO->currentIndex() != (params_.math ? 9 : 7)
+       if (!InsetParamsWidget::checkWidgets())
+               return false;
+       return spacingCO->currentIndex() != (math_mode_ ? 9 : 7)
                || !valueLE->text().isEmpty();
 }
 
-
-Dialog * createGuiMathHSpace(GuiView & lv) { return new GuiHSpace(lv, true); }
-
-
-Dialog * createGuiTextHSpace(GuiView & lv) { return new GuiHSpace(lv, false); }
-
-
 } // namespace frontend
 } // namespace lyx
 
index 5b0bdece3ba698a077922f5e29715f871890cb7f..20a98946e420724c4200b9ea3f126914176bf21d 100644 (file)
 #ifndef GUIHSPACE_H
 #define GUIHSPACE_H
 
-#include "GuiDialog.h"
+#include "InsetParamsWidget.h"
 #include "ui_HSpaceUi.h"
-#include "insets/InsetSpace.h"
 
 namespace lyx {
 namespace frontend {
 
-class GuiHSpace : public GuiDialog, public Ui::HSpaceUi
+class GuiHSpace : public InsetParamsWidget, public Ui::HSpaceUi
 {
        Q_OBJECT
 
 public:
-       GuiHSpace(GuiView & lv, bool math);
+       GuiHSpace(bool math_mode, QWidget * parent = 0);
 
 private Q_SLOTS:
        ///
-       void change_adaptor();
+       void changedSlot();
        ///
-       void enableWidgets(int);
-       ///
-       void patternChanged();
+       void enableWidgets();
 
 private:
-       ///
-       void setMath(bool custom);
-       /// Apply from dialog
-       void applyView();
-       /// Update the dialog
-       void updateContents();
-       ///
-       bool isValid();
-       ///
-       bool initialiseParams(std::string const & data);
-       /// clean-up on hide.
-       void clearParams();
-       /// clean-up on hide.
-       void dispatchParams();
-       ///
-       bool isBufferDependent() const { return true; }
-
-       ///
-       InsetSpaceParams params_;
+       /// \name InsetParamsWidget inherited methods
+       //@{
+       InsetCode insetCode() const { return SPACE_CODE; }
+       FuncCode creationCode() const { return LFUN_INSET_INSERT; }
+       void paramsToDialog(Inset const *);
+       docstring dialogToParams() const;
+       bool checkWidgets() const;
+       //@}
+       ///
+       docstring dialogToMathParams() const;
+       ///
+       bool const math_mode_;
 };
 
 } // namespace frontend
index 0c1100d9e4893ef6b2efeadf5240a758fc58a037..78163517cc79e1866fa5209768c19913515c0d30 100644 (file)
@@ -3457,7 +3457,6 @@ Dialog * createGuiIndex(GuiView & lv);
 Dialog * createGuiLabel(GuiView & lv);
 Dialog * createGuiListings(GuiView & lv);
 Dialog * createGuiLog(GuiView & lv);
-Dialog * createGuiMathHSpace(GuiView & lv);
 Dialog * createGuiMathMatrix(GuiView & lv);
 Dialog * createGuiNomenclature(GuiView & lv);
 Dialog * createGuiNote(GuiView & lv);
@@ -3476,7 +3475,6 @@ Dialog * createGuiSpellchecker(GuiView & lv);
 Dialog * createGuiSymbols(GuiView & lv);
 Dialog * createGuiTabularCreate(GuiView & lv);
 Dialog * createGuiTexInfo(GuiView & lv);
-Dialog * createGuiTextHSpace(GuiView & lv);
 Dialog * createGuiToc(GuiView & lv);
 Dialog * createGuiThesaurus(GuiView & lv);
 Dialog * createGuiHyperlink(GuiView & lv);
@@ -3538,8 +3536,6 @@ Dialog * GuiView::build(string const & name)
                return createGuiLog(*this);
        if (name == "mathdelimiter")
                return createGuiDelimiter(*this);
-       if (name == "mathspace")
-               return createGuiMathHSpace(*this);
        if (name == "mathmatrix")
                return createGuiMathMatrix(*this);
        if (name == "nomenclature")
@@ -3560,8 +3556,6 @@ Dialog * GuiView::build(string const & name)
                return createGuiRef(*this);
        if (name == "sendto")
                return createGuiSendTo(*this);
-       if (name == "space")
-               return createGuiTextHSpace(*this);
        if (name == "spellchecker")
                return createGuiSpellchecker(*this);
        if (name == "symbols")
index 16f29ca8e054861987e09ee085267423688fa201..aa5850677d11aa76cb85db912baeba48d3963f8c 100644 (file)
@@ -16,6 +16,7 @@
 #include "GuiBranch.h"\r
 #include "GuiERT.h"\r
 #include "GuiInfo.h"\r
+#include "GuiHSpace.h"\r
 #include "GuiTabular.h"\r
 #include "GuiVSpace.h"\r
 #include "FloatPlacement.h"\r
@@ -214,6 +215,12 @@ Dialog * createDialog(GuiView & lv, InsetCode code)
        case INFO_CODE:\r
                widget = new GuiInfo;\r
                break;\r
+       case MATH_SPACE_CODE:\r
+               widget = new GuiHSpace(true);\r
+               break;\r
+       case SPACE_CODE:\r
+               widget = new GuiHSpace(false);\r
+               break;\r
        case TABULAR_CODE:\r
                widget = new GuiTabular;\r
                break;\r
index d0fbd1157f93a0e534f1f012c8cc3989c13f22f3..58c98a7831d091ad4d38efb23595e78a52426509 100644 (file)
@@ -67,7 +67,7 @@ public:
        virtual docstring dialogToParams() const = 0;\r
 \r
        /// \return true if all CheckedWidgets are in a valid state.\r
-       bool checkWidgets() const;\r
+       virtual bool checkWidgets() const;\r
 \r
 protected:\r
        /// Add a widget to the list of all widgets whose validity should\r
index 5d6a7b5b8f809540cd41d5b507bbbf95b2506e8b..7d238275769e97717fbc976f8d551a3ad30de26a 100644 (file)
-<ui version="4.0" >
+<ui version="4.0">
  <class>HSpaceUi</class>
- <widget class="QDialog" name="HSpaceUi" >
-  <property name="geometry" >
+ <widget class="QWidget" name="HSpaceUi">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>259</width>
-    <height>160</height>
+    <width>239</width>
+    <height>109</height>
    </rect>
   </property>
-  <property name="windowTitle" >
+  <property name="windowTitle">
    <string/>
   </property>
-  <property name="sizeGripEnabled" >
+  <property name="sizeGripEnabled" stdset="0">
    <bool>true</bool>
   </property>
-  <layout class="QGridLayout" >
-   <property name="margin" >
+  <layout class="QGridLayout">
+   <property name="margin">
     <number>9</number>
    </property>
-   <property name="spacing" >
+   <property name="spacing">
     <number>6</number>
    </property>
-   <item row="2" column="1" >
-    <widget class="QComboBox" name="fillPatternCO" >
-     <property name="toolTip" >
+   <item row="2" column="1">
+    <widget class="QComboBox" name="fillPatternCO">
+     <property name="toolTip">
       <string>Select a fill pattern style for HFills</string>
      </property>
      <item>
-      <property name="text" >
+      <property name="text">
        <string>None</string>
       </property>
      </item>
      <item>
-      <property name="text" >
+      <property name="text">
        <string>...............</string>
       </property>
      </item>
      <item>
-      <property name="text" >
+      <property name="text">
        <string>________</string>
       </property>
      </item>
      <item>
-      <property name="text" >
+      <property name="text">
        <string>&lt;-----------</string>
       </property>
      </item>
      <item>
-      <property name="text" >
-       <string>-----------></string>
+      <property name="text">
+       <string>-----------&gt;</string>
       </property>
      </item>
      <item>
-      <property name="text" >
+      <property name="text">
        <string>\-----v-----/</string>
       </property>
      </item>
      <item>
-      <property name="text" >
+      <property name="text">
        <string>/-----^-----\</string>
       </property>
      </item>
     </widget>
    </item>
-   <item row="0" column="0" >
-    <widget class="QLabel" name="spacingL" >
-     <property name="text" >
+   <item row="0" column="0">
+    <widget class="QLabel" name="spacingL">
+     <property name="text">
       <string>&amp;Spacing:</string>
      </property>
-     <property name="buddy" >
+     <property name="buddy">
       <cstring>spacingCO</cstring>
      </property>
     </widget>
    </item>
-   <item row="0" column="1" colspan="2" >
-    <widget class="QComboBox" name="spacingCO" >
-     <property name="toolTip" >
+   <item row="0" column="1" colspan="2">
+    <widget class="QComboBox" name="spacingCO">
+     <property name="toolTip">
       <string>Supported spacing types</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="0" >
-    <widget class="QLabel" name="valueL" >
-     <property name="text" >
+   <item row="1" column="0">
+    <widget class="QLabel" name="valueL">
+     <property name="text">
       <string>&amp;Value:</string>
      </property>
-     <property name="buddy" >
+     <property name="buddy">
       <cstring>valueLE</cstring>
      </property>
     </widget>
    </item>
-   <item row="1" column="1" >
-    <widget class="QLineEdit" name="valueLE" >
-     <property name="enabled" >
+   <item row="1" column="1">
+    <widget class="QLineEdit" name="valueLE">
+     <property name="enabled">
       <bool>false</bool>
      </property>
-     <property name="toolTip" >
-      <string>Custom value. Needs spacing type "Custom".</string>
+     <property name="toolTip">
+      <string>Custom value. Needs spacing type &quot;Custom&quot;.</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="2" >
-    <widget class="LengthCombo" name="unitCO" />
+   <item row="1" column="2">
+    <widget class="LengthCombo" name="unitCO"/>
    </item>
-   <item row="2" column="0" >
-    <widget class="QLabel" name="fillPatternL" >
-     <property name="text" >
+   <item row="2" column="0">
+    <widget class="QLabel" name="fillPatternL">
+     <property name="text">
       <string>&amp;Fill Pattern:</string>
      </property>
-     <property name="buddy" >
+     <property name="buddy">
       <cstring>fillPatternCO</cstring>
      </property>
     </widget>
    </item>
-   <item row="3" column="0" >
-    <widget class="QLabel" name="keepL" >
-     <property name="toolTip" >
+   <item row="3" column="0">
+    <widget class="QLabel" name="keepL">
+     <property name="toolTip">
       <string/>
      </property>
-     <property name="text" >
+     <property name="text">
       <string>&amp;Protect:</string>
      </property>
-     <property name="buddy" >
+     <property name="buddy">
       <cstring>keepCB</cstring>
      </property>
     </widget>
    </item>
-   <item row="3" column="1" colspan="2" >
-    <widget class="QCheckBox" name="keepCB" >
-     <property name="toolTip" >
+   <item row="3" column="1" colspan="2">
+    <widget class="QCheckBox" name="keepCB">
+     <property name="toolTip">
       <string>Insert the spacing even after a line break</string>
      </property>
-     <property name="text" >
+     <property name="text">
       <string/>
      </property>
     </widget>
    </item>
-   <item row="4" column="0" colspan="3" >
-    <layout class="QHBoxLayout" >
-     <property name="margin" >
-      <number>0</number>
-     </property>
-     <property name="spacing" >
-      <number>6</number>
-     </property>
-     <item>
-      <widget class="QPushButton" name="okPB" >
-       <property name="text" >
-        <string>&amp;OK</string>
-       </property>
-       <property name="autoDefault" >
-        <bool>false</bool>
-       </property>
-       <property name="default" >
-        <bool>true</bool>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="applyPB" >
-       <property name="text" >
-        <string>&amp;Apply</string>
-       </property>
-       <property name="autoDefault" >
-        <bool>false</bool>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="closePB" >
-       <property name="text" >
-        <string>&amp;Close</string>
-       </property>
-       <property name="autoDefault" >
-        <bool>false</bool>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
   </layout>
  </widget>
  <customwidgets>
  <tabstops>
   <tabstop>spacingCO</tabstop>
   <tabstop>valueLE</tabstop>
-  <tabstop>okPB</tabstop>
-  <tabstop>applyPB</tabstop>
-  <tabstop>closePB</tabstop>
   <tabstop>keepCB</tabstop>
  </tabstops>
  <includes>
-  <include location="local" >qt_i18n.h</include>
+  <include location="local">qt_i18n.h</include>
  </includes>
  <resources/>
  <connections/>
index 119c1c4cd7048c469449680225fe88a431993a8d..c615b78ab9d2665db88ab298c6554aeed6914c71 100644 (file)
@@ -103,7 +103,7 @@ static void build_translator()
        insetnames[BRANCH_CODE] = InsetName("branch", _("Branch"));
        insetnames[BOX_CODE] = InsetName("box", _("Box"));
        insetnames[FLEX_CODE] = InsetName("flex");
-       insetnames[SPACE_CODE] = InsetName("space");
+       insetnames[SPACE_CODE] = InsetName("space", _("Horizontal Space"));
        insetnames[VSPACE_CODE] = InsetName("vspace", _("Vertical Space"));
        insetnames[MATH_MACROARG_CODE] = InsetName("mathmacroarg");
        insetnames[LISTINGS_CODE] = InsetName("listings");
@@ -149,7 +149,7 @@ static void build_translator()
        insetnames[MATH_ROOT_CODE] = InsetName("mathroot");
        insetnames[MATH_SCRIPT_CODE] = InsetName("mathscript");
        insetnames[MATH_SIZE_CODE] = InsetName("mathsize");
-       insetnames[MATH_SPACE_CODE] = InsetName("mathspace");
+       insetnames[MATH_SPACE_CODE] = InsetName("mathspace", _("Horizontal Math Space"));
        insetnames[MATH_SPECIALCHAR_CODE] = InsetName("mathspecialchar");
        insetnames[MATH_SPLIT_CODE] = InsetName("mathsplit");
        insetnames[MATH_SQRT_CODE] = InsetName("mathsqrt");
@@ -298,6 +298,8 @@ bool Inset::showInsetDialog(BufferView * bv) const
        case BOX_CODE:
        case BRANCH_CODE:
        case INFO_CODE:
+       case MATH_SPACE_CODE:
+       case SPACE_CODE:
        case TABULAR_CODE:
        case VSPACE_CODE:
                bv->showDialog(insetName(code));
index 5cd30542ddd158a5a666c501968bd58662f52996..3d9f0abef85d7c114cc519aa30a4e11fc6c92786 100644 (file)
@@ -60,12 +60,6 @@ GlueLength InsetSpace::length() const
 }
 
 
-InsetSpace::~InsetSpace()
-{
-       hideDialogs("space", this);
-}
-
-
 docstring InsetSpace::toolTip(BufferView const &, int, int) const
 {
        docstring message;
@@ -185,14 +179,6 @@ bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
-bool InsetSpace::showInsetDialog(BufferView * bv) const
-{
-       bv->showDialog("space", params2string(params()),
-               const_cast<InsetSpace *>(this));
-       return true;
-}
-
-
 namespace {
 int const arrow_size = 8;
 }
index 5aed4d50e7d346886e46f692b43125670a007009..d2d5d421df574c48ac9311a60f4fcd3b2240a68a 100644 (file)
@@ -23,8 +23,7 @@ namespace lyx {
 
 class LaTeXFeatures;
 
-class InsetSpaceParams {
-public:
+struct InsetSpaceParams {
        /// The different kinds of spaces we support
        enum Kind {
                /// Normal space ('\ ')
@@ -99,11 +98,9 @@ public:
        ///
        explicit InsetSpace(InsetSpaceParams const & par);
        ///
-       InsetSpaceParams params() const { return params_; }
+       InsetSpaceParams const & params() const { return params_; }
        ///
        InsetSpaceParams::Kind kind() const;
-       ///
-       ~InsetSpace();
 
        ///
        static void string2params(std::string const &, InsetSpaceParams &);
@@ -160,8 +157,6 @@ public:
        bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
 
 private:
-       ///
-       bool showInsetDialog(BufferView * bv) const;
        ///
        InsetSpaceParams params_;
 };
index 0a7810784acb6520c0380ce029f6ef7a23588263..d7ec9bd68c6a6ccfd609345dbd62d21c3a0cea59 100644 (file)
@@ -1191,11 +1191,10 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                if (name == "ref") {
                        InsetMathRef tmp(buffer_, name);
                        data = tmp.createDialogStr(to_utf8(name));
+                       cur.bv().showDialog(to_utf8(name), data);
                } else if (name == "mathspace") {
-                       InsetMathSpace tmp;
-                       data = tmp.createDialogStr();
+                       cur.bv().showDialog(to_utf8(name));
                }
-               cur.bv().showDialog(to_utf8(name), data);
                break;
        }
 
index c771d2595bcd402c2d7521354353bde781cf1943..bd426008cdab96a9d78ff729a695a5caf4690754 100644 (file)
@@ -104,12 +104,6 @@ InsetMathSpace::InsetMathSpace(Length const & length)
 }
 
 
-InsetMathSpace::~InsetMathSpace()
-{
-       hideDialogs("mathspace", this);
-}
-
-
 Inset * InsetMathSpace::clone() const
 {
        return new InsetMathSpace(*this);
@@ -230,13 +224,13 @@ void InsetMathSpace::write(WriteStream & os) const
 }
 
 
-string const InsetMathSpace::createDialogStr() const
+InsetSpaceParams InsetMathSpace::params() const
 {
        LASSERT(space_info[space_].visible, /**/);
        InsetSpaceParams isp(true);
        isp.kind = space_info[space_].kind;
        isp.length = GlueLength(length_);
-       return InsetSpace::params2string(isp);
+       return isp;
 }
 
 
@@ -279,14 +273,9 @@ void InsetMathSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
                cur.undispatched();
                break;
 
-       case LFUN_INSET_DIALOG_UPDATE:
-               cur.bv().updateDialog("mathspace", createDialogStr());
-               break;
-
        case LFUN_MOUSE_RELEASE:
                if (cmd.button() == mouse_button::button1) {
-                       string const data = createDialogStr();
-                       cur.bv().showDialog("mathspace", data, this);
+                       showInsetDialog(&cur.bv());
                        break;
                }
                cur.undispatched();
index 3e60b41c12e8409a043b279f50ed75f606afd1f0..381562178ce34703bb51da1b44f94a1ea641b74b 100644 (file)
@@ -18,6 +18,7 @@
 
 namespace lyx {
 
+struct InsetSpaceParams;
 
 /// Smart spaces
 class InsetMathSpace : public InsetMath {
@@ -29,8 +30,6 @@ public:
        ///
        explicit InsetMathSpace(Length const & length);
        ///
-       ~InsetMathSpace();
-       ///
        InsetMathSpace const * asSpaceInset() const { return this; }
        ///
        InsetMathSpace * asSpaceInset() { return this; }
@@ -56,7 +55,7 @@ public:
        ///
        void write(WriteStream & os) const;
        /// generate something that will be understood by the Dialogs.
-       std::string const createDialogStr() const;
+       InsetSpaceParams params() const;
        ///
        bool hasSettings() const { return true; }
        ///