]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiPrefs.cpp
On Linux show in crash message box the backtrace
[lyx.git] / src / frontends / qt4 / GuiPrefs.cpp
index 180327c76987a1149772084df3988e751bcc3e3f..6dfd337dcdd005f086eb6add84923f46861ae7a6 100644 (file)
@@ -20,7 +20,9 @@
 #include "GuiFontLoader.h"
 #include "GuiKeySymbol.h"
 #include "qt_helpers.h"
+#include "Validator.h"
 
+#include "Author.h"
 #include "BufferList.h"
 #include "Color.h"
 #include "ColorSet.h"
@@ -42,7 +44,9 @@
 #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"
 
@@ -89,7 +93,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,
@@ -108,7 +112,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);
 
@@ -179,7 +183,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);
 
@@ -193,19 +197,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;
@@ -214,6 +217,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;
+}
+
+
 
 /////////////////////////////////////////////////////////////////////
 //
@@ -223,11 +249,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)
@@ -361,10 +387,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,15 +406,16 @@ PrefOutput::PrefOutput(GuiPreferences * form)
        connect(pdfCB, SIGNAL(editTextChanged(QString)),
                this, SIGNAL(changed()));
        dviCB->addItem("");
-       dviCB->addItem("xdvi -sourceposition $$n:$$t $$o");
-       dviCB->addItem("yap -1 -s $$n$$t $$o");
-       dviCB->addItem("okular --unique $$o#src:$$n$$t");
-       dviCB->addItem("synctex view -i $$n:0:$$t -o $$o -x \"evince -p %{page+1} $$o\"");
+       dviCB->addItem("xdvi -sourceposition '$$n:\\ $$t' $$o");
+       dviCB->addItem("yap -1 -s \"$$n $$t\" $$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 $$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("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");
 }
 
@@ -448,7 +479,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);
 
@@ -461,9 +492,20 @@ PrefInput::PrefInput(GuiPreferences * form)
        connect(mouseWheelSpeedSB, SIGNAL(valueChanged(double)),
                this, SIGNAL(changed()));
        connect(scrollzoomEnableCB, SIGNAL(clicked()),
-                       this, SIGNAL(changed()));
+               this, SIGNAL(changed()));
        connect(scrollzoomValueCO, SIGNAL(activated(int)),
-                       this, SIGNAL(changed()));
+               this, SIGNAL(changed()));
+       connect(dontswapCB, SIGNAL(toggled(bool)),
+               this, SIGNAL(changed()));
+
+       // reveal checkbox for switching Ctrl and Meta on Mac:
+       bool swapcb = false;
+#ifdef Q_WS_MACX
+#if QT_VERSION > 0x040600
+       swapcb = true;
+#endif
+#endif
+       dontswapCB->setVisible(swapcb);
 }
 
 
@@ -489,6 +531,7 @@ void PrefInput::apply(LyXRC & rc) const
        } else {
                rc.scroll_wheel_zoom = LyXRC::SCROLL_WHEEL_ZOOM_OFF;
        }
+       rc.mac_dontswap_ctrl_meta  = dontswapCB->isChecked();
 }
 
 
@@ -516,6 +559,7 @@ void PrefInput::update(LyXRC const & rc)
                scrollzoomValueCO->setCurrentIndex(2);
                break;
        }
+       dontswapCB->setChecked(rc.mac_dontswap_ctrl_meta);
 }
 
 
@@ -565,7 +609,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);
 
@@ -589,6 +633,8 @@ PrefCompletion::PrefCompletion(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(cursorTextCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
+       connect(minlengthSB, SIGNAL(valueChanged(int)),
+                       this, SIGNAL(changed()));
 }
 
 
@@ -624,6 +670,7 @@ void PrefCompletion::apply(LyXRC & rc) const
        rc.completion_cursor_text = cursorTextCB->isChecked();
        rc.completion_popup_after_complete =
                popupAfterCompleteCB->isChecked();
+       rc.completion_minlength = minlengthSB->value();
 }
 
 
@@ -640,6 +687,7 @@ void PrefCompletion::update(LyXRC const & rc)
        cursorTextCB->setChecked(rc.completion_cursor_text);
        popupAfterCompleteCB->setChecked(rc.completion_popup_after_complete);
         enableCB();
+       minlengthSB->setValue(rc.completion_minlength);
 }
 
 
@@ -651,9 +699,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)),
@@ -676,7 +734,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)
@@ -781,8 +839,6 @@ void PrefLatex::apply(LyXRC & rc) const
        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
