]> git.lyx.org Git - lyx.git/commitdiff
Factor out (signed) glueLenghValidator
authorJuergen Spitzmueller <spitz@lyx.org>
Wed, 25 Sep 2024 08:22:36 +0000 (10:22 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Wed, 25 Sep 2024 08:22:36 +0000 (10:22 +0200)
src/frontends/qt/GuiDocument.cpp
src/frontends/qt/GuiLine.cpp
src/frontends/qt/GuiVSpace.cpp
src/frontends/qt/Validator.cpp
src/frontends/qt/Validator.h

index 32f98006d40c48e0dfd46339ef8cfd8cbd4f45fa..4eb945e1af0a40bcfc01020fb0a9f27802cb891a 100644 (file)
@@ -894,9 +894,7 @@ GuiDocument::GuiDocument(GuiView & lv)
        textLayoutModule->indentLE->setValidator(new LengthValidator(
                textLayoutModule->indentLE, false));
        // parskip accepts glue length
-       LengthValidator * skipLEValidator = new LengthValidator(textLayoutModule->skipLE, false);
-       skipLEValidator->setBottom(GlueLength());
-       textLayoutModule->skipLE->setValidator(skipLEValidator);
+       textLayoutModule->skipLE->setValidator(glueLengthValidator(textLayoutModule->skipLE));
 
        textLayoutModule->indentCO->addItem(qt_("Default"), toqstr("default"));
        textLayoutModule->indentCO->addItem(qt_("Custom"), toqstr("custom"));
index 8587a5d6ebb1aac6255591f2592f443171d5d5c5..af981c3d76467b30901003d2053b6e0d2a06091f 100644 (file)
@@ -56,10 +56,7 @@ GuiLine::GuiLine(QWidget * parent) : InsetParamsWidget(parent)
        addCheckedWidget(WidthLE, WidthValueL);
        addCheckedWidget(HeightLE, HeightValueL);
 
-       // Set up a signed glue length validator
-       LengthValidator * v = new LengthValidator(OffsetLE);
-       v->setBottom(GlueLength());
-       OffsetLE->setValidator(v);
+       OffsetLE->setValidator(glueLengthValidator(OffsetLE));
        WidthLE->setValidator(unsignedGlueLengthValidator(WidthLE));
        HeightLE->setValidator(unsignedGlueLengthValidator(HeightLE));
 
index 7163634441e7e56b1f49901d2909be0c57b8846c..01fa980a52c7aa4c54e002ffbad667e49171f5d5 100644 (file)
@@ -53,10 +53,7 @@ GuiVSpace::GuiVSpace(QWidget * parent) : InsetParamsWidget(parent)
        connect(spacingCO, SIGNAL(activated(int)),
                this, SLOT(enableCustom(int)));
 
-       // Set up a signed glue length validator
-       LengthValidator * v = new LengthValidator(valueLE);
-       v->setBottom(GlueLength());
-       valueLE->setValidator(v);
+       valueLE->setValidator(glueLengthValidator(valueLE));
 
        // initialize the length validator
        addCheckedWidget(valueLE, valueL);
index 9e8d8d07b9a5a3631b4c56d3eb23ed0cd2ded8d2..f6f871e6a8d777b3a918606f46d72fbf0c7f2dbd 100644 (file)
@@ -134,6 +134,15 @@ LengthValidator * unsignedGlueLengthValidator(QLineEdit * ed)
 }
 
 
+LengthValidator * glueLengthValidator(QLineEdit * ed)
+{
+       LengthValidator * v = new LengthValidator(ed);
+       v->setBottom(GlueLength());
+       v->setUnsigned(false);
+       return v;
+}
+
+
 LengthAutoValidator::LengthAutoValidator(QWidget * parent, QString const & autotext)
        : LengthValidator(parent),
          autotext_(autotext)
index 0793cf8104ca34a0aaba2e0d9df8a75b0bd0f813..647b47733b7fe47fb55f958f866a375e76afb372 100644 (file)
@@ -86,6 +86,11 @@ LengthValidator * unsignedLengthValidator(QLineEdit *);
  */
 LengthValidator * unsignedGlueLengthValidator(QLineEdit *);
 
+/** @returns a new @c LengthValidator that does accept negative lengths
+ *  and glue lengths.
+ */
+LengthValidator * glueLengthValidator(QLineEdit *);
+
 
 /** A class to ascertain whether the data passed to the @c validate()
  *  member function can be interpreted as a GlueLength or is @param autotext.