From: Jürgen Spitzmüller Date: Tue, 7 Apr 2009 05:01:08 +0000 (+0000) Subject: * First step towards default view format. X-Git-Tag: 2.0.0~6913 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=25a14730ed7710bc057dde5900bb99170b0d48d9;p=features.git * First step towards default view format. The icons could be replaced by something nicer. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29134 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index 7df6aa9628..77e29aba92 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -1358,9 +1358,11 @@ lib_images_files = Split(''' buffer-export_text.png buffer-new.png buffer-reload.png + buffer-update.png buffer-update_dvi.png buffer-update_pdf2.png buffer-update_ps.png + buffer-view.png buffer-view_dvi.png buffer-view_pdf2.png buffer-view_ps.png @@ -1425,6 +1427,8 @@ lib_images_files = Split(''' vc-register.png vc-revert.png marginalnote-insert.png + master-buffer-update.png + master-buffer-view.png math-display.png math-macro-add-greedy-optional-param.png math-macro-add-optional-param.png @@ -1951,6 +1955,7 @@ lib_images_math_files = Split(''' underset.png uparrow.png uparrow2.png + update-others.png updownarrow.png updownarrow2.png upharpoonleft.png @@ -1985,6 +1990,7 @@ lib_images_math_files = Split(''' veebar.png vert.png vert2.png + view-others.png vphantom.png wedge.png widehat.png diff --git a/lib/Makefile.am b/lib/Makefile.am index 4e85b0fd90..afa3f0f9e5 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -282,9 +282,11 @@ dist_images_DATA = \ images/buffer-export_text.png \ images/buffer-new.png \ images/buffer-reload.png \ + images/buffer-update.png \ images/buffer-update_dvi.png \ images/buffer-update_pdf2.png \ images/buffer-update_ps.png \ + images/buffer-view.png \ images/buffer-view_dvi.png \ images/buffer-view_pdf2.png \ images/buffer-view_ps.png \ @@ -349,6 +351,8 @@ dist_images_DATA = \ images/vc-register.png \ images/vc-revert.png \ images/marginalnote-insert.png \ + images/master-buffer-update.png \ + images/master-buffer-view.png \ images/math-display.png \ images/math-macro-add-greedy-optional-param.png \ images/math-macro-add-optional-param.png \ @@ -868,6 +872,7 @@ dist_imagesmath_DATA = \ images/math/underset.png \ images/math/uparrow.png \ images/math/uparrow2.png \ + images/math/update-others.png \ images/math/updownarrow.png \ images/math/updownarrow2.png \ images/math/upharpoonleft.png \ @@ -902,6 +907,7 @@ dist_imagesmath_DATA = \ images/math/veebar.png \ images/math/vert.png \ images/math/vert2.png \ + images/math/view-others.png \ images/math/vphantom.png \ images/math/wedge.png \ images/math/widehat.png \ diff --git a/lib/images/buffer-update.png b/lib/images/buffer-update.png new file mode 100644 index 0000000000..3f74d0e947 Binary files /dev/null and b/lib/images/buffer-update.png differ diff --git a/lib/images/buffer-view.png b/lib/images/buffer-view.png new file mode 100644 index 0000000000..d3ac51a32e Binary files /dev/null and b/lib/images/buffer-view.png differ diff --git a/lib/images/master-buffer-update.png b/lib/images/master-buffer-update.png new file mode 100644 index 0000000000..8a2c2ef4ea Binary files /dev/null and b/lib/images/master-buffer-update.png differ diff --git a/lib/images/master-buffer-view.png b/lib/images/master-buffer-view.png new file mode 100644 index 0000000000..b074bd7ce0 Binary files /dev/null and b/lib/images/master-buffer-view.png differ diff --git a/lib/images/math/update-others.png b/lib/images/math/update-others.png new file mode 100644 index 0000000000..d2d3155dd0 Binary files /dev/null and b/lib/images/math/update-others.png differ diff --git a/lib/images/math/view-others.png b/lib/images/math/view-others.png new file mode 100644 index 0000000000..f93c47cb0e Binary files /dev/null and b/lib/images/math/view-others.png differ diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc index 12638f885f..3188b6fd92 100644 --- a/lib/ui/stdmenus.inc +++ b/lib/ui/stdmenus.inc @@ -297,11 +297,15 @@ Menuset Item "Fold Math Macro" "math-macro-fold" Separator Item "View Source|S" "dialog-toggle view-source" - Submenu "Update|U" "view_update" - ViewFormats + Item "View|V" "buffer-view" + Item "Update|U" "buffer-update" + OptItem "View Master Document|M" "master-buffer-view" + OptItem "Update Master Document|a" "master-buffer-update" + Submenu "View (other formats)|f" "view_others" + Submenu "Update (other formats)|p" "view_update" Separator Item "Split View Into Left And Right Half|i" "split-view horizontal" - Item "Split View Into Upper And Lower Half|V" "split-view vertical" + Item "Split View Into Upper And Lower Half|e" "split-view vertical" Item "Close Tab Group|G" "close-tab-group" Item "Fullscreen|l" "ui-toggle fullscreen" Submenu "Toolbars|b" "toolbars" @@ -309,6 +313,10 @@ Menuset Documents End + Menu "view_others" + ViewFormats + End + Menu "view_update" UpdateFormats End diff --git a/lib/ui/stdtoolbars.inc b/lib/ui/stdtoolbars.inc index 77b5df270d..8432b30e22 100644 --- a/lib/ui/stdtoolbars.inc +++ b/lib/ui/stdtoolbars.inc @@ -203,11 +203,24 @@ ToolbarSet End Toolbar "view/update" "View/Update" + Item "View" "buffer-view" + Item "Update" "buffer-update" + Item "View Master Document" "master-buffer-view" + Item "Update Master Document" "master-buffer-update" + Separator + PopupMenu "view-others" "View Other Formats" + PopupMenu "update-others" "Update Other Formats" + End + + Toolbar "view-others" "View Other Formats" Item "View DVI" "buffer-view dvi" - Item "Update DVI" "buffer-update dvi" - Item "View PDF (pdflatex)" "command-alternatives buffer-view pdf2;buffer-view pdf4" - Item "Update PDF (pdflatex)" "command-alternatives buffer-update pdf2;buffer-view pdf4" + Item "View PDF (pdflatex)" "buffer-view pdf2" Item "View PostScript" "buffer-view ps" + End + + Toolbar "update-others" "Update Other Formats" + Item "Update DVI" "buffer-update dvi" + Item "Update PDF (pdflatex)" "buffer-update pdf2" Item "Update PostScript" "buffer-update ps" End diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 43d5c236b2..3b5a45bc02 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -2652,6 +2652,21 @@ string Buffer::bufferFormat() const } +string Buffer::getDefaultOutputFormat() const +{ + typedef vector Formats; + Formats formats = exportableFormats(true); + if (isDocBook() + || isLiterate() + || params().useXetex + || params().encoding().package() == Encoding::japanese) + // return the first we find + return formats.front()->name(); + return lyxrc.default_view_format; +} + + + bool Buffer::doExport(string const & format, bool put_in_tempdir, string & result_file) const { diff --git a/src/Buffer.h b/src/Buffer.h index 43d82b6477..dd1a2b4c84 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -471,6 +471,8 @@ public: /// return the format of the buffer on a string std::string bufferFormat() const; + /// return the default output format of the current backend + std::string getDefaultOutputFormat() const; /// bool doExport(std::string const & format, bool put_in_tempdir, diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index d8f5e9cf4c..93a83139f1 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -583,10 +583,17 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const break; } - case LFUN_BUFFER_UPDATE: - case LFUN_BUFFER_VIEW: case LFUN_MASTER_BUFFER_UPDATE: - case LFUN_MASTER_BUFFER_VIEW: { + case LFUN_MASTER_BUFFER_VIEW: + if (!buf->parent()) { + enable = false; + break; + } + case LFUN_BUFFER_UPDATE: + case LFUN_BUFFER_VIEW: { + string format = to_utf8(cmd.argument()); + if (cmd.argument().empty()) + format = buf->getDefaultOutputFormat(); typedef vector Formats; Formats formats; formats = buf->exportableFormats(true); @@ -594,7 +601,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const Formats::const_iterator end = formats.end(); enable = false; for (; fit != end ; ++fit) { - if ((*fit)->name() == to_utf8(cmd.argument())) + if ((*fit)->name() == format) enable = true; } break; @@ -867,25 +874,41 @@ void LyXFunc::dispatch(FuncRequest const & cmd) break; } - case LFUN_BUFFER_UPDATE: + case LFUN_BUFFER_UPDATE: { LASSERT(lyx_view_ && buffer, /**/); - buffer->doExport(argument, true); + string format = argument; + if (argument.empty()) + format = buffer->getDefaultOutputFormat(); + buffer->doExport(format, true); break; + } - case LFUN_BUFFER_VIEW: + case LFUN_BUFFER_VIEW: { LASSERT(lyx_view_ && buffer, /**/); - buffer->preview(argument); + string format = argument; + if (argument.empty()) + format = buffer->getDefaultOutputFormat(); + buffer->preview(format); break; + } - case LFUN_MASTER_BUFFER_UPDATE: + case LFUN_MASTER_BUFFER_UPDATE: { LASSERT(lyx_view_ && buffer && buffer->masterBuffer(), /**/); - buffer->masterBuffer()->doExport(argument, true); + string format = argument; + if (argument.empty()) + format = buffer->masterBuffer()->getDefaultOutputFormat(); + buffer->masterBuffer()->doExport(format, true); break; + } - case LFUN_MASTER_BUFFER_VIEW: + case LFUN_MASTER_BUFFER_VIEW: { LASSERT(lyx_view_ && buffer && buffer->masterBuffer(), /**/); - buffer->masterBuffer()->preview(argument); + string format = argument; + if (argument.empty()) + format = buffer->masterBuffer()->getDefaultOutputFormat(); + buffer->masterBuffer()->preview(format); break; + } case LFUN_BUILD_PROGRAM: LASSERT(lyx_view_ && buffer, /**/); @@ -1874,6 +1897,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_DEFAULT_LANGUAGE: case LyXRC::RC_GUI_LANGUAGE: case LyXRC::RC_DEFAULT_PAPERSIZE: + case LyXRC::RC_DEFAULT_VIEW_FORMAT: case LyXRC::RC_DEFFILE: case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN: case LyXRC::RC_DISPLAY_GRAPHICS: diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 3e14a07898..8397f70cbb 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -84,6 +84,7 @@ LexerKeyword lyxrcTags[] = { { "\\def_file", LyXRC::RC_DEFFILE }, { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE }, { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE }, + { "\\default_view_format", LyXRC::RC_DEFAULT_VIEW_FORMAT }, { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN }, { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS }, { "\\document_path", LyXRC::RC_DOCUMENTPATH }, @@ -227,6 +228,7 @@ void LyXRC::setDefaults() view_dvi_paper_option.erase(); default_papersize = PAPER_DEFAULT; custom_export_format = "ps"; + default_view_format = "pdf2"; chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38"; bibtex_command = "bibtex"; fontenc = "default"; @@ -1017,6 +1019,10 @@ int LyXRC::read(Lexer & lexrc) } break; } + case RC_DEFAULT_VIEW_FORMAT: + lexrc >> default_view_format; + break; + case RC_DEFAULT_LANGUAGE: lexrc >> default_language; break; @@ -2389,6 +2395,13 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n"; if (tag != RC_LAST) break; + case RC_DEFAULT_VIEW_FORMAT: + if (ignore_system_lyxrc || + default_view_format != system_lyxrc.default_view_format) { + os << "\\default_view_format " << default_view_format << '\n'; + } + if (tag != RC_LAST) + break; case RC_VIEWER: // Ignore it if (tag != RC_LAST) @@ -2422,7 +2435,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c << "\" \"" << cit->to << "\" \"\" \"\"\n"; if (tag != RC_LAST) break; - + case RC_COPIER: if (tag == RC_LAST) os << "\n#\n" @@ -2554,6 +2567,10 @@ string const LyXRC::getDescription(LyXRCTags tag) str = _("Command definition file. Can either specify an absolute path, or LyX will look in its global and local commands/ directories."); break; + case RC_DEFAULT_VIEW_FORMAT: + str = _("The default format used with LFUN_BUFFER_[VIEW|UPDATE]."); + break; + case RC_DEFAULT_LANGUAGE: str = _("New documents will be assigned this language."); break; diff --git a/src/LyXRC.h b/src/LyXRC.h index dd84720d1a..329c79201c 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -69,6 +69,7 @@ public: RC_DATE_INSERT_FORMAT, RC_DEFFILE, RC_DEFAULT_LANGUAGE, + RC_DEFAULT_VIEW_FORMAT, RC_GUI_LANGUAGE, RC_DEFAULT_PAPERSIZE, RC_DIALOGS_ICONIFY_WITH_MAIN, @@ -371,6 +372,8 @@ public: /// std::string gui_language; /// + std::string default_view_format; + /// bool mac_like_word_movement; /// bool cursor_follows_scrollbar; diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 809d3496b5..567df6a7ae 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -1474,6 +1474,8 @@ PrefFileformats::PrefFileformats(GuiPreferences * form) this, SLOT(updatePrettyname())); connect(formatsCB->lineEdit(), SIGNAL(textEdited(QString)), this, SIGNAL(changed())); + connect(defaultFormatCB, SIGNAL(activated(QString)), + this, SIGNAL(changed())); } @@ -1492,36 +1494,55 @@ string const l10n_shortcut(string const prettyname, string const shortcut) }; // namespace anon -void PrefFileformats::apply(LyXRC & /*rc*/) const +void PrefFileformats::apply(LyXRC & rc) const { + QString const default_format = defaultFormatCB->itemData( + defaultFormatCB->currentIndex()).toString(); + rc.default_view_format = fromqstr(default_format); } -void PrefFileformats::update(LyXRC const & /*rc*/) +void PrefFileformats::update(LyXRC const & rc) { + bool const init = defaultFormatCB->currentText().isEmpty(); updateView(); + if (init) { + int const pos = defaultFormatCB->findData(toqstr( + rc.default_view_format)); + defaultFormatCB->setCurrentIndex(pos); + } } void PrefFileformats::updateView() { QString const current = formatsCB->currentText(); + QString const current_def = defaultFormatCB->currentText(); // update combobox with formats formatsCB->blockSignals(true); + defaultFormatCB->blockSignals(true); formatsCB->clear(); form_->formats().sort(); Formats::const_iterator cit = form_->formats().begin(); Formats::const_iterator end = form_->formats().end(); - for (; cit != end; ++cit) + for (; cit != end; ++cit) { formatsCB->addItem(qt_(cit->prettyname()), - QVariant(form_->formats().getNumber(cit->name()))); + QVariant(form_->formats().getNumber(cit->name()))); + if (form_->converters().isReachable("latex", cit->name()) + || form_->converters().isReachable("pdflatex", cit->name())) + defaultFormatCB->addItem(qt_(cit->prettyname()), + QVariant(toqstr(cit->name()))); + } // restore selection - int const item = formatsCB->findText(current, Qt::MatchExactly); + int item = formatsCB->findText(current, Qt::MatchExactly); formatsCB->setCurrentIndex(item < 0 ? 0 : item); on_formatsCB_currentIndexChanged(item < 0 ? 0 : item); + item = defaultFormatCB->findText(current_def, Qt::MatchExactly); + defaultFormatCB->setCurrentIndex(item < 0 ? 0 : item); formatsCB->blockSignals(false); + defaultFormatCB->blockSignals(false); } diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index d323c7b313..5c02c392d5 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -791,8 +791,10 @@ void MenuDefinition::expandFormats(MenuItem::Kind kind, Buffer const * buf) label += "..."; break; case MenuItem::ViewFormats: - case MenuItem::ExportFormats: case MenuItem::UpdateFormats: + if ((*fit)->name() == buf->getDefaultOutputFormat()) + continue; + case MenuItem::ExportFormats: if (!(*fit)->documentFormat()) continue; break; diff --git a/src/frontends/qt4/ui/PrefFileformatsUi.ui b/src/frontends/qt4/ui/PrefFileformatsUi.ui index 695c55daa9..2f8141dd4b 100644 --- a/src/frontends/qt4/ui/PrefFileformatsUi.ui +++ b/src/frontends/qt4/ui/PrefFileformatsUi.ui @@ -5,8 +5,8 @@ 0 0 - 414 - 322 + 427 + 413 @@ -19,6 +19,53 @@ 6 + + + + Specify the default output format when using (PDF)LaTeX + + + Default Format + + + true + + + + 9 + + + 6 + + + + + De&fault Output Format: + + + defaultFormatCB + + + + + + + + + + + + + Qt::Vertical + + + + 124 + 21 + + + + @@ -149,19 +196,6 @@ - - - - Qt::Vertical - - - - 168 - 21 - - - -