"Fossies" - the Fresh Open Source Software Archive

Member "cb2bib-2.0.1/src/c2bConfigure.cpp" (12 Feb 2021, 47589 Bytes) of package /linux/privat/cb2bib-2.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "c2bConfigure.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.0.0_vs_2.0.1.

    1 /***************************************************************************
    2  *   Copyright (C) 2004-2021 by Pere Constans
    3  *   constans@molspaces.com
    4  *   cb2Bib version 2.0.1. Licensed under the GNU GPL version 3.
    5  *   See the LICENSE file that comes with this distribution.
    6  ***************************************************************************/
    7 #include "c2bConfigure.h"
    8 
    9 #include "c2b.h"
   10 #include "c2bConfigureFR.h"
   11 #include "c2bFileDialog.h"
   12 #include "c2bSettings.h"
   13 #include "c2bUtils.h"
   14 
   15 #include <QColorDialog>
   16 #include <QHeaderView>
   17 #include <QStatusTipEvent>
   18 
   19 
   20 /** \page configuration Configuration
   21 
   22 <p>&nbsp;</p>
   23 GET_TABLE_OF_CONTENTS
   24 <p>&nbsp;</p>
   25 
   26 \section c2bconf_annote Configuring Annote
   27 
   28  - <b>Annote Cascading Style Sheet (CSS)</b> \n This file contains the style
   29     sheet to personalize the appearance of the HTML notes generated by the
   30     cb2Bib. The cb2Bib distribution includes the <tt>tex2html.css</tt> file as
   31     a CSS template.
   32 
   33  - <b>MathJax Header File</b> \n The mathematical notation in the text notes is
   34     displayed by
   35     \htmlonly
   36     <a href="https://www.mathjax.org/" target="_blank">MathJax</a>,
   37     \endhtmlonly
   38     the successor of the
   39     \htmlonly
   40     <a href="http://www.math.union.edu/~dpvc/jsMath/" target="_blank">jsMath</a>
   41     \endhtmlonly
   42     Java Script library. Its location and configuration must
   43     be specified inside the HTML files in order to be known by the browser.
   44     Check and eventually edit the distribution file
   45     <tt>tex2html_local_mathjax_header.html</tt>. Should web script be preferred set
   46     script source to
   47     <tt>https://cdn.mathjax.org/mathjax/latest/MathJax.js</tt>.
   48 
   49  - <b>Include CSS in HTML</b> \n Styles for the notes will be included, if
   50     checked, into the HTML file. In this way, all the information, text and
   51     layout, is contained in one single file.
   52 
   53  - <b>Use relative links</b> \n If checked, linked local files will be set
   54     relative to the current HTML document.
   55 
   56  - <b>Annote Viewer Fonts</b> \n Selects default and monospaced fonts for
   57     the Annote viewer. Changes in the fonts might need restarting the viewer
   58     unless using some of the latest QtWebKit libraries. The viewer is disabled
   59     if cb2Bib was not compiled and linked against WebKit. Note also that fonts
   60     specified in the CSS prevail over this selection.
   61 
   62 
   63 \section c2bconf_bibtex Configuring BibTeX
   64 
   65  - <b>Cite ID Pattern</b> \n Specifies the pattern for formatting cite's ID.
   66     Predefined placeholders are available as a context menu, by right-clicking
   67     this edit line. Placeholders will be substituted by the actual reference
   68     field values. See \ref idplaceholders for descriptions.
   69 
   70  - <b>Author and Editor Name Format</b> \n Sets Authors and Editor names in
   71     abbreviated or full form, if the latter is available.
   72 
   73  - <b>Journal Name Format</b> \n Sets output journal names in abbreviated or
   74     full form. Note that this feature only works if journal names are found in
   75     the <tt>Journal Abbreviation List file</tt>. See \ref journalproc.
   76 
   77  - <b>Number Separator</b> \n Sets number separator, e.g., ' - ' or ' -- '.
   78     Spaces count. It applies to <tt>pages</tt>, multiple <tt>volume</tt>,
   79     <tt>number</tt>, and <tt>year</tt> cases.
   80 
   81  - <b>Cite Command Pattern</b> \n Specifies the pattern for formatting cite
   82     command. Predefined command patterns for LaTeX and Markdown (see
   83    \htmlonly
   84    <a href="https://pandoc.org/MANUAL.html#citations" target="_blank">Pandoc User's Guide</a>)
   85    \endhtmlonly
   86     are available in the line context menu. Other, customized command patterns
   87     are also available, see \ref citeplaceholders for descriptions.
   88 
   89  - <b>Convert entry strings to LaTeX</b> \n If checked, cb2Bib converts
   90     special characters to LaTeX commands. Most BibTeX import filters do not
   91     process LaTeX escaped characters. Therefore, keeping this box unchecked can
   92     be appropriate when using cb2Bib as a temporary media to transfer
   93     references to non BibTeX reference managers.
   94 
   95  - <b>Set 'title' in double braces</b> \n If checked, it writes extra braces
   96     in title. This will keep capitalization as is, when processed by BibTeX.
   97 
   98  - <b>Postprocess 'month'</b> \n If checked, cb2Bib elaborates the 'month'
   99     string on a BibTeX fashion. E.g., 'April 1' becomes '"1~" # apr'. No
  100     processing is done if the input string is not written in English.
  101 
  102  - <b>Try Heuristic Guess if recognition fails</b> \n If checked, when
  103     automatic recognition fails, cb2Bib tries to catch some of the fields of
  104     the reference through an heuristic set of rules. See \ref heuristics.
  105 
  106  - <b>Check Repeated On Save</b> \n If checked, cb2Bib looks for existing
  107     references in the BibTeX directory similar to the one being saved. The
  108     search is based on exact cite ID match, or on reference contents, by
  109     considering title and author field values, or, if empty, booktitle and
  110     editor, and using the
  111     \htmlonly
  112     <a href="https://arxiv.org/abs/0705.0751" target="_blank">approximate string</a>
  113     \endhtmlonly
  114     search pattern. If similar references are found, the current reference is
  115     not saved, and the similar ones are displayed. Pressing the <b>save button
  116     one second time will proceed to actually saving the current reference</b>.
  117     Note that this feature is not applied in command line mode, when using
  118     <tt>cb2bib --txt2bib</tt> or <tt>cb2bib --doc2bib</tt>. See also \ref
  119     keyboard.
  120 
  121  - <b>External BibTeX Postprocessing</b> \n Use this box to select a BibTeX
  122     postprocessing external tool. The name of the executable, the command
  123     arguments and the output file extension are required fields. Arguments, any
  124     number, are passed to the executable. For the sake of generality, it is
  125     required to specify the <tt>\%finput</tt> and <tt>\%foutput</tt>
  126     placeholders. The first one is later substituted by the current BibTeX
  127     filename. The second one is substituted by the current filename with the
  128     specified output extension. <b>Caution:</b> Be careful if using the same
  129     file extension for input and output, e.g., using <tt>bib</tt> because you
  130     want to use a beautifier or a sorting script. cb2Bib has no control on
  131     external disk modifications. Therefore, if the script failed, the input
  132     data would possibly be lost. See also \ref keyboard.
  133 
  134 
  135 \section c2bconf_clipboard Configuring Clipboard
  136 
  137  - <b>Replace/Remove from Input Stream</b> \n If checked, input stream is
  138     preprocessed by performing a customizable set of string
  139     substitutions/removals. This option is mainly intended to remove image HTML
  140     <tt>alt</tt> tags. Although not visible, <tt>alt</tt> tags reach the
  141     clipboard when selecting and copying text. Author lists with email icons
  142     may contain <tt>alt</tt> strings that would interfere with the author names
  143     processing. In addition, this option is also appropriate to help
  144     translating special characters to Unicode and LaTeX. Use it carefully, as
  145     to avoid unwanted or unsuspected substitutions. See also \ref clipboard.
  146 
  147  - <b>External Clipboard Preparsing Command</b> \n Preparses input stream
  148     through an external, user-defined tool. Use the box bellow to specify its
  149     name and path. cb2Bib executes the command <tt>tool_name tmp_inputfile
  150     tmp_outputfile</tt>. You might consider a wrapper shell script to fullfill
  151     this particular syntax requirement. Two examples, <tt>isi2bib</tt> and
  152     <tt>ris2bib</tt> are provided. To test them, make sure the
  153     \htmlonly
  154     <a href="http://bibutils.refbase.org/"
  155     target="_blank">BibUtils Package</a>
  156     \endhtmlonly
  157     is available on your machine. Otherwise, modify these scripts according to
  158     your needs. See also \ref keyboard, \ref clipboard, and the examples \ref
  159     ex_isi_format and \ref ex_ris.
  160 
  161  - <b>Perform always, as part of an automatic extraction</b> \n Performs
  162     preparsing each time the recognition engine is invoked. <b>Caution:</b>
  163     cb2Bib, when not in disconnected mode, starts the recognition engine each
  164     time the clipboard changes. Therefore, it might send arbitrary data to the
  165     external parsing tool. The tool might not be prepared to handle <b>'any
  166     data'</b> and might fall into a sort of <b>'infinite loop'</b>. cb2Bib
  167     kills the external tool after a reasonable waiting. But, if the tool is
  168     called through a wrapper script, killing the script will not end the tool
  169     itself. Therefore, <b>check this box only when needed</b>. If you write
  170     your own preparser, design it as to write no data to output file whenever
  171     it can not process an input properly. When the preparser produces no data,
  172     cb2Bib sends instead the input stream to the recognition engine. In this
  173     way, preparsing and normal cb2Bib functioning will work harmoniously.
  174 
  175  - <b>Do not show log</b> \n If unchecked, the external process messages,
  176     and the input and output streams are shown in a log window. Showing output
  177     logs is useful for debugging purposes.
  178 
  179  - <b>Add document metadata to Input Stream</b> \n When checked, if the
  180     document linked to a reference contains relevant metadata, then metadata
  181     will be added to the current clipboard contents. The metadata is included
  182     at the time of adding the document to the current reference, e. g., when
  183     dropping a file into the cb2Bib panel. If the document has BibTeX
  184     information, cb2Bib will automatically set the corresponding fields. If it
  185     has not, but relevant bibliographic information is found, this data is only
  186     added to the clipboard panel. To insert it in the edit lines, activate the
  187     Heuristic Guess (Alt+G). The option <b>Prepend</b> or <b>Append</b> to the
  188     clipboard contents is provided for conveniently writing regular expressions
  189     considering metadata contents. File documents are linked to the references
  190     by the BibTeX tag 'file'. See also \ref metadata.
  191 
  192 
  193 \section c2bconf_documents Configuring Documents
  194 
  195  - <b>Rename and Copy/Move document files to Directory</b> \n If selected,
  196     each file 'drag and dropped' onto the cb2Bib main window is renamed to
  197     <tt>DocumentID.pdf</tt> (or DocumentID.ps, DocumentID.dvi, etc.) and moved
  198     to the storage directory. If unselected, the file URL is written to the
  199     <tt>file</tt> BibTeX keyword, without any renaming or moving of the file.
  200     The actual copy/move action is scheduled and performed once the reference
  201     is accepted, e.g., once it is saved.
  202 
  203  - <b>Copy or Move document files</b> \n Choose whether copy or move Network
  204     Files dropped onto the cb2Bib main window. See also <b>Use External
  205     Network Client</b>.
  206 
  207  - <b>Set directory relative to the BibTeX File Directory</b> \n If checked,
  208     the document file is copied/moved to the current BibTeX file directory. If
  209     the Documents Directory box contains a <b>relative directory</b> it will be
  210     added to the file name. For example, if it contains <tt>articles</tt>,
  211     files will be copied to <tt>/current_bibtex_path/articles/</tt>. An
  212     absolute path in the Documents Directory box will be ignored in this
  213     context. Note that the file dialog returns here relative file addresses.
  214     Consequently, only the necessary portion of the full name, instead of the
  215     fullpath filename, is written to the BibTeX entry. File retrieving from
  216     within the cb2Bib browser will be relative to the BibTeX file absolute
  217     location.
  218     \n Use this option if you plan to store in a same or a related directory
  219     the BibTeX and document files. This option is appropriate for storing
  220     bibliographic collections in removal devices. Likewise, when cb2Bib is
  221     launched in USB mode, by means of the command line switch <tt>--conf</tt>,
  222     the alternate option is not available. See \ref relnotes084 and \ref
  223     export_entries.
  224 
  225  - <b>Insert BibTeX metadata to document files</b> \n If checked, cb2Bib
  226     will write bibliographic metadata to the linked document, once the current
  227     reference is accepted and saved. See also \ref metadata.
  228 
  229  - <b>Document ID Pattern</b> \n Specifies the pattern for formatting the
  230     document's filenames. Predefined placeholders are available as a context
  231     menu, by right-clicking this edit line. Placeholders will be substituted by
  232     the actual reference field values. See \ref idplaceholders for
  233     descriptions.
  234 
  235  - <b>ExifTool Metadata writer</b> \n cb2Bib uses
  236     \htmlonly
  237     <a href="https://exiftool.org/" target="_blank">ExifTool</a>
  238     \endhtmlonly
  239     for writing bibliographic metadata to the attached documents. Select here
  240     the ExifTool path name. On Windows, remember renaming
  241     <tt>exiftool(-k).exe</tt> to <tt>exiftool.exe</tt> for command line use.
  242     See also \ref metadata_write.
  243 
  244 
  245 \section c2bconf_files Configuring Files
  246 
  247  - <b>Journal Abbreviation List File</b> \n This file contains a list of
  248     journal names equivalences: a capital-letter acronym, standard abbreviated
  249     form, and full name of the journal. If an input journal name is recognized,
  250     cb2Bib will use the standard abbreviated form for the <tt>journal</tt>
  251     bibkey. If your usual journal were not within the distributed, default
  252     <tt>abbreviations.txt</tt>, you could edit this file, or point to a
  253     personalized abbreviation file. <b>Note:</b> Changes in the abbreviation
  254     file only take place after reestarting cb2Bib. See \ref journalproc.
  255 
  256  - <b>Regular Expression List File</b> \n The cb2Bib distribution includes
  257     the file <tt>regexps.txt</tt> with a few set of rules for reference
  258     extraction. This includes most of the scientific literature. Extracting
  259     from email alerts or publisher abstract pages is a <em>volatile</em> task.
  260     Information does not follow a standardized structure. Extraction pattern
  261     may then change as often as the web design needs to. Besides, such
  262     extraction from the clipboard is system dependent, in a way that produces
  263     different formatting of the text copies on different systems. You can use
  264     your personalized <tt>regexps.txt</tt> file, for testing, debugging
  265     -regular expressions are reloaded each time the automatic recognition
  266     engine executes-, and fullfiling your particular extraction needs.
  267 
  268  - <b>Bookmarks and Network Query Info File</b> \n The cb2Bib distribution
  269     includes the file <tt>netqinf.txt</tt> that contains bookmarks data, and
  270     server related information for bibliographic querying. Note that cb2Bib
  271     treats bibliographic queries as generalized net bookmarks. This allows
  272     accessing almost any online bibliographic resource. Check this file for
  273     implementations details and customization.
  274 
  275  - <b>Browser Cascading Style Sheet (CSS)</b> \n This file contains the
  276     style sheet to configure the appearance of the bibliographic references
  277     when viewed in browser mode. The cb2Bib distribution includes the
  278     <tt>references.css</tt> and <tt>references-dark.css</tt> file as a CSS
  279     examples.
  280 
  281  - <b>Part Of Speech (POS) Lexicon</b> \n This box must contain the address
  282     to the cb2Bib distribution file <tt>lexicon.pos</tt>. This file contains a
  283     set of patterns and related POS information required for indexing
  284     documents, i. e., to extract keywords from documents for the c2bCiter
  285     module.
  286 
  287  - <b>Search In Files Cache Directory</b> \n Directory containing internal
  288     data for Search In Files functionality. If an existing directory is
  289     selected cb2Bib will write all internal data on it. If otherwise, cache
  290     data will be written on the same directory from where BibTeX are searched.
  291     It might be, therefore, convenient to group all this files in a separate
  292     directory that does not need to be backup, and that can easily be deleted
  293     whenever desired.
  294 
  295 
  296 \section c2bconf_fonts Configuring Fonts
  297 
  298  - <b>Font Selector</b> \n Selects the main window and editor font family
  299     and size.
  300 
  301  - <b>Context Colors</b> \n Doubleclick on context color items to select
  302     syntax highlighter font color. Besides syntax highlighting, and to ease
  303     manual bibliographic extractions, cb2Bib has the following coloring
  304     convention. 'cb2Bib unrelevant text' colors non-word, non-digit, and
  305     cb2Bib's internal tags. 'cb2Bib relevant text' refers to the reference's
  306     year. 'cb2Bib highly relevant' attempts to guess text sectioning,
  307     highlighting 'abstract', 'introduction', and 'keywords'.
  308 
  309 
  310 \section c2bconf_network Configuring Network
  311 
  312  - <b>Use External Network Client</b> \n cb2Bib manages local and
  313     network files in an equivalent manner. Network file retrieving, however,
  314     requires sometimes password and/or cookies administration. The KDE desktop
  315     incorporates <tt>kfmclient</tt> utility. A command <tt>kfmclient
  316     (copy|move|exec) source [destination]</tt> permits copying or moving files,
  317     with <tt>kfmclient</tt> taking care of advanced browsing preferences. By
  318     checking this box, cb2Bib will use the specified file manger client.
  319 
  320  - <b>Use Proxy</b> \n If checked, cb2Bib will access the network
  321     through a proxy host. Set the Host name, the Port, and the proxy Type. A
  322     login dialog will appear if the proxy requires authentication. Login data
  323     is not stored, it must be entered at each session.
  324 
  325  - <b>Perform Network Queries after automatic reference extractions</b> \n
  326     Network queries can be used to complete a partial reference extraction. For
  327     instance, provided a reference 'J. Name, 25, 103' and an appropriate
  328     pattern to extract it, cb2Bib will attempt to complete the reference
  329     automatically. No query is performed if automatic reference extraction was
  330     tagged as BibTeX.
  331 
  332  - <b>Download document if available</b> \n If checked, cb2Bib downloads
  333     document files to the directory specified in <b>Rename and Copy/Move
  334     document files to Directory</b>. See also the file <tt>netqinf.txt</tt> for
  335     details. Download is scheduled and performed once the reference is
  336     accepted, e.g., once it is saved. Note that when document file is local,
  337     e.g., when PDFImport or switch <tt>--doc2bib</tt> is used, no document is
  338     downloaded.
  339 
  340  - <b>Keep Query temporary files (Debug Only)</b> \n cb2Bib may use up to
  341     three temporary files to perform a network query. If this box is checked,
  342     the temporary files are not deleted. This facilitates the testing and
  343     customization of the information file <tt>netqinf.txt</tt>.
  344 
  345 
  346 \section c2bconf_shortcuts Configuring Shortcuts
  347 
  348  - Customizes most key sequences for actions shortcuts. Concretely, cb2Bib
  349     specific actions are configurable, but not standard actions such as 'Open',
  350     'Exit', 'Copy', or 'Paste', which are already predefined to the standard,
  351     specific key sequences for each platform. Shortcuts are customizable for
  352     the cb2Bib main panel, editor, and reference list actions. Single-key
  353     shortcuts, i.e., for manual reference extraction and shortcuts in c2bCiter,
  354     are non-configurable, since they they closely map non-translatable BibTeX
  355     keywords.
  356 
  357 
  358 \section c2bconf_utilities Configuring Utilities
  359 
  360  - <b>To plain text converter</b> \n Selects the external
  361     <tt>some_format_to_text</tt> tool that cb2Bib uses to convert document
  362     files prior to reference extraction and searching. cb2Bib executes the line
  363     command <tt>converter [options] inputfile tmp_output.txt</tt>, where
  364     <tt>[options]</tt> are user defined arguments. As a default, cb2Bib
  365     launches <tt>pdf2cb</tt>, a modified PDF to text utility found in the XPDF
  366     package. Modifications are available at xpdf/ directory in the cb2Bib
  367     sources. Default arguments are <tt>-q -f 1 -l 1</tt> to extract only the
  368     first, title page when used within PDFImport, and <tt>-q</tt>, to convert
  369     the complete document when used within Search in Files. Appropriate for
  370     PDFImport could also be a document metadata extractor. Often metadata
  371     contains structured information regarding document authors, title, and
  372     source. A simple shell script wrapper could be the following
  373     <tt>any2text_search</tt>:
  374 
  375     \verbatim
  376    #!/bin/csh
  377    # Convert documents to text according to filename extension
  378    # any2text_search input_fn.ext output_fn.txt
  379    set ext = $1:e
  380    if ( $ext == 'djvu' ) then
  381       /usr/bin/djvutxt "$1" "$2"
  382       if ($status) exit 1
  383    else if ( $ext == 'chm' ) then
  384       (/usr/local/bin/archmage -c text "$1" "$2") >& /dev/null
  385       if ($status) exit 1
  386    else
  387    # If using pdf2cb
  388       /path/to/pdf2cb -q "$1" "$2"
  389    # If using pdftotex
  390    #  /usr/bin/pdftotext -enc UTF-8 "$1" "$2"
  391       if ($status) exit 1
  392    endif
  393    \endverbatim
  394 
  395     <p>&nbsp;</p>
  396 */
  397 
  398 c2bConfigure::c2bConfigure(QWidget* parentw) : QDialog(parentw)
  399 {
  400     ui.setupUi(this);
  401     setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
  402     setWindowFlags(windowFlags() | Qt::WindowMinMaxButtonsHint);
  403     resize(QSize(1, 1)); // Set it at minimum size
  404     settings = c2bSettingsP;
  405 
  406     for (int i = 0; i < ui.contentsWidget->count(); ++i)
  407         ui.contentsWidget->item(i)->setStatusTip(tr("Configure %1").arg(ui.contentsWidget->item(i)->text()));
  408     connect(ui.contentsWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this,
  409             SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
  410     ui.contentsWidget->setCurrentItem(ui.contentsWidget->item(settings->value("c2bConfigure/CurrentPage", 0).toInt()));
  411     ui.buttonBox->button(QDialogButtonBox::Apply)->setAutoDefault(false);
  412     ui.buttonBox->button(QDialogButtonBox::Cancel)->setAutoDefault(false);
  413     ui.buttonBox->button(QDialogButtonBox::Help)->setAutoDefault(false);
  414     connect(ui.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
  415     connect(ui.buttonBox, SIGNAL(helpRequested()), this, SLOT(help()));
  416     populateFontCombos();
  417 
  418     // Annote
  419     ui.AnnoteCssFile->setText(settings->fileName("c2bAnnote/AnnoteCssFile"));
  420     connect(ui.AnnoteCssDir, SIGNAL(clicked()), this, SLOT(getAnnoteCssFile()));
  421     ui.MathJaxHeaderFile->setText(settings->fileName("c2bAnnote/MathJaxHeaderFile"));
  422     connect(ui.MathJaxDir, SIGNAL(clicked()), this, SLOT(getMathJaxHeaderFile()));
  423     ui.IncludeCSS->setChecked(settings->value("c2bAnnote/IncludeCSS").toBool());
  424     ui.UseRelativeLinks->setChecked(settings->value("c2bAnnote/UseRelativeLinks").toBool());
  425     fontSelection(settings->value("c2bAnnote/Font").value<QFont>(), ui.af_familycombo, ui.af_psizecombo);
  426     fontSelection(settings->value("c2bAnnote/FixedFont").value<QFont>(), ui.aff_familycombo, ui.aff_psizecombo);
  427 #ifndef C2B_USE_QWEB
  428     ui.AnnoteViewerFont->setDisabled(true);
  429     ui.AnnoteViewerFixedFont->setDisabled(true);
  430 #endif
  431 
  432     // BibTeX
  433     ui.CiteIdPattern->setText(settings->value("cb2Bib/CiteIdPattern").toString());
  434     ui.UseAbbreviatedNames->setChecked(!settings->value("cb2Bib/UseFullNames").toBool());
  435     ui.UseFullNames->setChecked(settings->value("cb2Bib/UseFullNames").toBool());
  436     ui.SetJournalsToAbbreviated->setChecked(!settings->value("cb2Bib/SetJournalsToFullname").toBool());
  437     ui.SetJournalsToFullname->setChecked(settings->value("cb2Bib/SetJournalsToFullname").toBool());
  438     ui.PageNumberSeparator->setText(settings->value("cb2Bib/PageNumberSeparator").toString());
  439     ui.CiteCommandPattern->setText(settings->value("cb2Bib/CiteCommandPattern").toString());
  440     ui.ConvertReferenceToLaTeX->setChecked(settings->value("cb2Bib/ConvertReferenceToLaTeX").toBool());
  441     ui.UseDoubleBraces->setChecked(settings->value("cb2Bib/UseDoubleBraces").toBool());
  442     ui.PostprocessMonth->setChecked(settings->value("cb2Bib/PostprocessMonth").toBool());
  443     ui.DoHeuristicGuess->setChecked(settings->value("cb2Bib/DoHeuristicGuess").toBool());
  444     ui.CheckRepeatedOnSave->setChecked(settings->value("cb2Bib/CheckRepeatedOnSave").toBool());
  445     ui.PostprocessBibTeXBin->setText(settings->fileName("cb2Bib/PostprocessBibTeXBin"));
  446     ui.PostprocessBibTeXArg->setText(settings->value("cb2Bib/PostprocessBibTeXArg").toString());
  447     ui.PostprocessBibTeXExt->setText(settings->value("cb2Bib/PostprocessBibTeXExt").toString());
  448     connect(ui.CiteCommandPattern, SIGNAL(statusMessage(QString)), this, SLOT(showMessage(QString)));
  449     connect(ui.PostprocessBibTeXDir, SIGNAL(clicked()), this, SLOT(getPostprocessBibTeXBin()));
  450 
  451     // Clipboard
  452     ui.FindReplaceInput->setChecked(settings->value("cb2Bib/FindReplaceInput").toBool());
  453     connect(ui.FindReplaceInput, SIGNAL(toggled(bool)), this, SLOT(updateFindReplaceInputButtons()));
  454     updateFindReplaceInputButtons();
  455     QStringList FindReplaceInputList(settings->value("cb2Bib/FindReplaceInputList").toStringList());
  456     QStringList::Iterator i = FindReplaceInputList.begin();
  457     while (i != FindReplaceInputList.end())
  458     {
  459         const QStringList spLine((*i).split('|'));
  460         new QTreeWidgetItem(ui.FindReplaceList, spLine);
  461         ++i;
  462     }
  463     connect(ui.FindReplaceList, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(FindReplaceDialog_Edit()));
  464     connect(ui.FindReplaceList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this,
  465             SLOT(updateFindReplaceInputButtons()));
  466     connect(ui.FRNew, SIGNAL(clicked()), this, SLOT(FindReplaceDialog_New()));
  467     connect(ui.FREdit, SIGNAL(clicked()), this, SLOT(FindReplaceDialog_Edit()));
  468     connect(ui.FRDelete, SIGNAL(clicked()), this, SLOT(FindReplaceDialog_Delete()));
  469     ui.AddMetadata->setChecked(settings->value("cb2Bib/AddMetadata").toBool());
  470     const QString PreAppendMetadata(settings->value("cb2Bib/PreAppendMetadata").toString());
  471     if (PreAppendMetadata == "prepend")
  472         ui.Prepend->setChecked(true);
  473     else if (PreAppendMetadata == "append")
  474         ui.Append->setChecked(true);
  475     if (ui.AddMetadata->isChecked())
  476         ui.PreAppendMetadata->setEnabled(true);
  477     else
  478         ui.PreAppendMetadata->setEnabled(false);
  479     connect(ui.AddMetadata, SIGNAL(toggled(bool)), ui.PreAppendMetadata, SLOT(setEnabled(bool)));
  480     ui.PreparserAutomatic->setChecked(settings->value("cb2Bib/PreparserAutomatic").toBool());
  481     ui.PreparserShowLog->setChecked(!settings->value("cb2Bib/PreparserShowLog").toBool());
  482     ui.PreparserBin->setText(settings->fileName("cb2Bib/PreparserBin"));
  483     connect(ui.PreparserDir, SIGNAL(clicked()), this, SLOT(getPreparserBin()));
  484 
  485     // Documents
  486     ui.MovePdf->setChecked(settings->value("cb2Bib/MovePdf").toBool());
  487     ui.PdfDirectory->setText(settings->fileName("cb2Bib/PdfDirectory"));
  488     connect(ui.PdfDir, SIGNAL(clicked()), this, SLOT(getPdfDirectory()));
  489     const QString CopyMovePdf(settings->value("cb2Bib/CopyMovePdf").toString());
  490     if (CopyMovePdf == "copy")
  491         ui.Copy->setChecked(true);
  492     else if (CopyMovePdf == "move")
  493         ui.Move->setChecked(true);
  494     if (ui.MovePdf->isChecked())
  495     {
  496         ui.RenameCopyMovePdf->setEnabled(true);
  497         ui.DocumentIdPatternBox->setEnabled(true);
  498     }
  499     else
  500     {
  501         ui.RenameCopyMovePdf->setEnabled(false);
  502         ui.DocumentIdPatternBox->setEnabled(false);
  503     }
  504     connect(ui.MovePdf, SIGNAL(toggled(bool)), ui.RenameCopyMovePdf, SLOT(setEnabled(bool)));
  505     ui.RelativePdfDirectory->setChecked(settings->value("cb2Bib/RelativePdfDirectory").toBool());
  506     ui.RelativePdfDirectory->setDisabled(settings->isUsbConfiguredMode());
  507     ui.InsertMetadata->setChecked(settings->value("cb2Bib/InsertMetadata").toBool());
  508     ui.DocumentIdPattern->setDocumentIDEdit();
  509     ui.DocumentIdPattern->setText(settings->value("cb2Bib/DocumentIdPattern").toString());
  510     connect(ui.MovePdf, SIGNAL(toggled(bool)), ui.DocumentIdPatternBox, SLOT(setEnabled(bool)));
  511     ui.ExifToolBin->setText(settings->fileName("cb2Bib/ExifToolBin"));
  512     connect(ui.ExifToolDir, SIGNAL(clicked()), this, SLOT(getExifToolBin()));
  513 
  514     // Files
  515     ui.JournalFile->setText(settings->fileName("cb2Bib/JournalFile"));
  516     connect(ui.JournalDir, SIGNAL(clicked()), this, SLOT(getJournalFile()));
  517     ui.RegularExpressionFile->setText(settings->fileName("cb2Bib/RegularExpressionFile"));
  518     connect(ui.RegularExpressionDir, SIGNAL(clicked()), this, SLOT(getRegularExpressionFile()));
  519     ui.NetworkFile->setText(settings->fileName("cb2Bib/NetworkFile"));
  520     connect(ui.NetworkDir, SIGNAL(clicked()), this, SLOT(getNetworkFile()));
  521     ui.BrowserCssFile->setText(settings->fileName("cb2Bib/BrowserCssFile"));
  522     connect(ui.BrowserCssDir, SIGNAL(clicked()), this, SLOT(getBrowserCssFile()));
  523     ui.PosLexiconFile->setText(settings->fileName("cb2Bib/PosLexiconFile"));
  524     connect(ui.PosLexiconDir, SIGNAL(clicked()), this, SLOT(getPosLexiconFile()));
  525     ui.CacheDirectory->setText(settings->fileName("cb2Bib/CacheDirectory"));
  526     connect(ui.CacheDir, SIGNAL(clicked()), this, SLOT(getCacheDirectory()));
  527 
  528     // Fonts
  529     c2bMonoFont = settings->c2bMonoFont;
  530     ui.samplelineedit->setFont(c2bMonoFont);
  531     fontSelection(c2bMonoFont, ui.familycombo, ui.psizecombo);
  532     connect(ui.familycombo, SIGNAL(activated(QString)), this, SLOT(comboFamilyChanged(QString)));
  533     connect(ui.psizecombo, SIGNAL(activated(QString)), this, SLOT(comboSizeChanged(QString)));
  534     colors.loadColors(settings);
  535     QHashIterator<QString, QColor*> cit(colors.colorList);
  536     while (cit.hasNext())
  537     {
  538         cit.next();
  539         QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(cit.key()));
  540         item->setData(0, Qt::DecorationRole, *cit.value());
  541         item->setData(0, Qt::ForegroundRole, *cit.value());
  542         ui.ColorList->insertTopLevelItem(0, item);
  543     }
  544     ui.ColorList->header()->setSortIndicatorShown(false);
  545     ui.ColorList->viewport()->setCursor(QCursor(static_cast<Qt::CursorShape>(Qt::PointingHandCursor)));
  546     ui.ColorList->sortItems(0, Qt::AscendingOrder);
  547     connect(ui.ColorList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(changeContextColor(QTreeWidgetItem*)));
  548     connect(ui.ColorList, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this,
  549             SLOT(changeContextColor(QTreeWidgetItem*)));
  550 
  551     // Network
  552     ui.FmClient->setChecked(settings->value("cb2Bib/FmClient").toBool());
  553     ui.clientGroupBox->setEnabled(settings->value("cb2Bib/FmClient").toBool());
  554     ui.FmClientCopyBin->setText(settings->fileName("cb2Bib/FmClientCopyBin"));
  555     ui.FmClientCopyArg->setText(settings->value("cb2Bib/FmClientCopyArg").toString());
  556     ui.FmClientMoveBin->setText(settings->fileName("cb2Bib/FmClientMoveBin"));
  557     ui.FmClientMoveArg->setText(settings->value("cb2Bib/FmClientMoveArg").toString());
  558     connect(ui.FmClientCopyDir, SIGNAL(clicked()), this, SLOT(getFmClientCopyBin()));
  559     connect(ui.FmClientMoveDir, SIGNAL(clicked()), this, SLOT(getFmClientMoveBin()));
  560     ui.UseProxy->setChecked(settings->value("cb2Bib/UseProxy").toBool());
  561     ui.proxyGroupBox->setEnabled(settings->value("cb2Bib/UseProxy").toBool());
  562     ui.ProxyHostName->setText(settings->value("cb2Bib/ProxyHostName", QString()).toString());
  563     QValidator* proxyPortValidator = new QIntValidator(0, 999999, this);
  564     ui.ProxyPort->setValidator(proxyPortValidator);
  565     ui.ProxyPort->setText(settings->value("cb2Bib/ProxyPort").toString());
  566     ui.ProxyType->setCurrentIndex(settings->value("cb2Bib/ProxyType").toInt());
  567     ui.AutomaticQuery->setChecked(settings->value("cb2Bib/AutomaticQuery").toBool());
  568     ui.AutomaticPdfDownload->setChecked(settings->value("cb2Bib/AutomaticPdfDownload").toBool());
  569     ui.KeepTmpNQFiles->setChecked(settings->value("cb2Bib/KeepTmpNQFiles").toBool());
  570 
  571     // Shortcuts
  572     ui.cb2BibShortcuts->setShortcutNames("Shortcuts/cb2Bib/", settings->shortcutNames());
  573     connect(ui.cb2BibShortcuts, SIGNAL(statusMessage(QString)), this, SLOT(showMessage(QString)));
  574     ui.EditorShortcuts->setShortcutNames("Shortcuts/Editor/", settings->shortcutNames());
  575     connect(ui.EditorShortcuts, SIGNAL(statusMessage(QString)), this, SLOT(showMessage(QString)));
  576 
  577     // Utilities
  578     ui.PdfImportPdf2TextBin->setText(settings->fileName("c2bPdfImport/Pdf2TextBin"));
  579     ui.PdfImportPdf2TextArg->setText(settings->value("c2bPdfImport/Pdf2TextArg").toString());
  580     connect(ui.PdfImportPdf2TextDir, SIGNAL(clicked()), this, SLOT(getPdfImportPdf2TextBin()));
  581     ui.BibSearcherPdf2TextBin->setText(settings->fileName("c2bBibSearcher/Pdf2TextBin"));
  582     ui.BibSearcherPdf2TextArg->setText(settings->value("c2bBibSearcher/Pdf2TextArg").toString());
  583     connect(ui.BibSearcherPdf2TextDir, SIGNAL(clicked()), this, SLOT(getBibSearcherPdf2TextBin()));
  584 }
  585 
  586 c2bConfigure::~c2bConfigure() {}
  587 
  588 
  589 void c2bConfigure::setPage(int index)
  590 {
  591     ui.contentsWidget->setCurrentItem(ui.contentsWidget->item(index));
  592 }
  593 
  594 void c2bConfigure::accept()
  595 {
  596     apply();
  597     QDialog::accept();
  598 }
  599 
  600 void c2bConfigure::apply()
  601 {
  602     settings->setValue("c2bConfigure/CurrentPage", ui.contentsWidget->row(ui.contentsWidget->currentItem()));
  603 
  604     // Annote
  605     settings->setFilename("c2bAnnote/AnnoteCssFile", ui.AnnoteCssFile->text());
  606     settings->setFilename("c2bAnnote/MathJaxHeaderFile", ui.MathJaxHeaderFile->text());
  607     settings->setValue("c2bAnnote/IncludeCSS", ui.IncludeCSS->isChecked());
  608     settings->setValue("c2bAnnote/UseRelativeLinks", ui.UseRelativeLinks->isChecked());
  609     settings->setValue("c2bAnnote/Font", selectedFont(ui.af_familycombo, ui.af_psizecombo));
  610     settings->setValue("c2bAnnote/FixedFont", selectedFont(ui.aff_familycombo, ui.aff_psizecombo));
  611 
  612     // BibTeX
  613     settings->setValue("cb2Bib/CiteIdPattern", ui.CiteIdPattern->text());
  614     settings->setValue("cb2Bib/UseFullNames", ui.UseFullNames->isChecked());
  615     settings->setValue("cb2Bib/SetJournalsToFullname", ui.SetJournalsToFullname->isChecked());
  616     settings->setValue("cb2Bib/PageNumberSeparator", ui.PageNumberSeparator->text());
  617     settings->setValue("cb2Bib/CiteCommandPattern", ui.CiteCommandPattern->text());
  618     settings->setValue("cb2Bib/ConvertReferenceToLaTeX", ui.ConvertReferenceToLaTeX->isChecked());
  619     settings->setValue("cb2Bib/UseDoubleBraces", ui.UseDoubleBraces->isChecked());
  620     settings->setValue("cb2Bib/PostprocessMonth", ui.PostprocessMonth->isChecked());
  621     settings->setValue("cb2Bib/DoHeuristicGuess", ui.DoHeuristicGuess->isChecked());
  622     settings->setValue("cb2Bib/CheckRepeatedOnSave", ui.CheckRepeatedOnSave->isChecked());
  623     settings->setFilename("cb2Bib/PostprocessBibTeXBin", ui.PostprocessBibTeXBin->text());
  624     settings->setValue("cb2Bib/PostprocessBibTeXArg", ui.PostprocessBibTeXArg->text());
  625     settings->setValue("cb2Bib/PostprocessBibTeXExt", ui.PostprocessBibTeXExt->text());
  626 
  627     // Clipboard
  628     QStringList FindReplaceInputList;
  629     QTreeWidgetItemIterator it(ui.FindReplaceList);
  630     while (*it)
  631     {
  632         QTreeWidgetItem* item(*it);
  633         FindReplaceInputList.append(QString("%1|%2|%3").arg(item->text(0), item->text(1), item->text(2)));
  634         ++it;
  635     }
  636     if (FindReplaceInputList.isEmpty())
  637     {
  638         FindReplaceInputList = QString(C2B_FIND_REPLACE_LIST).split("^e");
  639         settings->setValue("cb2Bib/FindReplaceInput", false);
  640     }
  641     else
  642         settings->setValue("cb2Bib/FindReplaceInput", ui.FindReplaceInput->isChecked());
  643     settings->setValue("cb2Bib/FindReplaceInputList", FindReplaceInputList);
  644     QString PreAppendMetadata;
  645     if (ui.Prepend->isChecked())
  646         PreAppendMetadata = "prepend";
  647     else
  648         PreAppendMetadata = "append";
  649     settings->setValue("cb2Bib/PreAppendMetadata", PreAppendMetadata);
  650     settings->setValue("cb2Bib/AddMetadata", ui.AddMetadata->isChecked());
  651     settings->setValue("cb2Bib/PreparserAutomatic", ui.PreparserAutomatic->isChecked());
  652     settings->setValue("cb2Bib/PreparserShowLog", !ui.PreparserShowLog->isChecked());
  653     settings->setFilename("cb2Bib/PreparserBin", ui.PreparserBin->text());
  654 
  655     // Documents
  656     QString CopyMovePdf;
  657     if (ui.Copy->isChecked())
  658         CopyMovePdf = "copy";
  659     else
  660         CopyMovePdf = "move";
  661     settings->setValue("cb2Bib/CopyMovePdf", CopyMovePdf);
  662     settings->setValue("cb2Bib/MovePdf", ui.MovePdf->isChecked());
  663     settings->setFilename("cb2Bib/PdfDirectory", ui.PdfDirectory->text());
  664     settings->setValue("cb2Bib/RelativePdfDirectory", ui.RelativePdfDirectory->isChecked());
  665     settings->setValue("cb2Bib/InsertMetadata", ui.InsertMetadata->isChecked());
  666     settings->setValue("cb2Bib/DocumentIdPattern", ui.DocumentIdPattern->text());
  667     settings->setFilename("cb2Bib/ExifToolBin", ui.ExifToolBin->text());
  668 
  669     // Files
  670     settings->setFilename("cb2Bib/JournalFile", ui.JournalFile->text());
  671     settings->setFilename("cb2Bib/RegularExpressionFile", ui.RegularExpressionFile->text());
  672     settings->setFilename("cb2Bib/NetworkFile", ui.NetworkFile->text());
  673     settings->setFilename("cb2Bib/BrowserCssFile", ui.BrowserCssFile->text());
  674     settings->setFilename("cb2Bib/PosLexiconFile", ui.PosLexiconFile->text());
  675     settings->setFilename("cb2Bib/CacheDirectory", ui.CacheDirectory->text());
  676 
  677     // Fonts
  678     settings->setValue("cb2Bib/MonoFont", c2bMonoFont);
  679     colors.saveColors(settings);
  680 
  681     // Network
  682     settings->setValue("cb2Bib/FmClient", ui.FmClient->isChecked());
  683     settings->setFilename("cb2Bib/FmClientCopyBin", ui.FmClientCopyBin->text());
  684     settings->setFilename("cb2Bib/FmClientMoveBin", ui.FmClientMoveBin->text());
  685     settings->setValue("cb2Bib/FmClientCopyArg", ui.FmClientCopyArg->text().simplified());
  686     settings->setValue("cb2Bib/FmClientMoveArg", ui.FmClientMoveArg->text().simplified());
  687     settings->setValue("cb2Bib/UseProxy", ui.UseProxy->isChecked());
  688     settings->setValue("cb2Bib/ProxyHostName", ui.ProxyHostName->text().trimmed());
  689     settings->setValue("cb2Bib/ProxyPort", ui.ProxyPort->text().trimmed());
  690     settings->setValue("cb2Bib/ProxyType", ui.ProxyType->currentIndex());
  691     settings->setValue("cb2Bib/AutomaticQuery", ui.AutomaticQuery->isChecked());
  692     settings->setValue("cb2Bib/AutomaticPdfDownload", ui.AutomaticPdfDownload->isChecked());
  693     settings->setValue("cb2Bib/KeepTmpNQFiles", ui.KeepTmpNQFiles->isChecked());
  694 
  695     // Shortcuts
  696     settings->setKeysequences(ui.cb2BibShortcuts->modifiedKeysequences());
  697     settings->setKeysequences(ui.EditorShortcuts->modifiedKeysequences());
  698 
  699     // Utilities
  700     settings->setValue("c2bPdfImport/Pdf2TextArg", ui.PdfImportPdf2TextArg->text().simplified());
  701     settings->setFilename("c2bPdfImport/Pdf2TextBin", ui.PdfImportPdf2TextBin->text());
  702     settings->setValue("c2bBibSearcher/Pdf2TextArg", ui.BibSearcherPdf2TextArg->text().simplified());
  703     settings->setFilename("c2bBibSearcher/Pdf2TextBin", ui.BibSearcherPdf2TextBin->text());
  704 
  705     // Notify settings
  706     settings->notify();
  707 }
  708 
  709 void c2bConfigure::comboFamilyChanged(const QString& family)
  710 {
  711     ui.samplelineedit->setFont(QFont(family, ui.psizecombo->currentText().toInt()));
  712     c2bMonoFont.setFamily(family);
  713 }
  714 
  715 void c2bConfigure::comboSizeChanged(const QString& pt)
  716 {
  717     ui.samplelineedit->setFont(QFont(ui.familycombo->currentText(), pt.toInt()));
  718     c2bMonoFont.setPointSize(pt.toInt());
  719 }
  720 
  721 void c2bConfigure::FindReplaceDialog_Delete()
  722 {
  723     QTreeWidgetItem* item(ui.FindReplaceList->currentItem());
  724     delete item;
  725     item = ui.FindReplaceList->currentItem();
  726     if (item)
  727         item->setSelected(true);
  728     updateFindReplaceInputButtons();
  729 }
  730 
  731 void c2bConfigure::FindReplaceDialog_Edit()
  732 {
  733     QTreeWidgetItem* item(ui.FindReplaceList->currentItem());
  734     if (item)
  735     {
  736         c2bConfigureFR* frD(new c2bConfigureFR(item, this));
  737         frD->exec();
  738         delete frD;
  739     }
  740 }
  741 
  742 void c2bConfigure::FindReplaceDialog_New()
  743 {
  744     QStringList newlist;
  745     newlist << QString() << QString() << QString();
  746     QTreeWidgetItem* fri(new QTreeWidgetItem(ui.FindReplaceList, newlist));
  747     c2bConfigureFR* frD(new c2bConfigureFR(fri, this));
  748     if (frD->exec() != QDialog::Accepted)
  749         delete fri;
  750     delete frD;
  751 }
  752 
  753 void c2bConfigure::updateFindReplaceInputButtons()
  754 {
  755     if (!ui.FindReplaceInput->isChecked())
  756     {
  757         ui.FindReplaceList->setEnabled(false);
  758         ui.FRNew->setEnabled(false);
  759         ui.FREdit->setEnabled(false);
  760         ui.FRDelete->setEnabled(false);
  761         return;
  762     }
  763     else
  764     {
  765         ui.FindReplaceList->setEnabled(true);
  766         ui.FRNew->setEnabled(true);
  767         if (ui.FindReplaceList->topLevelItemCount() > 0)
  768         {
  769             ui.FREdit->setEnabled(true);
  770             ui.FRDelete->setEnabled(true);
  771         }
  772         else
  773         {
  774             ui.FREdit->setEnabled(false);
  775             ui.FRDelete->setEnabled(false);
  776         }
  777     }
  778 }
  779 
  780 void c2bConfigure::getAnnoteCssFile()
  781 {
  782     const QString fn(ui.AnnoteCssFile->text());
  783     const QString new_fn(c2bFileDialog::getOpenFilename(this, tr("Select CSS filename"), fn,
  784                          tr("Cascading Style Sheets (*.css);;All (*)")));
  785     if (!new_fn.isEmpty())
  786         ui.AnnoteCssFile->setText(new_fn);
  787 }
  788 
  789 void c2bConfigure::getMathJaxHeaderFile()
  790 {
  791     const QString fn(ui.MathJaxHeaderFile->text());
  792     const QString new_fn(
  793         c2bFileDialog::getOpenFilename(this, tr("Select MathJax filename"), fn, tr("HTML Header (*.html);;All (*)")));
  794     if (!new_fn.isEmpty())
  795         ui.MathJaxHeaderFile->setText(new_fn);
  796 }
  797 
  798 void c2bConfigure::getJournalFile()
  799 {
  800     const QString fn(ui.JournalFile->text());
  801     const QString new_fn(c2bFileDialog::getOpenFilename(this, tr("Select a filename (Restart to apply changes)"), fn,
  802                          tr("cb2Bib Journal Lists (*.txt);;All (*)")));
  803     if (!new_fn.isEmpty())
  804         ui.JournalFile->setText(new_fn);
  805 }
  806 
  807 void c2bConfigure::getRegularExpressionFile()
  808 {
  809     const QString fn(ui.RegularExpressionFile->text());
  810     const QString new_fn(c2bFileDialog::getFilename(this, QString(), fn, tr("cb2Bib RegExp Lists (*.txt);;All (*)")));
  811     if (!new_fn.isEmpty())
  812         ui.RegularExpressionFile->setText(new_fn);
  813 }
  814 
  815 void c2bConfigure::getNetworkFile()
  816 {
  817     const QString fn(ui.NetworkFile->text());
  818     const QString new_fn(
  819         c2bFileDialog::getFilename(this, QString(), fn, tr("cb2Bib Network Query Info (*.txt);;All (*)")));
  820     if (!new_fn.isEmpty())
  821         ui.NetworkFile->setText(new_fn);
  822 }
  823 
  824 void c2bConfigure::getBrowserCssFile()
  825 {
  826     const QString fn(ui.BrowserCssFile->text());
  827     const QString new_fn(c2bFileDialog::getOpenFilename(this,
  828                          tr("Select a filename (Restart browser to apply changes)"), fn,
  829                          tr("Cascading Style Sheets (*.css);;All (*)")));
  830     if (!new_fn.isEmpty())
  831         ui.BrowserCssFile->setText(new_fn);
  832 }
  833 
  834 void c2bConfigure::getFmClientCopyBin()
  835 {
  836     const QString fn(ui.FmClientCopyBin->text());
  837     const QString new_fn(c2bFileDialog::getOpenFilename(this, QString(), fn, tr("File Manager Client executable (*)")));
  838     if (!new_fn.isEmpty())
  839         ui.FmClientCopyBin->setText(new_fn);
  840 }
  841 
  842 void c2bConfigure::getPreparserBin()
  843 {
  844     const QString fn(ui.PreparserBin->text());
  845     const QString new_fn(c2bFileDialog::getOpenFilename(this, QString(), fn, tr("External Parser executable (*)")));
  846     if (!new_fn.isEmpty())
  847         ui.PreparserBin->setText(new_fn);
  848 }
  849 
  850 void c2bConfigure::getFmClientMoveBin()
  851 {
  852     const QString fn(ui.FmClientMoveBin->text());
  853     const QString new_fn(c2bFileDialog::getOpenFilename(this, QString(), fn, tr("File Manager Client executable (*)")));
  854     if (!new_fn.isEmpty())
  855         ui.FmClientMoveBin->setText(new_fn);
  856 }
  857 
  858 void c2bConfigure::getPostprocessBibTeXBin()
  859 {
  860     const QString fn(ui.PostprocessBibTeXBin->text());
  861     const QString new_fn(c2bFileDialog::getOpenFilename(this, QString(), fn, tr("BibTeX Postprocess executable (*)")));
  862     if (!new_fn.isEmpty())
  863         ui.PostprocessBibTeXBin->setText(new_fn);
  864 }
  865 
  866 void c2bConfigure::getPdfImportPdf2TextBin()
  867 {
  868     const QString fn(ui.PdfImportPdf2TextBin->text());
  869     const QString new_fn(c2bFileDialog::getOpenFilename(this, QString(), fn, tr("PDF to text converter (*)")));
  870     if (!new_fn.isEmpty())
  871         ui.PdfImportPdf2TextBin->setText(new_fn);
  872 }
  873 
  874 void c2bConfigure::getBibSearcherPdf2TextBin()
  875 {
  876     const QString fn(ui.BibSearcherPdf2TextBin->text());
  877     const QString new_fn(c2bFileDialog::getOpenFilename(this, QString(), fn, tr("PDF to text converter (*)")));
  878     if (!new_fn.isEmpty())
  879         ui.BibSearcherPdf2TextBin->setText(new_fn);
  880 }
  881 
  882 void c2bConfigure::getExifToolBin()
  883 {
  884     const QString fn(ui.ExifToolBin->text());
  885     const QString new_fn(c2bFileDialog::getOpenFilename(this, QString(), fn, tr("ExifTool (*)")));
  886     if (!new_fn.isEmpty())
  887         ui.ExifToolBin->setText(new_fn);
  888 }
  889 
  890 void c2bConfigure::getPosLexiconFile()
  891 {
  892     const QString fn(ui.PosLexiconFile->text());
  893     const QString new_fn(
  894         c2bFileDialog::getFilename(this, QString(), fn, tr("cb2Bib Part Of Speech Lexicon (*.pos);;All (*)")));
  895     if (!new_fn.isEmpty())
  896         ui.PosLexiconFile->setText(new_fn);
  897 }
  898 
  899 void c2bConfigure::getCacheDirectory()
  900 {
  901     const QString new_dir(
  902         c2bFileDialog::getExistingDirectory(this, tr("Select a cache directory"), ui.CacheDirectory->text()));
  903     if (!new_dir.isEmpty())
  904         ui.CacheDirectory->setText(new_dir);
  905 }
  906 
  907 void c2bConfigure::getPdfDirectory()
  908 {
  909     const QString dir(c2bUtils::documentAbsoluteName(ui.RelativePdfDirectory->isChecked(),
  910                       settings->fileName("cb2Bib/BibTeXFile"), ui.PdfDirectory->text(),
  911                       QString()));
  912     QString new_dir(c2bFileDialog::getExistingDirectory(this, tr("Select documents directory"), dir));
  913     if (!new_dir.isEmpty())
  914     {
  915         new_dir = c2bUtils::documentDirName(ui.RelativePdfDirectory->isChecked(),
  916                                             settings->fileName("cb2Bib/BibTeXFile"), new_dir);
  917         ui.PdfDirectory->setText(new_dir);
  918     }
  919 }
  920 
  921 void c2bConfigure::populateFontCombos()
  922 {
  923     QFontDatabase db;
  924     QList<int> sizes(db.standardSizes());
  925     QList<int>::Iterator it(sizes.begin());
  926     while (it != sizes.end())
  927     {
  928         ui.psizecombo->insertItem(0, QString::number(*it));
  929         ui.af_psizecombo->insertItem(0, QString::number(*it));
  930         ui.aff_psizecombo->insertItem(0, QString::number(*it));
  931         it++;
  932     }
  933 }
  934 
  935 void c2bConfigure::fontSelection(const QFont& f, QFontComboBox* fc, QComboBox* sc)
  936 {
  937     fc->setCurrentFont(f);
  938     const int p_font_size(f.pointSize());
  939     int i(0);
  940     while (i < sc->count())
  941     {
  942         if (sc->itemText(i) == QString::number(p_font_size))
  943         {
  944             sc->setCurrentIndex(i);
  945             break;
  946         }
  947         i++;
  948     }
  949 }
  950 
  951 QFont c2bConfigure::selectedFont(QFontComboBox* fc, QComboBox* sc) const
  952 {
  953     QFont f(fc->currentFont());
  954     f.setPointSize(sc->currentText().toInt());
  955     return f;
  956 }
  957 
  958 void c2bConfigure::changeContextColor(QTreeWidgetItem* item)
  959 {
  960     const QColor newColor(QColorDialog::getColor(item->foreground(0).color(), this));
  961     if (newColor.isValid())
  962     {
  963         item->setData(0, Qt::ForegroundRole, newColor);
  964         item->setData(0, Qt::DecorationRole, newColor);
  965         colors.updateColor(newColor, item->text(0));
  966     }
  967 }
  968 
  969 void c2bConfigure::changePage(QListWidgetItem* current, QListWidgetItem* previous)
  970 {
  971     if (!current)
  972         current = previous;
  973     setWindowTitle(tr("Configure %1 - cb2Bib").arg(current->text()));
  974     ui.pagesWidget->setCurrentIndex(ui.contentsWidget->row(current));
  975 }
  976 
  977 void c2bConfigure::showMessage(const QString& ms)
  978 {
  979     ui.statusBar->showMessage(ms, C2B_MESSAGE_TIME);
  980 }
  981 
  982 bool c2bConfigure::event(QEvent* qevent)
  983 {
  984     if (qevent->type() == QEvent::StatusTip)
  985     {
  986         ui.statusBar->showMessage(static_cast<QStatusTipEvent*>(qevent)->tip());
  987         return true;
  988     }
  989     else
  990         return QDialog::event(qevent);
  991 }
  992 
  993 void c2bConfigure::help()
  994 {
  995     c2bUtils::displayHelp("https://www.molspaces.com/cb2bib/doc/configuration/#configuring-" +
  996                           ui.contentsWidget->currentItem()->text().toLower());
  997 }