mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 21:55:29 +00:00
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
This commit is contained in:
parent
969a8356b8
commit
53e7a92494
@ -1,6 +1,9 @@
|
||||
LyX file-format changes
|
||||
-----------------------
|
||||
|
||||
2009-07-19 Uwe Stöhr <uwestoehr@web.de>
|
||||
* Format incremented to 365: support for paragraph indentation.
|
||||
|
||||
2009-07-13 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 364: add \filename_suffix parameter
|
||||
to branches.
|
||||
|
@ -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
|
||||
|
@ -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, []],
|
||||
|
@ -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<string, bool> DepClean;
|
||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||
|
@ -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...
|
||||
|
@ -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;
|
||||
///
|
||||
|
163
src/HSpace.cpp
Normal file
163
src/HSpace.cpp
Normal file
@ -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 <config.h>
|
||||
|
||||
#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
|
78
src/HSpace.h
Normal file
78
src/HSpace.h
Normal file
@ -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
|
@ -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 \
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
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);
|
||||
}
|
||||
default:
|
||||
skip = 0;
|
||||
break;
|
||||
}
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
|
@ -5,8 +5,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>366</height>
|
||||
<width>440</width>
|
||||
<height>410</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -50,7 +50,111 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="indentCO">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</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>size of the vertical space</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" colspan="2">
|
||||
<spacer name="spacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>135</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" 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="1" column="2">
|
||||
<widget class="LengthCombo" name="indentLengthCO">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>121</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>unit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<spacer name="spacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QRadioButton" name="skipRB">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@ -66,7 +170,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="skipCO">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
@ -88,7 +192,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" colspan="2">
|
||||
<item row="2" column="2" colspan="2">
|
||||
<spacer name="spacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -104,7 +208,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="skipLE">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
@ -132,20 +236,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<item row="3" column="2">
|
||||
<widget class="LengthCombo" name="skipLengthCO">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>69</width>
|
||||
<width>121</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<width>16777215</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -154,18 +258,15 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<spacer>
|
||||
<item row="3" 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>23</height>
|
||||
<width>48</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
Loading…
Reference in New Issue
Block a user