The attached patch adds the feature to specify the width of the paragraph indentation. This will be
a fileformat change.
Everything works fine so far (tested since a few days), the only thing I don't understand is why I
have to use this hack:
+ string indentation = bp_.getIndentation().asLyXCommand();
+ if (indentation == "defskip")
+ //set LaTeX's default indentation of 30 pt
+ indentation = "30 pt";
I failed to figured out how to set the default value of 30 pt when the dialog is created.
Furthermore, why is indentation == "defskip" when nothing was ever wrote to the line edit?
thanks and regards
Uwe
Index: BufferParams.cpp
===================================================================
--- BufferParams.cpp (revision 30552)
+++ BufferParams.cpp (working copy)
@@ -289,6 +289,7 @@
/** This is the amount of space used for paragraph_separation "skip",
* and for detached paragraphs in "indented" documents.
*/
+ VSpace indentation;
VSpace defskip;
PDFOptions pdfoptions;
LayoutFileIndex baseClass_;
@@ -468,6 +469,18 @@
}
+VSpace const & BufferParams::getIndentation() const
+{
+ return pimpl_->indentation;
+}
+
+
+void BufferParams::setIndentation(VSpace const & indent)
+{
+ pimpl_->indentation = indent;
+}
+
+
VSpace const & BufferParams::getDefSkip() const
{
return pimpl_->defskip;
@@ -566,6 +579,10 @@
string parsep;
lex >> parsep;
paragraph_separation = parseptranslator().find(parsep);
+ } else if (token == "\\paragraph_indentation") {
+ lex.next();
+ string indentation = lex.getString();
+ pimpl_->indentation = VSpace(indentation);
} else if (token == "\\defskip") {
lex.next();
string defskip = lex.getString();
@@ -904,6 +921,7 @@
<< "\n\\tocdepth " << tocdepth
<< "\n\\paragraph_separation "
<< string_paragraph_separation[paragraph_separation]
+ << "\n\\paragraph_indentation " << getIndentation().asLyXCommand()
<< "\n\\defskip " << getDefSkip().asLyXCommand()
<< "\n\\quotes_language "
<< string_quotes_language[quotes_language]
@@ -1370,6 +1388,7 @@
}
if (paragraph_separation) {
+ // when skip separation
switch (getDefSkip().kind()) {
case VSpace::SMALLSKIP:
os << "\\setlength{\\parskip}{\\smallskipamount}\n";
@@ -1390,9 +1409,14 @@
break;
}
texrow.newline();
-
os << "\\setlength{\\parindent}{0pt}\n";
texrow.newline();
+ } else {
+ // when separation by indentation
+ os << "\\setlength{\\parindent}{"
+ << from_utf8(getIndentation().length().asLatexString())
+ << "}\n";
+ texrow.newline();
}
// Now insert the LyX specific LaTeX commands...
Index: BufferParams.h
===================================================================
--- BufferParams.h (revision 30552)
+++ BufferParams.h (working copy)
@@ -90,6 +90,10 @@
bool hasClassDefaults() const;
///
+ VSpace const & getIndentation() const;
+ ///
+ void setIndentation(VSpace const & indent);
+ ///
VSpace const & getDefSkip() const;
///
void setDefSkip(VSpace const & vs);
Index: frontends/qt4/GuiDocument.cpp
===================================================================
--- frontends/qt4/GuiDocument.cpp (revision 30552)
+++ frontends/qt4/GuiDocument.cpp (working copy)
@@ -557,6 +557,14 @@
this, SLOT(change_adaptor()));
connect(textLayoutModule->indentRB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
+ connect(textLayoutModule->indentRB, SIGNAL(toggled(bool)),
+ textLayoutModule->indentLE, SLOT(setEnabled(bool)));
+ connect(textLayoutModule->indentRB, SIGNAL(toggled(bool)),
+ textLayoutModule->indentLengthCO, SLOT(setEnabled(bool)));
+ connect(textLayoutModule->indentLE, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(textLayoutModule->indentLengthCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString &)),
@@ -583,6 +591,8 @@
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));
@@ -590,8 +600,6 @@
textLayoutModule->skipCO->addItem(qt_("MedSkip"));
textLayoutModule->skipCO->addItem(qt_("BigSkip"));
textLayoutModule->skipCO->addItem(qt_("Length"));
- // remove the %-items from the unit choice
- textLayoutModule->skipLengthCO->noPercents();
textLayoutModule->lspacingCO->insertItem(
Spacing::Single, qt_("Single"));
textLayoutModule->lspacingCO->insertItem(
@@ -600,8 +608,11 @@
Spacing::Double, qt_("Double"));
textLayoutModule->lspacingCO->insertItem(
Spacing::Other, qt_("Custom"));
-
+ // remove the %-items from the unit choices
+ textLayoutModule->indentLengthCO->noPercents();
+ textLayoutModule->skipLengthCO->noPercents();
// initialize the length validator
+ bc().addCheckedLineEdit(textLayoutModule->indentLE);
bc().addCheckedLineEdit(textLayoutModule->skipLE);
// output
@@ -1890,9 +1901,14 @@
bp_.listings_params =
InsetListingsParams(fromqstr(textLayoutModule->listingsED->toPlainText())).params();
- if (textLayoutModule->indentRB->isChecked())
+ if (textLayoutModule->indentRB->isChecked()) {
bp_.paragraph_separation = BufferParams::ParagraphIndentSeparation;
- else
+ VSpace indent = VSpace(
+ widgetsToLength(textLayoutModule->indentLE,
+ textLayoutModule->indentLengthCO)
+ );
+ bp_.setIndentation(indent);
+ } else
bp_.paragraph_separation = BufferParams::ParagraphSkipSeparation;
switch (textLayoutModule->skipCO->currentIndex()) {
@@ -2206,9 +2222,16 @@
}
setLSpacing(nitem);
- if (bp_.paragraph_separation == BufferParams::ParagraphIndentSeparation)
+ if (bp_.paragraph_separation == BufferParams::ParagraphIndentSeparation) {
textLayoutModule->indentRB->setChecked(true);
- else
+ string indentation = bp_.getIndentation().asLyXCommand();
+ if (indentation == "defskip")
+ //set LaTeX's default indentation of 30 pt
+ indentation = "30 pt";
+ lengthToWidgets(textLayoutModule->indentLE,
+ textLayoutModule->indentLengthCO,
+ indentation, Length::PT);
+ } else
textLayoutModule->skipRB->setChecked(true);
int skip = 0;
Index: frontends/qt4/ui/TextLayoutUi.ui
===================================================================
--- frontends/qt4/ui/TextLayoutUi.ui (revision 30555)
+++ frontends/qt4/ui/TextLayoutUi.ui (working copy)
@@ -50,6 +50,75 @@
</property>
</widget>
</item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="indentLE">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>120</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>121</width>
+ <height>21</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>value</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="LengthCombo" name="indentLengthCO">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>69</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>70</width>
+ <height>21</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>unit</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <spacer name="spacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>62</width>
+ <height>26</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
<item row="1" column="0">
<widget class="QRadioButton" name="skipRB">
<property name="minimumSize">