]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiHSpace.cpp
QDialogButtonBox for the remaining dialogs.
[lyx.git] / src / frontends / qt4 / GuiHSpace.cpp
index a85037a1813705cf41147831b68339832b521625..4307ae0e0f35ec1f659719dc5f85ab542705ee63 100644 (file)
@@ -81,10 +81,13 @@ GuiHSpace::GuiHSpace(bool math_mode, QWidget * parent)
        connect(fillPatternCO, SIGNAL(activated(int)),
                this, SLOT(changedSlot()));
 
+       // Set up a signed (glue) length validator
+       LengthValidator * v = new LengthValidator(valueLE);
        if (math_mode_)
-               valueLE->setValidator(unsignedLengthValidator(valueLE));
+               v->setBottom(Length());
        else
-               valueLE->setValidator(unsignedGlueLengthValidator(valueLE));
+               v->setBottom(GlueLength());
+       valueLE->setValidator(v);
 
        // initialize the length validator
        addCheckedWidget(valueLE, valueL);
@@ -99,7 +102,7 @@ void GuiHSpace::changedSlot()
 }
 
 
-void GuiHSpace::enableWidgets()
+void GuiHSpace::enableWidgets() const
 {
        QString const selection = spacingCO->itemData(spacingCO->currentIndex()).toString();
        bool const custom = selection == "custom";
@@ -292,7 +295,7 @@ docstring GuiHSpace::dialogToParams() const
                        params.kind = keepCB->isChecked() ?
                                InsetSpaceParams::CUSTOM_PROTECTED : InsetSpaceParams::CUSTOM;
                        params.length = GlueLength(widgetsToLength(valueLE, unitCO));
-       } else if (item == "visible") 
+       } else if (item == "visible")
                params.kind = InsetSpaceParams::VISIBLE;
 
        return from_ascii(InsetSpace::params2string(params));
@@ -301,11 +304,17 @@ docstring GuiHSpace::dialogToParams() const
 
 bool GuiHSpace::checkWidgets(bool readonly) const
 {
-       spacingCO->setEnabled(!readonly);
-       unitCO->setEnabled(!readonly);
-       fillPatternCO->setEnabled(!readonly);
-       keepCB->setEnabled(!readonly);
        valueLE->setReadOnly(readonly);
+
+       if (readonly) {
+               spacingCO->setEnabled(false);
+               unitCO->setEnabled(false);
+               fillPatternCO->setEnabled(false);
+               keepCB->setEnabled(false);
+               valueLE->setEnabled(false);
+       } else
+               enableWidgets();
+
        if (!InsetParamsWidget::checkWidgets())
                return false;
        return spacingCO->itemData(spacingCO->currentIndex()).toString() != "custom"