]> git.lyx.org Git - features.git/commitdiff
* First step towards default view format.
authorJürgen Spitzmüller <spitz@lyx.org>
Tue, 7 Apr 2009 05:01:08 +0000 (05:01 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Tue, 7 Apr 2009 05:01:08 +0000 (05:01 +0000)
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

18 files changed:
development/scons/scons_manifest.py
lib/Makefile.am
lib/images/buffer-update.png [new file with mode: 0644]
lib/images/buffer-view.png [new file with mode: 0644]
lib/images/master-buffer-update.png [new file with mode: 0644]
lib/images/master-buffer-view.png [new file with mode: 0644]
lib/images/math/update-others.png [new file with mode: 0644]
lib/images/math/view-others.png [new file with mode: 0644]
lib/ui/stdmenus.inc
lib/ui/stdtoolbars.inc
src/Buffer.cpp
src/Buffer.h
src/LyXFunc.cpp
src/LyXRC.cpp
src/LyXRC.h
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/Menus.cpp
src/frontends/qt4/ui/PrefFileformatsUi.ui

index 7df6aa962830d25da03723f1a01b51cdc725aced..77e29aba92c43dbc610ac73a7701ff0df1c74916 100644 (file)
@@ -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
index 4e85b0fd90bb28a6c7f39df7f5ad94e693f2951c..afa3f0f9e5dd2df8401bb90c83cffd14bd91038d 100644 (file)
@@ -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 (file)
index 0000000..3f74d0e
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 (file)
index 0000000..d3ac51a
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 (file)
index 0000000..8a2c2ef
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 (file)
index 0000000..b074bd7
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 (file)
index 0000000..d2d3155
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 (file)
index 0000000..f93c47c
Binary files /dev/null and b/lib/images/math/view-others.png differ
index 12638f885ff636e0ee1ccb227616acaf8dfbd245..3188b6fd92ee7552e658dda52e622331c787a78a 100644 (file)
@@ -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
index 77b5df270d8f85406f1aef3006276ac4b3d995f1..8432b30e22995c6c8e8ed88ae6f5c87750f809ba 100644 (file)
@@ -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
 
index 43d5c236b2527c5ad070f7599d001cd5c1644b8c..3b5a45bc02bc95d99efe072d94a9d217c01fa127 100644 (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,
        string & result_file) const
 {
index 43d82b647730733ddf01101ba6774bd188400226..dd1a2b4c84501335a376cd99074322e5ac81146f 100644 (file)
@@ -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,
index d8f5e9cf4cac8b1519b269d75fa4e1779c4242f2..93a83139f1c846d1e0deed98ea34160ace18b7db 100644 (file)
@@ -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<Format const *> 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:
index 3e14a078982a228a60c957fe1187936fcb79b381..8397f70cbbda5fba64e495502b6e45f028fbd339 100644 (file)
@@ -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;
index dd84720d1a62fd53a883dff2de8abcd2a4f121a1..329c79201c1c3ac06bcfa5f1fa27b67c5410d3e0 100644 (file)
@@ -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;
index 809d3496b5991054dc1bf8d329a2fe5f13d1fe38..567df6a7aea49e47705c657fb45fc5aabf23341a 100644 (file)
@@ -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);
 }
 
 
index d323c7b3133b8a61096ecf6b2cce9f636af7fcb2..5c02c392d5e6eb1fc498fbac4c3b08de58462bdd 100644 (file)
@@ -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;
index 695c55daa94615d97d9b690228708b6bad6c9509..2f8141dd4becae9d8c09301eeabf013659836bcc 100644 (file)
@@ -5,8 +5,8 @@
    <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&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" >
     <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" >