]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiPrefs.cpp
Improve wording (#10670)
[lyx.git] / src / frontends / qt4 / GuiPrefs.cpp
index 3075e3c39840a63b0ed8995627f4dfe090c3f4dc..bacf17ac57de7ce9e0b97c2d2689614673588c5d 100644 (file)
@@ -20,6 +20,7 @@
 #include "GuiFontLoader.h"
 #include "GuiKeySymbol.h"
 #include "qt_helpers.h"
+#include "Validator.h"
 
 #include "Author.h"
 #include "BufferList.h"
 #include "LyXAction.h"
 #include "LyX.h"
 #include "PanelStack.h"
-#include "paper.h"
 #include "Session.h"
 #include "SpellChecker.h"
 
 #include "support/debug.h"
 #include "support/FileName.h"
 #include "support/filetools.h"
-#include "support/foreach.h"
 #include "support/gettext.h"
+#include "support/lassert.h"
 #include "support/lstrings.h"
+#include "support/Messages.h"
 #include "support/os.h"
 #include "support/Package.h"
 
@@ -71,6 +72,7 @@
 #include <iomanip>
 #include <sstream>
 #include <algorithm>
+#include <math.h>
 
 using namespace Ui;
 
@@ -90,7 +92,7 @@ namespace frontend {
 /** Launch a file dialog and return the chosen file.
        filename: a suggested filename.
        title: the title of the dialog.
-       pattern: *.ps etc.
+       filters: *.ps etc.
        dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
 */
 QString browseFile(QString const & filename,
@@ -109,7 +111,7 @@ QString browseFile(QString const & filename,
        else if(!fallback_dir.isEmpty())
                lastPath = fallback_dir;
 
-       FileDialog dlg(title, LFUN_SELECT_FILE_SYNC);
+       FileDialog dlg(title);
        dlg.setButton2(label1, dir1);
        dlg.setButton2(label2, dir2);
 
@@ -180,7 +182,7 @@ QString browseDir(QString const & pathname,
        if (!pathname.isEmpty())
                lastPath = onlyPath(pathname);
 
-       FileDialog dlg(title, LFUN_SELECT_FILE_SYNC);
+       FileDialog dlg(title);
        dlg.setButton1(label1, dir1);
        dlg.setButton2(label2, dir2);
 
@@ -194,19 +196,18 @@ QString browseDir(QString const & pathname,
 } // namespace frontend
 
 
-QString browseRelFile(QString const & filename, QString const & refpath,
+QString browseRelToParent(QString const & filename, QString const & relpath,
        QString const & title, QStringList const & filters, bool save,
        QString const & label1, QString const & dir1,
        QString const & label2, QString const & dir2)
 {
-       QString const fname = makeAbsPath(filename, refpath);
-
+       QString const fname = makeAbsPath(filename, relpath);
 
        QString const outname =
                frontend::browseFile(fname, title, filters, save, label1, dir1, label2, dir2);
 
        QString const reloutname =
-               toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(refpath)));
+               toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(relpath)));
 
        if (reloutname.startsWith("../"))
                return outname;
@@ -215,6 +216,29 @@ QString browseRelFile(QString const & filename, QString const & refpath,
 }
 
 
+QString browseRelToSub(QString const & filename, QString const & relpath,
+       QString const & title, QStringList const & filters, bool save,
+       QString const & label1, QString const & dir1,
+       QString const & label2, QString const & dir2)
+{
+       QString const fname = makeAbsPath(filename, relpath);
+
+       QString const outname =
+               frontend::browseFile(fname, title, filters, save, label1, dir1, label2, dir2);
+
+       QString const reloutname =
+               toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(relpath)));
+
+       QString testname = reloutname;
+       testname.remove(QRegExp("^(\\.\\./)+"));
+
+       if (testname.contains("/"))
+               return outname;
+       else
+               return reloutname;
+}
+
+
 
 /////////////////////////////////////////////////////////////////////
 //
@@ -224,11 +248,11 @@ QString browseRelFile(QString const & filename, QString const & refpath,
 
 namespace frontend {
 
-string const catLookAndFeel = N_("Look & Feel");
-string const catEditing = N_("Editing");
-string const catLanguage = N_("Language Settings");
-string const catOutput = N_("Output");
-string const catFiles = N_("File Handling");
+QString const catLookAndFeel = N_("Look & Feel");
+QString const catEditing = N_("Editing");
+QString const catLanguage = N_("Language Settings");
+QString const catOutput = N_("Output");
+QString const catFiles = N_("File Handling");
 
 static void parseFontName(QString const & mangled0,
        string & name, string & foundry)
@@ -289,7 +313,6 @@ static void setComboxFont(QComboBox * cb, string const & family,
        // for bug 1063.
 
        QFont font;
-       font.setKerning(false);
 
        QString const font_family = toqstr(family);
        if (font_family == guiApp->romanFontName()) {
@@ -362,10 +385,14 @@ QValidator::State StrftimeValidator::validate(QString & input, int & /*pos*/) co
 /////////////////////////////////////////////////////////////////////
 
 PrefOutput::PrefOutput(GuiPreferences * form)
-       : PrefModule(qt_(catOutput), qt_("General"), form)
+       : PrefModule(catOutput, N_("General"), form)
 {
        setupUi(this);
+
        DateED->setValidator(new StrftimeValidator(DateED));
+       dviCB->setValidator(new NoNewLineValidator(dviCB));
+       pdfCB->setValidator(new NoNewLineValidator(pdfCB));
+
        connect(DateED, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
        connect(plaintextLinelengthSB, SIGNAL(valueChanged(int)),
@@ -376,16 +403,29 @@ PrefOutput::PrefOutput(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(pdfCB, SIGNAL(editTextChanged(QString)),
                this, SIGNAL(changed()));
+       connect(printerPaperTypeED, SIGNAL(textChanged(QString)),
+               this, SIGNAL(changed()));
+       connect(printerLandscapeED, SIGNAL(textChanged(QString)),
+               this, SIGNAL(changed()));
+       connect(printerPaperSizeED, SIGNAL(textChanged(QString)),
+               this, SIGNAL(changed()));
+
+       printerPaperTypeED->setValidator(new NoNewLineValidator(printerPaperTypeED));
+       printerLandscapeED->setValidator(new NoNewLineValidator(printerLandscapeED));
+       printerPaperSizeED->setValidator(new NoNewLineValidator(printerPaperSizeED));
+
        dviCB->addItem("");
        dviCB->addItem("xdvi -sourceposition '$$n:\\ $$t' $$o");
        dviCB->addItem("yap -1 -s \"$$n $$t\" $$o");
-       dviCB->addItem("okular --unique \"file:$$o#src:$$n $$t\"");
-       dviCB->addItem("synctex view -i $$n:0:$$t -o $$o -x \"evince -p %{page+1} $$o\"");
+       dviCB->addItem("okular --unique \"$$o#src:$$n $$f\"");
+       dviCB->addItem("synctex view -i $$n:0:$$t -o $$o -x \"evince -i %{page+1} $$o\"");
        pdfCB->addItem("");
        pdfCB->addItem("CMCDDE SUMATRA control [ForwardSearch(\\\"$$o\\\",\\\"$$t\\\",$$n,0,0,1)]");
+       pdfCB->addItem("SumatraPDF -reuse-instance \"$$o\" -forward-search \"$$t\" $$n");
        pdfCB->addItem("synctex view -i $$n:0:$$t -o $$o -x \"xpdf -raise -remote $$t.tmp $$o %{page+1}\"");
-       pdfCB->addItem("okular --unique \"file:$$o#src:$$n $$t\"");
-       pdfCB->addItem("synctex view -i $$n:0:$$t -o $$o -x \"evince -p %{page+1} $$o\"");
+       pdfCB->addItem("okular --unique \"$$o#src:$$n $$f\"");
+       pdfCB->addItem("qpdfview --unique \"$$o#src:$$f:$$n:0\"");
+       pdfCB->addItem("synctex view -i $$n:0:$$t -o $$o -x \"evince -i %{page+1} $$o\"");
        pdfCB->addItem("/Applications/Skim.app/Contents/SharedSupport/displayline $$n $$o $$t");
 }
 
@@ -400,7 +440,7 @@ void PrefOutput::on_DateED_textChanged(const QString &)
 }
 
 
-void PrefOutput::apply(LyXRC & rc) const
+void PrefOutput::applyRC(LyXRC & rc) const
 {
        rc.date_insert_format = fromqstr(DateED->text());
        rc.plaintext_linelen = plaintextLinelengthSB->value();
@@ -418,10 +458,14 @@ void PrefOutput::apply(LyXRC & rc) const
                rc.export_overwrite = ALL_FILES;
                break;
        }
+
+       rc.print_paper_flag = fromqstr(printerPaperTypeED->text());
+       rc.print_landscape_flag = fromqstr(printerLandscapeED->text());
+       rc.print_paper_dimension_flag = fromqstr(printerPaperSizeED->text());
 }
 
 
-void PrefOutput::update(LyXRC const & rc)
+void PrefOutput::updateRC(LyXRC const & rc)
 {
        DateED->setText(toqstr(rc.date_insert_format));
        plaintextLinelengthSB->setValue(rc.plaintext_linelen);
@@ -439,6 +483,10 @@ void PrefOutput::update(LyXRC const & rc)
                overwriteCO->setCurrentIndex(2);
                break;
        }
+
+       printerPaperTypeED->setText(toqstr(rc.print_paper_flag));
+       printerLandscapeED->setText(toqstr(rc.print_landscape_flag));
+       printerPaperSizeED->setText(toqstr(rc.print_paper_dimension_flag));
 }
 
 
@@ -449,7 +497,7 @@ void PrefOutput::update(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 PrefInput::PrefInput(GuiPreferences * form)
-       : PrefModule(qt_(catEditing), qt_("Keyboard/Mouse"), form)
+       : PrefModule(catEditing, N_("Keyboard/Mouse"), form)
 {
        setupUi(this);
 
@@ -467,10 +515,12 @@ PrefInput::PrefInput(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(dontswapCB, SIGNAL(toggled(bool)),
                this, SIGNAL(changed()));
+       connect(mmPasteCB, SIGNAL(toggled(bool)),
+               this, SIGNAL(changed()));
 
        // reveal checkbox for switching Ctrl and Meta on Mac:
        bool swapcb = false;
-#ifdef Q_WS_MACX
+#ifdef Q_OS_MAC
 #if QT_VERSION > 0x040600
        swapcb = true;
 #endif
@@ -479,7 +529,7 @@ PrefInput::PrefInput(GuiPreferences * form)
 }
 
 
-void PrefInput::apply(LyXRC & rc) const
+void PrefInput::applyRC(LyXRC & rc) const
 {
        // FIXME: can derive CB from the two EDs
        rc.use_kbmap = keymapCB->isChecked();
@@ -502,10 +552,11 @@ void PrefInput::apply(LyXRC & rc) const
                rc.scroll_wheel_zoom = LyXRC::SCROLL_WHEEL_ZOOM_OFF;
        }
        rc.mac_dontswap_ctrl_meta  = dontswapCB->isChecked();
+       rc.mouse_middlebutton_paste = mmPasteCB->isChecked();
 }
 
 
-void PrefInput::update(LyXRC const & rc)
+void PrefInput::updateRC(LyXRC const & rc)
 {
        // FIXME: can derive CB from the two EDs
        keymapCB->setChecked(rc.use_kbmap);
@@ -530,6 +581,7 @@ void PrefInput::update(LyXRC const & rc)
                break;
        }
        dontswapCB->setChecked(rc.mac_dontswap_ctrl_meta);
+       mmPasteCB->setChecked(rc.mouse_middlebutton_paste);
 }
 
 
@@ -570,8 +622,8 @@ void PrefInput::on_scrollzoomEnableCB_toggled(bool enabled)
 {
        scrollzoomValueCO->setEnabled(enabled);
 }
-       
-       
+
+
 /////////////////////////////////////////////////////////////////////
 //
 // PrefCompletion
@@ -579,7 +631,7 @@ void PrefInput::on_scrollzoomEnableCB_toggled(bool enabled)
 /////////////////////////////////////////////////////////////////////
 
 PrefCompletion::PrefCompletion(GuiPreferences * form)
-       : PrefModule(qt_(catEditing), qt_("Input Completion"), form)
+       : PrefModule(catEditing, N_("Input Completion"), form)
 {
        setupUi(this);
 
@@ -603,6 +655,8 @@ PrefCompletion::PrefCompletion(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(cursorTextCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
+       connect(minlengthSB, SIGNAL(valueChanged(int)),
+                       this, SIGNAL(changed()));
 }
 
 
@@ -625,7 +679,7 @@ void PrefCompletion::enableCB()
 }
 
 
-void PrefCompletion::apply(LyXRC & rc) const
+void PrefCompletion::applyRC(LyXRC & rc) const
 {
        rc.completion_inline_delay = inlineDelaySB->value();
        rc.completion_inline_math = inlineMathCB->isChecked();
@@ -638,10 +692,11 @@ void PrefCompletion::apply(LyXRC & rc) const
        rc.completion_cursor_text = cursorTextCB->isChecked();
        rc.completion_popup_after_complete =
                popupAfterCompleteCB->isChecked();
+       rc.completion_minlength = minlengthSB->value();
 }
 
 
-void PrefCompletion::update(LyXRC const & rc)
+void PrefCompletion::updateRC(LyXRC const & rc)
 {
        inlineDelaySB->setValue(rc.completion_inline_delay);
        inlineMathCB->setChecked(rc.completion_inline_math);
@@ -653,7 +708,8 @@ void PrefCompletion::update(LyXRC const & rc)
        popupTextCB->setChecked(rc.completion_popup_text);
        cursorTextCB->setChecked(rc.completion_cursor_text);
        popupAfterCompleteCB->setChecked(rc.completion_popup_after_complete);
-        enableCB();
+       enableCB();
+       minlengthSB->setValue(rc.completion_minlength);
 }
 
 
@@ -665,9 +721,19 @@ void PrefCompletion::update(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 PrefLatex::PrefLatex(GuiPreferences * form)
-       : PrefModule(qt_(catOutput), qt_("LaTeX"), form)
+       : PrefModule(catOutput, N_("LaTeX"), form)
 {
        setupUi(this);
+
+       latexEncodingED->setValidator(new NoNewLineValidator(latexEncodingED));
+       latexDviPaperED->setValidator(new NoNewLineValidator(latexDviPaperED));
+       latexBibtexED->setValidator(new NoNewLineValidator(latexBibtexED));
+       latexJBibtexED->setValidator(new NoNewLineValidator(latexJBibtexED));
+       latexIndexED->setValidator(new NoNewLineValidator(latexIndexED));
+       latexJIndexED->setValidator(new NoNewLineValidator(latexJIndexED));
+       latexNomenclED->setValidator(new NoNewLineValidator(latexNomenclED));
+       latexChecktexED->setValidator(new NoNewLineValidator(latexChecktexED));
+
        connect(latexEncodingCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
        connect(latexEncodingED, SIGNAL(textChanged(QString)),
@@ -678,6 +744,8 @@ PrefLatex::PrefLatex(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(latexBibtexED, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
+       connect(latexJBibtexCO, SIGNAL(activated(int)),
+               this, SIGNAL(changed()));
        connect(latexJBibtexED, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
        connect(latexIndexCO, SIGNAL(activated(int)),
@@ -690,7 +758,7 @@ PrefLatex::PrefLatex(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(latexDviPaperED, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
-       connect(latexPaperSizeCO, SIGNAL(activated(int)),
+       connect(latexNomenclED, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
 
 #if defined(__CYGWIN__) || defined(_WIN32)
@@ -714,7 +782,7 @@ void PrefLatex::on_latexBibtexCO_activated(int n)
        QString const bibtex = latexBibtexCO->itemData(n).toString();
        if (bibtex.isEmpty()) {
                latexBibtexED->clear();
-               latexBibtexOptionsLA->setText(qt_("Co&mmand:"));
+               latexBibtexOptionsLA->setText(qt_("C&ommand:"));
                return;
        }
        for (LyXRC::CommandSet::const_iterator it = bibtex_alternatives.begin();
@@ -734,6 +802,31 @@ void PrefLatex::on_latexBibtexCO_activated(int n)
 }
 
 
+void PrefLatex::on_latexJBibtexCO_activated(int n)
+{
+       QString const jbibtex = latexJBibtexCO->itemData(n).toString();
+       if (jbibtex.isEmpty()) {
+               latexJBibtexED->clear();
+               latexJBibtexOptionsLA->setText(qt_("Co&mmand:"));
+               return;
+       }
+       for (LyXRC::CommandSet::const_iterator it = jbibtex_alternatives.begin();
+            it != jbibtex_alternatives.end(); ++it) {
+               QString const bib = toqstr(*it);
+               int ind = bib.indexOf(" ");
+               QString sel_command = bib.left(ind);
+               QString sel_options = ind < 0 ? QString() : bib.mid(ind + 1);
+               if (jbibtex == sel_command) {
+                       if (ind < 0)
+                               latexJBibtexED->clear();
+                       else
+                               latexJBibtexED->setText(sel_options.trimmed());
+               }
+       }
+       latexJBibtexOptionsLA->setText(qt_("Opt&ions:"));
+}
+
+
 void PrefLatex::on_latexIndexCO_activated(int n)
 {
        QString const index = latexIndexCO->itemData(n).toString();
@@ -759,7 +852,7 @@ void PrefLatex::on_latexIndexCO_activated(int n)
 }
 
 
-void PrefLatex::apply(LyXRC & rc) const
+void PrefLatex::applyRC(LyXRC & rc) const
 {
        // If bibtex is not empty, bibopt contains the options, otherwise
        // it is a customized bibtex command with options.
@@ -773,6 +866,18 @@ void PrefLatex::apply(LyXRC & rc) const
        else
                rc.bibtex_command = fromqstr(bibtex) + " " + fromqstr(bibopt);
 
+       // If jbibtex is not empty, jbibopt contains the options, otherwise
+       // it is a customized bibtex command with options.
+       QString const jbibtex = latexJBibtexCO->itemData(
+               latexJBibtexCO->currentIndex()).toString();
+       QString const jbibopt = latexJBibtexED->text();
+       if (jbibtex.isEmpty())
+               rc.jbibtex_command = fromqstr(jbibopt);
+       else if (jbibopt.isEmpty())
+               rc.jbibtex_command = fromqstr(jbibtex);
+       else
+               rc.jbibtex_command = fromqstr(jbibtex) + " " + fromqstr(jbibopt);
+
        // If index is not empty, idxopt contains the options, otherwise
        // it is a customized index command with options.
        QString const index = latexIndexCO->itemData(
@@ -790,23 +895,21 @@ void PrefLatex::apply(LyXRC & rc) const
        else
                rc.fontenc = "default";
        rc.chktex_command = fromqstr(latexChecktexED->text());
-       rc.jbibtex_command = fromqstr(latexJBibtexED->text());
        rc.jindex_command = fromqstr(latexJIndexED->text());
        rc.nomencl_command = fromqstr(latexNomenclED->text());
        rc.auto_reset_options = latexAutoresetCB->isChecked();
        rc.view_dvi_paper_option = fromqstr(latexDviPaperED->text());
-       rc.default_papersize =
-               form_->toPaperSize(latexPaperSizeCO->currentIndex());
 #if defined(__CYGWIN__) || defined(_WIN32)
        rc.windows_style_tex_paths = pathCB->isChecked();
 #endif
 }
 
 
-void PrefLatex::update(LyXRC const & rc)
+void PrefLatex::updateRC(LyXRC const & rc)
 {
        latexBibtexCO->clear();
 
+       latexBibtexCO->addItem(qt_("Automatic"), "automatic");
        latexBibtexCO->addItem(qt_("Custom"), QString());
        for (LyXRC::CommandSet::const_iterator it = rc.bibtex_alternatives.begin();
                             it != rc.bibtex_alternatives.end(); ++it) {
@@ -829,7 +932,35 @@ void PrefLatex::update(LyXRC const & rc)
        } else {
                latexBibtexED->setText(toqstr(rc.bibtex_command));
                latexBibtexCO->setCurrentIndex(0);
-               latexBibtexOptionsLA->setText(qt_("Co&mmand:"));
+               latexBibtexOptionsLA->setText(qt_("C&ommand:"));
+       }
+
+       latexJBibtexCO->clear();
+
+       latexJBibtexCO->addItem(qt_("Automatic"), "automatic");
+       latexJBibtexCO->addItem(qt_("Custom"), QString());
+       for (LyXRC::CommandSet::const_iterator it = rc.jbibtex_alternatives.begin();
+                            it != rc.jbibtex_alternatives.end(); ++it) {
+               QString const command = toqstr(*it).left(toqstr(*it).indexOf(" "));
+               latexJBibtexCO->addItem(command, command);
+       }
+
+       jbibtex_alternatives = rc.jbibtex_alternatives;
+
+       QString const jbib = toqstr(rc.jbibtex_command);
+       ind = jbib.indexOf(" ");
+       sel_command = jbib.left(ind);
+       sel_options = ind < 0 ? QString() : jbib.mid(ind + 1);
+
+       pos = latexJBibtexCO->findData(sel_command);
+       if (pos != -1) {
+               latexJBibtexCO->setCurrentIndex(pos);
+               latexJBibtexED->setText(sel_options.trimmed());
+               latexJBibtexOptionsLA->setText(qt_("Opt&ions:"));
+       } else {
+               latexJBibtexED->setText(toqstr(rc.bibtex_command));
+               latexJBibtexCO->setCurrentIndex(0);
+               latexJBibtexOptionsLA->setText(qt_("Co&mmand:"));
        }
 
        latexIndexCO->clear();
@@ -868,13 +999,10 @@ void PrefLatex::update(LyXRC const & rc)
                latexEncodingED->setText(toqstr(rc.fontenc));
        }
        latexChecktexED->setText(toqstr(rc.chktex_command));
-       latexJBibtexED->setText(toqstr(rc.jbibtex_command));
        latexJIndexED->setText(toqstr(rc.jindex_command));
        latexNomenclED->setText(toqstr(rc.nomencl_command));
        latexAutoresetCB->setChecked(rc.auto_reset_options);
        latexDviPaperED->setText(toqstr(rc.view_dvi_paper_option));
-       latexPaperSizeCO->setCurrentIndex(
-               form_->fromPaperSize(rc.default_papersize));
 #if defined(__CYGWIN__) || defined(_WIN32)
        pathCB->setChecked(rc.windows_style_tex_paths);
 #endif
@@ -888,7 +1016,7 @@ void PrefLatex::update(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 PrefScreenFonts::PrefScreenFonts(GuiPreferences * form)
-       : PrefModule(qt_(catLookAndFeel), qt_("Screen Fonts"), form)
+       : PrefModule(catLookAndFeel, N_("Screen Fonts"), form)
 {
        setupUi(this);
 
@@ -950,7 +1078,7 @@ PrefScreenFonts::PrefScreenFonts(GuiPreferences * form)
 }
 
 
-void PrefScreenFonts::apply(LyXRC & rc) const
+void PrefScreenFonts::applyRC(LyXRC & rc) const
 {
        LyXRC const oldrc = rc;
 
@@ -989,7 +1117,7 @@ void PrefScreenFonts::apply(LyXRC & rc) const
 }
 
 
-void PrefScreenFonts::update(LyXRC const & rc)
+void PrefScreenFonts::updateRC(LyXRC const & rc)
 {
        setComboxFont(screenRomanCO, rc.roman_font_name,
                        rc.roman_font_foundry);
@@ -1006,7 +1134,7 @@ void PrefScreenFonts::update(LyXRC const & rc)
        updateScreenFontSizes(rc);
 
        pixmapCacheCB->setChecked(rc.use_pixmap_cache);
-#if defined(Q_WS_X11)
+#if defined(Q_WS_X11) || defined(QPA_XCB)
        pixmapCacheCB->setEnabled(false);
 #endif
 
@@ -1052,20 +1180,9 @@ void PrefScreenFonts::selectTypewriter(const QString & name)
 //
 /////////////////////////////////////////////////////////////////////
 
-namespace {
-
-struct ColorSorter
-{
-       bool operator()(ColorCode lhs, ColorCode rhs) const {
-               return 
-                       compare_no_case(lcolor.getGUIName(lhs), lcolor.getGUIName(rhs)) < 0;
-       }
-};
-
-} // namespace anon
 
 PrefColors::PrefColors(GuiPreferences * form)
-       : PrefModule(qt_(catLookAndFeel), qt_("Colors"), form)
+       : PrefModule(catLookAndFeel, N_("Colors"), form)
 {
        setupUi(this);
 
@@ -1076,22 +1193,31 @@ PrefColors::PrefColors(GuiPreferences * form)
        for (int i = 0; i < Color_ignore; ++i) {
                ColorCode lc = static_cast<ColorCode>(i);
                if (lc == Color_none
-                       || lc == Color_black
-                       || lc == Color_white
-                       || lc == Color_red
-                       || lc == Color_green
-                       || lc == Color_blue
-                       || lc == Color_cyan
-                       || lc == Color_magenta
-                       || lc == Color_yellow
-                       || lc == Color_inherit
-                       || lc == Color_ignore
-                       || lc == Color_greyedouttext
-                       || lc == Color_shadedbg) continue;
-
+                   || lc == Color_black
+                   || lc == Color_white
+                   || lc == Color_blue
+                   || lc == Color_brown
+                   || lc == Color_cyan
+                   || lc == Color_darkgray
+                   || lc == Color_gray
+                   || lc == Color_green
+                   || lc == Color_lightgray
+                   || lc == Color_lime
+                   || lc == Color_magenta
+                   || lc == Color_olive
+                   || lc == Color_orange
+                   || lc == Color_pink
+                   || lc == Color_purple
+                   || lc == Color_red
+                   || lc == Color_teal
+                   || lc == Color_violet
+                   || lc == Color_yellow
+                   || lc == Color_inherit
+                   || lc == Color_ignore)
+                       continue;
                lcolors_.push_back(lc);
        }
-       sort(lcolors_.begin(), lcolors_.end(), ColorSorter());
+       qSort(lcolors_.begin(), lcolors_.end(), ColorSorter);
        vector<ColorCode>::const_iterator cit = lcolors_.begin();
        vector<ColorCode>::const_iterator const end = lcolors_.end();
        for (; cit != end; ++cit) {
@@ -1115,7 +1241,7 @@ PrefColors::PrefColors(GuiPreferences * form)
 }
 
 
-void PrefColors::apply(LyXRC & rc) const
+void PrefColors::applyRC(LyXRC & rc) const
 {
        LyXRC oldrc = rc;
 
@@ -1129,7 +1255,7 @@ void PrefColors::apply(LyXRC & rc) const
 }
 
 
-void PrefColors::update(LyXRC const & rc)
+void PrefColors::updateRC(LyXRC const & rc)
 {
        for (unsigned int i = 0; i < lcolors_.size(); ++i) {
                QColor color = QColor(guiApp->colorCache().get(lcolors_[i], false));
@@ -1168,12 +1294,17 @@ void PrefColors::changeSysColor()
 {
        for (int row = 0 ; row < lyxObjectsLW->count() ; ++row) {
                // skip colors that are taken from system palette
-               bool const hide = syscolorsCB->isChecked()
+               bool const disable = syscolorsCB->isChecked()
                        && guiApp->colorCache().isSystem(lcolors_[row]);
 
-               lyxObjectsLW->item(row)->setHidden(hide);
-       }
+               QListWidgetItem * const item = lyxObjectsLW->item(row);
+               Qt::ItemFlags const flags = item->flags();
 
+               if (disable)
+                       item->setFlags(flags & ~Qt::ItemIsEnabled);
+               else
+                       item->setFlags(flags | Qt::ItemIsEnabled);
+       }
 }
 
 void PrefColors::changeLyxObjectsSelection()
@@ -1189,7 +1320,7 @@ void PrefColors::changeLyxObjectsSelection()
 /////////////////////////////////////////////////////////////////////
 
 PrefDisplay::PrefDisplay(GuiPreferences * form)
-       : PrefModule(qt_(catLookAndFeel), qt_("Display"), form)
+       : PrefModule(catLookAndFeel, N_("Display"), form)
 {
        setupUi(this);
        connect(displayGraphicsCB, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
@@ -1205,24 +1336,23 @@ void PrefDisplay::on_instantPreviewCO_currentIndexChanged(int index)
 }
 
 
-void PrefDisplay::on_displayGraphicsCB_toggled(bool on)
-{
-       instantPreviewCO->setEnabled(on);
-       previewSizeSB->setEnabled(on && instantPreviewCO->currentIndex() > 0);
-}
-
-
-void PrefDisplay::apply(LyXRC & rc) const
+void PrefDisplay::applyRC(LyXRC & rc) const
 {
        switch (instantPreviewCO->currentIndex()) {
                case 0:
                        rc.preview = LyXRC::PREVIEW_OFF;
                        break;
                case 1:
-                       rc.preview = LyXRC::PREVIEW_NO_MATH;
+                       if (rc.preview != LyXRC::PREVIEW_NO_MATH) {
+                               rc.preview = LyXRC::PREVIEW_NO_MATH;
+                               form_->updatePreviews();
+                       }
                        break;
                case 2:
-                       rc.preview = LyXRC::PREVIEW_ON;
+                       if (rc.preview != LyXRC::PREVIEW_ON) {
+                               rc.preview = LyXRC::PREVIEW_ON;
+                               form_->updatePreviews();
+                       }
                        break;
        }
 
@@ -1240,7 +1370,7 @@ void PrefDisplay::apply(LyXRC & rc) const
 }
 
 
-void PrefDisplay::update(LyXRC const & rc)
+void PrefDisplay::updateRC(LyXRC const & rc)
 {
        switch (rc.preview) {
        case LyXRC::PREVIEW_OFF:
@@ -1255,7 +1385,6 @@ void PrefDisplay::update(LyXRC const & rc)
        }
 
        displayGraphicsCB->setChecked(rc.display_graphics);
-       instantPreviewCO->setEnabled(rc.display_graphics);
        previewSizeSB->setValue(rc.preview_scale_factor);
        paragraphMarkerCB->setChecked(rc.paragraph_markers);
        previewSizeSB->setEnabled(
@@ -1271,7 +1400,7 @@ void PrefDisplay::update(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 PrefPaths::PrefPaths(GuiPreferences * form)
-       : PrefModule(QString(), qt_("Paths"), form)
+       : PrefModule(QString(), N_("Paths"), form)
 {
        setupUi(this);
 
@@ -1314,10 +1443,16 @@ PrefPaths::PrefPaths(GuiPreferences * form)
 
        connect(pathPrefixED, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
+
+       connect(texinputsPrefixED, SIGNAL(textChanged(QString)),
+               this, SIGNAL(changed()));
+
+       pathPrefixED->setValidator(new NoNewLineValidator(pathPrefixED));
+       texinputsPrefixED->setValidator(new NoNewLineValidator(texinputsPrefixED));
 }
 
 
-void PrefPaths::apply(LyXRC & rc) const
+void PrefPaths::applyRC(LyXRC & rc) const
 {
        rc.document_path = internal_path(fromqstr(workingDirED->text()));
        rc.example_path = internal_path(fromqstr(exampleDirED->text()));
@@ -1327,12 +1462,13 @@ void PrefPaths::apply(LyXRC & rc) const
        rc.thesaurusdir_path = internal_path(fromqstr(thesaurusDirED->text()));
        rc.hunspelldir_path = internal_path(fromqstr(hunspellDirED->text()));
        rc.path_prefix = internal_path_list(fromqstr(pathPrefixED->text()));
+       rc.texinputs_prefix = internal_path_list(fromqstr(texinputsPrefixED->text()));
        // FIXME: should be a checkbox only
        rc.lyxpipes = internal_path(fromqstr(lyxserverDirED->text()));
 }
 
 
-void PrefPaths::update(LyXRC const & rc)
+void PrefPaths::updateRC(LyXRC const & rc)
 {
        workingDirED->setText(toqstr(external_path(rc.document_path)));
        exampleDirED->setText(toqstr(external_path(rc.example_path)));
@@ -1342,6 +1478,7 @@ void PrefPaths::update(LyXRC const & rc)
        thesaurusDirED->setText(toqstr(external_path(rc.thesaurusdir_path)));
        hunspellDirED->setText(toqstr(external_path(rc.hunspelldir_path)));
        pathPrefixED->setText(toqstr(external_path_list(rc.path_prefix)));
+       texinputsPrefixED->setText(toqstr(external_path_list(rc.texinputs_prefix)));
        // FIXME: should be a checkbox only
        lyxserverDirED->setText(toqstr(external_path(rc.lyxpipes)));
 }
@@ -1426,7 +1563,7 @@ void PrefPaths::selectLyxPipe()
 /////////////////////////////////////////////////////////////////////
 
 PrefSpellchecker::PrefSpellchecker(GuiPreferences * form)
-       : PrefModule(qt_(catLanguage), qt_("Spellchecker"), form)
+       : PrefModule(catLanguage, N_("Spellchecker"), form)
 {
        setupUi(this);
 
@@ -1460,6 +1597,9 @@ PrefSpellchecker::PrefSpellchecker(GuiPreferences * form)
                        this, SIGNAL(changed()));
                connect(spellcheckNotesCB, SIGNAL(clicked()),
                        this, SIGNAL(changed()));
+
+               altLanguageED->setValidator(new NoNewLineValidator(altLanguageED));
+               escapeCharactersED->setValidator(new NoNewLineValidator(escapeCharactersED));
        #else
                spellcheckerCB->setEnabled(false);
                altLanguageED->setEnabled(false);
@@ -1471,7 +1611,7 @@ PrefSpellchecker::PrefSpellchecker(GuiPreferences * form)
 }
 
 
-void PrefSpellchecker::apply(LyXRC & rc) const
+void PrefSpellchecker::applyRC(LyXRC & rc) const
 {
        string const speller = fromqstr(spellcheckerCB->
                itemData(spellcheckerCB->currentIndex()).toString());
@@ -1485,7 +1625,7 @@ void PrefSpellchecker::apply(LyXRC & rc) const
 }
 
 
-void PrefSpellchecker::update(LyXRC const & rc)
+void PrefSpellchecker::updateRC(LyXRC const & rc)
 {
        spellcheckerCB->setCurrentIndex(
                spellcheckerCB->findData(toqstr(rc.spellchecker)));
@@ -1500,12 +1640,12 @@ void PrefSpellchecker::update(LyXRC const & rc)
 void PrefSpellchecker::on_spellcheckerCB_currentIndexChanged(int index)
 {
        QString spellchecker = spellcheckerCB->itemData(index).toString();
-       
-       compoundWordCB->setEnabled(spellchecker != QString("native"));
+
+       compoundWordCB->setEnabled(spellchecker == QString("aspell"));
 }
-       
-       
-       
+
+
+
 /////////////////////////////////////////////////////////////////////
 //
 // PrefConverters
@@ -1514,7 +1654,7 @@ void PrefSpellchecker::on_spellcheckerCB_currentIndexChanged(int index)
 
 
 PrefConverters::PrefConverters(GuiPreferences * form)
-       : PrefModule(qt_(catFiles), qt_("Converters"), form)
+       : PrefModule(catFiles, N_("Converters"), form)
 {
        setupUi(this);
 
@@ -1542,22 +1682,32 @@ PrefConverters::PrefConverters(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(maxAgeLE, SIGNAL(textEdited(QString)),
                this, SIGNAL(changed()));
+       connect(needauthForbiddenCB, SIGNAL(toggled(bool)),
+               this, SIGNAL(changed()));
+       connect(needauthCB, SIGNAL(toggled(bool)),
+               this, SIGNAL(changed()));
 
-       maxAgeLE->setValidator(new QDoubleValidator(maxAgeLE));
+       converterED->setValidator(new NoNewLineValidator(converterED));
+       converterFlagED->setValidator(new NoNewLineValidator(converterFlagED));
+       maxAgeLE->setValidator(new QDoubleValidator(0, HUGE_VAL, 6, maxAgeLE));
        //converterDefGB->setFocusProxy(convertersLW);
 }
 
 
-void PrefConverters::apply(LyXRC & rc) const
+void PrefConverters::applyRC(LyXRC & rc) const
 {
        rc.use_converter_cache = cacheCB->isChecked();
+       rc.use_converter_needauth_forbidden = needauthForbiddenCB->isChecked();
+       rc.use_converter_needauth = needauthCB->isChecked();
        rc.converter_cache_maxage = int(widgetToDouble(maxAgeLE) * 86400.0);
 }
 
 
-void PrefConverters::update(LyXRC const & rc)
+void PrefConverters::updateRC(LyXRC const & rc)
 {
        cacheCB->setChecked(rc.use_converter_cache);
+       needauthForbiddenCB->setChecked(rc.use_converter_needauth_forbidden);
+       needauthCB->setChecked(rc.use_converter_needauth);
        QString max_age;
        doubleToWidget(maxAgeLE, (double(rc.converter_cache_maxage) / 86400.0), 'g', 6);
        updateGui();
@@ -1566,20 +1716,22 @@ void PrefConverters::update(LyXRC const & rc)
 
 void PrefConverters::updateGui()
 {
+       QString const pattern("%1 -> %2");
        form_->formats().sort();
        form_->converters().update(form_->formats());
        // save current selection
-       QString current = converterFromCO->currentText()
-               + " -> " + converterToCO->currentText();
+       QString current =
+               pattern
+               .arg(converterFromCO->currentText())
+               .arg(converterToCO->currentText());
 
        converterFromCO->clear();
        converterToCO->clear();
 
-       Formats::const_iterator cit = form_->formats().begin();
-       Formats::const_iterator end = form_->formats().end();
-       for (; cit != end; ++cit) {
-               converterFromCO->addItem(qt_(cit->prettyname()));
-               converterToCO->addItem(qt_(cit->prettyname()));
+       for (Format const & f : form_->formats()) {
+               QString const name = toqstr(translateIfPossible(f.prettyname()));
+               converterFromCO->addItem(name);
+               converterToCO->addItem(name);
        }
 
        // currentRowChanged(int) is also triggered when updating the listwidget
@@ -1587,19 +1739,20 @@ void PrefConverters::updateGui()
        convertersLW->blockSignals(true);
        convertersLW->clear();
 
-       Converters::const_iterator ccit = form_->converters().begin();
-       Converters::const_iterator cend = form_->converters().end();
-       for (; ccit != cend; ++ccit) {
+       for (Converter const & c : form_->converters()) {
                QString const name =
-                       qt_(ccit->From->prettyname()) + " -> " + qt_(ccit->To->prettyname());
-               int type = form_->converters().getNumber(ccit->From->name(), ccit->To->name());
+                       pattern
+                       .arg(toqstr(translateIfPossible(c.From()->prettyname())))
+                       .arg(toqstr(translateIfPossible(c.To()->prettyname())));
+               int type = form_->converters().getNumber(c.From()->name(),
+                                                        c.To()->name());
                new QListWidgetItem(name, convertersLW, type);
        }
        convertersLW->sortItems(Qt::AscendingOrder);
        convertersLW->blockSignals(false);
 
        // restore selection
-       if (!current.isEmpty()) {
+       if (current != pattern.arg(QString()).arg(QString())) {
                QList<QListWidgetItem *> const item =
                        convertersLW->findItems(current, Qt::MatchExactly);
                if (!item.isEmpty())
@@ -1618,10 +1771,10 @@ void PrefConverters::switchConverter()
 {
        int const cnr = convertersLW->currentItem()->type();
        Converter const & c(form_->converters().get(cnr));
-       converterFromCO->setCurrentIndex(form_->formats().getNumber(c.from));
-       converterToCO->setCurrentIndex(form_->formats().getNumber(c.to));
-       converterED->setText(toqstr(c.command));
-       converterFlagED->setText(toqstr(c.flags));
+       converterFromCO->setCurrentIndex(form_->formats().getNumber(c.from()));
+       converterToCO->setCurrentIndex(form_->formats().getNumber(c.to()));
+       converterED->setText(toqstr(c.command()));
+       converterFlagED->setText(toqstr(c.flags()));
 
        updateButtons();
 }
@@ -1635,7 +1788,7 @@ void PrefConverters::changeConverter()
 
 void PrefConverters::updateButtons()
 {
-       if (form_->formats().size() == 0)
+       if (form_->formats().empty())
                return;
        Format const & from = form_->formats().get(converterFromCO->currentIndex());
        Format const & to = form_->formats().get(converterToCO->currentIndex());
@@ -1644,10 +1797,16 @@ void PrefConverters::updateButtons()
        bool const valid = !(converterED->text().isEmpty()
                || from.name() == to.name());
 
-       int const cnr = convertersLW->currentItem()->type();
-       Converter const & c = form_->converters().get(cnr);
-       string const old_command = c.command;
-       string const old_flag = c.flags;
+       string old_command;
+       string old_flag;
+
+       if (convertersLW->count() > 0) {
+               int const cnr = convertersLW->currentItem()->type();
+               Converter const & c = form_->converters().get(cnr);
+               old_command = c.command();
+               old_flag = c.flags();
+       }
+
        string const new_command = fromqstr(converterED->text());
        string const new_flag = fromqstr(converterFlagED->text());
 
@@ -1709,6 +1868,12 @@ void PrefConverters::on_cacheCB_stateChanged(int state)
 }
 
 
+void PrefConverters::on_needauthForbiddenCB_toggled(bool checked)
+{
+       needauthCB->setEnabled(!checked);
+}
+
+
 /////////////////////////////////////////////////////////////////////
 //
 // FormatValidator
@@ -1808,7 +1973,7 @@ public:
 private:
        QString toString(Format const & format) const
        {
-               return qt_(format.prettyname());
+               return toqstr(translateIfPossible(format.prettyname()));
        }
 };
 
@@ -1820,11 +1985,17 @@ private:
 /////////////////////////////////////////////////////////////////////
 
 PrefFileformats::PrefFileformats(GuiPreferences * form)
-       : PrefModule(qt_(catFiles), qt_("File Formats"), form)
+       : PrefModule(catFiles, N_("File Formats"), form)
 {
        setupUi(this);
+
        formatED->setValidator(new FormatNameValidator(formatsCB, form_->formats()));
        formatsCB->setValidator(new FormatPrettynameValidator(formatsCB, form_->formats()));
+       extensionsED->setValidator(new NoNewLineValidator(extensionsED));
+       shortcutED->setValidator(new NoNewLineValidator(shortcutED));
+       editorED->setValidator(new NoNewLineValidator(editorED));
+       viewerED->setValidator(new NoNewLineValidator(viewerED));
+       copierED->setValidator(new NoNewLineValidator(copierED));
 
        connect(documentCB, SIGNAL(clicked()),
                this, SLOT(setFlags()));
@@ -1838,6 +2009,8 @@ PrefFileformats::PrefFileformats(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(defaultFormatCB, SIGNAL(activated(QString)),
                this, SIGNAL(changed()));
+       connect(defaultOTFFormatCB, SIGNAL(activated(QString)),
+               this, SIGNAL(changed()));
        connect(viewerCO, SIGNAL(activated(int)),
                this, SIGNAL(changed()));
        connect(editorCO, SIGNAL(activated(int)),
@@ -1847,37 +2020,43 @@ PrefFileformats::PrefFileformats(GuiPreferences * form)
 
 namespace {
 
-string const l10n_shortcut(string const prettyname, string const shortcut)
+string const l10n_shortcut(docstring const & prettyname, string const & shortcut)
 {
        if (shortcut.empty())
                return string();
 
        string l10n_format =
-               to_utf8(_(prettyname + '|' + shortcut));
+               to_utf8(_(to_utf8(prettyname) + '|' + shortcut));
        return split(l10n_format, '|');
 }
 
 } // namespace anon
 
 
-void PrefFileformats::apply(LyXRC & rc) const
+void PrefFileformats::applyRC(LyXRC & rc) const
 {
        QString const default_format = defaultFormatCB->itemData(
                defaultFormatCB->currentIndex()).toString();
        rc.default_view_format = fromqstr(default_format);
+       QString const default_otf_format = defaultOTFFormatCB->itemData(
+               defaultOTFFormatCB->currentIndex()).toString();
+       rc.default_otf_view_format = fromqstr(default_otf_format);
 }
 
 
-void PrefFileformats::update(LyXRC const & rc)
+void PrefFileformats::updateRC(LyXRC const & rc)
 {
        viewer_alternatives = rc.viewer_alternatives;
        editor_alternatives = rc.editor_alternatives;
        bool const init = defaultFormatCB->currentText().isEmpty();
        updateView();
        if (init) {
-               int const pos =
+               int pos =
                        defaultFormatCB->findData(toqstr(rc.default_view_format));
                defaultFormatCB->setCurrentIndex(pos);
+               pos = defaultOTFFormatCB->findData(toqstr(rc.default_otf_view_format));
+                               defaultOTFFormatCB->setCurrentIndex(pos);
+               defaultOTFFormatCB->setCurrentIndex(pos);
        }
 }
 
@@ -1886,45 +2065,61 @@ void PrefFileformats::updateView()
 {
        QString const current = formatsCB->currentText();
        QString const current_def = defaultFormatCB->currentText();
+       QString const current_def_otf = defaultOTFFormatCB->currentText();
 
        // update comboboxes with formats
        formatsCB->blockSignals(true);
        defaultFormatCB->blockSignals(true);
+       defaultOTFFormatCB->blockSignals(true);
        formatsCB->clear();
        defaultFormatCB->clear();
+       defaultOTFFormatCB->clear();
        form_->formats().sort();
-       Formats::const_iterator cit = form_->formats().begin();
-       Formats::const_iterator end = form_->formats().end();
-       for (; cit != end; ++cit) {
-               formatsCB->addItem(qt_(cit->prettyname()),
-                               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())));
+       for (Format const & f : form_->formats()) {
+               QString const prettyname = toqstr(translateIfPossible(f.prettyname()));
+               formatsCB->addItem(prettyname,
+                                  QVariant(form_->formats().getNumber(f.name())));
+               if (f.viewer().empty())
+                       continue;
+               if (form_->converters().isReachable("xhtml", f.name())
+                   || form_->converters().isReachable("dviluatex", f.name())
+                   || form_->converters().isReachable("luatex", f.name())
+                   || form_->converters().isReachable("xetex", f.name())) {
+                       defaultFormatCB->addItem(prettyname,
+                                       QVariant(toqstr(f.name())));
+                       defaultOTFFormatCB->addItem(prettyname,
+                                       QVariant(toqstr(f.name())));
+               } else if (form_->converters().isReachable("latex", f.name())
+                          || form_->converters().isReachable("pdflatex", f.name()))
+                       defaultFormatCB->addItem(prettyname,
+                                       QVariant(toqstr(f.name())));
        }
 
-       // restore selection
+       // restore selections
        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);
+       item = defaultOTFFormatCB->findText(current_def_otf, Qt::MatchExactly);
+       defaultOTFFormatCB->setCurrentIndex(item < 0 ? 0 : item);
        formatsCB->blockSignals(false);
        defaultFormatCB->blockSignals(false);
+       defaultOTFFormatCB->blockSignals(false);
 }
 
 
 void PrefFileformats::on_formatsCB_currentIndexChanged(int i)
 {
-       if (form_->formats().size() == 0)
+       if (form_->formats().empty())
                return;
        int const nr = formatsCB->itemData(i).toInt();
        Format const f = form_->formats().get(nr);
 
        formatED->setText(toqstr(f.name()));
        copierED->setText(toqstr(form_->movers().command(f.name())));
-       extensionED->setText(toqstr(f.extension()));
+       extensionsED->setText(toqstr(f.extensions()));
+       mimeED->setText(toqstr(f.mime()));
        shortcutED->setText(
                toqstr(l10n_shortcut(f.prettyname(), f.shortcut())));
        documentCB->setChecked((f.documentFormat()));
@@ -1959,12 +2154,13 @@ void PrefFileformats::on_copierED_textEdited(const QString & s)
 }
 
 
-void PrefFileformats::on_extensionED_textEdited(const QString & s)
+void PrefFileformats::on_extensionsED_textEdited(const QString & s)
 {
-       currentFormat().setExtension(fromqstr(s));
+       currentFormat().setExtensions(fromqstr(s));
        changed();
 }
 
+
 void PrefFileformats::on_viewerED_textEdited(const QString & s)
 {
        currentFormat().setViewer(fromqstr(s));
@@ -1979,6 +2175,13 @@ void PrefFileformats::on_editorED_textEdited(const QString & s)
 }
 
 
+void PrefFileformats::on_mimeED_textEdited(const QString & s)
+{
+       currentFormat().setMime(fromqstr(s));
+       changed();
+}
+
+
 void PrefFileformats::on_shortcutED_textEdited(const QString & s)
 {
        string const new_shortcut = fromqstr(s);
@@ -2031,10 +2234,10 @@ void PrefFileformats::on_formatsCB_editTextChanged(const QString &)
 void PrefFileformats::updatePrettyname()
 {
        QString const newname = formatsCB->currentText();
-       if (newname == qt_(currentFormat().prettyname()))
+       if (newname == toqstr(translateIfPossible(currentFormat().prettyname())))
                return;
 
-       currentFormat().setPrettyname(fromqstr(newname));
+       currentFormat().setPrettyname(qstring_to_ucs4(newname));
        formatsChanged();
        updateView();
        changed();
@@ -2045,13 +2248,13 @@ namespace {
        void updateComboBox(LyXRC::Alternatives const & alts,
                            string const & fmt, QComboBox * combo)
        {
-               LyXRC::Alternatives::const_iterator it = 
+               LyXRC::Alternatives::const_iterator it =
                                alts.find(fmt);
                if (it != alts.end()) {
                        LyXRC::CommandSet const & cmds = it->second;
-                       LyXRC::CommandSet::const_iterator sit = 
+                       LyXRC::CommandSet::const_iterator sit =
                                        cmds.begin();
-                       LyXRC::CommandSet::const_iterator const sen = 
+                       LyXRC::CommandSet::const_iterator const sen =
                                        cmds.end();
                        for (; sit != sen; ++sit) {
                                QString const qcmd = toqstr(*sit);
@@ -2136,7 +2339,7 @@ Format & PrefFileformats::currentFormat()
 
 void PrefFileformats::on_formatNewPB_clicked()
 {
-       form_->formats().add("", "", "", "", "", "", Format::none);
+       form_->formats().add("", "", docstring(), "", "", "", "", Format::none);
        updateView();
        formatsCB->setCurrentIndex(0);
        formatsCB->setFocus(Qt::OtherFocusReason);
@@ -2170,12 +2373,10 @@ void PrefFileformats::on_formatRemovePB_clicked()
 /////////////////////////////////////////////////////////////////////
 
 PrefLanguage::PrefLanguage(GuiPreferences * form)
-       : PrefModule(qt_(catLanguage), qt_("Language"), form)
+       : PrefModule(catLanguage, N_("Language"), form)
 {
        setupUi(this);
 
-       connect(rtlGB, SIGNAL(clicked()),
-               this, SIGNAL(changed()));
        connect(visualCursorRB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
        connect(logicalCursorRB, SIGNAL(clicked()),
@@ -2200,17 +2401,23 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(defaultDecimalPointLE, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
+       connect(defaultLengthUnitCO, SIGNAL(activated(int)),
+               this, SIGNAL(changed()));
 
-       uiLanguageCO->clear();
+       languagePackageED->setValidator(new NoNewLineValidator(languagePackageED));
+       startCommandED->setValidator(new NoNewLineValidator(startCommandED));
+       endCommandED->setValidator(new NoNewLineValidator(endCommandED));
 
-       QAbstractItemModel * language_model = guiApp->languageModel();
-       // FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
-       language_model->sort(0);
        defaultDecimalPointLE->setInputMask("X; ");
        defaultDecimalPointLE->setMaxLength(1);
 
-       set<string> added;
+       defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::CM]), Length::CM);
+       defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::IN]), Length::IN);
+
+       QAbstractItemModel * language_model = guiApp->languageModel();
+       language_model->sort(0);
        uiLanguageCO->blockSignals(true);
+       uiLanguageCO->clear();
        uiLanguageCO->addItem(qt_("Default"), toqstr("auto"));
        for (int i = 0; i != language_model->rowCount(); ++i) {
                QModelIndex index = language_model->index(i, 0);
@@ -2218,13 +2425,16 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
                // each language code only once
                string const name = fromqstr(index.data(Qt::UserRole).toString());
                Language const * lang = languages.getLanguage(name);
+               if (!lang)
+                       continue;
                // never remove the currently selected language
-               if (lang && name != form->rc().gui_language && name != lyxrc.gui_language)
-                       if (!lang->translated() || added.find(lang->code()) != added.end())
-                               continue;
-               added.insert(lang->code());
+               if (name != form->rc().gui_language
+                   && name != lyxrc.gui_language
+                   && (!Messages::available(lang->code())
+                       || !lang->hasGuiSupport()))
+                       continue;
                uiLanguageCO->addItem(index.data(Qt::DisplayRole).toString(),
-                       index.data(Qt::UserRole).toString());
+                                     index.data(Qt::UserRole).toString());
        }
        uiLanguageCO->blockSignals(false);
 }
@@ -2244,11 +2454,9 @@ void PrefLanguage::on_languagePackageCO_currentIndexChanged(int i)
 }
 
 
-void PrefLanguage::apply(LyXRC & rc) const
+void PrefLanguage::applyRC(LyXRC & rc) const
 {
-       // FIXME: remove rtl_support bool
-       rc.rtl_support = rtlGB->isChecked();
-       rc.visual_cursor = rtlGB->isChecked() && visualCursorRB->isChecked();
+       rc.visual_cursor = visualCursorRB->isChecked();
        rc.mark_foreign_language = markForeignCB->isChecked();
        rc.language_auto_begin = autoBeginCB->isChecked();
        rc.language_auto_end = autoEndCB->isChecked();
@@ -2268,13 +2476,12 @@ void PrefLanguage::apply(LyXRC & rc) const
        rc.gui_language = fromqstr(
                uiLanguageCO->itemData(uiLanguageCO->currentIndex()).toString());
        rc.default_decimal_point = fromqstr(defaultDecimalPointLE->text());
+       rc.default_length_unit = (Length::UNIT) defaultLengthUnitCO->itemData(defaultLengthUnitCO->currentIndex()).toInt();
 }
 
 
-void PrefLanguage::update(LyXRC const & rc)
+void PrefLanguage::updateRC(LyXRC const & rc)
 {
-       // FIXME: remove rtl_support bool
-       rtlGB->setChecked(rc.rtl_support);
        if (rc.visual_cursor)
                visualCursorRB->setChecked(true);
        else
@@ -2289,8 +2496,10 @@ void PrefLanguage::update(LyXRC const & rc)
        startCommandED->setText(toqstr(rc.language_command_begin));
        endCommandED->setText(toqstr(rc.language_command_end));
        defaultDecimalPointLE->setText(toqstr(rc.default_decimal_point));
+       int pos = defaultLengthUnitCO->findData(int(rc.default_length_unit));
+       defaultLengthUnitCO->setCurrentIndex(pos);
 
-       int pos = uiLanguageCO->findData(toqstr(rc.gui_language));
+       pos = uiLanguageCO->findData(toqstr(rc.gui_language));
        uiLanguageCO->blockSignals(true);
        uiLanguageCO->setCurrentIndex(pos);
        uiLanguageCO->blockSignals(false);
@@ -2299,110 +2508,80 @@ void PrefLanguage::update(LyXRC const & rc)
 
 /////////////////////////////////////////////////////////////////////
 //
-// PrefPrinter
+// PrefUserInterface
 //
 /////////////////////////////////////////////////////////////////////
 
-PrefPrinter::PrefPrinter(GuiPreferences * form)
-       : PrefModule(qt_(catOutput), qt_("Printer"), form)
+PrefUserInterface::PrefUserInterface(GuiPreferences * form)
+       : PrefModule(catLookAndFeel, N_("User Interface"), form)
 {
        setupUi(this);
 
-       connect(printerAdaptCB, SIGNAL(clicked()),
-               this, SIGNAL(changed()));
-       connect(printerCommandED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerNameED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerPageRangeED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerCopiesED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerReverseED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerToPrinterED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerExtensionED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerSpoolCommandED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerPaperTypeED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerEvenED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerOddED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerCollatedED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerLandscapeED, SIGNAL(textChanged(QString)),
+       connect(uiFilePB, SIGNAL(clicked()),
+               this, SLOT(selectUi()));
+       connect(uiFileED, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
-       connect(printerToFileED, SIGNAL(textChanged(QString)),
+       connect(iconSetCO, SIGNAL(activated(int)),
                this, SIGNAL(changed()));
-       connect(printerExtraED, SIGNAL(textChanged(QString)),
+       connect(useSystemThemeIconsCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
-       connect(printerSpoolPrefixED, SIGNAL(textChanged(QString)),
+       connect(lastfilesSB, SIGNAL(valueChanged(int)),
                this, SIGNAL(changed()));
-       connect(printerPaperSizeED, SIGNAL(textChanged(QString)),
+       connect(tooltipCB, SIGNAL(toggled(bool)),
                this, SIGNAL(changed()));
+       lastfilesSB->setMaximum(maxlastfiles);
+
+       iconSetCO->addItem(qt_("Default"), QString());
+       iconSetCO->addItem(qt_("Classic"), "classic");
+       iconSetCO->addItem(qt_("Oxygen"), "oxygen");
+
+#if (!(defined Q_WS_X11 || defined(QPA_XCB)) || QT_VERSION < 0x040600)
+       useSystemThemeIconsCB->hide();
+#endif
 }
 
 
-void PrefPrinter::apply(LyXRC & rc) const
+void PrefUserInterface::applyRC(LyXRC & rc) const
 {
-       rc.print_adapt_output = printerAdaptCB->isChecked();
-       rc.print_command = fromqstr(printerCommandED->text());
-       rc.printer = fromqstr(printerNameED->text());
+       rc.icon_set = fromqstr(iconSetCO->itemData(
+               iconSetCO->currentIndex()).toString());
 
-       rc.print_pagerange_flag = fromqstr(printerPageRangeED->text());
-       rc.print_copies_flag = fromqstr(printerCopiesED->text());
-       rc.print_reverse_flag = fromqstr(printerReverseED->text());
-       rc.print_to_printer = fromqstr(printerToPrinterED->text());
-       rc.print_file_extension = fromqstr(printerExtensionED->text());
-       rc.print_spool_command = fromqstr(printerSpoolCommandED->text());
-       rc.print_paper_flag = fromqstr(printerPaperTypeED->text());
-       rc.print_evenpage_flag = fromqstr(printerEvenED->text());
-       rc.print_oddpage_flag = fromqstr(printerOddED->text());
-       rc.print_collcopies_flag = fromqstr(printerCollatedED->text());
-       rc.print_landscape_flag = fromqstr(printerLandscapeED->text());
-       rc.print_to_file = internal_path(fromqstr(printerToFileED->text()));
-       rc.print_extra_options = fromqstr(printerExtraED->text());
-       rc.print_spool_printerprefix = fromqstr(printerSpoolPrefixED->text());
-       rc.print_paper_dimension_flag = fromqstr(printerPaperSizeED->text());
+       rc.ui_file = internal_path(fromqstr(uiFileED->text()));
+       rc.use_system_theme_icons = useSystemThemeIconsCB->isChecked();
+       rc.num_lastfiles = lastfilesSB->value();
+       rc.use_tooltip = tooltipCB->isChecked();
 }
 
 
-void PrefPrinter::update(LyXRC const & rc)
+void PrefUserInterface::updateRC(LyXRC const & rc)
 {
-       printerAdaptCB->setChecked(rc.print_adapt_output);
-       printerCommandED->setText(toqstr(rc.print_command));
-       printerNameED->setText(toqstr(rc.printer));
+       int iconset = iconSetCO->findData(toqstr(rc.icon_set));
+       if (iconset < 0)
+               iconset = 0;
+       iconSetCO->setCurrentIndex(iconset);
+       useSystemThemeIconsCB->setChecked(rc.use_system_theme_icons);
+       uiFileED->setText(toqstr(external_path(rc.ui_file)));
+       lastfilesSB->setValue(rc.num_lastfiles);
+       tooltipCB->setChecked(rc.use_tooltip);
+}
 
-       printerPageRangeED->setText(toqstr(rc.print_pagerange_flag));
-       printerCopiesED->setText(toqstr(rc.print_copies_flag));
-       printerReverseED->setText(toqstr(rc.print_reverse_flag));
-       printerToPrinterED->setText(toqstr(rc.print_to_printer));
-       printerExtensionED->setText(toqstr(rc.print_file_extension));
-       printerSpoolCommandED->setText(toqstr(rc.print_spool_command));
-       printerPaperTypeED->setText(toqstr(rc.print_paper_flag));
-       printerEvenED->setText(toqstr(rc.print_evenpage_flag));
-       printerOddED->setText(toqstr(rc.print_oddpage_flag));
-       printerCollatedED->setText(toqstr(rc.print_collcopies_flag));
-       printerLandscapeED->setText(toqstr(rc.print_landscape_flag));
-       printerToFileED->setText(toqstr(external_path(rc.print_to_file)));
-       printerExtraED->setText(toqstr(rc.print_extra_options));
-       printerSpoolPrefixED->setText(toqstr(rc.print_spool_printerprefix));
-       printerPaperSizeED->setText(toqstr(rc.print_paper_dimension_flag));
+
+void PrefUserInterface::selectUi()
+{
+       QString file = form_->browseUI(internalPath(uiFileED->text()));
+       if (!file.isEmpty())
+               uiFileED->setText(file);
 }
 
 
 /////////////////////////////////////////////////////////////////////
 //
-// PrefUserInterface
+// PrefDocumentHandling
 //
 /////////////////////////////////////////////////////////////////////
 
-PrefUserInterface::PrefUserInterface(GuiPreferences * form)
-       : PrefModule(qt_(catLookAndFeel), qt_("User Interface"), form)
+PrefDocHandling::PrefDocHandling(GuiPreferences * form)
+       : PrefModule(catLookAndFeel, N_("Document Handling"), form)
 {
        setupUi(this);
 
@@ -2414,14 +2593,9 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(singleInstanceCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
-#if QT_VERSION < 0x040500
-       singleCloseTabButtonCB->setEnabled(false);
-#endif
        connect(singleCloseTabButtonCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
-       connect(uiFilePB, SIGNAL(clicked()),
-               this, SLOT(selectUi()));
-       connect(uiFileED, SIGNAL(textChanged(QString)),
+       connect(closeLastViewCO, SIGNAL(activated(int)),
                this, SIGNAL(changed()));
        connect(restoreCursorCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
@@ -2437,37 +2611,42 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(saveCompressedCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
-       connect(lastfilesSB, SIGNAL(valueChanged(int)),
-               this, SIGNAL(changed()));
-       connect(tooltipCB, SIGNAL(toggled(bool)),
+       connect(saveOriginCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
-       lastfilesSB->setMaximum(maxlastfiles);
 }
 
 
-void PrefUserInterface::apply(LyXRC & rc) const
+void PrefDocHandling::applyRC(LyXRC & rc) const
 {
-       rc.ui_file = internal_path(fromqstr(uiFileED->text()));
        rc.use_lastfilepos = restoreCursorCB->isChecked();
        rc.load_session = loadSessionCB->isChecked();
        rc.allow_geometry_session = allowGeometrySessionCB->isChecked();
        rc.autosave = autoSaveCB->isChecked() ?  autoSaveSB->value() * 60 : 0;
        rc.make_backup = backupCB->isChecked();
        rc.save_compressed = saveCompressedCB->isChecked();
-       rc.num_lastfiles = lastfilesSB->value();
-       rc.use_tooltip = tooltipCB->isChecked();
+       rc.save_origin = saveOriginCB->isChecked();
        rc.open_buffers_in_tabs = openDocumentsInTabsCB->isChecked();
        rc.single_instance = singleInstanceCB->isChecked();
        rc.single_close_tab_button = singleCloseTabButtonCB->isChecked();
-#if QT_VERSION < 0x040500
-       rc.single_close_tab_button = true;
-#endif
+
+       switch (closeLastViewCO->currentIndex()) {
+       case 0:
+               rc.close_buffer_with_last_view = "yes";
+               break;
+       case 1:
+               rc.close_buffer_with_last_view = "no";
+               break;
+       case 2:
+               rc.close_buffer_with_last_view = "ask";
+               break;
+       default:
+               ;
+       }
 }
 
 
-void PrefUserInterface::update(LyXRC const & rc)
+void PrefDocHandling::updateRC(LyXRC const & rc)
 {
-       uiFileED->setText(toqstr(external_path(rc.ui_file)));
        restoreCursorCB->setChecked(rc.use_lastfilepos);
        loadSessionCB->setChecked(rc.load_session);
        allowGeometrySessionCB->setChecked(rc.allow_geometry_session);
@@ -2481,24 +2660,21 @@ void PrefUserInterface::update(LyXRC const & rc)
        autoSaveSB->setEnabled(autosave);
        backupCB->setChecked(rc.make_backup);
        saveCompressedCB->setChecked(rc.save_compressed);
-       lastfilesSB->setValue(rc.num_lastfiles);
-       tooltipCB->setChecked(rc.use_tooltip);
+       saveOriginCB->setChecked(rc.save_origin);
        openDocumentsInTabsCB->setChecked(rc.open_buffers_in_tabs);
        singleInstanceCB->setChecked(rc.single_instance && !rc.lyxpipes.empty());
        singleInstanceCB->setEnabled(!rc.lyxpipes.empty());
        singleCloseTabButtonCB->setChecked(rc.single_close_tab_button);
+       if (rc.close_buffer_with_last_view == "yes")
+               closeLastViewCO->setCurrentIndex(0);
+       else if (rc.close_buffer_with_last_view == "no")
+               closeLastViewCO->setCurrentIndex(1);
+       else if (rc.close_buffer_with_last_view == "ask")
+               closeLastViewCO->setCurrentIndex(2);
 }
 
 
-void PrefUserInterface::selectUi()
-{
-       QString file = form_->browseUI(internalPath(uiFileED->text()));
-       if (!file.isEmpty())
-               uiFileED->setText(file);
-}
-
-
-void PrefUserInterface::on_clearSessionPB_clicked()
+void PrefDocHandling::on_clearSessionPB_clicked()
 {
        guiApp->clearSession();
 }
@@ -2512,7 +2688,7 @@ void PrefUserInterface::on_clearSessionPB_clicked()
 /////////////////////////////////////////////////////////////////////
 
 PrefEdit::PrefEdit(GuiPreferences * form)
-       : PrefModule(qt_(catEditing), qt_("Control"), form)
+       : PrefModule(catEditing, N_("Control"), form)
 {
        setupUi(this);
 
@@ -2520,7 +2696,7 @@ PrefEdit::PrefEdit(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(scrollBelowCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
-       connect(macLikeWordMovementCB, SIGNAL(clicked()),
+       connect(macLikeCursorMovementCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
        connect(sortEnvironmentsCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
@@ -2528,6 +2704,8 @@ PrefEdit::PrefEdit(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(macroEditStyleCO, SIGNAL(activated(int)),
                this, SIGNAL(changed()));
+       connect(cursorWidthSB, SIGNAL(valueChanged(int)),
+               this, SIGNAL(changed()));
        connect(fullscreenLimitGB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
        connect(fullscreenWidthSB, SIGNAL(valueChanged(int)),
@@ -2538,16 +2716,18 @@ PrefEdit::PrefEdit(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(toggleScrollbarCB, SIGNAL(toggled(bool)),
                this, SIGNAL(changed()));
+       connect(toggleStatusbarCB, SIGNAL(toggled(bool)),
+               this, SIGNAL(changed()));
        connect(toggleToolbarsCB, SIGNAL(toggled(bool)),
                this, SIGNAL(changed()));
 }
 
 
-void PrefEdit::apply(LyXRC & rc) const
+void PrefEdit::applyRC(LyXRC & rc) const
 {
        rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked();
        rc.scroll_below_document = scrollBelowCB->isChecked();
-       rc.mac_like_word_movement = macLikeWordMovementCB->isChecked();
+       rc.mac_like_cursor_movement = macLikeCursorMovementCB->isChecked();
        rc.sort_layouts = sortEnvironmentsCB->isChecked();
        rc.group_layouts = groupEnvironmentsCB->isChecked();
        switch (macroEditStyleCO->currentIndex()) {
@@ -2555,8 +2735,10 @@ void PrefEdit::apply(LyXRC & rc) const
                case 1: rc.macro_edit_style = LyXRC::MACRO_EDIT_INLINE; break;
                case 2: rc.macro_edit_style = LyXRC::MACRO_EDIT_LIST;   break;
        }
+       rc.cursor_width = cursorWidthSB->value();
        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();
@@ -2564,15 +2746,17 @@ void PrefEdit::apply(LyXRC & rc) const
 }
 
 
-void PrefEdit::update(LyXRC const & rc)
+void PrefEdit::updateRC(LyXRC const & rc)
 {
        cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
        scrollBelowCB->setChecked(rc.scroll_below_document);
-       macLikeWordMovementCB->setChecked(rc.mac_like_word_movement);
+       macLikeCursorMovementCB->setChecked(rc.mac_like_cursor_movement);
        sortEnvironmentsCB->setChecked(rc.sort_layouts);
        groupEnvironmentsCB->setChecked(rc.group_layouts);
        macroEditStyleCO->setCurrentIndex(rc.macro_edit_style);
+       cursorWidthSB->setValue(rc.cursor_width);
        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);
@@ -2596,7 +2780,9 @@ GuiShortcutDialog::GuiShortcutDialog(QWidget * parent) : QDialog(parent)
 
 
 PrefShortcuts::PrefShortcuts(GuiPreferences * form)
-       : PrefModule(qt_(catEditing), qt_("Shortcuts"), form)
+       : PrefModule(catEditing, N_("Shortcuts"), form),
+         editItem_(0), mathItem_(0), bufferItem_(0), layoutItem_(0),
+         systemItem_(0)
 {
        setupUi(this);
 
@@ -2617,8 +2803,6 @@ PrefShortcuts::PrefShortcuts(GuiPreferences * form)
        shortcut_bc_.setOK(shortcut_->okPB);
        shortcut_bc_.setCancel(shortcut_->cancelPB);
 
-       connect(shortcut_->okPB, SIGNAL(clicked()),
-               shortcut_, SLOT(accept()));
        connect(shortcut_->okPB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
        connect(shortcut_->cancelPB, SIGNAL(clicked()),
@@ -2634,7 +2818,7 @@ PrefShortcuts::PrefShortcuts(GuiPreferences * form)
 }
 
 
-void PrefShortcuts::apply(LyXRC & rc) const
+void PrefShortcuts::applyRC(LyXRC & rc) const
 {
        rc.bind_file = internal_path(fromqstr(bindFileED->text()));
        // write user_bind and user_unbind to .lyx/bind/user.bind
@@ -2661,7 +2845,7 @@ void PrefShortcuts::apply(LyXRC & rc) const
 }
 
 
-void PrefShortcuts::update(LyXRC const & rc)
+void PrefShortcuts::updateRC(LyXRC const & rc)
 {
        bindFileED->setText(toqstr(external_path(rc.bind_file)));
        //
@@ -2716,17 +2900,30 @@ void PrefShortcuts::updateShortcutsTW()
        KeyMap::BindingList::const_iterator it = bindinglist.begin();
        KeyMap::BindingList::const_iterator it_end = bindinglist.end();
        for (; it != it_end; ++it)
-               insertShortcutItem(it->request, it->sequence, KeyMap::ItemType(it->tag));
+               insertShortcutItem(it->request, it->sequence, it->tag);
 
        shortcutsTW->sortItems(0, Qt::AscendingOrder);
-       QList<QTreeWidgetItem*> items = shortcutsTW->selectedItems();
-       removePB->setEnabled(!items.isEmpty() && !items[0]->text(1).isEmpty());
-       modifyPB->setEnabled(!items.isEmpty());
-
+       on_shortcutsTW_itemSelectionChanged();
+       on_searchLE_textEdited();
        shortcutsTW->resizeColumnToContents(0);
 }
 
 
+//static
+KeyMap::ItemType PrefShortcuts::itemType(QTreeWidgetItem & item)
+{
+       return static_cast<KeyMap::ItemType>(item.data(0, Qt::UserRole).toInt());
+}
+
+
+//static
+bool PrefShortcuts::isAlwaysHidden(QTreeWidgetItem & item)
+{
+       // Hide rebound system settings that are empty
+       return itemType(item) == KeyMap::UserUnbind && item.text(1).isEmpty();
+}
+
+
 void PrefShortcuts::setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag)
 {
        item->setData(0, Qt::UserRole, QVariant(tag));
@@ -2746,7 +2943,7 @@ void PrefShortcuts::setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag)
                font.setStrikeOut(true);
                break;
        }
-
+       item->setHidden(isAlwaysHidden(*item));
        item->setFont(1, font);
 }
 
@@ -2759,7 +2956,6 @@ QTreeWidgetItem * PrefShortcuts::insertShortcutItem(FuncRequest const & lfun,
        QString const lfun_name = toqstr(from_utf8(action_name)
                        + ' ' + lfun.argument());
        QString const shortcut = toqstr(seq.print(KeySequence::ForGui));
-       KeyMap::ItemType item_tag = tag;
 
        QTreeWidgetItem * newItem = 0;
        // for unbind items, try to find an existing item in the system bind list
@@ -2767,15 +2963,15 @@ QTreeWidgetItem * PrefShortcuts::insertShortcutItem(FuncRequest const & lfun,
                QList<QTreeWidgetItem*> const items = shortcutsTW->findItems(lfun_name,
                        Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 0);
                for (int i = 0; i < items.size(); ++i) {
-                       if (items[i]->text(1) == shortcut)
+                       if (items[i]->text(1) == shortcut) {
                                newItem = items[i];
                                break;
                        }
+               }
                // if not found, this unbind item is KeyMap::UserExtraUnbind
                // Such an item is not displayed to avoid confusion (what is
                // unmatched removed?).
                if (!newItem) {
-                       item_tag = KeyMap::UserExtraUnbind;
                        return 0;
                }
        }
@@ -2808,7 +3004,7 @@ QTreeWidgetItem * PrefShortcuts::insertShortcutItem(FuncRequest const & lfun,
        newItem->setText(1, shortcut);
        // record BindFile representation to recover KeySequence when needed.
        newItem->setData(1, Qt::UserRole, toqstr(seq.print(KeySequence::BindFile)));
-       setItemType(newItem, item_tag);
+       setItemType(newItem, tag);
        return newItem;
 }
 
@@ -2821,9 +3017,7 @@ void PrefShortcuts::on_shortcutsTW_itemSelectionChanged()
        if (items.isEmpty())
                return;
 
-       KeyMap::ItemType tag = 
-               static_cast<KeyMap::ItemType>(items[0]->data(0, Qt::UserRole).toInt());
-       if (tag == KeyMap::UserUnbind)
+       if (itemType(*items[0]) == KeyMap::UserUnbind)
                removePB->setText(qt_("Res&tore"));
        else
                removePB->setText(qt_("Remo&ve"));
@@ -2852,6 +3046,23 @@ void PrefShortcuts::modifyShortcut()
 }
 
 
+void PrefShortcuts::unhideEmpty(QString const & lfun, bool select)
+{
+       // list of items that match lfun
+       QList<QTreeWidgetItem*> items = shortcutsTW->findItems(lfun,
+            Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 0);
+       for (int i = 0; i < items.size(); ++i) {
+               QTreeWidgetItem * item = items[i];
+               if (isAlwaysHidden(*item)) {
+                       setItemType(item, KeyMap::System);
+                       if (select)
+                               shortcutsTW->setCurrentItem(item);
+                       return;
+               }
+       }
+}
+
+
 void PrefShortcuts::removeShortcut()
 {
        // it seems that only one item can be selected, but I am
@@ -2861,10 +3072,8 @@ void PrefShortcuts::removeShortcut()
                string shortcut = fromqstr(items[i]->data(1, Qt::UserRole).toString());
                string lfun = fromqstr(items[i]->text(0));
                FuncRequest func = lyxaction.lookupFunc(lfun);
-               KeyMap::ItemType tag = 
-                       static_cast<KeyMap::ItemType>(items[i]->data(0, Qt::UserRole).toInt());
 
-               switch (tag) {
+               switch (itemType(*items[i])) {
                case KeyMap::System: {
                        // for system bind, we do not touch the item
                        // but add an user unbind item
@@ -2883,11 +3092,19 @@ void PrefShortcuts::removeShortcut()
                        else
                                shortcutsTW->scrollToItem(parent);
                        user_bind_.unbind(shortcut, func);
+                       // If this user binding hid an empty system binding, unhide the
+                       // latter and select it.
+                       unhideEmpty(items[i]->text(0), true);
                        break;
                }
                case KeyMap::UserUnbind: {
                        // for user_unbind, we remove the unbind, and the item
                        // become KeyMap::System again.
+                       KeySequence seq;
+                       seq.parse(shortcut);
+                       // Ask the user to replace current binding
+                       if (!validateNewShortcut(func, seq, QString()))
+                               break;
                        user_unbind_.unbind(shortcut, func);
                        setItemType(items[i], KeyMap::System);
                        removePB->setText(qt_("Remo&ve"));
@@ -2905,6 +3122,37 @@ void PrefShortcuts::removeShortcut()
 }
 
 
+void PrefShortcuts::deactivateShortcuts(QList<QTreeWidgetItem*> const & items)
+{
+       for (int i = 0; i < items.size(); ++i) {
+               string shortcut = fromqstr(items[i]->data(1, Qt::UserRole).toString());
+               string lfun = fromqstr(items[i]->text(0));
+               FuncRequest func = lyxaction.lookupFunc(lfun);
+
+               switch (itemType(*items[i])) {
+               case KeyMap::System:
+                       // for system bind, we do not touch the item
+                       // but add an user unbind item
+                       user_unbind_.bind(shortcut, func);
+                       setItemType(items[i], KeyMap::UserUnbind);
+                       break;
+
+               case KeyMap::UserBind: {
+                       // for user_bind, we remove this bind
+                       QTreeWidgetItem * parent = items[i]->parent();
+                       int itemIdx = parent->indexOfChild(items[i]);
+                       parent->takeChild(itemIdx);
+                       user_bind_.unbind(shortcut, func);
+                       unhideEmpty(items[i]->text(0), false);
+                       break;
+               }
+               default:
+                       break;
+               }
+       }
+}
+
+
 void PrefShortcuts::selectBind()
 {
        QString file = form_->browsebind(internalPath(bindFileED->text()));
@@ -2944,8 +3192,11 @@ void PrefShortcuts::on_searchLE_textEdited()
        if (searchLE->text().isEmpty()) {
                // show all hidden items
                QTreeWidgetItemIterator it(shortcutsTW, QTreeWidgetItemIterator::Hidden);
-               while (*it)
-                       shortcutsTW->setItemHidden(*it++, false);
+               for (; *it; ++it)
+                       shortcutsTW->setItemHidden(*it, isAlwaysHidden(**it));
+               // close all categories
+               for (int i = 0; i < shortcutsTW->topLevelItemCount(); ++i)
+                       shortcutsTW->collapseItem(shortcutsTW->topLevelItem(i));
                return;
        }
        // search both columns
@@ -2959,10 +3210,11 @@ void PrefShortcuts::on_searchLE_textEdited()
        while (*it)
                shortcutsTW->setItemHidden(*it++, true);
        // show matched items
-       for (int i = 0; i < matched.size(); ++i) {
-               shortcutsTW->setItemHidden(matched[i], false);
-        shortcutsTW->setItemExpanded(matched[i]->parent(), true);
-       }
+       for (int i = 0; i < matched.size(); ++i)
+               if (!isAlwaysHidden(*matched[i])) {
+                       shortcutsTW->setItemHidden(matched[i], false);
+                       shortcutsTW->setItemExpanded(matched[i]->parent(), true);
+               }
 }
 
 
@@ -2975,56 +3227,101 @@ docstring makeCmdString(FuncRequest const & f)
 }
 
 
-void PrefShortcuts::shortcutOkPressed()
+FuncRequest PrefShortcuts::currentBinding(KeySequence const & k)
 {
-       QString const new_lfun = shortcut_->lfunLE->text();
-       FuncRequest func = lyxaction.lookupFunc(fromqstr(new_lfun));
+       FuncRequest res = user_bind_.getBinding(k);
+       if (res.action() != LFUN_UNKNOWN_ACTION)
+               return res;
+       res = system_bind_.getBinding(k);
+       // Check if it is unbound. Note: user_unbind_ can only unbind one
+       // FuncRequest per key sequence.
+       if (user_unbind_.getBinding(k) == res)
+               return FuncRequest::unknown;
+       return res;
+}
+
 
+bool PrefShortcuts::validateNewShortcut(FuncRequest const & func,
+                                        KeySequence const & k,
+                                        QString const & lfun_to_modify)
+{
        if (func.action() == LFUN_UNKNOWN_ACTION) {
                Alert::error(_("Failed to create shortcut"),
                        _("Unknown or invalid LyX function"));
-               return;
+               return false;
+       }
+
+       // It is not currently possible to bind Hidden lfuns such as self-insert. In
+       // the future, to remove this limitation, see GuiPrefs::insertShortcutItem
+       // and how it is used in GuiPrefs::shortcutOkPressed.
+       if (lyxaction.getActionType(func.action()) == LyXAction::Hidden) {
+               Alert::error(_("Failed to create shortcut"),
+                       _("This LyX function is hidden and cannot be bound."));
+               return false;
        }
 
-       KeySequence k = shortcut_->shortcutWG->getKeySequence();
        if (k.length() == 0) {
                Alert::error(_("Failed to create shortcut"),
                        _("Invalid or empty key sequence"));
-               return;
+               return false;
        }
 
-       // check to see if there's been any change
-       FuncRequest oldBinding = system_bind_.getBinding(k);
-       if (oldBinding.action() == LFUN_UNKNOWN_ACTION)
-               oldBinding = user_bind_.getBinding(k);
+       FuncRequest oldBinding = currentBinding(k);
        if (oldBinding == func)
-               // nothing has changed
-               return;
-       
-       // make sure this key isn't already bound---and, if so, not unbound
-       FuncCode const unbind = user_unbind_.getBinding(k).action();
+               // nothing to change
+               return false;
+
+       // make sure this key isn't already bound---and, if so, prompt user
+       // (exclude the lfun the user already wants to modify)
        docstring const action_string = makeCmdString(oldBinding);
-       if (oldBinding.action() > LFUN_NOACTION && unbind == LFUN_UNKNOWN_ACTION
-                 && save_lfun_ != toqstr(action_string)) {
-               // FIXME Perhaps we should offer to over-write the old shortcut?
-               // If so, we'll need to remove it from our list, etc.
-               Alert::error(_("Failed to create shortcut"),
-                       bformat(_("Shortcut `%1$s' is already bound to:\n%2$s\n"
-                         "You need to remove that binding before creating a new one."), 
-                       k.print(KeySequence::ForGui), action_string));
-               return;
+       if (oldBinding.action() != LFUN_UNKNOWN_ACTION
+           && lfun_to_modify != toqstr(action_string)) {
+               docstring const new_action_string = makeCmdString(func);
+               docstring const text = bformat(_("Shortcut `%1$s' is already bound to "
+                                                "%2$s.\n"
+                                                "Are you sure you want to unbind the "
+                                                "current shortcut and bind it to %3$s?"),
+                                              k.print(KeySequence::ForGui), action_string,
+                                              new_action_string);
+               int ret = Alert::prompt(_("Redefine shortcut?"),
+                                       text, 0, 1, _("&Redefine"), _("&Cancel"));
+               if (ret != 0)
+                       return false;
+               QString const sequence_text = toqstr(k.print(KeySequence::ForGui));
+               QList<QTreeWidgetItem*> items = shortcutsTW->findItems(sequence_text,
+                       Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 1);
+               deactivateShortcuts(items);
        }
+       return true;
+}
+
+
+void PrefShortcuts::shortcutOkPressed()
+{
+       QString const new_lfun = shortcut_->lfunLE->text();
+       FuncRequest func = lyxaction.lookupFunc(fromqstr(new_lfun));
+       KeySequence k = shortcut_->shortcutWG->getKeySequence();
+
+       // save_lfun_ contains the text of the lfun to modify, if the user clicked
+       // "modify", or is empty if they clicked "new" (which I do not really like)
+       if (!validateNewShortcut(func, k, save_lfun_))
+               return;
 
-       if (!save_lfun_.isEmpty())
+       if (!save_lfun_.isEmpty()) {
                // real modification of the lfun's shortcut,
                // so remove the previous one
-               removeShortcut();
+               QList<QTreeWidgetItem*> to_modify = shortcutsTW->selectedItems();
+               deactivateShortcuts(to_modify);
+       }
+
+       shortcut_->accept();
 
        QTreeWidgetItem * item = insertShortcutItem(func, k, KeyMap::UserBind);
        if (item) {
                user_bind_.bind(&k, func);
                shortcutsTW->sortItems(0, Qt::AscendingOrder);
                shortcutsTW->setItemExpanded(item->parent(), true);
+               shortcutsTW->setCurrentItem(item);
                shortcutsTW->scrollToItem(item);
        } else {
                Alert::error(_("Failed to create shortcut"),
@@ -3059,7 +3356,7 @@ void PrefShortcuts::shortcutRemovePressed()
 /////////////////////////////////////////////////////////////////////
 
 PrefIdentity::PrefIdentity(GuiPreferences * form)
-       : PrefModule(QString(), qt_("Identity"), form)
+       : PrefModule(QString(), N_("Identity"), form)
 {
        setupUi(this);
 
@@ -3067,17 +3364,20 @@ PrefIdentity::PrefIdentity(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(emailED, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
+
+       nameED->setValidator(new NoNewLineValidator(nameED));
+       emailED->setValidator(new NoNewLineValidator(emailED));
 }
 
 
-void PrefIdentity::apply(LyXRC & rc) const
+void PrefIdentity::applyRC(LyXRC & rc) const
 {
        rc.user_name = fromqstr(nameED->text());
        rc.user_email = fromqstr(emailED->text());
 }
 
 
-void PrefIdentity::update(LyXRC const & rc)
+void PrefIdentity::updateRC(LyXRC const & rc)
 {
        nameED->setText(toqstr(rc.user_name));
        emailED->setText(toqstr(rc.user_email));
@@ -3092,7 +3392,8 @@ void PrefIdentity::update(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 GuiPreferences::GuiPreferences(GuiView & lv)
-       : GuiDialog(lv, "prefs", qt_("Preferences")), update_screen_font_(false)
+       : GuiDialog(lv, "prefs", qt_("Preferences")), update_screen_font_(false),
+         update_previews_(false)
 {
        setupUi(this);
 
@@ -3104,6 +3405,7 @@ GuiPreferences::GuiPreferences(GuiView & lv)
        connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
 
        addModule(new PrefUserInterface(this));
+       addModule(new PrefDocHandling(this));
        addModule(new PrefEdit(this));
        addModule(new PrefShortcuts(this));
        PrefScreenFonts * screenfonts = new PrefScreenFonts(this);
@@ -3123,9 +3425,8 @@ GuiPreferences::GuiPreferences(GuiView & lv)
        addModule(new PrefSpellchecker(this));
 
        //for strftime validator
-       PrefOutput * output = new PrefOutput(this); 
+       PrefOutput * output = new PrefOutput(this);
        addModule(output);
-       addModule(new PrefPrinter(this));
        addModule(new PrefLatex(this));
 
        PrefConverters * converters = new PrefConverters(this);
@@ -3135,7 +3436,7 @@ GuiPreferences::GuiPreferences(GuiView & lv)
        addModule(converters);
        addModule(formats);
 
-       prefsPS->setCurrentPanel(qt_("User Interface"));
+       prefsPS->setCurrentPanel("User Interface");
 // FIXME: hack to work around resizing bug in Qt >= 4.2
 // bug verified with Qt 4.2.{0-3} (JSpitzm)
 #if QT_VERSION >= 0x040200
@@ -3171,42 +3472,43 @@ void GuiPreferences::change_adaptor()
 }
 
 
-void GuiPreferences::apply(LyXRC & rc) const
+void GuiPreferences::applyRC(LyXRC & rc) const
 {
        size_t end = modules_.size();
        for (size_t i = 0; i != end; ++i)
-               modules_[i]->apply(rc);
+               modules_[i]->applyRC(rc);
 }
 
 
-void GuiPreferences::updateRc(LyXRC const & rc)
+void GuiPreferences::updateRC(LyXRC const & rc)
 {
        size_t const end = modules_.size();
        for (size_t i = 0; i != end; ++i)
-               modules_[i]->update(rc);
+               modules_[i]->updateRC(rc);
 }
 
 
 void GuiPreferences::applyView()
 {
-       apply(rc());
+       applyRC(rc());
 }
 
 
 bool GuiPreferences::initialiseParams(string const &)
 {
        rc_ = lyxrc;
-       formats_ = lyx::formats;
+       formats_ = theFormats();
        converters_ = theConverters();
        converters_.update(formats_);
        movers_ = theMovers();
        colors_.clear();
        update_screen_font_ = false;
-       
-       updateRc(rc_);
-       // Make sure that the bc is in the INITIAL state  
-       if (bc().policy().buttonStatus(ButtonPolicy::RESTORE))  
-               bc().restore();  
+       update_previews_ = false;
+
+       updateRC(rc_);
+       // Make sure that the bc is in the INITIAL state
+       if (bc().policy().buttonStatus(ButtonPolicy::RESTORE))
+               bc().restore();
 
        return true;
 }
@@ -3222,16 +3524,17 @@ void GuiPreferences::dispatchParams()
        prefsApplied(rc_);
        // FIXME: these need lfuns
        // FIXME UNICODE
-       Author const & author = 
+       Author const & author =
                Author(from_utf8(rc_.user_name), from_utf8(rc_.user_email));
        theBufferList().recordCurrentAuthor(author);
 
-       lyx::formats = formats_;
+       theFormats() = formats_;
 
        theConverters() = converters_;
-       theConverters().update(lyx::formats);
+       theConverters().update(formats_);
        theConverters().buildGraph();
-
+       theBufferList().invalidateConverterCache();
+       
        theMovers() = movers_;
 
        vector<string>::const_iterator it = colors_.begin();
@@ -3242,9 +3545,16 @@ void GuiPreferences::dispatchParams()
 
        if (update_screen_font_) {
                dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
+               // resets flag in case second apply in same dialog
                update_screen_font_ = false;
        }
 
+        if (update_previews_) {
+               // resets flag in case second apply in same dialog
+               theBufferList().updatePreviews();
+               update_previews_ = false;
+       }
+
        // The Save button has been pressed
        if (isClosing())
                dispatch(FuncRequest(LFUN_PREFERENCES_SAVE));
@@ -3263,6 +3573,12 @@ void GuiPreferences::updateScreenFonts()
 }
 
 
+void GuiPreferences::updatePreviews()
+{
+       update_previews_ = true;
+}
+
+
 QString GuiPreferences::browsebind(QString const & file) const
 {
        return browseLibFile("bind", file, "bind", qt_("Choose bind file"),
@@ -3291,60 +3607,6 @@ QString GuiPreferences::browse(QString const & file,
 }
 
 
-// We support less paper sizes than the document dialog
-// Therefore this adjustment is needed.
-PAPER_SIZE GuiPreferences::toPaperSize(int i) const
-{
-       switch (i) {
-       case 0:
-               return PAPER_DEFAULT;
-       case 1:
-               return PAPER_USLETTER;
-       case 2:
-               return PAPER_USLEGAL;
-       case 3:
-               return PAPER_USEXECUTIVE;
-       case 4:
-               return PAPER_A3;
-       case 5:
-               return PAPER_A4;
-       case 6:
-               return PAPER_A5;
-       case 7:
-               return PAPER_B5;
-       default:
-               // should not happen
-               return PAPER_DEFAULT;
-       }
-}
-
-
-int GuiPreferences::fromPaperSize(PAPER_SIZE papersize) const
-{
-       switch (papersize) {
-       case PAPER_DEFAULT:
-               return 0;
-       case PAPER_USLETTER:
-               return 1;
-       case PAPER_USLEGAL:
-               return 2;
-       case PAPER_USEXECUTIVE:
-               return 3;
-       case PAPER_A3:
-               return 4;
-       case PAPER_A4:
-               return 5;
-       case PAPER_A5:
-               return 6;
-       case PAPER_B5:
-               return 7;
-       default:
-               // should not happen
-               return 0;
-       }
-}
-
-
 Dialog * createGuiPreferences(GuiView & lv) { return new GuiPreferences(lv); }