]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiHSpace.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiHSpace.cpp
index 1967c2431d75e3015a04cb4cf989daf5f192bb4d..07b98aee23b6064f0734e0a9d6f7bf30fe52215c 100644 (file)
@@ -16,7 +16,6 @@
 #include "qt_helpers.h"
 #include "Validator.h"
 
-#include "LyXRC.h"
 #include "Spacing.h"
 #include "FuncRequest.h"
 
@@ -58,7 +57,10 @@ GuiHSpace::GuiHSpace(GuiView & lv, bool math)
        connect(fillPatternCO, SIGNAL(activated(int)),
                this, SLOT(patternChanged()));
 
-       valueLE->setValidator(unsignedLengthValidator(valueLE));
+       if (params_.math)
+               valueLE->setValidator(unsignedLengthValidator(valueLE));
+       else
+               valueLE->setValidator(unsignedGlueLengthValidator(valueLE));
 
        // Manage the ok, apply, restore and cancel/close buttons
        bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
@@ -75,9 +77,6 @@ GuiHSpace::GuiHSpace(GuiView & lv, bool math)
 
        // initialize the length validator
        bc().addCheckedLineEdit(valueLE, valueL);
-
-       // remove the %-items from the unit choice
-       unitCO->noPercents();
 }
 
 
@@ -248,11 +247,11 @@ static void setWidgetsFromHSpace(InsetSpaceParams const & params,
        fillPattern->setCurrentIndex(pattern);
        keep->setChecked(protect);
 
-       Length::UNIT default_unit =
-                       (lyxrc.default_papersize > 3) ? Length::CM : Length::IN;
-       if (item == (params.math ? 9 : 7))
-               lengthToWidgets(value, unit, params.length, default_unit);
-       else
+       Length::UNIT const default_unit = Length::defaultUnit();
+       if (item == (params.math ? 9 : 7)) {
+               string length = params.length.asString();
+               lengthToWidgets(value, unit, length, default_unit);
+       else
                lengthToWidgets(value, unit, "", default_unit);
 }
 
@@ -274,7 +273,7 @@ static InsetSpaceParams setHSpaceFromWidgets(int spacing,
                case 8: params.kind = InsetSpaceParams::QQUAD;     break;
                case 9:
                        params.kind = InsetSpaceParams::CUSTOM;
-                       params.length = Length(widgetsToLength(value, unit));
+                       params.length = GlueLength(widgetsToLength(value, unit));
                        break;
                }
                return params;
@@ -328,7 +327,7 @@ static InsetSpaceParams setHSpaceFromWidgets(int spacing,
                                params.kind = InsetSpaceParams::CUSTOM_PROTECTED;
                        else
                                params.kind = InsetSpaceParams::CUSTOM;
-                       params.length = Length(widgetsToLength(value, unit));
+                       params.length = GlueLength(widgetsToLength(value, unit));
                        break;
        }
        return params;