From 242f543e01a5ddc0de3f0d041e412311463c8baa Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sat, 9 Sep 2017 08:53:08 +0200 Subject: [PATCH] Add default output format for pLaTeX Fixes: #10747 --- lib/RELEASE-NOTES | 8 ++ lib/scripts/prefs2prefs_prefs.py | 20 ++++- src/BufferParams.cpp | 5 +- src/LyXRC.cpp | 18 ++++- src/LyXRC.h | 3 + src/frontends/qt4/GuiPrefs.cpp | 25 +++++- src/frontends/qt4/ui/PrefFileformatsUi.ui | 92 +++++++++++++++-------- 7 files changed, 133 insertions(+), 38 deletions(-) diff --git a/lib/RELEASE-NOTES b/lib/RELEASE-NOTES index f5d91f5ae4..126f7c541e 100644 --- a/lib/RELEASE-NOTES +++ b/lib/RELEASE-NOTES @@ -70,6 +70,10 @@ * \pygmentize_command holds the name of the driver command used by the Pygments python module. +* \default_platex_view_format + Determine the default output format for Japanese documents that use the + pLaTeX backend [default: "pdf3" == "PDF (dvipdfm)"] + !!!The following pref variables were changed in 2.3: @@ -79,6 +83,10 @@ !!!The following new LyX functions have been introduced in 2.3: +* buffer-zoom + Zooms the screen fonts to a given value or resets to the default zoom + when no argument is given. + * branch-invert Toggles inversion status of branch inset. diff --git a/lib/scripts/prefs2prefs_prefs.py b/lib/scripts/prefs2prefs_prefs.py index 68b4d837dc..77f3fd8106 100644 --- a/lib/scripts/prefs2prefs_prefs.py +++ b/lib/scripts/prefs2prefs_prefs.py @@ -94,6 +94,11 @@ # Add pygmentize_command for the python pygments syntax highlighter # No conversion necessary. +# Incremented to format 23, by spitz +# Add default_platex_view_format, a default output format for +# Japanese documents via pLaTeX. +# No conversion necessary. + # NOTE: The format should also be updated in LYXRC.cpp and # in configure.py. @@ -364,6 +369,18 @@ def remove_print_support(line): # End conversions for LyX 2.1 to 2.2 #################################### +################################# +# Conversions from LyX 2.2 to 2.3 + +# Only format changes that don't require conversion + +# End conversions for LyX 2.2 to 2.3 +#################################### + + +############################################################ +# Format-conversion map. Also add empty format changes here. + conversions = [ [ 1, [ # there were several conversions for format 1 export_menu, @@ -392,5 +409,6 @@ conversions = [ [ 19, [remove_print_support]], [ 20, []], [ 21, []], - [ 22, []] + [ 22, []], + [ 23, []] ] diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 5e8f6126dd..060d9e411c 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -2695,14 +2695,15 @@ string BufferParams::getDefaultOutputFormat() const if (!default_output_format.empty() && default_output_format != "default") return default_output_format; - if (isDocBook() - || encoding().package() == Encoding::japanese) { + if (isDocBook()) { FormatList const & formats = exportableFormats(true); if (formats.empty()) return string(); // return the first we find return formats.front()->name(); } + if (encoding().package() == Encoding::japanese) + return lyxrc.default_platex_view_format; if (useNonTeXFonts) return lyxrc.default_otf_view_format; return lyxrc.default_view_format; diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 431f4a40d6..e98eae5cf0 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -59,7 +59,7 @@ namespace { // The format should also be updated in configure.py, and conversion code // should be added to prefs2prefs_prefs.py. -static unsigned int const LYXRC_FILEFORMAT = 22; // ef: pygmentize_command +static unsigned int const LYXRC_FILEFORMAT = 23; // spitz: default_platex_view_format // when adding something to this array keep it sorted! LexerKeyword lyxrcTags[] = { @@ -98,6 +98,7 @@ LexerKeyword lyxrcTags[] = { { "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT }, { "\\default_length_unit", LyXRC::RC_DEFAULT_LENGTH_UNIT }, { "\\default_otf_view_format", LyXRC::RC_DEFAULT_OTF_VIEW_FORMAT }, + { "\\default_platex_view_format", LyXRC::RC_DEFAULT_PLATEX_VIEW_FORMAT }, { "\\default_view_format", LyXRC::RC_DEFAULT_VIEW_FORMAT }, { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN }, { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS }, @@ -237,6 +238,7 @@ void LyXRC::setDefaults() view_dvi_paper_option.erase(); default_view_format = "pdf2"; default_otf_view_format = "pdf4"; + default_platex_view_format = "pdf3"; chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38"; bibtex_command = "automatic"; fontenc = "default"; @@ -1082,6 +1084,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) lexrc >> default_otf_view_format; break; + case RC_DEFAULT_PLATEX_VIEW_FORMAT: + lexrc >> default_platex_view_format; + break; + case RC_DEFAULT_VIEW_FORMAT: lexrc >> default_view_format; break; @@ -2786,6 +2792,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c if (tag != RC_LAST) break; // fall through + case RC_DEFAULT_PLATEX_VIEW_FORMAT: + if ((ignore_system_lyxrc || + default_platex_view_format != system_lyxrc.default_platex_view_format) + && !default_platex_view_format.empty()) { + os << "\\default_platex_view_format " << default_platex_view_format << '\n'; + } + if (tag != RC_LAST) + break; + // fall through case RC_DEFAULT_VIEW_FORMAT: if (ignore_system_lyxrc || default_view_format != system_lyxrc.default_view_format) { @@ -2912,6 +2927,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_DATE_INSERT_FORMAT: case LyXRC::RC_GUI_LANGUAGE: case LyXRC::RC_DEFAULT_OTF_VIEW_FORMAT: + case LyXRC::RC_DEFAULT_PLATEX_VIEW_FORMAT: case LyXRC::RC_DEFAULT_VIEW_FORMAT: case LyXRC::RC_DEFFILE: case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN: diff --git a/src/LyXRC.h b/src/LyXRC.h index 8ac70c1bca..f2b0ab73e6 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -70,6 +70,7 @@ public: RC_DEFAULT_DECIMAL_POINT, RC_DEFAULT_LENGTH_UNIT, RC_DEFAULT_OTF_VIEW_FORMAT, + RC_DEFAULT_PLATEX_VIEW_FORMAT, RC_DEFAULT_VIEW_FORMAT, RC_DEFFILE, RC_DIALOGS_ICONIFY_WITH_MAIN, @@ -392,6 +393,8 @@ public: /// std::string default_otf_view_format; /// + std::string default_platex_view_format; + /// std::string default_view_format; /// all available viewers Alternatives viewer_alternatives; diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 212d19f601..7f55a4d435 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -2033,6 +2033,8 @@ PrefFileformats::PrefFileformats(GuiPreferences * form) this, SIGNAL(changed())); connect(defaultOTFFormatCB, SIGNAL(activated(QString)), this, SIGNAL(changed())); + connect(defaultPlatexFormatCB, SIGNAL(activated(QString)), + this, SIGNAL(changed())); connect(viewerCO, SIGNAL(activated(int)), this, SIGNAL(changed())); connect(editorCO, SIGNAL(activated(int)), @@ -2063,6 +2065,9 @@ void PrefFileformats::applyRC(LyXRC & rc) const QString const default_otf_format = defaultOTFFormatCB->itemData( defaultOTFFormatCB->currentIndex()).toString(); rc.default_otf_view_format = fromqstr(default_otf_format); + QString const default_platex_format = defaultPlatexFormatCB->itemData( + defaultPlatexFormatCB->currentIndex()).toString(); + rc.default_platex_view_format = fromqstr(default_platex_format); } @@ -2079,6 +2084,9 @@ void PrefFileformats::updateRC(LyXRC const & rc) pos = defaultOTFFormatCB->findData(toqstr(rc.default_otf_view_format)); defaultOTFFormatCB->setCurrentIndex(pos); defaultOTFFormatCB->setCurrentIndex(pos); + pos = defaultPlatexFormatCB->findData(toqstr(rc.default_platex_view_format)); + defaultPlatexFormatCB->setCurrentIndex(pos); + defaultPlatexFormatCB->setCurrentIndex(pos); } } @@ -2088,14 +2096,17 @@ void PrefFileformats::updateView() QString const current = formatsCB->currentText(); QString const current_def = defaultFormatCB->currentText(); QString const current_def_otf = defaultOTFFormatCB->currentText(); + QString const current_def_platex = defaultPlatexFormatCB->currentText(); // update comboboxes with formats formatsCB->blockSignals(true); defaultFormatCB->blockSignals(true); defaultOTFFormatCB->blockSignals(true); + defaultPlatexFormatCB->blockSignals(true); formatsCB->clear(); defaultFormatCB->clear(); defaultOTFFormatCB->clear(); + defaultPlatexFormatCB->clear(); form_->formats().sort(); for (Format const & f : form_->formats()) { QString const prettyname = toqstr(translateIfPossible(f.prettyname())); @@ -2111,10 +2122,15 @@ void PrefFileformats::updateView() QVariant(toqstr(f.name()))); defaultOTFFormatCB->addItem(prettyname, QVariant(toqstr(f.name()))); - } else if (form_->converters().isReachable("latex", f.name()) - || form_->converters().isReachable("pdflatex", f.name())) - defaultFormatCB->addItem(prettyname, + } else { + if (form_->converters().isReachable("latex", f.name()) + || form_->converters().isReachable("pdflatex", f.name())) + defaultFormatCB->addItem(prettyname, QVariant(toqstr(f.name()))); + if (form_->converters().isReachable("platex", f.name())) + defaultPlatexFormatCB->addItem(prettyname, + QVariant(toqstr(f.name()))); + } } // restore selections @@ -2125,9 +2141,12 @@ void PrefFileformats::updateView() defaultFormatCB->setCurrentIndex(item < 0 ? 0 : item); item = defaultOTFFormatCB->findText(current_def_otf, Qt::MatchExactly); defaultOTFFormatCB->setCurrentIndex(item < 0 ? 0 : item); + item = defaultPlatexFormatCB->findText(current_def_platex, Qt::MatchExactly); + defaultPlatexFormatCB->setCurrentIndex(item < 0 ? 0 : item); formatsCB->blockSignals(false); defaultFormatCB->blockSignals(false); defaultOTFFormatCB->blockSignals(false); + defaultPlatexFormatCB->blockSignals(false); } diff --git a/src/frontends/qt4/ui/PrefFileformatsUi.ui b/src/frontends/qt4/ui/PrefFileformatsUi.ui index faa24e42a3..942c31af70 100644 --- a/src/frontends/qt4/ui/PrefFileformatsUi.ui +++ b/src/frontends/qt4/ui/PrefFileformatsUi.ui @@ -6,8 +6,8 @@ 0 0 - 386 - 417 + 496 + 584 @@ -199,7 +199,7 @@ - Specify the default output format when using (PDF)LaTeX + Specification of the default output formats when using specific LaTeX variants Default Output Formats @@ -208,23 +208,6 @@ true - - - - With &TeX fonts: - - - defaultFormatCB - - - - - - - The default output format for documents (except with non-TeX fonts) - - - @@ -238,25 +221,28 @@ - - - - With n&on-TeX fonts: + + + + Qt::Horizontal - - defaultFormatCB + + + 148 + 20 + - + - + The default output format for documents using non-TeX fonts - - + + Qt::Horizontal @@ -268,10 +254,54 @@ + + + + This is the default output format for LyX documents, except for DocBook classes, documents that use non-TeX fonts and Japanese documents + + + + + + + The default output format for Japanese documents (using pLaTeX) + + + + + + + With n&on-TeX fonts: + + + defaultFormatCB + + + + + + + With &TeX fonts: + + + defaultFormatCB + + + + + + + &Japanese: + + + defaultPlatexFormatCB + + + - + Qt::Vertical -- 2.39.2