PDFOptions: Pavel's final touches patch

PDFSupportUi.ui: recreated dialog to fix the appearance in the dialog settings dialog

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20881 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2007-10-10 00:34:23 +00:00
parent 392ddbfdbd
commit 38dfe36093
4 changed files with 298 additions and 312 deletions

View File

@ -47,14 +47,14 @@ bool PDFOptions::empty() const
&& pdfborder == x.pdfborder && pdfborder == x.pdfborder
&& colorlinks == x.colorlinks && colorlinks == x.colorlinks
&& backref == x.backref && backref == x.backref
&& pagebackref == x.pagebackref ; && pagebackref == x.pagebackref
&& pdfusetitle == x.pdfusetitle;
} }
void PDFOptions::writeFile(ostream & os) const void PDFOptions::writeFile(ostream & os) const
{ {
os << "\\use_hyperref " << convert<string>(use_hyperref) << '\n'; os << "\\use_hyperref " << convert<string>(use_hyperref) << '\n';
os << "\\pdf_store_options " << convert<string>(store_options) << '\n'; if (!use_hyperref && empty())
if (!use_hyperref && !store_options)
return; return;
if (!title.empty() ) if (!title.empty() )
@ -77,6 +77,7 @@ void PDFOptions::writeFile(ostream & os) const
os << "\\pdf_colorlinks " << convert<string>(colorlinks) << '\n'; os << "\\pdf_colorlinks " << convert<string>(colorlinks) << '\n';
os << "\\pdf_backref " << convert<string>(backref) << '\n'; os << "\\pdf_backref " << convert<string>(backref) << '\n';
os << "\\pdf_pagebackref " << convert<string>(pagebackref) << '\n'; os << "\\pdf_pagebackref " << convert<string>(pagebackref) << '\n';
os << "\\pdf_pdfusetitle " << convert<string>(pdfusetitle) << '\n';
if (!pagemode.empty()) if (!pagemode.empty())
os << "\\pdf_pagemode " << pagemode << '\n'; os << "\\pdf_pagemode " << pagemode << '\n';
@ -99,10 +100,10 @@ void PDFOptions::writeLaTeX(odocstringstream &os) const
// try to extract author and title from document when none is // try to extract author and title from document when none is
// explicitely given // explicitely given
if (title.empty() && author.empty()) if (pdfusetitle && title.empty() && author.empty())
opt += "pdfusetitle,\n "; opt += "pdfusetitle,";
else opt += "\n ";
opt += "\n ";
opt += "bookmarks=" + convert<string>(bookmarks) + ','; opt += "bookmarks=" + convert<string>(bookmarks) + ',';
if (bookmarks) { if (bookmarks) {
opt += "bookmarksnumbered=" + convert<string>(bookmarksnumbered) + ','; opt += "bookmarksnumbered=" + convert<string>(bookmarksnumbered) + ',';
@ -181,12 +182,14 @@ string PDFOptions::readToken(Lexer &lex, string const & token)
lex >> backref; lex >> backref;
} else if (token == "\\pdf_pagebackref") { } else if (token == "\\pdf_pagebackref") {
lex >> pagebackref; lex >> pagebackref;
} else if (token == "\\pdf_pdfusetitle") {
lex >> pdfusetitle;
} else if (token == "\\pdf_pagemode") { } else if (token == "\\pdf_pagemode") {
lex >> pagemode; lex >> pagemode;
} else if (token == "\\pdf_quoted_options") { } else if (token == "\\pdf_quoted_options") {
lex >> quoted_options; lex >> quoted_options;
} else if (token == "\\pdf_store_options") { } else if (token == "\\pdf_store_options") {
lex >> store_options; //leftover from previous option; intended for later removal
} else { } else {
return token; return token;
} }
@ -194,13 +197,13 @@ string PDFOptions::readToken(Lexer &lex, string const & token)
} }
//prepared for check // prepared for check
string PDFOptions::quoted_options_get() const string PDFOptions::quoted_options_get() const
{ {
return quoted_options; return quoted_options;
} }
// Keep implicit hyperref settings // set implicit settings for hyperref
void PDFOptions::clear() void PDFOptions::clear()
{ {
use_hyperref = false; use_hyperref = false;
@ -219,7 +222,7 @@ void PDFOptions::clear()
pagebackref = false; pagebackref = false;
pagemode.clear(); pagemode.clear();
quoted_options.clear(); quoted_options.clear();
store_options = false; pdfusetitle = true; //in contrast with hyperref
} }
} // namespace lyx } // namespace lyx

