From e2fc0d43851bad3aff6cb7d6d7f7960d7bb3bbc4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Sat, 4 Oct 2008 09:24:40 +0000 Subject: [PATCH] Box fixes from Vincent and me. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26711 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiBox.cpp | 12 +++++++++--- src/insets/InsetBox.cpp | 35 +++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/frontends/qt4/GuiBox.cpp b/src/frontends/qt4/GuiBox.cpp index 06eb3bf642..744cbd2a3e 100644 --- a/src/frontends/qt4/GuiBox.cpp +++ b/src/frontends/qt4/GuiBox.cpp @@ -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")); diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index 09d7a49797..2f31dcc719 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -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 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); } -- 2.39.2