]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiExternal.cpp
If we are in a closeEvent, we don't want to close all buffers, because these may...
[lyx.git] / src / frontends / qt4 / GuiExternal.cpp
index d5c14b8d7dc2e215bb3bcf0f47f19e9156dcb148..c32f3edecd5ba6f33317c36408bfd3805e336ed4 100644 (file)
@@ -213,23 +213,25 @@ bool GuiExternal::activateAspectratio() const
        if (usingScale())
                return false;
 
-       string const wstr = fromqstr(widthED->text());
-       if (wstr.empty())
+       QString const wstr = widthED->text();
+       if (wstr.isEmpty())
                return false;
-       bool const wIsDbl = isStrDbl(wstr);
-       if (wIsDbl && float_equal(convert<double>(wstr), 0.0, 0.05))
+       bool wIsDbl;
+       double val = wstr.trimmed().toDouble(&wIsDbl);
+       if (wIsDbl && float_equal(val, 0.0, 0.05))
                return false;
        Length l;
-       if (!wIsDbl && (!isValidLength(wstr, &l) || l.zero()))
+       if (!wIsDbl && (!isValidLength(fromqstr(wstr), &l) || l.zero()))
                return false;
 
-       string const hstr = fromqstr(heightED->text());
-       if (hstr.empty())
+       QString const hstr = heightED->text();
+       if (hstr.isEmpty())
                return false;
-       bool const hIsDbl = isStrDbl(hstr);
-       if (hIsDbl && float_equal(convert<double>(hstr), 0.0, 0.05))
+       bool hIsDbl;
+       val = hstr.trimmed().toDouble(&hIsDbl);
+       if (hIsDbl && float_equal(val, 0.0, 0.05))
                return false;
-       if (!hIsDbl && (!isValidLength(hstr, &l) || l.zero()))
+       if (!hIsDbl && (!isValidLength(fromqstr(hstr), &l) || l.zero()))
                return false;
 
        return true;
@@ -349,27 +351,11 @@ void GuiExternal::widthUnitChanged()
 }
 
 
-static Length::UNIT defaultUnit()
-{
-       Length::UNIT default_unit = Length::CM;
-       switch (lyxrc.default_papersize) {
-       case PAPER_USLETTER:
-       case PAPER_USLEGAL:
-       case PAPER_USEXECUTIVE:
-               default_unit = Length::IN;
-               break;
-       default:
-               break;
-       }
-       return default_unit;
-}
-
-
 static void setRotation(QLineEdit & angleED, QComboBox & originCO,
        external::RotationData const & data)
 {
        originCO.setCurrentIndex(int(data.origin()));
-       angleED.setText(toqstr(data.angle));
+       doubleToWidget(&angleED, data.angle);
 }
 
 
@@ -379,7 +365,7 @@ static void getRotation(external::RotationData & data,
        typedef external::RotationData::OriginType OriginType;
 
        data.origin(static_cast<OriginType>(originCO.currentIndex()));
-       data.angle = fromqstr(angleED.text());
+       data.angle = widgetToDoubleStr(&angleED);
 }
 
 
@@ -397,15 +383,15 @@ static void setSize(QLineEdit & widthED, LengthCombo & widthUnitCO,
        }
 
        if (using_scale) {
-               widthED.setText(toqstr(scale));
+               doubleToWidget(&widthED, scale);
                widthUnitCO.setCurrentItem("scale");
        } else
                lengthToWidgets(&widthED, &widthUnitCO,
-                       data.width.asString(), defaultUnit());
+                               data.width.asString(), Length::defaultUnit());
 
        string const h = data.height.zero() ? string() : data.height.asString();
-       Length::UNIT default_unit = data.width.zero() ?
-               defaultUnit() : data.width.unit();
+       Length::UNIT const default_unit = data.width.zero() ?
+               Length::defaultUnit() : data.width.unit();
        lengthToWidgets(&heightED, &heightUnitCO, h, default_unit);
 
        heightED.setEnabled(!using_scale);
@@ -424,11 +410,9 @@ static void getSize(external::ResizeData & data,
        QLineEdit const & heightED, LengthCombo const & heightUnitCO,
        QCheckBox const & aspectratioCB, bool const scaling)
 {
-       string const width = fromqstr(widthED.text());
-
        if (scaling) {
                // scaling instead of a width
-               data.scale = width;
+               data.scale = widgetToDoubleStr(&widthED);
                data.width = Length();
        } else {
                data.width = Length(widgetsToLength(&widthED, &widthUnitCO));