@@ -859,8 +915,6 @@ void PrefLatex::update(LyXRC const & rc)
        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
@@ -874,7 +928,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);
 
@@ -900,8 +954,6 @@ PrefScreenFonts::PrefScreenFonts(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(screenZoomSB, SIGNAL(valueChanged(int)),
                this, SIGNAL(changed()));
-       connect(screenDpiSB, SIGNAL(valueChanged(int)),
-               this, SIGNAL(changed()));
        connect(screenTinyED, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
        connect(screenSmallestED, SIGNAL(textChanged(QString)),
@@ -950,7 +1002,6 @@ void PrefScreenFonts::apply(LyXRC & rc) const
                rc.typewriter_font_name, rc.typewriter_font_foundry);
 
        rc.zoom = screenZoomSB->value();
-       rc.dpi = screenDpiSB->value();
        rc.font_sizes[FONT_SIZE_TINY] = widgetToDoubleStr(screenTinyED);
        rc.font_sizes[FONT_SIZE_SCRIPT] = widgetToDoubleStr(screenSmallestED);
        rc.font_sizes[FONT_SIZE_FOOTNOTE] = widgetToDoubleStr(screenSmallerED);
@@ -967,7 +1018,7 @@ void PrefScreenFonts::apply(LyXRC & rc) const
                || rc.roman_font_name != oldrc.roman_font_name
                || rc.sans_font_name != oldrc.sans_font_name
                || rc.typewriter_font_name != oldrc.typewriter_font_name
-               || rc.zoom != oldrc.zoom || rc.dpi != oldrc.dpi) {
+               || rc.zoom != oldrc.zoom) {
                // The global QPixmapCache is used in GuiPainter to cache text
                // painting so we must reset it in case any of the above
                // parameter is changed.
@@ -992,7 +1043,18 @@ void PrefScreenFonts::update(LyXRC const & rc)
        selectTypewriter(screenTypewriterCO->currentText());
 
        screenZoomSB->setValue(rc.zoom);
-       screenDpiSB->setValue(rc.dpi);
+       updateScreenFontSizes(rc);
+
+       pixmapCacheCB->setChecked(rc.use_pixmap_cache);
+#if defined(Q_WS_X11)
+       pixmapCacheCB->setEnabled(false);
+#endif
+
+}
+
+
+void PrefScreenFonts::updateScreenFontSizes(LyXRC const & rc)
+{
        doubleToWidget(screenTinyED, rc.font_sizes[FONT_SIZE_TINY]);
        doubleToWidget(screenSmallestED, rc.font_sizes[FONT_SIZE_SCRIPT]);
        doubleToWidget(screenSmallerED, rc.font_sizes[FONT_SIZE_FOOTNOTE]);
@@ -1003,12 +1065,6 @@ void PrefScreenFonts::update(LyXRC const & rc)
        doubleToWidget(screenLargestED, rc.font_sizes[FONT_SIZE_LARGEST]);
        doubleToWidget(screenHugeED, rc.font_sizes[FONT_SIZE_HUGE]);
        doubleToWidget(screenHugerED, rc.font_sizes[FONT_SIZE_HUGER]);
-
-       pixmapCacheCB->setChecked(rc.use_pixmap_cache);
-#if defined(Q_WS_X11)
-       pixmapCacheCB->setEnabled(false);
-#endif
-
 }
 
 
@@ -1049,7 +1105,7 @@ struct ColorSorter
 } // namespace anon
 
 PrefColors::PrefColors(GuiPreferences * form)
-       : PrefModule(qt_(catLookAndFeel), qt_("Colors"), form)
+       : PrefModule(catLookAndFeel, N_("Colors"), form)
 {
        setupUi(this);
 
@@ -1060,19 +1116,17 @@ 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_red
+                   || lc == Color_green
+                   || lc == Color_blue
+                   || lc == Color_cyan
+                   || lc == Color_magenta
+                   || lc == Color_yellow
+                   || lc == Color_inherit
+                   || lc == Color_ignore)
+                       continue;
                lcolors_.push_back(lc);
        }
        sort(lcolors_.begin(), lcolors_.end(), ColorSorter());
@@ -1092,26 +1146,37 @@ PrefColors::PrefColors(GuiPreferences * form)
                this, SLOT(changeLyxObjectsSelection()));
        connect(lyxObjectsLW, SIGNAL(itemActivated(QListWidgetItem*)),
                this, SLOT(changeColor()));
+       connect(syscolorsCB, SIGNAL(toggled(bool)),
+               this, SIGNAL(changed()));
+       connect(syscolorsCB, SIGNAL(toggled(bool)),
+               this, SLOT(changeSysColor()));
 }
 
 
