diff --git a/src/frontends/qt4/GuiBox.cpp b/src/frontends/qt4/GuiBox.cpp index 8e412a9c08..a90238b3cd 100644 --- a/src/frontends/qt4/GuiBox.cpp +++ b/src/frontends/qt4/GuiBox.cpp @@ -63,6 +63,8 @@ GuiBoxDialog::GuiBoxDialog(LyXView & lv) this, SLOT(change_adaptor())); connect(valignCO, SIGNAL(highlighted(const QString &)), this, SLOT(change_adaptor())); + connect(heightCB, SIGNAL(stateChanged(int)), + this, SLOT(change_adaptor())); connect(heightED, SIGNAL(textChanged(const QString &)), this, SLOT(change_adaptor())); connect(heightUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT) ), @@ -70,6 +72,7 @@ GuiBoxDialog::GuiBoxDialog(LyXView & lv) connect(restorePB, SIGNAL(clicked()), this, SLOT(restoreClicked())); connect(typeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); connect(typeCO, SIGNAL(activated(int)), this, SLOT(typeChanged(int))); + connect(heightCB, SIGNAL(stateChanged(int)), this, SLOT(heightChecked(int))); connect(halignCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); connect(ialignCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); connect(innerBoxCO, SIGNAL(activated(const QString&)), @@ -87,8 +90,9 @@ GuiBoxDialog::GuiBoxDialog(LyXView & lv) bc().addReadOnly(ialignCO); bc().addReadOnly(halignCO); bc().addReadOnly(widthED); - bc().addReadOnly(heightED); bc().addReadOnly(widthUnitsLC); + bc().addReadOnly(heightCB); + bc().addReadOnly(heightED); bc().addReadOnly(heightUnitsLC); bc().setRestore(restorePB); @@ -98,7 +102,7 @@ GuiBoxDialog::GuiBoxDialog(LyXView & lv) // initialize the length validator bc().addCheckedLineEdit(widthED, widthLA); - bc().addCheckedLineEdit(heightED, heightLA); + bc().addCheckedLineEdit(heightED, heightCB); } @@ -127,8 +131,11 @@ void GuiBoxDialog::innerBoxChanged(const QString & str) valignCO->setEnabled(ibox); ialignCO->setEnabled(ibox); halignCO->setEnabled(!ibox); - heightED->setEnabled(ibox); - heightUnitsLC->setEnabled(ibox); + heightCB->setEnabled(ibox); + if (heightCB->checkState() == Qt::Checked && ibox) { + heightED->setEnabled(true); + heightUnitsLC->setEnabled(true); + } setSpecial(ibox); } @@ -140,6 +147,7 @@ void GuiBoxDialog::typeChanged(int index) valignCO->setEnabled(true); ialignCO->setEnabled(true); halignCO->setEnabled(false); + heightCB->setEnabled(true); heightED->setEnabled(true); heightUnitsLC->setEnabled(true); setSpecial(true); @@ -149,11 +157,23 @@ void GuiBoxDialog::typeChanged(int index) } +void GuiBoxDialog::heightChecked(int checkState) +{ + if (checkState == Qt::Unchecked) { + heightED->setEnabled(false); + heightUnitsLC->setEnabled(false); + } else { + heightED->setEnabled(true); + heightUnitsLC->setEnabled(true); + } +} + void GuiBoxDialog::restoreClicked() { setInnerType(true, 2); widthED->setText("100"); widthUnitsLC->setCurrentItem(Length::PCW); + heightCB->setCheckState(Qt::Checked); heightED->setText("1"); for (int j = 0; j < heightUnitsLC->count(); j++) { if (heightUnitsLC->itemText(j) == qt_("Total Height")) @@ -230,9 +250,7 @@ void GuiBoxDialog::updateContents() } } } - - heightED->setEnabled(ibox); - heightUnitsLC->setEnabled(ibox); + heightCB->setEnabled(ibox); } @@ -319,7 +337,16 @@ void GuiBoxDialog::applyView() } else height = widgetsToLength(heightED, heightUnitsLC); - controller().params().height = Length(height); + // the height parameter is omitted in InsetBox.cpp when the value + // is "1in" and "Total Height" is used as unit. + // 1in + "Total Height" means "1\height" which is the LaTeX default when + // no height is given + if (heightCB->checkState() == Qt::Checked) + controller().params().height = Length(height); + else { + controller().params().height = Length("1in"); + controller().params().height_special = ids_spec_[3]; + } } diff --git a/src/frontends/qt4/GuiBox.h b/src/frontends/qt4/GuiBox.h index 938721a285..d3513cf7ab 100644 --- a/src/frontends/qt4/GuiBox.h +++ b/src/frontends/qt4/GuiBox.h @@ -33,6 +33,7 @@ private Q_SLOTS: void change_adaptor(); void innerBoxChanged(const QString &); void typeChanged(int); + void heightChecked(int); void restoreClicked(); private: diff --git a/src/frontends/qt4/ui/BoxUi.ui b/src/frontends/qt4/ui/BoxUi.ui index 02944c5fef..eee1688de5 100644 --- a/src/frontends/qt4/ui/BoxUi.ui +++ b/src/frontends/qt4/ui/BoxUi.ui @@ -1,15 +1,12 @@ - - - BoxUi 0 0 - 333 - 274 + 348 + 256 @@ -18,361 +15,400 @@ true - - - 9 + + + + 10 + 220 + 328 + 27 + - - 6 + + + 0 + + + 6 + + + + + + + + &Restore + + + false + + + false + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + + + + + + &OK + + + true + + + + + + + + + + &Apply + + + false + + + false + + + + + + + &Close + + + false + + + false + + + + + + + + + 10 + 80 + 321 + 24 + - - - - - - - Inner box -- needed for fixed width & line breaks - - + + + 1 + + + 6 + + + + + + - None + &Height (optional): + + + true + + + false + + + + + + + + 1 + 0 + 0 + 0 + + + + Height value + + + + + + + + + + + + 10 + 10 + 321 + 70 + + + + + 0 + + + 6 + + + + + + 1 + 0 + 0 + 0 + + + + Width value + + + + + + + Supported box types + + + + + + + - - - Parbox + Inner Bo&x: + + + innerBoxCO + + + + + + + + + + - - - Minipage + &Decoration: - - - - - - - Supported box types - - - - - - - Inner box -- needed for fixed width & line breaks - - - Inner Bo&x: - - - innerBoxCO - - - - - - - Supported box types - - - &Decoration: - - - typeCO - - - - - - - - 1 - 0 - 0 - 0 - - - - Height value - - - - - - - - 1 - 0 - 0 - 0 - - - - Width value - - - - - - - Height value - - - &Height: - - - heightED - - - - - - - - - - Width value - - - &Width: - - - widthED - - - - - - - Alignment - - - - 9 + + typeCO - - 6 + + + + + + - - - - Horizontal alignment of the content inside the box - - - - Left - - - - - Center - - - - - Right - - - - - Stretch - - - - - - - - Horizontal alignment of the content inside the box - - - Horizontal - - - - - - - Vertical alignment of the box (with regard to baseline) - - - - Top - - - - - Middle - - - - - Bottom - - - - - - - - Vertical alignment of the box (with regard to baseline) - - - &Box: - - - valignCO - - - - - - - Co&ntent: - - - ialignCO - - - - - - - Vertical alignment of the content inside the box - - - - Top - - - - - Middle - - - - - Bottom - - - - - Stretch - - - - - - - - Vertical alignment of the content inside the box - - - Vertical - - - - - - - - - - 0 - - - 6 - - - - - - + + &Width: + + + widthED + + + + + + + Inner box -- needed for fixed width & line breaks + + - &Restore - - - false - - - false - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 20 - 20 - - - - - - - - + None + + - &OK - - - true - - - - - - - + Parbox + + - &Apply + Minipage - - false - - - false - - - - - + + + + + + + + + 10 + 110 + 321 + 104 + + + + Alignment + + + + 9 + + + 6 + + + + + Horizontal alignment of the content inside the box + + - &Close + Left - - false + + + + Center - - false + + + + Right - - - - - + + + + Stretch + + + + + + + + Horizontal alignment of the content inside the box + + + Horizontal + + + + + + + Vertical alignment of the box (with regard to baseline) + + + + Top + + + + + Middle + + + + + Bottom + + + + + + + + Vertical alignment of the box (with regard to baseline) + + + &Box: + + + valignCO + + + + + + + Co&ntent: + + + ialignCO + + + + + + + Vertical alignment of the content inside the box + + + + Top + + + + + Middle + + + + + Bottom + + + + + Stretch + + + + + + + + Vertical alignment of the content inside the box + + + Vertical + + + + + - - - qt_helpers.h - LengthCombo QComboBox
LengthCombo.h
- 0 -
@@ -380,6 +416,7 @@ innerBoxCO widthED widthUnitsLC + heightCB heightED heightUnitsLC ialignCO @@ -390,6 +427,9 @@ closePB applyPB + + qt_helpers.h +
diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index 22c4026054..4d52aec2e9 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -333,14 +333,16 @@ int InsetBox::latex(Buffer const & buf, odocstream & os, os << "[" << params_.pos << "]"; if (params_.height_special == "none") { // FIXME UNICODE - os << '[' << from_ascii(params_.height.asLatexString()) - << ']'; + os << "[" << from_ascii(params_.height.asLatexString()) << "]"; } else { // Special heights - // FIXME UNICODE - os << "[" << params_.height.value() - << '\\' << from_utf8(params_.height_special) - << ']'; + // set no optional argument when the value is the default "1\height" + // (special units like \height are handled as "in") + if (params_.height != Length("1in")) { + // FIXME UNICODE + os << "[" << params_.height.value() + << "\\" << from_utf8(params_.height_special) << "]"; + } } if (params_.inner_pos != params_.pos) os << "[" << params_.inner_pos << "]"; diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 7ced6e3c2a..7a86b240f0 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -430,7 +430,7 @@ bool getTokenValue(string const & str, char const * token, bool & flag) bool getTokenValue(string const & str, char const * token, Length & len) { - // set the lenght to be zero() as default as this it should be if not + // set the length to be zero() as default as this it should be if not // in the file format. len = Length(); string tmp;