From 53e7a924944709066ff37b76ed714325a09a21d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Sun, 19 Jul 2009 21:13:27 +0000 Subject: [PATCH] support to specify the paragraph indentation in the document settings dialog; introduces the new class HSpace; - file format change git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30694 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/FORMAT | 3 + development/scons/scons_manifest.py | 2 + lib/lyx2lyx/lyx_2_0.py | 76 +++++++++- src/Buffer.cpp | 2 +- src/BufferParams.cpp | 38 ++++- src/BufferParams.h | 5 + src/HSpace.cpp | 163 +++++++++++++++++++++ src/HSpace.h | 78 ++++++++++ src/Makefile.am | 2 + src/TextMetrics.cpp | 16 ++- src/frontends/qt4/GuiDocument.cpp | 203 ++++++++++++++++++--------- src/frontends/qt4/GuiDocument.h | 2 + src/frontends/qt4/ui/TextLayoutUi.ui | 133 +++++++++++++++--- 13 files changed, 632 insertions(+), 91 deletions(-) create mode 100644 src/HSpace.cpp create mode 100644 src/HSpace.h diff --git a/development/FORMAT b/development/FORMAT index 5c36ddb902..ece447fbcf 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,6 +1,9 @@ LyX file-format changes ----------------------- +2009-07-19 Uwe Stöhr + * Format incremented to 365: support for paragraph indentation. + 2009-07-13 Jürgen Spitzmüller * Format incremented to 364: add \filename_suffix parameter to branches. diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index da065ca46f..ada004755b 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -74,6 +74,7 @@ src_header_files = Split(''' FuncRequest.h FuncStatus.h Graph.h + HSpace.h HunspellSpellChecker.h IndicesList.h InsetIterator.h @@ -177,6 +178,7 @@ src_pre_files = Split(''' FuncRequest.cpp FuncStatus.cpp Graph.cpp + HSpace.cpp IndicesList.cpp InsetIterator.cpp InsetList.cpp diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index cb2461dd52..5d043a1dde 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -175,6 +175,50 @@ def lyx2latex(document, lines): return content +def latex_length(string): + 'Convert some LyX stuff into corresponding LaTeX stuff, as best we can.' + i = 0 + percent = False + i = string.find("text%") + if i > -1: + percent = True + value = string[:i] + value = str(float(value)/100) + return value + "\\textwidth" + i = string.find("col%") + if i > -1: + percent = True + value = string[:i] + value = str(float(value)/100) + return value + "\\columnwidth" + i = string.find("page%") + if i > -1: + percent = True + value = string[:i] + value = str(float(value)/100) + return value + "\\paperwidth" + i = string.find("line%") + if i > -1: + percent = True + value = string[:i] + value = str(float(value)/100) + return value + "\\linewidth" + i = string.find("theight%") + if i > -1: + percent = True + value = string[:i] + value = str(float(value)/100) + return value + "\\textheight" + i = string.find("pheight%") + if i > -1: + percent = True + value = string[:i] + value = str(float(value)/100) + return value + "\\paperheight" + if percent == False: + return string + + #################################################################### @@ -760,6 +804,32 @@ def revert_branch_filename(document): del document.header[i] +def revert_paragraph_indentation(document): + " Revert custom paragraph indentation to preamble code " + i = 0 + j = 0 + while True: + i = find_token(document.header, "\\paragraph_indentation", i) + if i == -1: + break + # only remove the preamble line when default + # otherwise also write the value to the preamble + j = document.header[i].find("default") + if j > -1: + del document.header[i] + break + else: + # search for the beginning of the value via the space + j = document.header[i].find(" ") + length = document.header[i][j+1:] + # handle percent lengths + length = latex_length(length) + add_to_preamble(document, ["% this command was inserted by lyx2lyx"]) + add_to_preamble(document, ["\\setlength{\\parindent}{" + length + "}"]) + del document.header[i] + i = i + 1 + + ## # Conversion hub # @@ -783,10 +853,12 @@ convert = [[346, []], [361, []], [362, []], [363, []], - [364, []] + [364, []], + [365, []] ] -revert = [[363, [revert_branch_filename]], +revert = [[364, [revert_paragraph_indentation]], + [363, [revert_branch_filename]], [362, [revert_longtable_align]], [361, [revert_applemac]], [360, []], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index b9bdb05c08..dfc32f3950 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -127,7 +127,7 @@ namespace { // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -int const LYX_FORMAT = 364; // spitz: branch suffixes for filenames +int const LYX_FORMAT = 365; // uwestoehr: support for custom paragraph indentation typedef map DepClean; typedef map > RefCache; diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 1d54cd9fba..250d3aa75d 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -25,6 +25,7 @@ #include "Color.h" #include "ColorSet.h" #include "Encoding.h" +#include "HSpace.h" #include "IndicesList.h" #include "Language.h" #include "LaTeXFeatures.h" @@ -289,6 +290,7 @@ public: /** This is the amount of space used for paragraph_separation "skip", * and for detached paragraphs in "indented" documents. */ + HSpace indentation; VSpace defskip; PDFOptions pdfoptions; LayoutFileIndex baseClass_; @@ -468,6 +470,18 @@ PDFOptions const & BufferParams::pdfoptions() const } +HSpace const & BufferParams::getIndentation() const +{ + return pimpl_->indentation; +} + + +void BufferParams::setIndentation(HSpace const & indent) +{ + pimpl_->indentation = indent; +} + + VSpace const & BufferParams::getDefSkip() const { return pimpl_->defskip; @@ -566,6 +580,10 @@ string BufferParams::readToken(Lexer & lex, string const & token, string parsep; lex >> parsep; paragraph_separation = parseptranslator().find(parsep); + } else if (token == "\\paragraph_indentation") { + lex.next(); + string indentation = lex.getString(); + pimpl_->indentation = HSpace(indentation); } else if (token == "\\defskip") { lex.next(); string defskip = lex.getString(); @@ -903,9 +921,12 @@ void BufferParams::writeFile(ostream & os) const os << "\\secnumdepth " << secnumdepth << "\n\\tocdepth " << tocdepth << "\n\\paragraph_separation " - << string_paragraph_separation[paragraph_separation] - << "\n\\defskip " << getDefSkip().asLyXCommand() - << "\n\\quotes_language " + << string_paragraph_separation[paragraph_separation]; + if (!paragraph_separation) + os << "\n\\paragraph_indentation " << getIndentation().asLyXCommand(); + else + os << "\n\\defskip " << getDefSkip().asLyXCommand(); + os << "\n\\quotes_language " << string_quotes_language[quotes_language] << "\n\\papercolumns " << columns << "\n\\papersides " << sides @@ -1370,6 +1391,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, } if (paragraph_separation) { + // when skip separation switch (getDefSkip().kind()) { case VSpace::SMALLSKIP: os << "\\setlength{\\parskip}{\\smallskipamount}\n"; @@ -1390,9 +1412,17 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, break; } texrow.newline(); - os << "\\setlength{\\parindent}{0pt}\n"; texrow.newline(); + } else { + // when separation by indentation + // only output something when a width is given + if (getIndentation().asLyXCommand() != "default") { + os << "\\setlength{\\parindent}{" + << from_utf8(getIndentation().asLatexCommand()) + << "}\n"; + texrow.newline(); + } } // Now insert the LyX specific LaTeX commands... diff --git a/src/BufferParams.h b/src/BufferParams.h index d0888406f8..32ea2e2ae0 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -36,6 +36,7 @@ class BranchList; class Bullet; class DocumentClass; class Encoding; +class HSpace; class IndicesList; class Language; class LatexFeatures; @@ -89,6 +90,10 @@ public: /// bool hasClassDefaults() const; + /// + HSpace const & getIndentation() const; + /// + void setIndentation(HSpace const & indent); /// VSpace const & getDefSkip() const; /// diff --git a/src/HSpace.cpp b/src/HSpace.cpp new file mode 100644 index 0000000000..5a2b16695f --- /dev/null +++ b/src/HSpace.cpp @@ -0,0 +1,163 @@ +/** + * \file HSpace.cpp + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Jürgen Spitzmüller + * \author Uwe Stöhr + * + * Full author contact details are available in file CREDITS. + */ + +#include + +#include "HSpace.h" + +#include "Buffer.h" +#include "BufferParams.h" +#include "BufferView.h" +#include "support/gettext.h" +#include "Length.h" +#include "Text.h" + +#include "support/lstrings.h" + +#include "support/lassert.h" + +using namespace std; +using namespace lyx::support; + + +namespace lyx { + + +HSpace::HSpace() + : kind_(DEFAULT), len_() +{} + + +HSpace::HSpace(HSpaceKind k) + : kind_(k), len_() +{} + + +HSpace::HSpace(Length const & l) + : kind_(LENGTH), len_(l) +{} + + +HSpace::HSpace(GlueLength const & l) + : kind_(LENGTH), len_(l) +{} + + +HSpace::HSpace(string const & data) + : kind_(DEFAULT), len_() +{ + if (data.empty()) + return; + + string input = rtrim(data); + + if (prefixIs(input, "default")) + kind_ = DEFAULT; + else if (isValidGlueLength(input, &len_)) + kind_ = LENGTH; +} + + +bool HSpace::operator==(HSpace const & other) const +{ + if (kind_ != other.kind_) + return false; + if (len_ != other.len_) + return false; + return true; +} + + +string const HSpace::asLyXCommand() const +{ + string result; + switch (kind_) { + case DEFAULT: + result = "default"; + break; + case LENGTH: + result = len_.asString(); + break; + } + return result; +} + + +string const HSpace::asLatexCommand() const +{ + switch (kind_) { + case DEFAULT: + return string(); + break; + case LENGTH: { + return len_.asLatexString(); + break; + } + default: { + LASSERT(false, /**/); + return string(); + } + } +} + + +docstring const HSpace::asGUIName() const +{ + docstring result; + switch (kind_) { + case DEFAULT: + result = _("Default"); + break; + case LENGTH: + result = from_ascii(len_.asString()); + break; + } + return result; +} + + +string HSpace::asHTMLLength() const +{ + string result; + switch (kind_) { + case DEFAULT: + // 30pt are LaTeX's default + result = "30pt"; + break; + case LENGTH: { + Length tmp = len_.len(); + if (tmp.value() > 0) + result = tmp.asHTMLString(); + break; + } + } + return result; +} + +int HSpace::inPixels(BufferView const & bv) const +{ + switch (kind_) { + case DEFAULT: + // FIXME: replace by correct length + return bv.buffer().params().getIndentation().inPixels(bv); + //return 0; + break; + case LENGTH: + return len_.len().inPixels(bv.workWidth()); + break; + default: + LASSERT(false, /**/); + return 0; + } +} + + +} // namespace lyx diff --git a/src/HSpace.h b/src/HSpace.h new file mode 100644 index 0000000000..7c01f37336 --- /dev/null +++ b/src/HSpace.h @@ -0,0 +1,78 @@ +// -*- C++ -*- +/** + * \file HSpace.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Jürgen Spitzmüller + * \author Uwe Stöhr + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef HSPACE_H +#define HSPACE_H + +#include "Length.h" + + +namespace lyx { + + +class BufferParams; +class BufferView; + + +/// A class representing latex horizontal spacing +class HSpace { +public: + /// The different kinds of spaces. + enum HSpaceKind { + DEFAULT, + LENGTH ///< user-defined length + }; + + /// + HSpace(); + /// + explicit HSpace(HSpaceKind k); + /// + explicit HSpace(Length const & l); + /// + explicit HSpace(GlueLength const & l); + + /// Constructor for reading from a .lyx file + explicit HSpace(std::string const & data); + + /// return the type of vertical space + HSpaceKind kind() const { return kind_; } + /// return the length of this space + GlueLength const & length() const { return len_; } + + /// + bool operator==(HSpace const &) const; + + // conversion + + /// how it goes into the LyX file + std::string const asLyXCommand() const; + /// the latex representation + std::string const asLatexCommand() const; + /// + std::string asHTMLLength() const; + /// how it is seen in the LyX window + docstring const asGUIName() const; + /// the size of the space on-screen + int inPixels(BufferView const & bv) const; + +private: + /// This HSpace kind + HSpaceKind kind_; + /// the specified length + GlueLength len_; +}; + + +} // namespace lyx + +#endif // HSPACE_H diff --git a/src/Makefile.am b/src/Makefile.am index f1c9a5cbe4..c32ab7fa3c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -116,6 +116,7 @@ SOURCEFILESCORE = \ FuncRequest.cpp \ FuncStatus.cpp \ Graph.cpp \ + HSpace.cpp \ IndicesList.cpp \ InsetIterator.cpp \ InsetList.cpp \ @@ -216,6 +217,7 @@ HEADERFILESCORE = \ FuncRequest.h \ FuncStatus.h \ Graph.h \ + HSpace.h \ IndicesList.h \ InsetIterator.h \ InsetList.h \ diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index c17bf2180a..45300db647 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -28,6 +28,7 @@ #include "Cursor.h" #include "CutAndPaste.h" #include "FuncRequest.h" +#include "HSpace.h" #include "InsetList.h" #include "Layout.h" #include "Length.h" @@ -1949,11 +1950,16 @@ int TextMetrics::leftMargin(int max_width, || tclass.isPlainLayout(par.layout())) || buffer.params().paragraph_separation == BufferParams::ParagraphIndentSeparation) ) - { - l_margin += theFontMetrics(buffer.params().getFont()).signedWidth( - parindent); - } - + { + // use the parindent of the layout when the default indentation is used + // otherwise use the indentation set in the document settings + if (buffer.params().getIndentation().asLyXCommand() == "default") + l_margin += theFontMetrics(buffer.params().getFont()).signedWidth( + parindent); + else + l_margin += buffer.params().getIndentation().inPixels(*bv_); + } + return l_margin; } diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 5b560160c9..6286db3d99 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -34,6 +34,7 @@ #include "FloatPlacement.h" #include "Format.h" #include "FuncRequest.h" +#include "HSpace.h" #include "IndicesList.h" #include "Language.h" #include "LaTeXFeatures.h" @@ -553,20 +554,38 @@ GuiDocument::GuiDocument(GuiView & lv) this, SLOT(setLSpacing(int))); connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString &)), this, SLOT(change_adaptor())); - connect(textLayoutModule->skipRB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + connect(textLayoutModule->indentRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(textLayoutModule->indentRB, SIGNAL(toggled(bool)), + textLayoutModule->indentCO, SLOT(setEnabled(bool))); + connect(textLayoutModule->indentCO, SIGNAL(activated(int)), + this, SLOT(change_adaptor())); + connect(textLayoutModule->indentCO, SIGNAL(activated(int)), + this, SLOT(setIndent(int))); + connect(textLayoutModule->indentLE, SIGNAL(textChanged(const QString &)), + this, SLOT(change_adaptor())); + connect(textLayoutModule->indentLengthCO, SIGNAL(activated(int)), + this, SLOT(change_adaptor())); + + connect(textLayoutModule->skipRB, SIGNAL(clicked()), + this, SLOT(change_adaptor())); + connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)), + textLayoutModule->skipCO, SLOT(setEnabled(bool))); connect(textLayoutModule->skipCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(textLayoutModule->skipCO, SIGNAL(activated(int)), + this, SLOT(setSkip(int))); connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString &)), this, SLOT(change_adaptor())); connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(textLayoutModule->skipCO, SIGNAL(activated(int)), - this, SLOT(setSkip(int))); + + connect(textLayoutModule->indentRB, SIGNAL(toggled(bool)), + this, SLOT(enableIndent(bool))); connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)), this, SLOT(enableSkip(bool))); + connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()), @@ -583,9 +602,13 @@ GuiDocument::GuiDocument(GuiView & lv) qt_("Input listings parameters on the right. Enter ? for a list of parameters.")); textLayoutModule->lspacingLE->setValidator(new QDoubleValidator( textLayoutModule->lspacingLE)); + textLayoutModule->indentLE->setValidator(unsignedLengthValidator( + textLayoutModule->indentLE)); textLayoutModule->skipLE->setValidator(unsignedLengthValidator( textLayoutModule->skipLE)); + textLayoutModule->indentCO->addItem(qt_("Default")); + textLayoutModule->indentCO->addItem(qt_("Custom")); textLayoutModule->skipCO->addItem(qt_("SmallSkip")); textLayoutModule->skipCO->addItem(qt_("MedSkip")); textLayoutModule->skipCO->addItem(qt_("BigSkip")); @@ -600,8 +623,8 @@ GuiDocument::GuiDocument(GuiView & lv) Spacing::Double, qt_("Double")); textLayoutModule->lspacingCO->insertItem( Spacing::Other, qt_("Custom")); - // initialize the length validator + bc().addCheckedLineEdit(textLayoutModule->indentLE); bc().addCheckedLineEdit(textLayoutModule->skipLE); // output @@ -1115,19 +1138,39 @@ void GuiDocument::setLSpacing(int item) } +void GuiDocument::setIndent(int item) +{ + bool const enable = (item == 1); + textLayoutModule->indentLE->setEnabled(enable); + textLayoutModule->indentLengthCO->setEnabled(enable); + textLayoutModule->skipLE->setEnabled(false); + textLayoutModule->skipLengthCO->setEnabled(false); + isValid(); +} + + +void GuiDocument::enableIndent(bool indent) +{ + textLayoutModule->skipLE->setEnabled(!indent); + textLayoutModule->skipLengthCO->setEnabled(!indent); + if (indent) + setIndent(textLayoutModule->indentCO->currentIndex()); +} + + void GuiDocument::setSkip(int item) { bool const enable = (item == 3); textLayoutModule->skipLE->setEnabled(enable); textLayoutModule->skipLengthCO->setEnabled(enable); + isValid(); } void GuiDocument::enableSkip(bool skip) { - textLayoutModule->skipCO->setEnabled(skip); - textLayoutModule->skipLE->setEnabled(skip); - textLayoutModule->skipLengthCO->setEnabled(skip); + textLayoutModule->indentLE->setEnabled(!skip); + textLayoutModule->indentLengthCO->setEnabled(!skip); if (skip) setSkip(textLayoutModule->skipCO->currentIndex()); } @@ -1894,35 +1937,53 @@ void GuiDocument::applyView() bp_.listings_params = InsetListingsParams(fromqstr(textLayoutModule->listingsED->toPlainText())).params(); - if (textLayoutModule->indentRB->isChecked()) + if (textLayoutModule->indentRB->isChecked()) { + // if paragraphs are separated by an indentation bp_.paragraph_separation = BufferParams::ParagraphIndentSeparation; - else + switch (textLayoutModule->indentCO->currentIndex()) { + case 0: + bp_.setIndentation(HSpace(HSpace::DEFAULT)); + break; + case 1: { + HSpace indent = HSpace( + widgetsToLength(textLayoutModule->indentLE, + textLayoutModule->indentLengthCO) + ); + bp_.setIndentation(indent); + break; + } + default: + // this should never happen + bp_.setIndentation(HSpace(HSpace::DEFAULT)); + break; + } + } else { + // if paragraphs are separated by a skip bp_.paragraph_separation = BufferParams::ParagraphSkipSeparation; - - switch (textLayoutModule->skipCO->currentIndex()) { - case 0: - bp_.setDefSkip(VSpace(VSpace::SMALLSKIP)); - break; - case 1: - bp_.setDefSkip(VSpace(VSpace::MEDSKIP)); - break; - case 2: - bp_.setDefSkip(VSpace(VSpace::BIGSKIP)); - break; - case 3: - { - VSpace vs = VSpace( - widgetsToLength(textLayoutModule->skipLE, + switch (textLayoutModule->skipCO->currentIndex()) { + case 0: + bp_.setDefSkip(VSpace(VSpace::SMALLSKIP)); + break; + case 1: + bp_.setDefSkip(VSpace(VSpace::MEDSKIP)); + break; + case 2: + bp_.setDefSkip(VSpace(VSpace::BIGSKIP)); + break; + case 3: + { + VSpace vs = VSpace( + widgetsToLength(textLayoutModule->skipLE, textLayoutModule->skipLengthCO) - ); - bp_.setDefSkip(vs); - break; - } - default: - // DocumentDefskipCB assures that this never happens - // so Assert then !!! - jbl - bp_.setDefSkip(VSpace(VSpace::MEDSKIP)); - break; + ); + bp_.setDefSkip(vs); + break; + } + default: + // this should never happen + bp_.setDefSkip(VSpace(VSpace::MEDSKIP)); + break; + } } bp_.options = @@ -2210,37 +2271,49 @@ void GuiDocument::paramsToDialog() } setLSpacing(nitem); - if (bp_.paragraph_separation == BufferParams::ParagraphIndentSeparation) + if (bp_.paragraph_separation == BufferParams::ParagraphIndentSeparation) { textLayoutModule->indentRB->setChecked(true); - else + string indentation = bp_.getIndentation().asLyXCommand(); + int indent = 0; + if (indentation == "default") + indent = 0; + else { + lengthToWidgets(textLayoutModule->indentLE, + textLayoutModule->indentLengthCO, + indentation, defaultUnit); + indent = 1; + } + textLayoutModule->indentCO->setCurrentIndex(indent); + setIndent(indent); + } else { textLayoutModule->skipRB->setChecked(true); - - int skip = 0; - switch (bp_.getDefSkip().kind()) { - case VSpace::SMALLSKIP: - skip = 0; - break; - case VSpace::MEDSKIP: - skip = 1; - break; - case VSpace::BIGSKIP: - skip = 2; - break; - case VSpace::LENGTH: - { - skip = 3; - string const length = bp_.getDefSkip().asLyXCommand(); - lengthToWidgets(textLayoutModule->skipLE, - textLayoutModule->skipLengthCO, - length, defaultUnit); - break; - } - default: - skip = 0; - break; + int skip = 0; + switch (bp_.getDefSkip().kind()) { + case VSpace::SMALLSKIP: + skip = 0; + break; + case VSpace::MEDSKIP: + skip = 1; + break; + case VSpace::BIGSKIP: + skip = 2; + break; + case VSpace::LENGTH: + { + skip = 3; + string const length = bp_.getDefSkip().asLyXCommand(); + lengthToWidgets(textLayoutModule->skipLE, + textLayoutModule->skipLengthCO, + length, defaultUnit); + break; + } + default: + skip = 0; + break; + } + textLayoutModule->skipCO->setCurrentIndex(skip); + setSkip(skip); } - textLayoutModule->skipCO->setCurrentIndex(skip); - setSkip(skip); textLayoutModule->twoColumnCB->setChecked( bp_.columns == 2); @@ -2539,7 +2612,11 @@ bool GuiDocument::isValid() { return validateListingsParameters().isEmpty() && (textLayoutModule->skipCO->currentIndex() != 3 - || !textLayoutModule->skipLE->text().isEmpty()); + || !textLayoutModule->skipLE->text().isEmpty() + || textLayoutModule->indentRB->isChecked()) + && (textLayoutModule->indentCO->currentIndex() != 1 + || !textLayoutModule->indentLE->text().isEmpty() + || textLayoutModule->skipRB->isChecked()); } diff --git a/src/frontends/qt4/GuiDocument.h b/src/frontends/qt4/GuiDocument.h index 00665eba73..161f48f6f6 100644 --- a/src/frontends/qt4/GuiDocument.h +++ b/src/frontends/qt4/GuiDocument.h @@ -93,6 +93,8 @@ private Q_SLOTS: void romanChanged(int); void sansChanged(int); void ttChanged(int); + void setIndent(int); + void enableIndent(bool); void setSkip(int); void enableSkip(bool); void portraitChanged(); diff --git a/src/frontends/qt4/ui/TextLayoutUi.ui b/src/frontends/qt4/ui/TextLayoutUi.ui index 3e6712472c..d91703049f 100644 --- a/src/frontends/qt4/ui/TextLayoutUi.ui +++ b/src/frontends/qt4/ui/TextLayoutUi.ui @@ -5,8 +5,8 @@ 0 0 - 400 - 366 + 440 + 410 @@ -50,7 +50,111 @@ - + + + + false + + + + 120 + 20 + + + + + 121 + 21 + + + + size of the vertical space + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 135 + 26 + + + + + + + + false + + + + 0 + 0 + + + + + 120 + 20 + + + + + 121 + 21 + + + + value + + + + + + + + + + false + + + + 121 + 20 + + + + + 16777215 + 21 + + + + unit + + + + + + + Qt::Horizontal + + + + 48 + 26 + + + + + @@ -66,7 +170,7 @@ - + false @@ -88,7 +192,7 @@ - + Qt::Horizontal @@ -104,7 +208,7 @@ - + false @@ -132,20 +236,20 @@ - + false - 69 + 121 20 - 70 + 16777215 21 @@ -154,18 +258,15 @@ - - + + Qt::Horizontal - - QSizePolicy::Expanding - - 62 - 23 + 48 + 26 -- 2.39.2