-void PrefColors::apply(LyXRC & /*rc*/) const
+void PrefColors::apply(LyXRC & rc) const
 {
+       LyXRC oldrc = rc;
+
        for (unsigned int i = 0; i < lcolors_.size(); ++i)
                if (curcolors_[i] != newcolors_[i])
                        form_->setColor(lcolors_[i], newcolors_[i]);
+       rc.use_system_colors = syscolorsCB->isChecked();
+
+       if (oldrc.use_system_colors != rc.use_system_colors)
+               guiApp->colorCache().clear();
 }
 
 
-void PrefColors::update(LyXRC const & /*rc*/)
+void PrefColors::update(LyXRC const & rc)
 {
        for (unsigned int i = 0; i < lcolors_.size(); ++i) {
-               QColor color = QColor(guiApp->colorCache().get(lcolors_[i]));
+               QColor color = QColor(guiApp->colorCache().get(lcolors_[i], false));
                QPixmap coloritem(32, 32);
                coloritem.fill(color);
                lyxObjectsLW->item(i)->setIcon(QIcon(coloritem));
                newcolors_[i] = curcolors_[i] = color.name();
        }
+       syscolorsCB->setChecked(rc.use_system_colors);
        changeLyxObjectsSelection();
 }
 
@@ -1137,6 +1202,18 @@ void PrefColors::changeColor()
        }
 }
 
+void PrefColors::changeSysColor()
+{
+       for (int row = 0 ; row < lyxObjectsLW->count() ; ++row) {
+               // skip colors that are taken from system palette
+               bool const hide = syscolorsCB->isChecked()
+                       && guiApp->colorCache().isSystem(lcolors_[row]);
+
+               lyxObjectsLW->item(row)->setHidden(hide);
+       }
+
+}
+
 void PrefColors::changeLyxObjectsSelection()
 {
        colorChangePB->setDisabled(lyxObjectsLW->currentRow() < 0);
@@ -1150,35 +1227,34 @@ 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()));
        connect(instantPreviewCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
        connect(previewSizeSB, SIGNAL(valueChanged(double)), this, SIGNAL(changed()));
        connect(paragraphMarkerCB, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
-       if (instantPreviewCO->currentIndex() == 0)
-               previewSizeSB->setEnabled(false);
-       else
-               previewSizeSB->setEnabled(true);
 }
 
 
 void PrefDisplay::on_instantPreviewCO_currentIndexChanged(int index)
 {
-       if (index == 0)
-               previewSizeSB->setEnabled(false);
-       else
-               previewSizeSB->setEnabled(true);
+       previewSizeSB->setEnabled(index != 0);
 }
 
 
 void PrefDisplay::apply(LyXRC & rc) const
 {
        switch (instantPreviewCO->currentIndex()) {
-               case 0: rc.preview = LyXRC::PREVIEW_OFF; break;
-               case 1: rc.preview = LyXRC::PREVIEW_NO_MATH; break;
-               case 2: rc.preview = LyXRC::PREVIEW_ON; break;
+               case 0:
+                       rc.preview = LyXRC::PREVIEW_OFF;
+                       break;
+               case 1:
+                       rc.preview = LyXRC::PREVIEW_NO_MATH;
+                       break;
+               case 2:
+                       rc.preview = LyXRC::PREVIEW_ON;
+                       break;
        }
 
        rc.display_graphics = displayGraphicsCB->isChecked();
@@ -1210,9 +1286,11 @@ 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(
+               rc.display_graphics
+               && rc.preview != LyXRC::PREVIEW_OFF);
 }
 
 
@@ -1223,7 +1301,7 @@ void PrefDisplay::update(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 PrefPaths::PrefPaths(GuiPreferences * form)
-       : PrefModule(QString(), qt_("Paths"), form)
+       : PrefModule(QString(), N_("Paths"), form)
 {
        setupUi(this);
 
@@ -1255,12 +1333,23 @@ PrefPaths::PrefPaths(GuiPreferences * form)
        connect(tempDirED, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
 
+#if defined(USE_HUNSPELL)
        connect(hunspellDirPB, SIGNAL(clicked()), this, SLOT(selectHunspelldir()));
        connect(hunspellDirED, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
+#else
+       hunspellDirPB->setEnabled(false);
+       hunspellDirED->setEnabled(false);
+#endif
 
        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));
 }
 
 
@@ -1274,6 +1363,7 @@ 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()));
 }
@@ -1289,6 +1379,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)));
 }
@@ -1373,25 +1464,25 @@ void PrefPaths::selectLyxPipe()
 /////////////////////////////////////////////////////////////////////
 
 PrefSpellchecker::PrefSpellchecker(GuiPreferences * form)
-       : PrefModule(qt_(catLanguage), qt_("Spellchecker"), form)
+       : PrefModule(catLanguage, N_("Spellchecker"), form)
 {
        setupUi(this);
 
 // FIXME: this check should test the target platform (darwin)
 #if defined(USE_MACOSX_PACKAGING)
-       spellcheckerCB->addItem(qt_("native"), QString("native"));
+       spellcheckerCB->addItem(qt_("Native"), QString("native"));
 #define CONNECT_APPLESPELL
 #else
 #undef CONNECT_APPLESPELL
 #endif
 #if defined(USE_ASPELL)
-       spellcheckerCB->addItem(qt_("aspell"), QString("aspell"));
+       spellcheckerCB->addItem(qt_("Aspell"), QString("aspell"));
 #endif
 #if defined(USE_ENCHANT)
-       spellcheckerCB->addItem(qt_("enchant"), QString("enchant"));
+       spellcheckerCB->addItem(qt_("Enchant"), QString("enchant"));
 #endif
 #if defined(USE_HUNSPELL)
-       spellcheckerCB->addItem(qt_("hunspell"), QString("hunspell"));
+       spellcheckerCB->addItem(qt_("Hunspell"), QString("hunspell"));
 #endif
 
        #if defined(CONNECT_APPLESPELL) || defined(USE_ASPELL) || defined(USE_ENCHANT) || defined(USE_HUNSPELL)
@@ -1407,6 +1498,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);
@@ -1420,8 +1514,10 @@ PrefSpellchecker::PrefSpellchecker(GuiPreferences * form)
 
 void PrefSpellchecker::apply(LyXRC & rc) const
 {
-       rc.spellchecker = fromqstr(spellcheckerCB->itemData(
-                       spellcheckerCB->currentIndex()).toString());
+       string const speller = fromqstr(spellcheckerCB->
+               itemData(spellcheckerCB->currentIndex()).toString());
+       if (!speller.empty())
+               rc.spellchecker = speller;
        rc.spellchecker_alt_lang = fromqstr(altLanguageED->text());
        rc.spellchecker_esc_chars = fromqstr(escapeCharactersED->text());
        rc.spellchecker_accept_compound = compoundWordCB->isChecked();
@@ -1442,7 +1538,15 @@ void PrefSpellchecker::update(LyXRC const & rc)
 }
 
 
-
+void PrefSpellchecker::on_spellcheckerCB_currentIndexChanged(int index)
+{
+       QString spellchecker = spellcheckerCB->itemData(index).toString();
+       
+       compoundWordCB->setEnabled(spellchecker == QString("aspell"));
+}
+       
+       
+       
 /////////////////////////////////////////////////////////////////////
 //
 // PrefConverters
@@ -1451,7 +1555,7 @@ void PrefSpellchecker::update(LyXRC const & rc)
 
 
 PrefConverters::PrefConverters(GuiPreferences * form)
-       : PrefModule(qt_(catFiles), qt_("Converters"), form)
+       : PrefModule(catFiles, N_("Converters"), form)
 {
        setupUi(this);
 
@@ -1480,6 +1584,8 @@ PrefConverters::PrefConverters(GuiPreferences * form)
        connect(maxAgeLE, SIGNAL(textEdited(QString)),
                this, SIGNAL(changed()));
 
+       converterED->setValidator(new NoNewLineValidator(converterED));
+       converterFlagED->setValidator(new NoNewLineValidator(converterFlagED));
        maxAgeLE->setValidator(new QDoubleValidator(maxAgeLE));
        //converterDefGB->setFocusProxy(convertersLW);
 }
@@ -1572,7 +1678,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());
@@ -1581,10 +1687,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());
 
@@ -1757,22 +1869,32 @@ 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()));
        connect(vectorCB, SIGNAL(clicked()),
                this, SLOT(setFlags()));
+       connect(exportMenuCB, SIGNAL(clicked()),
+               this, SLOT(setFlags()));
        connect(formatsCB->lineEdit(), SIGNAL(editingFinished()),
                this, SLOT(updatePrettyname()));
        connect(formatsCB->lineEdit(), SIGNAL(textEdited(QString)),
                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)),
@@ -1792,7 +1914,7 @@ string const l10n_shortcut(string const prettyname, string const shortcut)
        return split(l10n_format, '|');
 }
 
-}; // namespace anon
+} // namespace anon
 
 
 void PrefFileformats::apply(LyXRC & rc) const
@@ -1800,6 +1922,9 @@ void PrefFileformats::apply(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);
 }
 
 
@@ -1810,9 +1935,12 @@ void PrefFileformats::update(LyXRC const & rc)
        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);
        }
 }
 
@@ -1821,49 +1949,68 @@ 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()))
+               if (cit->viewer().empty())
+                       continue;
+               if (form_->converters().isReachable("xhtml", cit->name())
+                   || form_->converters().isReachable("dviluatex", cit->name())
+                   || form_->converters().isReachable("luatex", cit->name())
+                   || form_->converters().isReachable("xetex", cit->name())) {
+                       defaultFormatCB->addItem(qt_(cit->prettyname()),
+                                       QVariant(toqstr(cit->name())));
+                       defaultOTFFormatCB->addItem(qt_(cit->prettyname()),
+                                       QVariant(toqstr(cit->name())));
+               } else if (form_->converters().isReachable("latex", cit->name())
+                          || form_->converters().isReachable("pdflatex", cit->name()))
                        defaultFormatCB->addItem(qt_(cit->prettyname()),
                                        QVariant(toqstr(cit->name())));
        }
 
-       // restore selection
+       // restore 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()));
        vectorCB->setChecked((f.vectorFormat()));
+       exportMenuCB->setChecked((f.inExportMenu()));
+       exportMenuCB->setEnabled((f.documentFormat()));
        updateViewers();
        updateEditors();
 }
@@ -1876,7 +2023,10 @@ void PrefFileformats::setFlags()
                flags |= Format::document;
        if (vectorCB->isChecked())
                flags |= Format::vector;
+       if (exportMenuCB->isChecked())
+               flags |= Format::export_menu;
        currentFormat().setFlags(flags);
+       exportMenuCB->setEnabled(documentCB->isChecked());
        changed();
 }
 
@@ -1889,12 +2039,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));
@@ -1909,6 +2060,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);
@@ -1923,8 +2081,17 @@ void PrefFileformats::on_shortcutED_textEdited(const QString & s)
 void PrefFileformats::on_formatED_editingFinished()
 {
        string const newname = fromqstr(formatED->displayText());
-       if (newname == currentFormat().name())
+       string const oldname = currentFormat().name();
+       if (newname == oldname)
                return;
+       if (form_->converters().formatIsUsed(oldname)) {
+               Alert::error(_("Format in use"),
+                            _("You cannot change a format's short name "
+                              "if the format is used by a converter. "
+                              "Please remove the converter first."));
+               updateView();
+               return;
+       }
 
        currentFormat().setName(newname);
        changed();
@@ -2057,7 +2224,7 @@ Format & PrefFileformats::currentFormat()
 
 void PrefFileformats::on_formatNewPB_clicked()
 {
-       form_->formats().add("", "", "", "", "", "", Format::none);
+       form_->formats().add("", "", "", "", "", "", "", Format::none);
        updateView();
        formatsCB->setCurrentIndex(0);
        formatsCB->setFocus(Qt::OtherFocusReason);
@@ -2091,7 +2258,7 @@ void PrefFileformats::on_formatRemovePB_clicked()
 /////////////////////////////////////////////////////////////////////
 
 PrefLanguage::PrefLanguage(GuiPreferences * form)
-       : PrefModule(qt_(catLanguage), qt_("Language"), form)
+       : PrefModule(catLanguage, N_("Language"), form)
 {
        setupUi(this);
 
@@ -2107,12 +2274,12 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(autoEndCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
-       connect(useBabelCB, SIGNAL(clicked()),
-               this, SIGNAL(changed()));
-       connect(globalCB, SIGNAL(clicked()),
+       connect(languagePackageCO, SIGNAL(activated(int)),
                this, SIGNAL(changed()));
        connect(languagePackageED, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
+       connect(globalCB, SIGNAL(clicked()),
+               this, SIGNAL(changed()));
        connect(startCommandED, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
        connect(endCommandED, SIGNAL(textChanged(QString)),
@@ -2121,19 +2288,42 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(defaultDecimalPointLE, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
+       connect(defaultLengthUnitCO, SIGNAL(activated(int)),
+               this, SIGNAL(changed()));
+
+       languagePackageED->setValidator(new NoNewLineValidator(languagePackageED));
+       startCommandED->setValidator(new NoNewLineValidator(startCommandED));
+       endCommandED->setValidator(new NoNewLineValidator(endCommandED));
 
        uiLanguageCO->clear();
 
        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);
 
-       // FIXME: This is wrong, we need filter this list based on the available
-       // translation.
+       defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::CM]), Length::CM);
+       defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::IN]), Length::IN);
+
+       set<string> added;
        uiLanguageCO->blockSignals(true);
        uiLanguageCO->addItem(qt_("Default"), toqstr("auto"));
        for (int i = 0; i != language_model->rowCount(); ++i) {
                QModelIndex index = language_model->index(i, 0);
+               // Filter the list based on the available translation and add
+               // 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 (name != form->rc().gui_language 
+                   && name != lyxrc.gui_language
+                   && (!Messages::available(lang->code())
+                       || added.find(lang->code()) != added.end()))
+                               continue;
+               added.insert(lang->code());
                uiLanguageCO->addItem(index.data(Qt::DisplayRole).toString(),
                        index.data(Qt::UserRole).toString());
        }
@@ -2149,6 +2339,12 @@ void PrefLanguage::on_uiLanguageCO_currentIndexChanged(int)
 }
 
 
+void PrefLanguage::on_languagePackageCO_currentIndexChanged(int i)
+{
+        languagePackageED->setEnabled(i == 2);
+}
+
+
 void PrefLanguage::apply(LyXRC & rc) const
 {
        // FIXME: remove rtl_support bool
@@ -2157,14 +2353,23 @@ void PrefLanguage::apply(LyXRC & rc) const
        rc.mark_foreign_language = markForeignCB->isChecked();
        rc.language_auto_begin = autoBeginCB->isChecked();
        rc.language_auto_end = autoEndCB->isChecked();
-       rc.language_use_babel = useBabelCB->isChecked();
+       int const p = languagePackageCO->currentIndex();
+       if (p == 0)
+               rc.language_package_selection = LyXRC::LP_AUTO;
+       else if (p == 1)
+               rc.language_package_selection = LyXRC::LP_BABEL;
+       else if (p == 2)
+               rc.language_package_selection = LyXRC::LP_CUSTOM;
+       else if (p == 3)
+               rc.language_package_selection = LyXRC::LP_NONE;
+       rc.language_custom_package = fromqstr(languagePackageED->text());
        rc.language_global_options = globalCB->isChecked();
-       rc.language_package = fromqstr(languagePackageED->text());
        rc.language_command_begin = fromqstr(startCommandED->text());
        rc.language_command_end = fromqstr(endCommandED->text());
        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();
 }
 
 
@@ -2179,14 +2384,17 @@ void PrefLanguage::update(LyXRC const & rc)
        markForeignCB->setChecked(rc.mark_foreign_language);
        autoBeginCB->setChecked(rc.language_auto_begin);
        autoEndCB->setChecked(rc.language_auto_end);
-       useBabelCB->setChecked(rc.language_use_babel);
+       languagePackageCO->setCurrentIndex(rc.language_package_selection);
+       languagePackageED->setText(toqstr(rc.language_custom_package));
+       languagePackageED->setEnabled(languagePackageCO->currentIndex() == 2);
        globalCB->setChecked(rc.language_global_options);
-       languagePackageED->setText(toqstr(rc.language_package));
        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);
@@ -2200,7 +2408,7 @@ void PrefLanguage::update(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 PrefPrinter::PrefPrinter(GuiPreferences * form)
-       : PrefModule(qt_(catOutput), qt_("Printer"), form)
+       : PrefModule(catOutput, N_("Printer"), form)
 {
        setupUi(this);
 
@@ -2240,6 +2448,24 @@ PrefPrinter::PrefPrinter(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(printerPaperSizeED, SIGNAL(textChanged(QString)),
                this, SIGNAL(changed()));
+
+       printerNameED->setValidator(new NoNewLineValidator(printerNameED));
+       printerCommandED->setValidator(new NoNewLineValidator(printerCommandED));
+       printerEvenED->setValidator(new NoNewLineValidator(printerEvenED));
+       printerPageRangeED->setValidator(new NoNewLineValidator(printerPageRangeED));
+       printerCopiesED->setValidator(new NoNewLineValidator(printerCopiesED));
+       printerReverseED->setValidator(new NoNewLineValidator(printerReverseED));
+       printerToFileED->setValidator(new NoNewLineValidator(printerToFileED));
+       printerPaperTypeED->setValidator(new NoNewLineValidator(printerPaperTypeED));
+       printerExtraED->setValidator(new NoNewLineValidator(printerExtraED));
+       printerOddED->setValidator(new NoNewLineValidator(printerOddED));
+       printerCollatedED->setValidator(new NoNewLineValidator(printerCollatedED));
+       printerLandscapeED->setValidator(new NoNewLineValidator(printerLandscapeED));
+       printerToPrinterED->setValidator(new NoNewLineValidator(printerToPrinterED));
+       printerExtensionED->setValidator(new NoNewLineValidator(printerExtensionED));
+       printerPaperSizeED->setValidator(new NoNewLineValidator(printerPaperSizeED));
+       printerSpoolCommandED->setValidator(new NoNewLineValidator(printerSpoolCommandED));
+       printerSpoolPrefixED->setValidator(new NoNewLineValidator(printerSpoolPrefixED));
 }
 
 
@@ -2298,7 +2524,75 @@ void PrefPrinter::update(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 PrefUserInterface::PrefUserInterface(GuiPreferences * form)
-       : PrefModule(qt_(catLookAndFeel), qt_("User interface"), form)
+       : PrefModule(catLookAndFeel, N_("User Interface"), form)
+{
+       setupUi(this);
+
+       connect(uiFilePB, SIGNAL(clicked()),
+               this, SLOT(selectUi()));
+       connect(uiFileED, SIGNAL(textChanged(QString)),
+               this, SIGNAL(changed()));
+       connect(iconSetCO, SIGNAL(activated(int)),
+               this, SIGNAL(changed()));
+       connect(useSystemThemeIconsCB, SIGNAL(clicked()),
+               this, SIGNAL(changed()));
+       connect(lastfilesSB, SIGNAL(valueChanged(int)),
+               this, SIGNAL(changed()));
+       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 || QT_VERSION < 0x040600)
+       useSystemThemeIconsCB->hide();
+#endif
+}
+
+
+void PrefUserInterface::apply(LyXRC & rc) const
+{
+       rc.icon_set = fromqstr(iconSetCO->itemData(
+               iconSetCO->currentIndex()).toString());
+
+       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 PrefUserInterface::update(LyXRC const & rc)
+{
+       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);
+}
+
+
+void PrefUserInterface::selectUi()
+{
+       QString file = form_->browseUI(internalPath(uiFileED->text()));
+       if (!file.isEmpty())
+               uiFileED->setText(file);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// PrefDocumentHandling
+//
+/////////////////////////////////////////////////////////////////////
+
+PrefDocHandling::PrefDocHandling(GuiPreferences * form)
+       : PrefModule(catLookAndFeel, N_("Document Handling"), form)
 {
        setupUi(this);
 
@@ -2308,14 +2602,11 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form)
                TextLabel1, SLOT(setEnabled(bool)));
        connect(openDocumentsInTabsCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
-#if QT_VERSION < 0x040500
-       singleCloseTabButtonCB->setEnabled(false);
-#endif
+       connect(singleInstanceCB, SIGNAL(clicked()),
+               this, SIGNAL(changed()));
        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()));
@@ -2331,36 +2622,39 @@ 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)),
-               this, SIGNAL(changed()));
-       lastfilesSB->setMaximum(maxlastfiles);
 }
 
 
-void PrefUserInterface::apply(LyXRC & rc) const
+void PrefDocHandling::apply(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.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::update(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);
@@ -2374,22 +2668,20 @@ 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);
        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();
 }
@@ -2403,7 +2695,7 @@ void PrefUserInterface::on_clearSessionPB_clicked()
 /////////////////////////////////////////////////////////////////////
 
 PrefEdit::PrefEdit(GuiPreferences * form)
-       : PrefModule(qt_(catEditing), qt_("Control"), form)
+       : PrefModule(catEditing, N_("Control"), form)
 {
        setupUi(this);
 
@@ -2411,12 +2703,16 @@ PrefEdit::PrefEdit(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(scrollBelowCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
+       connect(macLikeCursorMovementCB, SIGNAL(clicked()),
+               this, SIGNAL(changed()));
        connect(sortEnvironmentsCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
        connect(groupEnvironmentsCB, SIGNAL(clicked()),
                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)),
@@ -2427,6 +2723,8 @@ 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()));
 }
@@ -2436,6 +2734,7 @@ void PrefEdit::apply(LyXRC & rc) const
 {
        rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked();
        rc.scroll_below_document = scrollBelowCB->isChecked();
+       rc.mac_like_cursor_movement = macLikeCursorMovementCB->isChecked();
        rc.sort_layouts = sortEnvironmentsCB->isChecked();
        rc.group_layouts = groupEnvironmentsCB->isChecked();
        switch (macroEditStyleCO->currentIndex()) {
@@ -2443,8 +2742,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();
@@ -2456,10 +2757,13 @@ void PrefEdit::update(LyXRC const & rc)
 {
        cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
        scrollBelowCB->setChecked(rc.scroll_below_document);
+       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);
+       toggleScrollbarCB->setChecked(rc.full_screen_statusbar);
        toggleToolbarsCB->setChecked(rc.full_screen_toolbars);
        toggleTabbarCB->setChecked(rc.full_screen_tabbar);
        toggleMenubarCB->setChecked(rc.full_screen_menubar);
@@ -2483,7 +2787,7 @@ GuiShortcutDialog::GuiShortcutDialog(QWidget * parent) : QDialog(parent)
 
 
 PrefShortcuts::PrefShortcuts(GuiPreferences * form)
-       : PrefModule(qt_(catEditing), qt_("Shortcuts"), form)
+       : PrefModule(catEditing, N_("Shortcuts"), form)
 {
        setupUi(this);
 
@@ -2504,8 +2808,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()),
@@ -2568,7 +2870,7 @@ void PrefShortcuts::updateShortcutsTW()
        shortcutsTW->clear();
 
        editItem_ = new QTreeWidgetItem(shortcutsTW);
-       editItem_->setText(0, qt_("Cursor, Mouse and Editing functions"));
+       editItem_->setText(0, qt_("Cursor, Mouse and Editing Functions"));
        editItem_->setFlags(editItem_->flags() & ~Qt::ItemIsSelectable);
 
        mathItem_ = new QTreeWidgetItem(shortcutsTW);
@@ -2888,20 +3190,40 @@ void PrefShortcuts::shortcutOkPressed()
                // nothing has changed
                return;
        
-       // make sure this key isn't already bound---and, if so, not unbound
+       // make sure this key isn't already bound---and, if so, prompt user
        FuncCode const unbind = user_unbind_.getBinding(k).action();
        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;
+               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;
+               QString const sequence_text = toqstr(k.print(KeySequence::ForGui));
+               QList<QTreeWidgetItem*> items = shortcutsTW->findItems(sequence_text,
+                       Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 1);
+               if (items.size() > 0) {
+                       // should always happen
+                       bool expanded = items[0]->parent()->isExpanded();
+                       shortcutsTW->setCurrentItem(items[0]);
+                       removeShortcut();
+                       shortcutsTW->setCurrentItem(0);
+                       // make sure user doesn't see tree expansion if
+                       // old binding wasn't in an expanded tree
+                       if (!expanded)
+                               items[0]->parent()->setExpanded(false);
+               }
        }
 
+       shortcut_->accept();
+
        if (!save_lfun_.isEmpty())
                // real modification of the lfun's shortcut,
                // so remove the previous one
@@ -2946,7 +3268,7 @@ void PrefShortcuts::shortcutRemovePressed()
 /////////////////////////////////////////////////////////////////////
 
 PrefIdentity::PrefIdentity(GuiPreferences * form)
-       : PrefModule(QString(), qt_("Identity"), form)
+       : PrefModule(QString(), N_("Identity"), form)
 {
        setupUi(this);
 
@@ -2954,6 +3276,9 @@ 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));
 }
 
 
@@ -2991,9 +3316,13 @@ 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));
-       addModule(new PrefScreenFonts(this));
+       PrefScreenFonts * screenfonts = new PrefScreenFonts(this);
+       connect(this, SIGNAL(prefsApplied(LyXRC const &)),
+                       screenfonts, SLOT(updateScreenFontSizes(LyXRC const &)));
+       addModule(screenfonts);
        addModule(new PrefColors(this));
        addModule(new PrefDisplay(this));
        addModule(new PrefInput(this));
@@ -3019,7 +3348,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
@@ -3076,6 +3405,7 @@ void GuiPreferences::applyView()
        apply(rc());
 }
 
+
 bool GuiPreferences::initialiseParams(string const &)
 {
        rc_ = lyxrc;
@@ -3100,9 +3430,14 @@ void GuiPreferences::dispatchParams()
        ostringstream ss;
        rc_.write(ss, true);
        dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
+       // issue prefsApplied signal. This will update the
+       // localized screen font sizes.
+       prefsApplied(rc_);
        // FIXME: these need lfuns
        // FIXME UNICODE
-       theBufferList().setCurrentAuthor(from_utf8(rc_.user_name), from_utf8(rc_.user_email));
+       Author const & author = 
+               Author(from_utf8(rc_.user_name), from_utf8(rc_.user_email));
+       theBufferList().recordCurrentAuthor(author);
 
        lyx::formats = formats_;
 
@@ -3169,60 +3504,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); }