From 8365eabd6f978d8bdc7fbcfabba83548ae409d94 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Thu, 27 Aug 2020 08:45:41 +0200 Subject: [PATCH] Make paper search function accessible and customizable --- lib/Makefile.am | 1 - lib/configure.py | 3 +- lib/doc/UserGuide.lyx | 421 +++++++++++++++++------------- lib/scripts/lyxpaperview | 26 -- lib/scripts/prefs2prefs_prefs.py | 3 +- lib/ui/stdcontext.inc | 2 +- src/BiblioInfo.cpp | 11 +- src/BiblioInfo.h | 5 +- src/LyXRC.cpp | 41 ++- src/LyXRC.h | 16 +- src/frontends/qt/GuiPrefs.cpp | 22 +- src/frontends/qt/GuiPrefs.h | 3 + src/frontends/qt/GuiView.cpp | 10 +- src/frontends/qt/qt_helpers.cpp | 16 +- src/frontends/qt/qt_helpers.h | 9 +- src/frontends/qt/ui/PrefEditUi.ui | 299 ++++++++++++--------- src/insets/InsetCitation.cpp | 15 +- 17 files changed, 532 insertions(+), 371 deletions(-) delete mode 100755 lib/scripts/lyxpaperview diff --git a/lib/Makefile.am b/lib/Makefile.am index 6b5a1204e4..dfe1986d0b 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -2511,7 +2511,6 @@ dist_scripts_DATA += \ scripts/legacy_lyxpreview2ppm.py \ scripts/listerrors \ scripts/lyxpak.py \ - scripts/lyxpaperview \ scripts/lyxpaperview.py \ scripts/lyxpreview2bitmap.py \ scripts/lyxpreview_tools.py \ diff --git a/lib/configure.py b/lib/configure.py index b708edff2a..1547000b37 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -1310,13 +1310,12 @@ def checkOtherEntries(): rc_entry = [ r'\nomencl_command "makeindex -s nomencl.ist"' ]) checkProg('a python-pygments driver command', ['pygmentize'], rc_entry = [ r'\pygmentize_command "%%"' ]) - checkProg('external script for searching and showing citation sources', - ['lyxpaperview', 'lyxpaperview.py'], rc_entry = [ r'\citation_search_view "%%"' ]) ## FIXME: OCTAVE is not used anywhere # path, OCTAVE = checkProg('Octave', ['octave']) ## FIXME: MAPLE is not used anywhere # path, MAPLE = checkProg('Maple', ['maple']) # Add the rest of the entries (no checkProg is required) + addToRC(r'''\citation_search_view "python -tt $$s/scripts/lyxpaperview.py"''') addToRC(r'''\copier fig "python -tt $$s/scripts/fig_copy.py $$i $$o" \copier pstex "python -tt $$s/scripts/tex_copy.py $$i $$o $$l" \copier pdftex "python -tt $$s/scripts/tex_copy.py $$i $$o $$l" diff --git a/lib/doc/UserGuide.lyx b/lib/doc/UserGuide.lyx index 2efde46e83..49fa68925b 100644 --- a/lib/doc/UserGuide.lyx +++ b/lib/doc/UserGuide.lyx @@ -8742,12 +8742,14 @@ Verbatim \end_layout \begin_layout Verbatim + This is Verbatim. \end_layout \begin_layout Verbatim \noindent \align block + The following 2 lines are empty: \end_layout @@ -8760,6 +8762,7 @@ The following 2 lines are empty: \end_layout \begin_layout Verbatim + Almost everything is allowed in Verbatim:"%&$§#~'` \backslash }][{| @@ -8783,6 +8786,7 @@ Verbatim \end_layout \begin_layout Verbatim* + This is Verbatim*. \end_layout @@ -31647,184 +31651,6 @@ Additional Features \end_layout -\begin_layout Subsection - -\change_inserted 5863208 1598273424 -Bibliography entries allowing external view of the cited material -\end_layout - -\begin_layout Standard - -\change_inserted 5863208 1598273449 -\SpecialChar LyX - supports viewing the material the selected citation points to – though - you need to satisfy some conditions so the -\family sans -Open -\begin_inset space ~ -\end_inset - -Citation -\begin_inset space ~ -\end_inset - -Content -\family default - in the context menu of the citation inset is active and working. -\end_layout - -\begin_layout Standard - -\change_inserted 5863208 1598270259 -There are several ways how to make this feature available: -\end_layout - -\begin_layout Itemize - -\change_inserted 5863208 1598273631 -Have citations entries including any of the following fields: -\begin_inset Flex Code -status open - -\begin_layout Plain Layout - -\change_inserted 5863208 1598273574 -url -\change_unchanged - -\end_layout - -\end_inset - - or -\begin_inset Flex Code -status open - -\begin_layout Plain Layout - -\change_inserted 5863208 1598273595 -doi -\change_unchanged - -\end_layout - -\end_inset - - for BibTeX, -\begin_inset Flex Code -status open - -\begin_layout Plain Layout - -\change_inserted 5863208 1598273611 -eprint -\change_unchanged - -\end_layout - -\end_inset - - for BibLaTeX (covering arXiv, JSTOR, PubMed, HDL, Google Books -\begin_inset Flex Code -status open - -\begin_layout Plain Layout - -\change_inserted 5863208 1598273631 -eprinttype -\change_unchanged - -\end_layout - -\end_inset - -). - This will launch web browser with the appropriate link. -\end_layout - -\begin_layout Itemize - -\change_inserted 5863208 1598273665 -Having fields pointing to local files on your disk: -\begin_inset Flex Code -status open - -\begin_layout Plain Layout - -\change_inserted 5863208 1598273656 -file -\change_unchanged - -\end_layout - -\end_inset - - (filled by JabRef), -\begin_inset Flex Code -status open - -\begin_layout Plain Layout - -\change_inserted 5863208 1598273665 -localfile -\change_unchanged - -\end_layout - -\end_inset - - (filled by KBibTeX). - This will launch appropriate file viewer. - At the moment only absolute paths are accepted. -\change_unchanged - -\end_layout - -\begin_layout Itemize - -\change_inserted 5863208 1598273865 -Supplying your own script named either -\begin_inset Flex Code -status open - -\begin_layout Plain Layout - -\change_inserted 5863208 1598273683 -lyxpaperview -\change_unchanged - -\end_layout - -\end_inset - - or -\begin_inset Flex Code -status open - -\begin_layout Plain Layout - -\change_inserted 5863208 1598273697 -lyxpaperview.py -\change_unchanged - -\end_layout - -\end_inset - -, which takes year and first author name as an input. - It will be responsibility of this script to search for the appropriate - file on your disk and launch the viewer. - This script needs to be found among other executables so -\family sans -Tools\SpecialChar menuseparator -Reconfigure -\family default - can recognize it. - Example templates with identical names can be found within your installation. -\change_unchanged - -\end_layout - \begin_layout Subsection Citation Format \begin_inset Index idx @@ -32350,6 +32176,192 @@ General text after fields you can add pre- and postnotes that apply to the whole list. \end_layout +\begin_layout Subsection + +\change_inserted -712698321 1598509964 +\begin_inset CommandInset label +LatexCommand label +name "subsec:Opening-cited-documents" + +\end_inset + +Opening cited documents from within \SpecialChar LyX + +\end_layout + +\begin_layout Standard + +\change_inserted -712698321 1598509000 +\SpecialChar LyX + supports opening documents selected citations point to via the +\family sans +Try +\begin_inset space ~ +\end_inset + +to +\begin_inset space ~ +\end_inset + +Open +\begin_inset space ~ +\end_inset + +Citation +\begin_inset space ~ +\end_inset + +Content\SpecialChar ldots + +\family default + context menu if specific conditions are met: +\end_layout + +\begin_layout Itemize + +\change_inserted -712698321 1598509037 +If citation entries include any of the fields +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1598508820 +url +\end_layout + +\end_inset + + or +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1598508820 +doi +\end_layout + +\end_inset + + for BibTeX, +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1598508820 +eprint +\end_layout + +\end_inset + + for BibLaTeX (covering arXiv, JSTOR, PubMed, HDL, Google Books +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1598508820 +eprinttype +\end_layout + +\end_inset + +), the action will launch a web browser with the appropriate link. +\end_layout + +\begin_layout Itemize + +\change_inserted -712698321 1598509157 +If citation entries include any of the fields +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1598508820 +file +\end_layout + +\end_inset + + (filled by JabRef) or +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1598508820 +localfile +\end_layout + +\end_inset + + (filled by KBibTeX) containing an URL that points to a file on your local + drive, the action will launch an appropriate file viewer. + At the moment only absolute paths are accepted. +\end_layout + +\begin_layout Standard + +\change_inserted -712698321 1598509196 +Note that \SpecialChar LyX + does not check if the URLs are valid. +\end_layout + +\begin_layout Standard + +\change_inserted -712698321 1598509866 +In addition to that, \SpecialChar LyX + also searches your disk for matching files if you + enable +\family sans +Search drive for cited files +\family default + in +\family sans +Tools\SpecialChar menuseparator +Preferences\SpecialChar ldots +\SpecialChar menuseparator +Edit\SpecialChar menuseparator +Control +\family default +. + It uses the tokens supplied at +\family sans +Pattern +\family default + in the same preferences section (by default: year and authors). + Any of the tokens in the pattern must occur in the title (at arbitrary + position). + The pattern syntax uses specific keywords. + These are basically Bib\SpecialChar TeX + keys embraced in +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1598509565 +% +\change_unchanged + +\end_layout + +\end_inset + +, but there are also special keys, which are documented in the Customization + manual, sec. + +\emph on +Cite format description +\emph default +. +\change_unchanged + +\end_layout + \begin_layout Section Index \begin_inset Index idx @@ -49818,6 +49830,59 @@ Math Macros Math \emph default manual. +\change_inserted -712698321 1598509726 + +\end_layout + +\begin_layout Standard + +\change_inserted -712698321 1598509987 +The option +\family sans +Search drive for cited files +\family default + allows \SpecialChar LyX + to query your disk for cited documents when using the +\family sans +Try +\begin_inset space ~ +\end_inset + +to +\begin_inset space ~ +\end_inset + +Open +\begin_inset space ~ +\end_inset + +Citation +\begin_inset space ~ +\end_inset + +Content\SpecialChar ldots + +\family default + context menu on a citation. + The +\family sans +Patterns +\family default + field determines the search pattern. + See sec. +\begin_inset space ~ +\end_inset + + +\begin_inset CommandInset ref +LatexCommand ref +reference "subsec:Opening-cited-documents" + +\end_inset + + for details. +\change_unchanged + \end_layout \begin_layout Subsubsection diff --git a/lib/scripts/lyxpaperview b/lib/scripts/lyxpaperview deleted file mode 100755 index 5d7ea3cb2d..0000000000 --- a/lib/scripts/lyxpaperview +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -#This is just an example of an external script for finding corresponding file to the citation of the form Author + Year. -#You will need to accomodate it to your particular situation. -# -#Syntax: paperview Year Author -#Output: absolute path to the file(s) -# -#Dependencies: -#1) mlocate/updatedb or similar package installed and running. -#2) stored papers must contain first author name and year of publication in filename. - -VIEWER=qpdfview -MAX_RESULTS=2 - -name="$2" -year="$1" - -if [ -z "$name" ]; then exit; fi - -FILE=`locate -i "$name" | grep -Ei '\.pdf$|\.ps$' | grep "$year" | head -n $MAX_RESULTS` - - -#Putting in background necessary so that LyX does not wait for viewer to end -$VIEWER ${FILE} & - diff --git a/lib/scripts/prefs2prefs_prefs.py b/lib/scripts/prefs2prefs_prefs.py index d22d758a11..322990add5 100644 --- a/lib/scripts/prefs2prefs_prefs.py +++ b/lib/scripts/prefs2prefs_prefs.py @@ -130,7 +130,8 @@ # No convergence necessary. # Incremented to format 33, by sanda -# Add \citation_search_view. +# Add \citation_search, \citation_search_pattern +# and \citation_search_view. # No conversion necessary. diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc index ec2f563f8b..c3156e41ef 100644 --- a/lib/ui/stdcontext.inc +++ b/lib/ui/stdcontext.inc @@ -128,7 +128,7 @@ Menuset CiteStyles Separator Item "Settings...|S" "inset-settings" - Item "Open Citation Content...|O" "inset-edit" + Item "Try to Open Citation Content...|O" "inset-edit" End diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index a517768b22..5ec3986af6 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -996,7 +996,7 @@ docstring BibTeXInfo::expandFormat(docstring const & format, docstring const & BibTeXInfo::getInfo(BibTeXInfoList const & xrefs, - Buffer const & buf, CiteItem const & ci) const + Buffer const & buf, CiteItem const & ci, docstring const & format_in) const { bool const richtext = ci.richtext; @@ -1013,8 +1013,9 @@ docstring const & BibTeXInfo::getInfo(BibTeXInfoList const & xrefs, CiteEngineType const engine_type = buf.params().citeEngineType(); DocumentClass const & dc = buf.params().documentClass(); - docstring const & format = - from_utf8(dc.getCiteFormat(engine_type, to_utf8(entry_type_))); + docstring const & format = format_in.empty()? + from_utf8(dc.getCiteFormat(engine_type, to_utf8(entry_type_))) + : format_in; int counter = 0; info_ = expandFormat(format, xrefs, counter, buf, ci, false, false); @@ -1388,7 +1389,7 @@ docstring const BiblioInfo::getYear(docstring const & key, Buffer const & buf, b docstring const BiblioInfo::getInfo(docstring const & key, - Buffer const & buf, CiteItem const & ci) const + Buffer const & buf, CiteItem const & ci, docstring const & format) const { BiblioInfo::const_iterator it = find(key); if (it == end()) @@ -1400,7 +1401,7 @@ docstring const BiblioInfo::getInfo(docstring const & key, if (xrefit != end()) xrefptrs.push_back(&(xrefit->second)); } - return data.getInfo(xrefptrs, buf, ci); + return data.getInfo(xrefptrs, buf, ci, format); } diff --git a/src/BiblioInfo.h b/src/BiblioInfo.h index ddf1daa5e9..bc385f292a 100644 --- a/src/BiblioInfo.h +++ b/src/BiblioInfo.h @@ -75,7 +75,8 @@ public: /// \return formatted BibTeX data suitable for framing. /// \param vector of pointers to crossref/xdata information docstring const & getInfo(BibTeXInfoList const & xrefs, - Buffer const & buf, CiteItem const & ci) const; + Buffer const & buf, CiteItem const & ci, + docstring const & format = docstring()) const; /// \return formatted BibTeX data for a citation label docstring const getLabel(BibTeXInfoList const xrefs, Buffer const & buf, docstring const & format, @@ -227,7 +228,7 @@ public: /// output any richtext tags marked in the citation format and escape < and > /// elsewhere, and the general output context. docstring const getInfo(docstring const & key, Buffer const & buf, - CiteItem const & ci) const; + CiteItem const & ci, docstring const & format = docstring()) const; /// \return formatted BibTeX data for citation labels. /// Citation labels can have more than one key. docstring const getLabel(std::vector keys, Buffer const & buf, diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index e3bb0de803..eb5d0dcf83 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -78,6 +78,8 @@ LexerKeyword lyxrcTags[] = { { "\\bind_file", LyXRC::RC_BINDFILE }, { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES }, { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND }, + { "\\citation_search", LyXRC::RC_CITATION_SEARCH }, + { "\\citation_search_pattern", LyXRC::RC_CITATION_SEARCH_PATTERN }, { "\\citation_search_view", LyXRC::RC_CITATION_SEARCH_VIEW }, { "\\close_buffer_with_last_view", LyXRC::RC_CLOSE_BUFFER_WITH_LAST_VIEW }, { "\\completion_cursor_text", LyXRC::RC_COMPLETION_CURSOR_TEXT }, @@ -680,8 +682,18 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) } break; + case RC_CITATION_SEARCH: + lexrc >> citation_search; + break; + + case RC_CITATION_SEARCH_PATTERN: + if (lexrc.next()) + citation_search_pattern = lexrc.getString(); + break; + case RC_CITATION_SEARCH_VIEW: - lexrc >> citation_search_view; + if (lexrc.next()) + citation_search_view = lexrc.getString(); break; case RC_CT_ADDITIONS_UNDERLINED: @@ -1607,11 +1619,32 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c if (tag != RC_LAST) break; // fall through + case RC_CITATION_SEARCH: + if (ignore_system_lyxrc || + citation_search != system_lyxrc.citation_search) { + os << "# Set to true to use script to search\n" + << "# locl disk for citation targets.\n" + << "\\citation_search " + << convert(citation_search) + << '\n'; + } + if (tag != RC_LAST) + break; + // fall through case RC_CITATION_SEARCH_VIEW: if (ignore_system_lyxrc || citation_search_view != system_lyxrc.citation_search_view) { - os << "\\citaton_search_view " - << citation_search_view << '\n'; + os << "\\citation_search_view \"" + << citation_search_view << "\"\n"; + } + if (tag != RC_LAST) + break; + // fall through + case RC_CITATION_SEARCH_PATTERN: + if (ignore_system_lyxrc || + citation_search_pattern != system_lyxrc.citation_search_pattern) { + os << "\\citation_search_pattern \"" + << citation_search_pattern << "\"\n"; } if (tag != RC_LAST) break; @@ -2788,6 +2821,8 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_BIBTEX_ALTERNATIVES: case LyXRC::RC_BIBTEX_COMMAND: case LyXRC::RC_BINDFILE: + case LyXRC::RC_CITATION_SEARCH: + case LyXRC::RC_CITATION_SEARCH_PATTERN: case LyXRC::RC_CITATION_SEARCH_VIEW: case LyXRC::RC_CHECKLASTFILES: case LyXRC::RC_COMPLETION_CURSOR_TEXT: diff --git a/src/LyXRC.h b/src/LyXRC.h index d795d345ec..09179528f1 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -53,6 +53,8 @@ public: RC_BINDFILE, RC_CHECKLASTFILES, RC_CHKTEX_COMMAND, + RC_CITATION_SEARCH, + RC_CITATION_SEARCH_PATTERN, RC_CITATION_SEARCH_VIEW, RC_COMPLETION_CURSOR_TEXT, RC_COMPLETION_INLINE_DELAY, @@ -244,13 +246,15 @@ public: /// default paper size for local xdvi/dvips/ghostview/whatever /// command to run chktex incl. options std::string chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38"; - // Name of external script, which searches for file corresponding to a - // given citation. At this moment only script lyxpaperview[.py] is supported - // (search for pdf based on author+year), but we can generalize if requested. - // Citation context menu item "Open Citation Content" will be always enabled - // if the name of this script in nonempty (last resort when citation entry - // does not contain neccessary info. + /// Use external script to search for file corresponding to a + /// given citation. + bool citation_search = false; + /// Name of external script which searches for file corresponding to a + /// given citation. At this moment only script lyxpaperview.p is supported + /// (search for pdf or ps based on specific items) std::string citation_search_view; + /// Items to search for in citation_search_view + std::string citation_search_pattern = "%year% %abbrvciteauthor%"; /// all available commands to run bibtex incl. options CommandSet bibtex_alternatives; /// command to run bibtex incl. options diff --git a/src/frontends/qt/GuiPrefs.cpp b/src/frontends/qt/GuiPrefs.cpp index 1fe444788f..ad1ee8e457 100644 --- a/src/frontends/qt/GuiPrefs.cpp +++ b/src/frontends/qt/GuiPrefs.cpp @@ -2756,7 +2756,9 @@ PrefEdit::PrefEdit(GuiPreferences * form) this, SIGNAL(changed())); connect(cursorWidthSB, SIGNAL(valueChanged(int)), this, SIGNAL(changed())); - connect(fullscreenLimitGB, SIGNAL(clicked()), + connect(citationSearchCB, SIGNAL(toggled(bool)), + this, SIGNAL(changed())); + connect(citationSearchLE, SIGNAL(textChanged(QString)), this, SIGNAL(changed())); connect(fullscreenWidthSB, SIGNAL(valueChanged(int)), this, SIGNAL(changed())); @@ -2773,6 +2775,14 @@ PrefEdit::PrefEdit(GuiPreferences * form) } +void PrefEdit::on_fullscreenLimitCB_toggled(bool const state) +{ + fullscreenWidthSB->setEnabled(state); + fullscreenWidthLA->setEnabled(state); + changed(); +} + + void PrefEdit::applyRC(LyXRC & rc) const { rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked(); @@ -2787,13 +2797,15 @@ void PrefEdit::applyRC(LyXRC & rc) const case 2: rc.macro_edit_style = LyXRC::MACRO_EDIT_LIST; break; } rc.cursor_width = cursorWidthSB->value(); + rc.citation_search = citationSearchCB->isChecked(); + rc.citation_search_pattern = fromqstr(citationSearchLE->text()); rc.full_screen_toolbars = toggleToolbarsCB->isChecked(); rc.full_screen_scrollbar = toggleScrollbarCB->isChecked(); rc.full_screen_statusbar = toggleStatusbarCB->isChecked(); rc.full_screen_tabbar = toggleTabbarCB->isChecked(); rc.full_screen_menubar = toggleMenubarCB->isChecked(); rc.full_screen_width = fullscreenWidthSB->value(); - rc.full_screen_limit = fullscreenLimitGB->isChecked(); + rc.full_screen_limit = fullscreenLimitCB->isChecked(); } @@ -2807,13 +2819,17 @@ void PrefEdit::updateRC(LyXRC const & rc) groupEnvironmentsCB->setChecked(rc.group_layouts); macroEditStyleCO->setCurrentIndex(rc.macro_edit_style); cursorWidthSB->setValue(rc.cursor_width); + citationSearchCB->setChecked(rc.citation_search); + citationSearchLE->setText(toqstr(rc.citation_search_pattern)); toggleScrollbarCB->setChecked(rc.full_screen_scrollbar); toggleStatusbarCB->setChecked(rc.full_screen_statusbar); toggleToolbarsCB->setChecked(rc.full_screen_toolbars); toggleTabbarCB->setChecked(rc.full_screen_tabbar); toggleMenubarCB->setChecked(rc.full_screen_menubar); fullscreenWidthSB->setValue(rc.full_screen_width); - fullscreenLimitGB->setChecked(rc.full_screen_limit); + fullscreenLimitCB->setChecked(rc.full_screen_limit); + fullscreenWidthSB->setEnabled(rc.full_screen_limit); + fullscreenWidthLA->setEnabled(rc.full_screen_limit); } diff --git a/src/frontends/qt/GuiPrefs.h b/src/frontends/qt/GuiPrefs.h index 8bd264eaff..433439d2ed 100644 --- a/src/frontends/qt/GuiPrefs.h +++ b/src/frontends/qt/GuiPrefs.h @@ -452,6 +452,9 @@ public: void applyRC(LyXRC & rc) const; void updateRC(LyXRC const & rc); + +public Q_SLOTS: + void on_fullscreenLimitCB_toggled(bool); }; diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp index 5c1c3577a6..b5bfe504fc 100644 --- a/src/frontends/qt/GuiView.cpp +++ b/src/frontends/qt/GuiView.cpp @@ -4624,9 +4624,15 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr) dr.screenUpdate(Update::Force); break; - case LFUN_CITATION_OPEN: - frontend::showTarget(argument); + case LFUN_CITATION_OPEN: { + string pdfv, psv; + if (theFormats().getFormat("pdf")) + pdfv = theFormats().getFormat("pdf")->viewer(); + if (theFormats().getFormat("ps")) + psv = theFormats().getFormat("ps")->viewer(); + frontend::showTarget(argument, pdfv, psv); break; + } default: // The LFUN must be for one of BufferView, Buffer or Cursor; diff --git a/src/frontends/qt/qt_helpers.cpp b/src/frontends/qt/qt_helpers.cpp index 92ee029372..f064d50d14 100644 --- a/src/frontends/qt/qt_helpers.cpp +++ b/src/frontends/qt/qt_helpers.cpp @@ -298,15 +298,21 @@ void showDirectory(FileName const & directory) LYXERR0("Unable to open QUrl even though dir exists!"); } -void showTarget(string const & target){ +void showTarget(string const & target, string const & pdfv, string const & psv){ LYXERR(Debug::INSETS, "Showtarget:" << target << "\n"); - if (prefixIs(target,"EXTERNAL ")) { - if (lyxrc.citation_search_view.empty()) + if (prefixIs(target, "EXTERNAL ")) { + if (!lyxrc.citation_search) return; - string tmp,tar; + string tmp, tar, opts; tar = split(target, tmp, ' '); + if (!pdfv.empty()) + opts = " -v " + pdfv; + if (!psv.empty()) + opts += " -w " + psv; + if (!opts.empty()) + opts += " "; FuncRequest cmd = FuncRequest(LFUN_VC_COMMAND,"U . \"" + - lyxrc.citation_search_view + " " + tar + "\""); + lyxrc.citation_search_view + " " + opts + tar + "\""); lyx::dispatch(cmd); return; } diff --git a/src/frontends/qt/qt_helpers.h b/src/frontends/qt/qt_helpers.h index 967ee5f37d..f0e535fe81 100644 --- a/src/frontends/qt/qt_helpers.h +++ b/src/frontends/qt/qt_helpers.h @@ -101,9 +101,12 @@ void setSectionResizeMode(QHeaderView * view, QHeaderView::ResizeMode mode); /// Shows a directory in OSs file browser void showDirectory(support::FileName const & directory); -/// handle request for showing citation content - shows pdf or -/// web page in target; external script can be used for pdf view -void showTarget(std::string const & target); +/// handle request for showing citation content - shows pdf/ps or +/// web page in target; external script can be used for pdf/ps view +/// \p pdfv takes a pad viewer, \p psv a ps viewer +void showTarget(std::string const & target, + std::string const & pdfv, + std::string const & psv); } // namespace frontend diff --git a/src/frontends/qt/ui/PrefEditUi.ui b/src/frontends/qt/ui/PrefEditUi.ui index 987dc92d90..fe36a5b5b3 100644 --- a/src/frontends/qt/ui/PrefEditUi.ui +++ b/src/frontends/qt/ui/PrefEditUi.ui @@ -6,8 +6,8 @@ 0 0 - 494 - 614 + 610 + 552 @@ -19,8 +19,8 @@ - - + + Editing @@ -32,6 +32,19 @@ true + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -39,14 +52,7 @@ - - - - Sort &environments alphabetically - - - - + Qt::Horizontal @@ -59,14 +65,85 @@ - + + + + + Edit Math Macros inline with a box around + + + + + Edit Math Macros inline with the name in the status bar + + + + + Edit Math Macros with a parameter list (like in LyX < 1.6) + + + + + + + + If this is checked, deleted and added text in change tracking mode will not be resolved on copy/paste operations and when moving content from/to insets + + + &Keep change tracking markup on copy and paste + + + + + + + Sort &environments alphabetically + + + + Cursor &follows scrollbar - + + + + + + If this is activated, LyX will search your disk for matching files when clicking on "Try to Open Citation Content..." in the citation context menu + + + Search &drive for cited files + + + + + + + + + Patte&rn: + + + citationSearchLE + + + + + + + Define search pattern (see UserGuide for syntax) + + + + + + + + @@ -99,26 +176,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - &Group environments by their category - - - @@ -129,39 +186,17 @@ - - - - - Edit Math Macros inline with a box around - - - - - Edit Math Macros inline with the name in the status bar - - - - - Edit Math Macros with a parameter list (like in LyX < 1.6) - - - - - - - - If this is checked, deleted and added text in change tracking mode will not be resolved on copy/paste operations and when moving content from/to insets - + + - &Keep change tracking markup on copy and paste + &Group environments by their category - + Fullscreen @@ -186,92 +221,101 @@ - - - - Hide scr&ollbar - - - - - - - Hide &tabbar - - - - + Hide &menubar - + + + + Hide scr&ollbar + + + + + + + Qt::Horizontal + + + + 146 + 38 + + + + + Hide sta&tusbar - - - - &Limit text width + + + + H&ide tabbar - - true - - - true - - - - - - Screen used (&pixels): - - - fullscreenWidthSB - - - - - - - 0 - - - 10000 - - - 10 - - - 700 - - - - - - - - Qt::Horizontal - - - - 157 - 20 - - - + + + + + + &Limit text width + + + + + + + Screen used (pi&xels): + + + fullscreenWidthSB + + + + + + + 0 + + + 10000 + + + 10 + + + 700 + + + + + + + Qt::Horizontal + + + + 157 + 20 + + + + + - + Qt::Vertical @@ -293,7 +337,6 @@ scrollBelowCB macLikeCursorMovementCB sortEnvironmentsCB - groupEnvironmentsCB macroEditStyleCO diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp index 7ae75b810f..df722aaf7f 100644 --- a/src/insets/InsetCitation.cpp +++ b/src/insets/InsetCitation.cpp @@ -206,13 +206,18 @@ void InsetCitation::openCitation() docstring const & key = getParam("key"); vector keys = getVectorFromString(key); - docstring year, author, doi, url, file; + docstring titledata, doi, url, file; for (docstring const & kvar : keys) { - year = bi.getYear(kvar, buffer(), false); - author = bi.getAuthorOrEditorList(kvar, buffer()); + CiteItem ci; + titledata = bi.getInfo(kvar, buffer(), ci, + from_ascii(lyxrc.citation_search_pattern)); + // some cleanup: commas and " and ", as used in name lists, + // are not expected in file names + titledata = subst(titledata, ',', char()); + titledata = subst(titledata, from_ascii(" and "), from_ascii(" ")); bi.getLocators(kvar, doi, url, file); LYXERR(Debug::INSETS, "Locators: doi:" << doi << " url:" - << url << " file:" << file << " author:" << author << " year:" << year); + << url << " file:" << file << " title data:" << titledata); docstring locator; if (!file.empty()) { locator = file; @@ -221,7 +226,7 @@ void InsetCitation::openCitation() } else if (!url.empty()) { locator = url; } else { - locator = "EXTERNAL " + year + " " + author; + locator = "EXTERNAL " + titledata; } FuncRequest cmd = FuncRequest(LFUN_CITATION_OPEN, locator); lyx::dispatch(cmd);