View File

@ -19,18 +19,6 @@ namespace lyx {
class Lexer; class Lexer;
/// Options for PDF generation /// Options for PDF generation
/*
Possible cleanups, left for next fileformat change:
- bookmarksopenlevel is stored in .lyx as string;
after change to spinbox it would be appropriate
change to int.
- store_options flag can be completely replaced by
function store_options() doing essentialy the same
as empty() now.
*/
class PDFOptions { class PDFOptions {
public: public:
/// ///
@ -43,7 +31,7 @@ public:
void writeLaTeX(odocstringstream &) const; void writeLaTeX(odocstringstream &) const;
/// read tokens from lyx header /// read tokens from lyx header
std::string readToken(Lexer &lex, std::string const & token); std::string readToken(Lexer &lex, std::string const & token);
/// keep implicit hyperref settings /// set implicit settings for hyperref
void clear(); void clear();
/// ///
@ -128,6 +116,15 @@ public:
* dialog -> PDFOptions.pagemode . * dialog -> PDFOptions.pagemode .
*/ */
std::string pagemode; std::string pagemode;
/**
* Flag indicating whether hyperref tries to derive the values for
* pdftitle and pdfauthor from \title and \author.
* pdfusetitle boolean false
*
* Note that we use true as default value instead. The option is also
* used in latex output only when title and author is not filled.
*/
bool pdfusetitle;
///latex string ///latex string
static const std::string pagemode_fullscreen; static const std::string pagemode_fullscreen;
/** /**

View File

@ -653,6 +653,8 @@ GuiDocument::GuiDocument(LyXView & lv)
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(pdfSupportModule->backrefCB, SIGNAL(toggled(bool)), connect(pdfSupportModule->backrefCB, SIGNAL(toggled(bool)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(pdfSupportModule->pdfusetitleCB, SIGNAL(toggled(bool)),
this, SLOT(change_adaptor()));
connect(pdfSupportModule->pagebackrefCB, SIGNAL(toggled(bool)), connect(pdfSupportModule->pagebackrefCB, SIGNAL(toggled(bool)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(pdfSupportModule->fullscreenCB, SIGNAL(toggled(bool)), connect(pdfSupportModule->fullscreenCB, SIGNAL(toggled(bool)),
@ -1248,6 +1250,7 @@ void GuiDocument::apply(BufferParams & params)
pdf.breaklinks = pdfSupportModule->breaklinksCB->isChecked(); pdf.breaklinks = pdfSupportModule->breaklinksCB->isChecked();
pdf.pdfborder = pdfSupportModule->pdfborderCB->isChecked(); pdf.pdfborder = pdfSupportModule->pdfborderCB->isChecked();
pdf.pdfusetitle = pdfSupportModule->pdfusetitleCB->isChecked();
pdf.colorlinks = pdfSupportModule->colorlinksCB->isChecked(); pdf.colorlinks = pdfSupportModule->colorlinksCB->isChecked();
pdf.backref = pdfSupportModule->backrefCB->isChecked(); pdf.backref = pdfSupportModule->backrefCB->isChecked();
pdf.pagebackref = pdfSupportModule->pagebackrefCB->isChecked(); pdf.pagebackref = pdfSupportModule->pagebackrefCB->isChecked();
@ -1256,8 +1259,6 @@ void GuiDocument::apply(BufferParams & params)
else else
pdf.pagemode.clear(); pdf.pagemode.clear();
pdf.quoted_options = fromqstr(pdfSupportModule->optionsLE->text()); pdf.quoted_options = fromqstr(pdfSupportModule->optionsLE->text());
if (pdf.use_hyperref || !pdf.empty())
pdf.store_options = true;
} }
@ -1555,6 +1556,7 @@ void GuiDocument::updateParams(BufferParams const & params)
pdfSupportModule->breaklinksCB->setChecked(pdf.breaklinks); pdfSupportModule->breaklinksCB->setChecked(pdf.breaklinks);
pdfSupportModule->pdfborderCB->setChecked(pdf.pdfborder); pdfSupportModule->pdfborderCB->setChecked(pdf.pdfborder);
pdfSupportModule->pdfusetitleCB->setChecked(pdf.pdfusetitle);
pdfSupportModule->colorlinksCB->setChecked(pdf.colorlinks); pdfSupportModule->colorlinksCB->setChecked(pdf.colorlinks);
pdfSupportModule->backrefCB->setChecked(pdf.backref); pdfSupportModule->backrefCB->setChecked(pdf.backref);
pdfSupportModule->pagebackrefCB->setChecked(pdf.pagebackref); pdfSupportModule->pagebackrefCB->setChecked(pdf.pagebackref);

View File

@ -5,306 +5,290 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>436</width> <width>427</width>
<height>394</height> <height>398</height>
</rect> </rect>
</property> </property>
<widget class="QGroupBox" name="use_hyperrefGB" > <property name="windowTitle" >
<property name="geometry" > <string>Form</string>
<rect> </property>
<x>2</x> <layout class="QGridLayout" >
<y>2</y> <item row="0" column="0" >
<width>423</width> <widget class="QGroupBox" name="use_hyperrefGB" >
<height>381</height> <property name="focusPolicy" >
</rect> <enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip" >
<string>Enable clickable crossreferences and header informations</string>
</property>
<property name="title" >
<string>&amp;Use hyperref support</string>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
<property name="checked" >
<bool>false</bool>
</property>
<widget class="QGroupBox" name="groupBox_4" >
<property name="geometry" >
<rect>
<x>186</x>
<y>170</y>
<width>231</width>
<height>148</height>
</rect>
</property>
<property name="title" >
<string>Links</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property> </property>
<property name="spacing" > <property name="title" >
<number>6</number> <string>&amp;Use hyperref support</string>
</property> </property>
<item row="2" column="0" > <property name="checkable" >
<widget class="QCheckBox" name="colorlinksCB" > <bool>true</bool>
<property name="text" >
<string>Color links</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QCheckBox" name="pdfborderCB" >
<property name="text" >
<string>No frames around links</string>
</property>
<property name="tristate" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QCheckBox" name="breaklinksCB" >
<property name="toolTip" >
<string>Allows link text to break across lines.</string>
</property>
<property name="text" >
<string>Break links over lines</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QCheckBox" name="backrefCB" >
<property name="toolTip" >
<string>Adds "backlink" text to the end of each item in the bibliography</string>
</property>
<property name="text" >
<string>&amp;Bibliographical backreferences</string>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QCheckBox" name="pagebackrefCB" >
<property name="toolTip" >
<string>Adds "backlink" text to the end of each item in the bibliography</string>
</property>
<property name="text" >
<string>Backreference by pa&amp;ge number</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="bookmarksGB" >
<property name="geometry" >
<rect>
<x>6</x>
<y>170</y>
<width>171</width>
<height>112</height>
</rect>
</property>
<property name="title" >
<string>Generate Bookmarks</string>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
<property name="checked" >
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property> </property>
<property name="spacing" > <property name="checked" >
<number>6</number> <bool>false</bool>
</property> </property>
<item row="0" column="0" > <layout class="QGridLayout" >
<widget class="QCheckBox" name="bookmarksnumberedCB" > <item row="0" column="0" colspan="2" >
<property name="text" > <widget class="QGroupBox" name="groupBox_2" >
<string>Numbered bookmarks</string> <property name="title" >
</property> <string>Header Information</string>
</widget> </property>
</item> <layout class="QGridLayout" >
<item row="1" column="0" > <item row="0" column="0" >
<widget class="QGroupBox" name="bookmarksopenGB" > <widget class="QLabel" name="titleL" >
<property name="title" > <property name="text" >
<string>Open bookmarks</string> <string>&amp;Title:</string>
</property> </property>
<property name="checkable" > <property name="buddy" >
<bool>true</bool> <cstring>titleLE</cstring>
</property> </property>
<property name="checked" > </widget>
<bool>false</bool> </item>
</property> <item row="0" column="1" >
<widget class="QLabel" name="label" > <widget class="QLineEdit" name="titleLE" />
<property name="geometry" > </item>
<rect> <item row="1" column="0" >
<x>21</x> <widget class="QLabel" name="authorL" >
<y>22</y> <property name="text" >
<width>31</width> <string>&amp;Author:</string>
<height>16</height> </property>
</rect> <property name="buddy" >
<cstring>authorLE</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="authorLE" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="subjectL" >
<property name="text" >
<string>&amp;Subject:</string>
</property>
<property name="buddy" >
<cstring>subjectLE</cstring>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="subjectLE" />
</item>
<item row="3" column="0" >
<widget class="QLabel" name="keywordsL" >
<property name="text" >
<string>&amp;Keywords:</string>
</property>
<property name="buddy" >
<cstring>keywordsLE</cstring>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="keywordsLE" />
</item>
</layout>
</widget>
</item>
<item row="1" column="0" >
<widget class="QGroupBox" name="bookmarksGB" >
<property name="title" >
<string>Generate Bookmarks</string>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
<property name="checked" >
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QCheckBox" name="bookmarksnumberedCB" >
<property name="text" >
<string>Numbered bookmarks</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QGroupBox" name="bookmarksopenGB" >
<property name="title" >
<string>Open bookmarks</string>
</property>
<property name="flat" >
<bool>true</bool>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
<property name="checked" >
<bool>false</bool>
</property>
<widget class="QLabel" name="label" >
<property name="geometry" >
<rect>
<x>21</x>
<y>22</y>
<width>31</width>
<height>16</height>
</rect>
</property>
<property name="text" >
<string>&amp;Level:</string>
</property>
<property name="buddy" >
<cstring>bookmarksopenlevelSB</cstring>
</property>
</widget>
<widget class="QSpinBox" name="bookmarksopenlevelSB" >
<property name="geometry" >
<rect>
<x>60</x>
<y>20</y>
<width>61</width>
<height>22</height>
</rect>
</property>
<property name="toolTip" >
<string>Number of levels</string>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item rowspan="3" row="1" column="1" >
<widget class="QGroupBox" name="groupBox_4" >
<property name="title" >
<string>Links</string>
</property>
<property name="checkable" >
<bool>false</bool>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QCheckBox" name="breaklinksCB" >
<property name="toolTip" >
<string>Allows link text to break across lines.</string>
</property>
<property name="text" >
<string>Break links over lines</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QCheckBox" name="pdfborderCB" >
<property name="text" >
<string>No frames around links</string>
</property>
<property name="tristate" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QCheckBox" name="colorlinksCB" >
<property name="text" >
<string>Color links</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QCheckBox" name="backrefCB" >
<property name="toolTip" >
<string>Adds "backlink" text to the end of each item in the bibliography</string>
</property>
<property name="text" >
<string>&amp;Bibliographical backreferences</string>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QCheckBox" name="pagebackrefCB" >
<property name="toolTip" >
<string>Adds "backlink" text to the end of each item in the bibliography</string>
</property>
<property name="text" >
<string>Backreference by pa&amp;ge number</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" >
<widget class="QCheckBox" name="pdfusetitleCB" >
<property name="toolTip" >
<string>If not stated explicitly, fill title and author from appropriate environments</string>
</property> </property>
<property name="text" > <property name="text" >
<string>&amp;Level:</string> <string>Automatically fill header</string>
</property>
<property name="buddy" >
<cstring>bookmarksopenlevelSB</cstring>
</property> </property>
</widget> </widget>
<widget class="QSpinBox" name="bookmarksopenlevelSB" > </item>
<property name="geometry" > <item row="3" column="0" >
<rect> <widget class="QCheckBox" name="fullscreenCB" >
<x>60</x>
<y>20</y>
<width>61</width>
<height>22</height>
</rect>
</property>
<property name="toolTip" > <property name="toolTip" >
<string>Number of levels</string> <string>Enable fullscreen PDF presentation</string>
</property>
<property name="text" >
<string>Load in &amp;fullscreen mode</string>
</property> </property>
</widget> </widget>
</widget> </item>
</item> <item row="4" column="0" colspan="2" >
</layout> <widget class="QGroupBox" name="groupBox_3" >
</widget> <property name="title" >
<widget class="QCheckBox" name="fullscreenCB" > <string>Additional o&amp;ptions for hyperref</string>
<property name="geometry" > </property>
<rect> <property name="flat" >
<x>10</x> <bool>false</bool>
<y>300</y> </property>
<width>161</width> <property name="checkable" >
<height>21</height> <bool>false</bool>
</rect> </property>
</property> <property name="checked" >
<property name="toolTip" > <bool>false</bool>
<string>Enable fullscreen PDF presentation</string> </property>
</property> <layout class="QGridLayout" >
<property name="text" > <item row="0" column="0" >
<string>Load in &amp;fullscreen mode</string> <widget class="QLineEdit" name="optionsLE" >
</property> <property name="sizePolicy" >
</widget> <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<widget class="QGroupBox" name="groupBox_2" > <horstretch>0</horstretch>
<property name="geometry" > <verstretch>0</verstretch>
<rect> </sizepolicy>
<x>6</x> </property>
<y>20</y> <property name="toolTip" >
<width>411</width> <string>eg: pdfstartview=XYZ, plainpages=false, pdfpagelabels</string>
<height>141</height> </property>
</rect> </widget>
</property> </item>
<property name="title" > </layout>
<string>Header Information</string> </widget>
</property> </item>
<layout class="QGridLayout" > </layout>
<property name="margin" > </widget>
<number>9</number> </item>
</property> </layout>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="1" >
<widget class="QLineEdit" name="authorLE" />
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="titleLE" />
</item>
<item row="0" column="0" >
<widget class="QLabel" name="titleL" >
<property name="text" >
<string>&amp;Title:</string>
</property>
<property name="buddy" >
<cstring>titleLE</cstring>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="authorL" >
<property name="text" >
<string>&amp;Author:</string>
</property>
<property name="buddy" >
<cstring>authorLE</cstring>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="subjectL" >
<property name="text" >
<string>&amp;Subject:</string>
</property>
<property name="buddy" >
<cstring>subjectLE</cstring>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="keywordsL" >
<property name="text" >
<string>&amp;Keywords:</string>
</property>
<property name="buddy" >
<cstring>keywordsLE</cstring>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="keywordsLE" />
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="subjectLE" />
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox_3" >
<property name="geometry" >
<rect>
<x>6</x>
<y>330</y>
<width>411</width>
<height>54</height>
</rect>
</property>
<property name="title" >
<string>Additional o&amp;ptions for hyperref</string>
</property>
<property name="flat" >
<bool>true</bool>
</property>
<property name="checkable" >
<bool>false</bool>
</property>
<property name="checked" >
<bool>false</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QLineEdit" name="optionsLE" >
<property name="toolTip" >
<string>eg: pdfstartview=XYZ, plainpages=false, pdfpagelabels</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget> </widget>
<includes>
<include location="local" >qt_helpers.h</include>
</includes>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>