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
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
underset.png
uparrow.png
uparrow2.png
+ update-others.png
updownarrow.png
updownarrow2.png
upharpoonleft.png
veebar.png
vert.png
vert2.png
+ view-others.png
vphantom.png
wedge.png
widehat.png
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 \
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 \
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 \
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 \
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"
Documents
End
+ Menu "view_others"
+ ViewFormats
+ End
+
Menu "view_update"
UpdateFormats
End
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
}
+string Buffer::getDefaultOutputFormat() const
+{
+ typedef vector<Format const *> 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
{
/// 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,
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<Format const *> Formats;
Formats formats;
formats = buf->exportableFormats(true);
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;
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, /**/);
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:
{ "\\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 },
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";
}
break;
}
+ case RC_DEFAULT_VIEW_FORMAT:
+ lexrc >> default_view_format;
+ break;
+
case RC_DEFAULT_LANGUAGE:
lexrc >> default_language;
break;
<< "\" \"\" \"\" \"\" \"\" \"\" \"\"\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)
<< "\" \"" << cit->to << "\" \"\" \"\"\n";
if (tag != RC_LAST)
break;
-
+
case RC_COPIER:
if (tag == RC_LAST)
os << "\n#\n"
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;
RC_DATE_INSERT_FORMAT,
RC_DEFFILE,
RC_DEFAULT_LANGUAGE,
+ RC_DEFAULT_VIEW_FORMAT,
RC_GUI_LANGUAGE,
RC_DEFAULT_PAPERSIZE,
RC_DIALOGS_ICONIFY_WITH_MAIN,
///
std::string gui_language;
///
+ std::string default_view_format;
+ ///
bool mac_like_word_movement;
///
bool cursor_follows_scrollbar;
this, SLOT(updatePrettyname()));
connect(formatsCB->lineEdit(), SIGNAL(textEdited(QString)),
this, SIGNAL(changed()));
+ connect(defaultFormatCB, SIGNAL(activated(QString)),
+ this, SIGNAL(changed()));
}
}; // 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);
}
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;
<rect>
<x>0</x>
<y>0</y>
- <width>414</width>
- <height>322</height>
+ <width>427</width>
+ <height>413</height>
</rect>
</property>
<property name="windowTitle" >
<property name="spacing" >
<number>6</number>
</property>
+ <item row="10" column="0" colspan="4" >
+ <widget class="QGroupBox" name="defaultFormatGB" >
+ <property name="toolTip" >
+ <string>Specify the default output format when using (PDF)LaTeX</string>
+ </property>
+ <property name="title" >
+ <string>Default Format</string>
+ </property>
+ <property name="flat" >
+ <bool>true</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="QLabel" name="defaultFormatLA" >
+ <property name="text" >
+ <string>De&fault Output Format:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>defaultFormatCB</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QComboBox" name="defaultFormatCB" />
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="9" column="1" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>124</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
<item row="8" column="1" colspan="3" >
<widget class="QLineEdit" name="copierED" />
</item>
<item row="4" column="1" >
<widget class="QLineEdit" name="extensionED" />
</item>
- <item row="9" column="1" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>168</width>
- <height>21</height>
- </size>
- </property>
- </spacer>
- </item>
<item row="8" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >