]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/QPrefsDialog.C
enable Font cache only for MacOSX and inline width() for other platform.
[lyx.git] / src / frontends / qt4 / QPrefsDialog.C
index dbba8dce80d247b345ae797eb67868a2e8cb01a0..c3fa706a57b7f7575ad54eafff11f14a616b640b 100644 (file)
@@ -13,7 +13,7 @@
 #include "debug.h"
 #include "qt_helpers.h"
 
-#include "lcolorcache.h"
+#include "GuiApplication.h"
 #include "Qt2BC.h"
 #include "qt_helpers.h"
 
@@ -40,7 +40,6 @@
 
 #include "gettext.h"
 #include "LColor.h"
-#include "lcolorcache.h"
 
 #include "controllers/ControlPrefs.h"
 
@@ -97,8 +96,8 @@ void setComboxFont(QComboBox * cb, string const & family, string const & foundry
 {
        string const name = makeFontName(family, foundry);
        for (int i = 0; i < cb->count(); ++i) {
-               if (fromqstr(cb->text(i)) == name) {
-                       cb->setCurrentItem(i);
+               if (fromqstr(cb->itemText(i)) == name) {
+                       cb->setCurrentIndex(i);
                        return;
                }
        }
@@ -107,9 +106,9 @@ void setComboxFont(QComboBox * cb, string const & family, string const & foundry
 
        // We count in reverse in order to prefer the Xft foundry
        for (int i = cb->count() - 1; i >= 0; --i) {
-               pair<string, string> tmp = parseFontName(fromqstr(cb->text(i)));
+               pair<string, string> tmp = parseFontName(fromqstr(cb->itemText(i)));
                if (compare_no_case(tmp.first, family) == 0) {
-                       cb->setCurrentItem(i);
+                       cb->setCurrentIndex(i);
                        return;
                }
        }
@@ -119,9 +118,9 @@ void setComboxFont(QComboBox * cb, string const & family, string const & foundry
 
        // We count in reverse in order to prefer the Xft foundry
        for (int i = cb->count() - 1; i >= 0; --i) {
-               pair<string, string> tmp = parseFontName(fromqstr(cb->text(i)));
+               pair<string, string> tmp = parseFontName(fromqstr(cb->itemText(i)));
                if (compare_no_case(tmp.first, tmpfam.first) == 0) {
-                       cb->setCurrentItem(i);
+                       cb->setCurrentIndex(i);
                        return;
                }
        }
@@ -131,13 +130,13 @@ void setComboxFont(QComboBox * cb, string const & family, string const & foundry
 
        QFont font;
 
-       if (family == lyx_gui::roman_font_name()) {
+       if (family == theApp->romanFontName()) {
                font.setStyleHint(QFont::Serif);
                font.setFamily(family.c_str());
-       } else if (family == lyx_gui::sans_font_name()) {
+       } else if (family == theApp->sansFontName()) {
                font.setStyleHint(QFont::SansSerif);
                font.setFamily(family.c_str());
-       } else if (family == lyx_gui::typewriter_font_name()) {
+       } else if (family == theApp->typewriterFontName()) {
                font.setStyleHint(QFont::TypeWriter);
                font.setFamily(family.c_str());
        } else {
@@ -152,10 +151,10 @@ void setComboxFont(QComboBox * cb, string const & family, string const & foundry
        lyxerr << "Apparent font is " << default_font_name << endl;
 
        for (int i = 0; i < cb->count(); ++i) {
-               lyxerr << "Looking at " << fromqstr(cb->text(i)) << endl;
-               if (compare_no_case(fromqstr(cb->text(i)),
+               lyxerr << "Looking at " << fromqstr(cb->itemText(i)) << endl;
+               if (compare_no_case(fromqstr(cb->itemText(i)),
                                    default_font_name) == 0) {
-                       cb->setCurrentItem(i);
+                       cb->setCurrentIndex(i);
                        return;
                }
        }
@@ -180,11 +179,11 @@ string const internal_path(QString const & input)
 
 
 PrefAscii::PrefAscii(QWidget * parent)
-: PrefModule(_(Outputs), _("Plain text"), 0, parent)
+: PrefModule(lyx::to_utf8(_(Outputs)), lyx::to_utf8(_("Plain text")), 0, parent)
 {
        setupUi(this);
        connect(asciiLinelengthSB, SIGNAL(valueChanged(int)),
-               this, SIGNAL(changed));
+               this, SIGNAL(changed()));
        connect(asciiRoffED, SIGNAL(textChanged(const QString&)),
                this, SIGNAL(changed()));
 }
@@ -205,7 +204,7 @@ void PrefAscii::update(LyXRC const & rc)
 
 
 PrefDate::PrefDate(QWidget * parent)
-: PrefModule(_(Outputs), _("Date format"), 0, parent)
+: PrefModule(lyx::to_utf8(_(Outputs)), lyx::to_utf8(_("Date format")), 0, parent)
 {
        setupUi(this);
        connect(DateED, SIGNAL(textChanged(const QString&)),
@@ -226,7 +225,7 @@ void PrefDate::update(LyXRC const & rc)
 
 
 PrefKeyboard::PrefKeyboard(QPrefs * form, QWidget * parent)
-: PrefModule(_(LookAndFeel), _("Keyboard"), form, parent)
+: PrefModule(lyx::to_utf8(_(LookAndFeel)), lyx::to_utf8(_("Keyboard")), form, parent)
 {
        setupUi(this);
 
@@ -283,7 +282,7 @@ QString PrefKeyboard::testKeymap(QString keymap)
 }
 
 
-void PrefKeyboard::on_firstKeymapED_clicked()
+void PrefKeyboard::on_firstKeymapPB_clicked(bool)
 {
        QString file = testKeymap(firstKeymapED->text());
        if (!file.isEmpty())
@@ -291,7 +290,7 @@ void PrefKeyboard::on_firstKeymapED_clicked()
 }
 
 
-void PrefKeyboard::on_secondKeymapED_clicked()
+void PrefKeyboard::on_secondKeymapPB_clicked(bool)
 {
        QString file = testKeymap(secondKeymapED->text());
        if (!file.isEmpty())
@@ -300,7 +299,7 @@ void PrefKeyboard::on_secondKeymapED_clicked()
 
 
 PrefLatex::PrefLatex(QPrefs * form, QWidget * parent)
-: PrefModule(_(Outputs), _("LaTeX"), form, parent)
+: PrefModule(lyx::to_utf8(_(Outputs)), lyx::to_utf8(_("LaTeX")), form, parent)
 {
        setupUi(this);
        connect(latexEncodingED, SIGNAL(textChanged(const QString&)),
@@ -329,7 +328,7 @@ void PrefLatex::apply(LyXRC & rc) const
        rc.auto_reset_options = latexAutoresetCB->isChecked();
        rc.view_dvi_paper_option = fromqstr(latexDviPaperED->text());
        rc.default_papersize =
-               form_->controller().toPaperSize(latexPaperSizeCO->currentItem());
+               form_->controller().toPaperSize(latexPaperSizeCO->currentIndex());
 }
 
 
@@ -347,7 +346,7 @@ void PrefLatex::update(LyXRC const & rc)
 
 
 PrefScreenFonts::PrefScreenFonts(QPrefs * form, QWidget * parent)
-: PrefModule(_(LookAndFeel), _("Screen fonts"), form, parent)
+: PrefModule(lyx::to_utf8(_(LookAndFeel)), lyx::to_utf8(_("Screen fonts")), form, parent)
 {
        setupUi(this);
 
@@ -361,9 +360,9 @@ PrefScreenFonts::PrefScreenFonts(QPrefs * form, QWidget * parent)
        QFontDatabase fontdb;
        QStringList families(fontdb.families());
        for (QStringList::Iterator it = families.begin(); it != families.end(); ++it) {
-               screenRomanCO->insertItem(*it);
-               screenSansCO->insertItem(*it);
-               screenTypewriterCO->insertItem(*it);
+               screenRomanCO->addItem(*it);
+               screenSansCO->addItem(*it);
+               screenTypewriterCO->addItem(*it);
        }
        connect(screenRomanCO, SIGNAL(activated(const QString&)),
                this, SIGNAL(changed()));
@@ -499,7 +498,7 @@ void PrefScreenFonts::select_typewriter(const QString& name)
 
 
 PrefColors::PrefColors(QPrefs * form, QWidget * parent)
-: PrefModule(_(LookAndFeel), _("Colors"), form, parent)
+: PrefModule(lyx::to_utf8(_(LookAndFeel)), lyx::to_utf8(_("Colors")), form, parent)
 {
        setupUi(this);
 
@@ -519,32 +518,33 @@ PrefColors::PrefColors(QPrefs * form, QWidget * parent)
                        || lc == LColor::ignore) continue;
 
                lcolors_.push_back(lc);
-               QColor color = QColor(lcolorcache.get(lc));
+               QColor color = QColor(guiApp->colorCache().get(lc));
                prefcolors_.push_back(color.name());
                QPixmap coloritem(32, 32);
                coloritem.fill(color);
-               QListWidgetItem * newItem = new QListWidgetItem(QIcon(coloritem),
+               // This is not a memory leak:
+               /*QListWidgetItem * newItem =*/ new QListWidgetItem(QIcon(coloritem),
                        toqstr(lcolor.getGUIName(lc)), lyxObjectsLW);
        }
        newcolors_ = prefcolors_;
 
-       connect(colorChangePB, SIGNAL(clicked()), 
+       connect(colorChangePB, SIGNAL(clicked()),
                this, SLOT(change_color()));
-       connect(lyxObjectsLW, SIGNAL(itemActivated(QListWidgetItem*)), 
+       connect(lyxObjectsLW, SIGNAL(itemActivated(QListWidgetItem*)),
                this, SLOT(change_color()));
 }
 
 
-void PrefColors::apply(LyXRC & rc) const
+void PrefColors::apply(LyXRC & /*rc*/) const
 {
-       for (int i = 0; i < lcolors_.size(); ++i) {
+       for (unsigned int i = 0; i < lcolors_.size(); ++i) {
                if (prefcolors_[i]!=newcolors_[i])
                        form_->controller().setColor(lcolors_[i], fromqstr(newcolors_[i]));
        }
 }
 
 
-void PrefColors::update(LyXRC const & rc)
+void PrefColors::update(LyXRC const & /*rc*/)
 {
 }
 
@@ -552,21 +552,22 @@ void PrefColors::change_color()
 {
        int const row = lyxObjectsLW->currentRow();
        QString color = newcolors_[row];
-       QColor c(QColorDialog::getColor(QColor(color), 
-               qApp->focusWidget() ? qApp->focusWidget() : qApp->mainWidget()));
+       QColor c(QColorDialog::getColor(QColor(color),
+               qApp->focusWidget()));
 
        if (c.name()!=color) {
                newcolors_[row] = c.name();
                QPixmap coloritem(32, 32);
                coloritem.fill(c);
                lyxObjectsLW->currentItem()->setIcon(QIcon(coloritem));
-               emit changed();
+               // emit signal
+               changed();
        }
 }
 
 
 PrefCygwinPath::PrefCygwinPath(QWidget * parent)
-: PrefModule(_(Outputs), _("Paths"), 0, parent)
+: PrefModule(lyx::to_utf8(_(Outputs)), lyx::to_utf8(_("Paths")), 0, parent)
 {
        setupUi(this);
        connect(pathCB, SIGNAL(toggled(bool)),
@@ -576,18 +577,18 @@ PrefCygwinPath::PrefCygwinPath(QWidget * parent)
 
 void PrefCygwinPath::apply(LyXRC & rc) const
 {
-       rc.cygwin_path_fix = pathCB->isChecked();
+       rc.windows_style_tex_paths = pathCB->isChecked();
 }
 
 
 void PrefCygwinPath::update(LyXRC const & rc)
 {
-       pathCB->setChecked(rc.cygwin_path_fix);
+       pathCB->setChecked(rc.windows_style_tex_paths);
 }
 
 
 PrefDisplay::PrefDisplay(QWidget * parent)
-: PrefModule(_(LookAndFeel), _("Graphics"), 0, parent)
+: PrefModule(lyx::to_utf8(_(LookAndFeel)), lyx::to_utf8(_("Graphics")), 0, parent)
 {
        setupUi(this);
        connect(instantPreviewCO, SIGNAL(activated(int)),
@@ -599,14 +600,14 @@ PrefDisplay::PrefDisplay(QWidget * parent)
 
 void PrefDisplay::apply(LyXRC & rc) const
 {
-       switch (instantPreviewCO->currentItem()) {
+       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;
        }
 
        lyx::graphics::DisplayType dtype;
-       switch (displayGraphicsCO->currentItem()) {
+       switch (displayGraphicsCO->currentIndex()) {
        case 3: dtype = lyx::graphics::NoDisplay; break;
        case 2: dtype = lyx::graphics::ColorDisplay; break;
        case 1: dtype = lyx::graphics::GrayscaleDisplay;        break;
@@ -654,7 +655,7 @@ void PrefDisplay::update(LyXRC const & rc)
 
 
 PrefPaths::PrefPaths(QPrefs * form, QWidget * parent)
-: PrefModule(string(), _("Paths"), form, parent)
+: PrefModule(string(), lyx::to_utf8(_("Paths")), form, parent)
 {
        setupUi(this);
        connect(templateDirPB, SIGNAL(clicked()), this, SLOT(select_templatedir()));
@@ -700,11 +701,11 @@ void PrefPaths::update(LyXRC const & rc)
        lyxserverDirED->setText(external_path(rc.lyxpipes));
 }
 
-// NB: the _() is OK here because it gets passed back and we toqstr() them
+// NB: the lyx::to_utf8(_() is OK here because it gets passed back and we toqstr()) them
 
 void PrefPaths::select_templatedir()
 {
-       string file(form_->controller().browsedir(fromqstr(templateDirED->text()), _("Select a document templates directory")));
+       string file(form_->controller().browsedir(fromqstr(templateDirED->text()), lyx::to_utf8(_("Select a document templates directory"))));
        if (!file.empty())
                templateDirED->setText(toqstr(file));
 }
@@ -712,7 +713,7 @@ void PrefPaths::select_templatedir()
 
 void PrefPaths::select_tempdir()
 {
-       string file(form_->controller().browsedir(fromqstr(tempDirED->text()), _("Select a temporary directory")));
+       string file(form_->controller().browsedir(fromqstr(tempDirED->text()), lyx::to_utf8(_("Select a temporary directory"))));
        if (!file.empty())
                tempDirED->setText(toqstr(file));
 }
@@ -720,7 +721,7 @@ void PrefPaths::select_tempdir()
 
 void PrefPaths::select_backupdir()
 {
-       string file(form_->controller().browsedir(fromqstr(backupDirED->text()), _("Select a backups directory")));
+       string file(form_->controller().browsedir(fromqstr(backupDirED->text()), lyx::to_utf8(_("Select a backups directory"))));
        if (!file.empty())
                backupDirED->setText(toqstr(file));
 }
@@ -728,7 +729,7 @@ void PrefPaths::select_backupdir()
 
 void PrefPaths::select_workingdir()
 {
-       string file(form_->controller().browsedir(fromqstr(workingDirED->text()), _("Select a document directory")));
+       string file(form_->controller().browsedir(fromqstr(workingDirED->text()), lyx::to_utf8(_("Select a document directory"))));
        if (!file.empty())
                workingDirED->setText(toqstr(file));
 }
@@ -736,14 +737,14 @@ void PrefPaths::select_workingdir()
 
 void PrefPaths::select_lyxpipe()
 {
-       string file(form_->controller().browse(fromqstr(lyxserverDirED->text()), _("Give a filename for the LyX server pipe")));
+       string file(form_->controller().browse(fromqstr(lyxserverDirED->text()), lyx::to_utf8(_("Give a filename for the LyX server pipe"))));
        if (!file.empty())
                lyxserverDirED->setText(toqstr(file));
 }
 
 
 PrefSpellchecker::PrefSpellchecker(QPrefs * form, QWidget * parent)
-: PrefModule(_(LanguageSettings), _("Spellchecker"), form, parent)
+: PrefModule(lyx::to_utf8(_(LanguageSettings)), lyx::to_utf8(_("Spellchecker")), form, parent)
 {
        setupUi(this);
 
@@ -765,14 +766,14 @@ PrefSpellchecker::PrefSpellchecker(QPrefs * form, QWidget * parent)
        connect(inputEncodingCB, SIGNAL(toggled(bool)),
                this, SIGNAL(changed()));
 
-       spellCommandCO->insertItem(qt_("ispell"));
-       spellCommandCO->insertItem(qt_("aspell"));
-       spellCommandCO->insertItem(qt_("hspell"));
+       spellCommandCO->addItem(qt_("ispell"));
+       spellCommandCO->addItem(qt_("aspell"));
+       spellCommandCO->addItem(qt_("hspell"));
 #ifdef USE_PSPELL
-       spellCommandCO->insertItem(qt_("pspell (library)"));
+       spellCommandCO->addItem(qt_("pspell (library)"));
 #else
 #ifdef USE_ASPELL
-       spellCommandCO->insertItem(qt_("aspell (library)"));
+       spellCommandCO->addItem(qt_("aspell (library)"));
 #endif
 #endif
 }
@@ -780,7 +781,7 @@ PrefSpellchecker::PrefSpellchecker(QPrefs * form, QWidget * parent)
 
 void PrefSpellchecker::apply(LyXRC & rc) const
 {
-       switch (spellCommandCO->currentItem()) {
+       switch (spellCommandCO->currentIndex()) {
                case 0:
                case 1:
                case 2:
@@ -844,41 +845,41 @@ void PrefSpellchecker::select_dict()
 
 
 PrefConverters::PrefConverters(QPrefs * form, QWidget * parent)
-: PrefModule(string(), _("Converters"), form, parent)
+: PrefModule(string(), lyx::to_utf8(_("Converters")), form, parent)
 {
        setupUi(this);
 
-       connect(converterNewPB, SIGNAL(clicked()), 
+       connect(converterNewPB, SIGNAL(clicked()),
                this, SLOT(new_converter()));
-       connect(converterRemovePB, SIGNAL(clicked()), 
+       connect(converterRemovePB, SIGNAL(clicked()),
                this, SLOT(remove_converter()));
-       connect(converterModifyPB, SIGNAL(clicked()), 
+       connect(converterModifyPB, SIGNAL(clicked()),
                this, SLOT(modify_converter()));
-       connect(convertersLW, SIGNAL(currentRowChanged(int)), 
+       connect(convertersLW, SIGNAL(currentRowChanged(int)),
                this, SLOT(switch_converter(int)));
-       connect(converterFromCO, SIGNAL(activated(const QString&)), 
+       connect(converterFromCO, SIGNAL(activated(const QString&)),
                this, SLOT(converter_changed()));
-       connect(converterToCO, SIGNAL(activated(const QString&)), 
+       connect(converterToCO, SIGNAL(activated(const QString&)),
                this, SLOT(converter_changed()));
-       connect(converterED, SIGNAL(textChanged(const QString&)), 
+       connect(converterED, SIGNAL(textChanged(const QString&)),
                this, SLOT(converter_changed()));
-       connect(converterFlagED, SIGNAL(textChanged(const QString&)), 
+       connect(converterFlagED, SIGNAL(textChanged(const QString&)),
                this, SLOT(converter_changed()));
-       connect(converterNewPB, SIGNAL(clicked()), 
+       connect(converterNewPB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
-       connect(converterRemovePB, SIGNAL(clicked()), 
+       connect(converterRemovePB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
-       connect(converterModifyPB, SIGNAL(clicked()), 
+       connect(converterModifyPB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
 }
 
 
-void PrefConverters::apply(LyXRC & rc) const
+void PrefConverters::apply(LyXRC & /*rc*/) const
 {
 }
 
 
-void PrefConverters::update(LyXRC const & rc)
+void PrefConverters::update(LyXRC const & /*rc*/)
 {
        updateGui();
 }
@@ -896,8 +897,8 @@ void PrefConverters::updateGui()
        Formats::const_iterator cit = form_->formats().begin();
        Formats::const_iterator end = form_->formats().end();
        for (; cit != end; ++cit) {
-               converterFromCO->insertItem(toqstr(cit->prettyname()));
-               converterToCO->insertItem(toqstr(cit->prettyname()));
+               converterFromCO->addItem(toqstr(cit->prettyname()));
+               converterToCO->addItem(toqstr(cit->prettyname()));
        }
 
        convertersLW->clear();
@@ -914,7 +915,7 @@ void PrefConverters::updateGui()
 
        // restore selection
        if (!current.isEmpty()) {
-               QList<QListWidgetItem *> const item = 
+               QList<QListWidgetItem *> const item =
                        convertersLW->findItems(current, Qt::MatchExactly);
                if (item.size()>0)
                        convertersLW->setCurrentItem(item.at(0));
@@ -952,9 +953,9 @@ void PrefConverters::converter_changed()
 void PrefConverters::updateButtons()
 {
        Format const & from(form_->formats().get(
-               converterFromCO->currentItem()));
+               converterFromCO->currentIndex()));
        Format const & to(form_->formats().get(
-               converterToCO->currentItem()));
+               converterToCO->currentIndex()));
        int const sel = form_->converters().getNumber(from.name(), to.name());
        bool const known = !(sel < 0);
        bool const valid = !(converterED->text().isEmpty()
@@ -979,8 +980,8 @@ void PrefConverters::updateButtons()
 // specify unique from/to or it doesn't appear. This is really bad UI
 void PrefConverters::new_converter()
 {
-       Format const & from(form_->formats().get(converterFromCO->currentItem()));
-       Format const & to(form_->formats().get(converterToCO->currentItem()));
+       Format const & from(form_->formats().get(converterFromCO->currentIndex()));
+       Format const & to(form_->formats().get(converterToCO->currentIndex()));
        string const command(fromqstr(converterED->text()));
        string const flags(fromqstr(converterFlagED->text()));
 
@@ -1004,8 +1005,8 @@ void PrefConverters::modify_converter()
        QString const current_text =
                convertersLW->currentItem()->text();
 
-       Format const & from(form_->formats().get(converterFromCO->currentItem()));
-       Format const & to(form_->formats().get(converterToCO->currentItem()));
+       Format const & from(form_->formats().get(converterFromCO->currentIndex()));
+       Format const & to(form_->formats().get(converterToCO->currentIndex()));
        string flags(fromqstr(converterFlagED->text()));
        string name(fromqstr(converterED->text()));
 
@@ -1025,22 +1026,22 @@ void PrefConverters::modify_converter()
 
 void PrefConverters::remove_converter()
 {
-       Format const & from(form_->formats().get(converterFromCO->currentItem()));
-       Format const & to(form_->formats().get(converterToCO->currentItem()));
+       Format const & from(form_->formats().get(converterFromCO->currentIndex()));
+       Format const & to(form_->formats().get(converterToCO->currentIndex()));
        form_->converters().erase(from.name(), to.name());
        updateGui();
 }
 
 
 PrefCopiers::PrefCopiers(QPrefs * form, QWidget * parent)
-: PrefModule(string(), _("Copiers"), form, parent)
+: PrefModule(string(), lyx::to_utf8(_("Copiers")), form, parent)
 {
        setupUi(this);
 
        connect(copierNewPB, SIGNAL(clicked()), this, SLOT(new_copier()));
        connect(copierRemovePB, SIGNAL(clicked()), this, SLOT(remove_copier()));
        connect(copierModifyPB, SIGNAL(clicked()), this, SLOT(modify_copier()));
-       connect(AllCopiersLW, SIGNAL(currentRowChanged(int)), 
+       connect(AllCopiersLW, SIGNAL(currentRowChanged(int)),
                this, SLOT(switch_copierLB(int)));
        connect(copierFormatCO, SIGNAL(activated(int)), this, SLOT(switch_copierCO(int)));
        connect(copierNewPB, SIGNAL(clicked()),
@@ -1054,12 +1055,12 @@ PrefCopiers::PrefCopiers(QPrefs * form, QWidget * parent)
 }
 
 
-void PrefCopiers::apply(LyXRC & rc) const
+void PrefCopiers::apply(LyXRC & /*rc*/) const
 {
 }
 
 
-void PrefCopiers::update(LyXRC const & rc)
+void PrefCopiers::update(LyXRC const & /*rc*/)
 {
        update();
 }
@@ -1075,7 +1076,7 @@ void PrefCopiers::update()
        for (Formats::const_iterator it = form_->formats().begin(),
                     end = form_->formats().end();
             it != end; ++it) {
-               copierFormatCO->insertItem(toqstr(it->prettyname()));
+               copierFormatCO->addItem(toqstr(it->prettyname()));
        }
 
        // The browser widget
@@ -1094,7 +1095,7 @@ void PrefCopiers::update()
 
        // restore selection
        if (!current.isEmpty()) {
-               QList<QListWidgetItem *> item = 
+               QList<QListWidgetItem *> item =
                        AllCopiersLW->findItems(current, Qt::MatchExactly);
                if (item.size()>0)
                        AllCopiersLW->setCurrentItem(item.at(0));
@@ -1148,7 +1149,7 @@ void PrefCopiers::switch_copierLB(int row)
        copierED->clear();
        int const combo_size = copierFormatCO->count();
        for (int i = 0; i < combo_size; ++i) {
-               QString const text = copierFormatCO->text(i);
+               QString const text = copierFormatCO->itemText(i);
                if (text == gui_name) {
                        copierFormatCO->setCurrentIndex(i);
                        copierED->setText(command);
@@ -1201,7 +1202,7 @@ void PrefCopiers::updateButtons()
        QString selected = copierFormatCO->currentText();
 
        bool known = false;
-       for (unsigned int i = 0; i != AllCopiersLW->count(); i++) {
+       for (int i = 0; i < AllCopiersLW->count(); ++i) {
                if (AllCopiersLW->item(i)->text() == selected)
                        known = true;
        }
@@ -1276,14 +1277,14 @@ void PrefCopiers::remove_copier()
 
 
 PrefFileformats::PrefFileformats(QPrefs * form, QWidget * parent)
-: PrefModule(string(), _("File formats"), form, parent)
+: PrefModule(string(), lyx::to_utf8(_("File formats")), form, parent)
 {
        setupUi(this);
 
        connect(formatNewPB, SIGNAL(clicked()), this, SLOT(new_format()));
        connect(formatRemovePB, SIGNAL(clicked()), this, SLOT(remove_format()));
        connect(formatModifyPB, SIGNAL(clicked()), this, SLOT(modify_format()));
-       connect(formatsLW, SIGNAL(currentRowChanged(int)), 
+       connect(formatsLW, SIGNAL(currentRowChanged(int)),
                this, SLOT(switch_format(int)));
        connect(formatED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
        connect(guiNameED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
@@ -1291,6 +1292,8 @@ PrefFileformats::PrefFileformats(QPrefs * form, QWidget * parent)
        connect(extensionED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
        connect(viewerED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
        connect(editorED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
+       connect(documentCB, SIGNAL(toggled(bool)), this, SLOT(fileformat_changed()));
+       connect(vectorCB, SIGNAL(toggled(bool)), this, SLOT(fileformat_changed()));
        connect(formatNewPB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
        connect(formatRemovePB, SIGNAL(clicked()),
@@ -1300,12 +1303,12 @@ PrefFileformats::PrefFileformats(QPrefs * form, QWidget * parent)
 }
 
 
-void PrefFileformats::apply(LyXRC & rc) const
+void PrefFileformats::apply(LyXRC & /*rc*/) const
 {
 }
 
 
-void PrefFileformats::update(LyXRC const & rc)
+void PrefFileformats::update(LyXRC const & /*rc*/)
 {
        update();
 }
@@ -1353,6 +1356,8 @@ void PrefFileformats::switch_format(int nr)
        shortcutED->setText(toqstr(f.shortcut()));
        viewerED->setText(toqstr(f.viewer()));
        editorED->setText(toqstr(f.editor()));
+       documentCB->setChecked((f.documentFormat()));
+       vectorCB->setChecked((f.vectorFormat()));
        formatRemovePB->setEnabled(
                !form_->converters().formatIsUsed(f.name()));
 
@@ -1373,7 +1378,7 @@ void PrefFileformats::updateButtons()
        int const sel = form_->formats().getNumber(fromqstr(format));
        bool gui_name_known = false;
        int where = sel;
-       for (unsigned int i = 0; i != formatsLW->count(); i++) {
+       for (int i = 0; i < formatsLW->count(); ++i) {
                if (formatsLW->item(i)->text() == gui_name) {
                        gui_name_known = true;
                        where = formatsLW->item(i)->type();
@@ -1394,16 +1399,21 @@ void PrefFileformats::updateButtons()
        string const old_extension(f.extension());
        string const old_viewer(f.viewer());
        string const old_editor(f.editor());
+       bool const old_document(f.documentFormat());
+       bool const old_vector(f.vectorFormat());
 
        string const new_pretty(fromqstr(gui_name));
        string const new_shortcut(fromqstr(shortcutED->text()));
        string const new_extension(fromqstr(extensionED->text()));
        string const new_viewer(fromqstr(viewerED->text()));
        string const new_editor(fromqstr(editorED->text()));
+       bool const new_document(documentCB->isChecked());
+       bool const new_vector(vectorCB->isChecked());
 
        bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut)
                || (old_extension != new_extension) || (old_viewer != new_viewer)
-               || (old_editor != new_editor));
+               || old_editor != new_editor || old_document != new_document
+               || old_vector != new_vector);
 
        formatModifyPB->setEnabled(
                valid && known && modified && !known_otherwise);
@@ -1424,8 +1434,14 @@ void PrefFileformats::new_format()
        string const shortcut = fromqstr(shortcutED->text());
        string const viewer = fromqstr(viewerED->text());
        string const editor = fromqstr(editorED->text());
-
-       form_->formats().add(name, extension, prettyname, shortcut, viewer, editor);
+       int flags = Format::none;
+       if (documentCB->isChecked())
+               flags |= Format::document;
+       if (vectorCB->isChecked())
+               flags |= Format::vector;
+
+       form_->formats().add(name, extension, prettyname, shortcut, viewer,
+                            editor, flags);
        form_->formats().sort();
        update();
 
@@ -1457,8 +1473,14 @@ void PrefFileformats::modify_format()
        string const shortcut = fromqstr(shortcutED->text());
        string const viewer = fromqstr(viewerED->text());
        string const editor = fromqstr(editorED->text());
-
-       form_->formats().add(name, extension, prettyname, shortcut, viewer, editor);
+       int flags = Format::none;
+       if (documentCB->isChecked())
+               flags |= Format::document;
+       if (vectorCB->isChecked())
+               flags |= Format::vector;
+
+       form_->formats().add(name, extension, prettyname, shortcut, viewer,
+                            editor, flags);
        form_->formats().sort();
 
        formatsLW->setUpdatesEnabled(false);
@@ -1484,8 +1506,8 @@ void PrefFileformats::remove_format()
        string const current_text = form_->formats().get(nr).name();
        if (form_->converters().formatIsUsed(current_text)) {
                Alert::error(_("Format in use"),
-                               _("Cannot remove a Format used by a Converter. "
-                                     "Remove the converter first."));
+                            _("Cannot remove a Format used by a Converter. "
+                                           "Remove the converter first."));
                return;
        }
 
@@ -1500,7 +1522,7 @@ void PrefFileformats::remove_format()
 
 
 PrefLanguage::PrefLanguage(QWidget * parent)
-: PrefModule(string(), _("Language"), 0, parent)
+: PrefModule(string(), lyx::to_utf8(_("Language")), 0, parent)
 {
        setupUi(this);
 
@@ -1536,7 +1558,7 @@ PrefLanguage::PrefLanguage(QWidget * parent)
        std::vector<LanguagePair>::const_iterator lit  = langs.begin();
        std::vector<LanguagePair>::const_iterator lend = langs.end();
        for (; lit != lend; ++lit) {
-               defaultLanguageCO->insertItem(toqstr(lit->first));
+               defaultLanguageCO->addItem(toqstr(lit->first));
        }
 }
 
@@ -1553,7 +1575,7 @@ void PrefLanguage::apply(LyXRC & rc) const
        rc.language_package = fromqstr(languagePackageED->text());
        rc.language_command_begin = fromqstr(startCommandED->text());
        rc.language_command_end = fromqstr(endCommandED->text());
-       rc.default_language = lang_[defaultLanguageCO->currentItem()];
+       rc.default_language = lang_[defaultLanguageCO->currentIndex()];
 }
 
 
@@ -1576,7 +1598,7 @@ void PrefLanguage::update(LyXRC const & rc)
 
 
 PrefPrinter::PrefPrinter(QWidget * parent)
-: PrefModule(_(Outputs), _("Printer"), 0, parent)
+: PrefModule(lyx::to_utf8(_(Outputs)), lyx::to_utf8(_("Printer")), 0, parent)
 {
        setupUi(this);
 
@@ -1668,7 +1690,7 @@ void PrefPrinter::update(LyXRC const & rc)
 
 
 PrefUserInterface::PrefUserInterface(QPrefs * form, QWidget * parent)
-: PrefModule(_(LookAndFeel), _("User interface"), form, parent)
+: PrefModule(lyx::to_utf8(_(LookAndFeel)), lyx::to_utf8(_("User interface")), form, parent)
 {
        setupUi(this);
 
@@ -1685,6 +1707,22 @@ PrefUserInterface::PrefUserInterface(QPrefs * form, QWidget * parent)
                this, SIGNAL(changed()));
        connect(loadSessionCB, SIGNAL(toggled(bool)),
                this, SIGNAL(changed()));
+       connect(loadWindowSizeCB, SIGNAL(toggled(bool)),
+               this, SIGNAL(changed()));
+       connect(loadWindowSizeCB, SIGNAL(toggled(bool)),
+               windowWidthLA, SLOT(setDisabled(bool)));
+       connect(loadWindowSizeCB, SIGNAL(toggled(bool)),
+               windowHeightLA, SLOT(setDisabled(bool)));
+       connect(loadWindowSizeCB, SIGNAL(toggled(bool)),
+               windowWidthSB, SLOT(setDisabled(bool)));
+       connect(loadWindowSizeCB, SIGNAL(toggled(bool)),
+               windowHeightSB, SLOT(setDisabled(bool)));
+       connect(loadWindowLocationCB, SIGNAL(toggled(bool)),
+               this, SIGNAL(changed()));
+       connect(windowWidthSB, SIGNAL(valueChanged(int)),
+               this, SIGNAL(changed()));
+       connect(windowHeightSB, SIGNAL(valueChanged(int)),
+               this, SIGNAL(changed()));
        connect(cursorFollowsCB, SIGNAL(toggled(bool)),
                this, SIGNAL(changed()));
        connect(autoSaveSB, SIGNAL(valueChanged(int)),
@@ -1693,7 +1731,7 @@ PrefUserInterface::PrefUserInterface(QPrefs * form, QWidget * parent)
                this, SIGNAL(changed()));
        connect(lastfilesSB, SIGNAL(valueChanged(int)),
                this, SIGNAL(changed()));
-       lastfilesSB->setMaxValue(maxlastfiles);
+       lastfilesSB->setMaximum(maxlastfiles);
 }
 
 
@@ -1703,6 +1741,14 @@ void PrefUserInterface::apply(LyXRC & rc) const
        rc.bind_file = internal_path(bindFileED->text());
        rc.use_lastfilepos = restoreCursorCB->isChecked();
        rc.load_session = loadSessionCB->isChecked();
+       if (loadWindowSizeCB->isChecked()) {
+               rc.geometry_width = 0;
+               rc.geometry_height = 0;
+       } else {
+               rc.geometry_width = windowWidthSB->value();
+               rc.geometry_height = windowHeightSB->value();
+       }
+       rc.geometry_xysaved = loadWindowLocationCB->isChecked();
        rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked();
        rc.autosave = autoSaveSB->value() * 60;
        rc.make_backup = autoSaveCB->isChecked();
@@ -1716,6 +1762,17 @@ void PrefUserInterface::update(LyXRC const & rc)
        bindFileED->setText(external_path(rc.bind_file));
        restoreCursorCB->setChecked(rc.use_lastfilepos);
        loadSessionCB->setChecked(rc.load_session);
+       bool loadWindowSize = rc.geometry_width == 0 && rc.geometry_height == 0;
+       loadWindowSizeCB->setChecked(loadWindowSize);
+       windowWidthSB->setEnabled(!loadWindowSize);
+       windowHeightSB->setEnabled(!loadWindowSize);
+       windowWidthLA->setEnabled(!loadWindowSize);
+       windowHeightLA->setEnabled(!loadWindowSize);
+       if (!loadWindowSize) {
+               windowWidthSB->setValue(rc.geometry_width);
+               windowHeightSB->setValue(rc.geometry_height);
+       }
+       loadWindowLocationCB->setChecked(rc.geometry_xysaved);
        cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
        // convert to minutes
        int mins(rc.autosave / 60);
@@ -1745,7 +1802,7 @@ void PrefUserInterface::select_bind()
 
 
 PrefIdentity::PrefIdentity(QWidget * parent)
-: PrefModule(string(), _("Identity"), 0, parent)
+: PrefModule(string(), lyx::to_utf8(_("Identity")), 0, parent)
 {
        setupUi(this);
 
@@ -1793,7 +1850,7 @@ QPrefsDialog::QPrefsDialog(QPrefs * form)
        add(new PrefScreenFonts(form_));
        add(new PrefColors(form_));
 
-#if defined(__CYGWIN__) || defined(__CYGWIN32__)
+#if defined(__CYGWIN__) || defined(_WIN32)
        add(new PrefCygwinPath);
 #endif
 
@@ -1808,13 +1865,13 @@ QPrefsDialog::QPrefsDialog(QPrefs * form)
        add(formats);
 
        add(new PrefCopiers(form_));
-       
+
        add(new PrefLanguage);
        add(new PrefPrinter);
        add(new PrefUserInterface(form_));
        add(new PrefIdentity);
 
-       prefsPS->setCurrentPanel(_("User interface"));
+       prefsPS->setCurrentPanel(lyx::to_utf8(_("User interface")));
 
        form_->bcview().setOK(savePB);
        form_->bcview().setApply(applyPB);