]> git.lyx.org Git - features.git/commitdiff
Box fixes from Vincent and me.
authorJürgen Spitzmüller <spitz@lyx.org>
Sat, 4 Oct 2008 09:24:40 +0000 (09:24 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Sat, 4 Oct 2008 09:24:40 +0000 (09:24 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26711 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiBox.cpp
src/insets/InsetBox.cpp

index 06eb3bf642482caeaa722d6d9bd06f60500c706e..744cbd2a3e08a0a4a1d18a5039e76f6dd0f7ab45 100644 (file)
@@ -185,6 +185,8 @@ void GuiBox::typeChanged(int index)
        if (index != 1)
                pagebreakCB->setChecked(false);
        int itype = innerBoxCO->currentIndex();
+       if (innerBoxCO->count() == 2)
+               ++itype;
        pagebreakCB->setEnabled(index == 1 && itype == 0);
        widthED->setEnabled(index != 5);
        widthUnitsLC->setEnabled(index != 5);
@@ -414,8 +416,10 @@ void GuiBox::setSpecial(bool ibox)
        ids_spec_ = boxGuiSpecialLengthIds();
        gui_names_spec_ = boxGuiSpecialLengthNames();
 
+       QString const current_text = widthUnitsLC->currentText();
+
        // check if the widget contains the special units
-       int count = widthUnitsLC->count();
+       int const count = widthUnitsLC->count();
        bool has_special = false;
        for (int i = 0; i != count; ++i)
                if (widthUnitsLC->itemText(i).contains(qt_("Total Height")) > 0)
@@ -430,6 +434,10 @@ void GuiBox::setSpecial(bool ibox)
                for (int i = 0; i != num_units; ++i)
                        widthUnitsLC->addItem(qt_(unit_name_gui[i]));
        }
+       // restore selected text, if possible
+       int const idx = widthUnitsLC->findText(current_text);
+       if (idx != -1)
+               widthUnitsLC->setCurrentIndex(idx);
 }
 
 
@@ -446,8 +454,6 @@ void GuiBox::setInnerType(bool frameless, int i)
                else
                        innerBoxCO->setCurrentIndex(i);
        } else {
-               if (innerBoxCO->count() == 2)
-                       ++i;
                innerBoxCO->clear();
                innerBoxCO->addItem(qt_("None"));
                innerBoxCO->addItem(qt_("Parbox"));
index 09d7a49797d772b6b57785e9f5b1d98c7a27d25c..2f31dcc71986ab3b63433298d1f0077c016d14c2 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "support/debug.h"
 #include "support/gettext.h"
+#include "support/lstrings.h"
 #include "support/Translator.h"
 
 #include "frontends/Application.h"
@@ -35,6 +36,7 @@
 #include <sstream>
 
 using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 
@@ -139,21 +141,34 @@ void InsetBox::read(Lexer & lex)
 
 void InsetBox::setButtonLabel()
 {
-       BoxType btype = boxtranslator().find(params_.type);
+       BoxType const btype = boxtranslator().find(params_.type);
 
-       docstring label;
-       label += _("Box");
-       label += " (";
-       if (btype == Frameless) {
+       docstring const type = _("Box");
+
+       docstring inner;
+       if (params_.inner_box) {
                if (params_.use_parbox)
-                       label += _("Parbox");
+                       inner = _("Parbox");
                else
-                       label += _("Minipage");
-       } else {
-               label += boxtranslator_loc().find(btype);
+                       inner = _("Minipage");
        }
-       label += ")";
 
+       docstring frame;
+       if (btype != Frameless)
+               frame = boxtranslator_loc().find(btype);
+
+       docstring label;
+       if (inner.empty() && frame.empty())
+               label = type;
+       else if (inner.empty())
+               label = bformat(_("%1$s (%2$s)"),
+                       type, frame);
+       else if (frame.empty())
+               label = bformat(_("%1$s (%2$s)"),
+                       type, inner);
+       else
+               label = bformat(_("%1$s (%2$s, %3$s)"),
+                       type, inner, frame);
        setLabel(label);
 }