]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiBox.cpp
On Linux show in crash message box the backtrace
[lyx.git] / src / frontends / qt4 / GuiBox.cpp
index 9f7bd075f30d7922f854911d11ea10a28e1806e1..d3bd8e86c06320a6b4dc7db3698f0fd05071db68 100644 (file)
@@ -126,9 +126,9 @@ void GuiBox::on_innerBoxCO_activated(int /* index */)
                heightCB->setChecked(false);
        heightCB->setEnabled(ibox);
        // the width can only be selected for makebox or framebox
-       widthCB->setEnabled(itype == "makebox" 
+       widthCB->setEnabled(itype == "makebox"
                            || (outer == "Boxed" && itype == "none"));
-       widthCB->setChecked(itype != "none" && !widthCB->isEnabled());
+       widthCB->setChecked(!widthED->text().isEmpty());
        // except for frameless and boxed, the width cannot be specified if
        // there is no inner box
        bool const width_enabled =
@@ -175,12 +175,12 @@ void GuiBox::on_typeCO_activated(int index)
                setSpecial(ibox);
        }
        // the width can only be selected for makebox or framebox
-       widthCB->setEnabled(itype == "makebox" 
+       widthCB->setEnabled(itype == "makebox"
                            || (type == "Boxed" && itype == "none"));
        widthCB->setChecked(itype != "none" && !widthCB->isEnabled());
        // except for frameless and boxed, the width cannot be specified if
        // there is no inner box
-       bool const width_enabled = 
+       bool const width_enabled =
                itype != "none" || frameless || type == "Boxed";
        // enable if width_enabled, except if checkbaox is active but unset
        widthED->setEnabled(width_enabled || (widthCB->isEnabled() && widthCB->isChecked()));
@@ -205,13 +205,15 @@ void GuiBox::initDialog()
 {
        setInnerType(true, toqstr("minipage"));
        widthED->setText("100");
+       widthCB->setChecked(true);
+       widthCB->setEnabled(false);
        widthUnitsLC->setCurrentItem(Length::PCW);
        heightED->setText("1");
        heightUnitsLC->setCurrentItem("totalheight");
 }
 
 
-void GuiBox::on_widthCB_stateChanged(int state)
+void GuiBox::on_widthCB_stateChanged(int)
 {
        if (widthCB->isEnabled()) {
                widthED->setEnabled(widthCB->isChecked());
@@ -303,16 +305,17 @@ void GuiBox::paramsToDialog(Inset const * inset)
        Length::UNIT const default_unit = Length::defaultUnit();
 
        // the width can only be selected for makebox or framebox
-       widthCB->setEnabled(inner_type == "makebox" 
-                           || (type == "Boxed" && !ibox && !pagebreakCB->isChecked()));
-       // "-999col%" is the code for no width
-       if ((params.width).asString() == "-999col%")
-               widthCB->setCheckState(Qt::Unchecked);
-       else {
-               if (widthCB->isEnabled())
-                       widthCB->setChecked(true);
+       widthCB->setEnabled(inner_type == "makebox"
+                           || (type == "Boxed"
+                               && !ibox && !pagebreakCB->isChecked()));
+       if (params.width.empty()) {
+               widthCB->setChecked(false);
                lengthToWidgets(widthED, widthUnitsLC,
-                       (params.width).asString(), default_unit);
+                       params.width, default_unit);
+       } else {
+               widthCB->setChecked(true);
+               lengthToWidgets(widthED, widthUnitsLC,
+                       params.width, default_unit);
                QString const special = toqstr(params.special);
                if (!special.isEmpty() && special != "none")
                        widthUnitsLC->setCurrentItem(special);
@@ -323,7 +326,7 @@ void GuiBox::paramsToDialog(Inset const * inset)
 
        lengthToWidgets(heightED, heightUnitsLC,
                (params.height).asString(), default_unit);
-       
+
        QString const height_special = toqstr(params.height_special);
        if (!height_special.isEmpty() && height_special != "none")
                heightUnitsLC->setCurrentItem(height_special);
@@ -367,21 +370,21 @@ docstring GuiBox::dialogToParams() const
                widthUnitsLC->itemData(widthUnitsLC->currentIndex()).toString();
        QString value = widthED->text();
 
-       if (widthCB->isChecked()) {
-        if (ids_spec_.contains(unit) && !isValidLength(fromqstr(value))) {
-                params.special = fromqstr(unit);
-                // Note: the unit is simply ignored in this case
-                params.width = Length(value.toDouble(), Length::IN);
-        } else {
-                params.special = "none";
-                params.width = Length(widgetsToLength(widthED, widthUnitsLC));
-        }
-       } else {
-               if (widthCB->isEnabled()) {
-                       // use the code "-999col%" for the case that no width was selected
+       if (widthED->isEnabled()) {
+               if (ids_spec_.contains(unit) && !isValidLength(fromqstr(value))) {
+                       params.special = fromqstr(unit);
+                       // Note: the unit is simply ignored in this case
+                       params.width = Length(value.toDouble(), Length::IN);
+               } else {
                        params.special = "none";
-                       params.width = Length("-999col%");
+                       // we must specify a valid length in this case
+                       if (value.isEmpty())
+                               widthED->setText("0");
+                       params.width = Length(widgetsToLength(widthED, widthUnitsLC));
                }
+       } else {
+               params.special = "none";
+               params.width = Length();
        }
 
        // the height parameter is omitted if the value