* 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
This commit is contained in:
Jürgen Spitzmüller 2009-04-07 05:01:08 +00:00
parent 23f9e34a08
commit 25a14730ed
18 changed files with 191 additions and 40 deletions

View File

@ -1358,9 +1358,11 @@ lib_images_files = Split('''
buffer-export_text.png buffer-export_text.png
buffer-new.png buffer-new.png
buffer-reload.png buffer-reload.png
buffer-update.png
buffer-update_dvi.png buffer-update_dvi.png
buffer-update_pdf2.png buffer-update_pdf2.png
buffer-update_ps.png buffer-update_ps.png
buffer-view.png
buffer-view_dvi.png buffer-view_dvi.png
buffer-view_pdf2.png buffer-view_pdf2.png
buffer-view_ps.png buffer-view_ps.png
@ -1425,6 +1427,8 @@ lib_images_files = Split('''
vc-register.png vc-register.png
vc-revert.png vc-revert.png
marginalnote-insert.png marginalnote-insert.png
master-buffer-update.png
master-buffer-view.png
math-display.png math-display.png
math-macro-add-greedy-optional-param.png math-macro-add-greedy-optional-param.png
math-macro-add-optional-param.png math-macro-add-optional-param.png
@ -1951,6 +1955,7 @@ lib_images_math_files = Split('''
underset.png underset.png
uparrow.png uparrow.png
uparrow2.png uparrow2.png
update-others.png
updownarrow.png updownarrow.png
updownarrow2.png updownarrow2.png
upharpoonleft.png upharpoonleft.png
@ -1985,6 +1990,7 @@ lib_images_math_files = Split('''
veebar.png veebar.png
vert.png vert.png
vert2.png vert2.png
view-others.png
vphantom.png vphantom.png
wedge.png wedge.png
widehat.png widehat.png

View File

@ -282,9 +282,11 @@ dist_images_DATA = \
images/buffer-export_text.png \ images/buffer-export_text.png \
images/buffer-new.png \ images/buffer-new.png \
images/buffer-reload.png \ images/buffer-reload.png \
images/buffer-update.png \
images/buffer-update_dvi.png \ images/buffer-update_dvi.png \
images/buffer-update_pdf2.png \ images/buffer-update_pdf2.png \
images/buffer-update_ps.png \ images/buffer-update_ps.png \
images/buffer-view.png \
images/buffer-view_dvi.png \ images/buffer-view_dvi.png \
images/buffer-view_pdf2.png \ images/buffer-view_pdf2.png \
images/buffer-view_ps.png \ images/buffer-view_ps.png \
@ -349,6 +351,8 @@ dist_images_DATA = \
images/vc-register.png \ images/vc-register.png \
images/vc-revert.png \ images/vc-revert.png \
images/marginalnote-insert.png \ images/marginalnote-insert.png \
images/master-buffer-update.png \
images/master-buffer-view.png \
images/math-display.png \ images/math-display.png \
images/math-macro-add-greedy-optional-param.png \ images/math-macro-add-greedy-optional-param.png \
images/math-macro-add-optional-param.png \ images/math-macro-add-optional-param.png \
@ -868,6 +872,7 @@ dist_imagesmath_DATA = \
images/math/underset.png \ images/math/underset.png \
images/math/uparrow.png \ images/math/uparrow.png \
images/math/uparrow2.png \ images/math/uparrow2.png \
images/math/update-others.png \
images/math/updownarrow.png \ images/math/updownarrow.png \
images/math/updownarrow2.png \ images/math/updownarrow2.png \
images/math/upharpoonleft.png \ images/math/upharpoonleft.png \
@ -902,6 +907,7 @@ dist_imagesmath_DATA = \
images/math/veebar.png \ images/math/veebar.png \
images/math/vert.png \ images/math/vert.png \
images/math/vert2.png \ images/math/vert2.png \
images/math/view-others.png \
images/math/vphantom.png \ images/math/vphantom.png \
images/math/wedge.png \ images/math/wedge.png \
images/math/widehat.png \ images/math/widehat.png \

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
lib/images/buffer-view.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -297,11 +297,15 @@ Menuset
Item "Fold Math Macro" "math-macro-fold" Item "Fold Math Macro" "math-macro-fold"
Separator Separator
Item "View Source|S" "dialog-toggle view-source" Item "View Source|S" "dialog-toggle view-source"
Submenu "Update|U" "view_update" Item "View|V" "buffer-view"
ViewFormats 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 Separator
Item "Split View Into Left And Right Half|i" "split-view horizontal" 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 "Close Tab Group|G" "close-tab-group"
Item "Fullscreen|l" "ui-toggle fullscreen" Item "Fullscreen|l" "ui-toggle fullscreen"
Submenu "Toolbars|b" "toolbars" Submenu "Toolbars|b" "toolbars"
@ -309,6 +313,10 @@ Menuset
Documents Documents
End End
Menu "view_others"
ViewFormats
End
Menu "view_update" Menu "view_update"
UpdateFormats UpdateFormats
End End

View File

@ -203,11 +203,24 @@ ToolbarSet
End End
Toolbar "view/update" "View/Update" 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 "View DVI" "buffer-view dvi"
Item "Update DVI" "buffer-update dvi" Item "View PDF (pdflatex)" "buffer-view pdf2"
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 PostScript" "buffer-view ps" 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" Item "Update PostScript" "buffer-update ps"
End End

View File

@ -2652,6 +2652,21 @@ string Buffer::bufferFormat() const
} }
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, bool Buffer::doExport(string const & format, bool put_in_tempdir,
string & result_file) const string & result_file) const
{ {

View File

@ -471,6 +471,8 @@ public:
/// return the format of the buffer on a string /// return the format of the buffer on a string
std::string bufferFormat() const; 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, bool doExport(std::string const & format, bool put_in_tempdir,

View File

@ -583,10 +583,17 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
break; break;
} }
case LFUN_BUFFER_UPDATE:
case LFUN_BUFFER_VIEW:
case LFUN_MASTER_BUFFER_UPDATE: 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; typedef vector<Format const *> Formats;
Formats formats; Formats formats;
formats = buf->exportableFormats(true); formats = buf->exportableFormats(true);
@ -594,7 +601,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
Formats::const_iterator end = formats.end(); Formats::const_iterator end = formats.end();
enable = false; enable = false;
for (; fit != end ; ++fit) { for (; fit != end ; ++fit) {
if ((*fit)->name() == to_utf8(cmd.argument())) if ((*fit)->name() == format)
enable = true; enable = true;
} }
break; break;
@ -867,25 +874,41 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
break; break;
} }
case LFUN_BUFFER_UPDATE: case LFUN_BUFFER_UPDATE: {
LASSERT(lyx_view_ && buffer, /**/); LASSERT(lyx_view_ && buffer, /**/);
buffer->doExport(argument, true); string format = argument;
if (argument.empty())
format = buffer->getDefaultOutputFormat();
buffer->doExport(format, true);
break; break;
}
case LFUN_BUFFER_VIEW: case LFUN_BUFFER_VIEW: {
LASSERT(lyx_view_ && buffer, /**/); LASSERT(lyx_view_ && buffer, /**/);
buffer->preview(argument); string format = argument;
if (argument.empty())
format = buffer->getDefaultOutputFormat();
buffer->preview(format);
break; break;
}
case LFUN_MASTER_BUFFER_UPDATE: case LFUN_MASTER_BUFFER_UPDATE: {
LASSERT(lyx_view_ && buffer && buffer->masterBuffer(), /**/); 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; break;
}
case LFUN_MASTER_BUFFER_VIEW: case LFUN_MASTER_BUFFER_VIEW: {
LASSERT(lyx_view_ && buffer && buffer->masterBuffer(), /**/); 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; break;
}
case LFUN_BUILD_PROGRAM: case LFUN_BUILD_PROGRAM:
LASSERT(lyx_view_ && buffer, /**/); 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_DEFAULT_LANGUAGE:
case LyXRC::RC_GUI_LANGUAGE: case LyXRC::RC_GUI_LANGUAGE:
case LyXRC::RC_DEFAULT_PAPERSIZE: case LyXRC::RC_DEFAULT_PAPERSIZE:
case LyXRC::RC_DEFAULT_VIEW_FORMAT:
case LyXRC::RC_DEFFILE: case LyXRC::RC_DEFFILE:
case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN: case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN:
case LyXRC::RC_DISPLAY_GRAPHICS: case LyXRC::RC_DISPLAY_GRAPHICS:

View File

@ -84,6 +84,7 @@ LexerKeyword lyxrcTags[] = {
{ "\\def_file", LyXRC::RC_DEFFILE }, { "\\def_file", LyXRC::RC_DEFFILE },
{ "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE }, { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
{ "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE }, { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
{ "\\default_view_format", LyXRC::RC_DEFAULT_VIEW_FORMAT },
{ "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN }, { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
{ "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS }, { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
{ "\\document_path", LyXRC::RC_DOCUMENTPATH }, { "\\document_path", LyXRC::RC_DOCUMENTPATH },
@ -227,6 +228,7 @@ void LyXRC::setDefaults()
view_dvi_paper_option.erase(); view_dvi_paper_option.erase();
default_papersize = PAPER_DEFAULT; default_papersize = PAPER_DEFAULT;
custom_export_format = "ps"; custom_export_format = "ps";
default_view_format = "pdf2";
chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38"; chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
bibtex_command = "bibtex"; bibtex_command = "bibtex";
fontenc = "default"; fontenc = "default";
@ -1017,6 +1019,10 @@ int LyXRC::read(Lexer & lexrc)
} }
break; break;
} }
case RC_DEFAULT_VIEW_FORMAT:
lexrc >> default_view_format;
break;
case RC_DEFAULT_LANGUAGE: case RC_DEFAULT_LANGUAGE:
lexrc >> default_language; lexrc >> default_language;
break; break;
@ -2389,6 +2395,13 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
<< "\" \"\" \"\" \"\" \"\" \"\" \"\"\n"; << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
if (tag != RC_LAST) if (tag != RC_LAST)
break; 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: case RC_VIEWER:
// Ignore it // Ignore it
if (tag != RC_LAST) if (tag != RC_LAST)
@ -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."); str = _("Command definition file. Can either specify an absolute path, or LyX will look in its global and local commands/ directories.");
break; break;
case RC_DEFAULT_VIEW_FORMAT:
str = _("The default format used with LFUN_BUFFER_[VIEW|UPDATE].");
break;
case RC_DEFAULT_LANGUAGE: case RC_DEFAULT_LANGUAGE:
str = _("New documents will be assigned this language."); str = _("New documents will be assigned this language.");
break; break;

View File

@ -69,6 +69,7 @@ public:
RC_DATE_INSERT_FORMAT, RC_DATE_INSERT_FORMAT,
RC_DEFFILE, RC_DEFFILE,
RC_DEFAULT_LANGUAGE, RC_DEFAULT_LANGUAGE,
RC_DEFAULT_VIEW_FORMAT,
RC_GUI_LANGUAGE, RC_GUI_LANGUAGE,
RC_DEFAULT_PAPERSIZE, RC_DEFAULT_PAPERSIZE,
RC_DIALOGS_ICONIFY_WITH_MAIN, RC_DIALOGS_ICONIFY_WITH_MAIN,
@ -371,6 +372,8 @@ public:
/// ///
std::string gui_language; std::string gui_language;
/// ///
std::string default_view_format;
///
bool mac_like_word_movement; bool mac_like_word_movement;
/// ///
bool cursor_follows_scrollbar; bool cursor_follows_scrollbar;

View File

@ -1474,6 +1474,8 @@ PrefFileformats::PrefFileformats(GuiPreferences * form)
this, SLOT(updatePrettyname())); this, SLOT(updatePrettyname()));
connect(formatsCB->lineEdit(), SIGNAL(textEdited(QString)), connect(formatsCB->lineEdit(), SIGNAL(textEdited(QString)),
this, SIGNAL(changed())); 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 }; // 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(); updateView();
if (init) {
int const pos = defaultFormatCB->findData(toqstr(
rc.default_view_format));
defaultFormatCB->setCurrentIndex(pos);
}
} }
void PrefFileformats::updateView() void PrefFileformats::updateView()
{ {
QString const current = formatsCB->currentText(); QString const current = formatsCB->currentText();
QString const current_def = defaultFormatCB->currentText();
// update combobox with formats // update combobox with formats
formatsCB->blockSignals(true); formatsCB->blockSignals(true);
defaultFormatCB->blockSignals(true);
formatsCB->clear(); formatsCB->clear();
form_->formats().sort(); form_->formats().sort();
Formats::const_iterator cit = form_->formats().begin(); Formats::const_iterator cit = form_->formats().begin();
Formats::const_iterator end = form_->formats().end(); Formats::const_iterator end = form_->formats().end();
for (; cit != end; ++cit) for (; cit != end; ++cit) {
formatsCB->addItem(qt_(cit->prettyname()), 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 // restore selection
int const item = formatsCB->findText(current, Qt::MatchExactly); int item = formatsCB->findText(current, Qt::MatchExactly);
formatsCB->setCurrentIndex(item < 0 ? 0 : item); formatsCB->setCurrentIndex(item < 0 ? 0 : item);
on_formatsCB_currentIndexChanged(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); formatsCB->blockSignals(false);
defaultFormatCB->blockSignals(false);
} }

View File

@ -791,8 +791,10 @@ void MenuDefinition::expandFormats(MenuItem::Kind kind, Buffer const * buf)
label += "..."; label += "...";
break; break;
case MenuItem::ViewFormats: case MenuItem::ViewFormats:
case MenuItem::ExportFormats:
case MenuItem::UpdateFormats: case MenuItem::UpdateFormats:
if ((*fit)->name() == buf->getDefaultOutputFormat())
continue;
case MenuItem::ExportFormats:
if (!(*fit)->documentFormat()) if (!(*fit)->documentFormat())
continue; continue;
break; break;

View File

@ -5,8 +5,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>414</width> <width>427</width>
<height>322</height> <height>413</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
@ -19,6 +19,53 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </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&amp;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" > <item row="8" column="1" colspan="3" >
<widget class="QLineEdit" name="copierED" /> <widget class="QLineEdit" name="copierED" />
</item> </item>
@ -149,19 +196,6 @@
<item row="4" column="1" > <item row="4" column="1" >
<widget class="QLineEdit" name="extensionED" /> <widget class="QLineEdit" name="extensionED" />
</item> </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" > <item row="8" column="0" >
<widget class="QLabel" name="label" > <widget class="QLabel" name="label" >
<property name="text" > <property name="text" >