+ rc.windows_style_tex_paths = pathCB->isChecked();
+}
+
+
+void PrefCygwinPath::update(LyXRC const & rc)
+{
+ pathCB->setChecked(rc.windows_style_tex_paths);
+}
+
+
+PrefDisplay::PrefDisplay(QWidget * parent)
+: PrefModule(_(LookAndFeel), _("Graphics"), 0, parent)
+{
+ setupUi(this);
+ connect(instantPreviewCO, SIGNAL(activated(int)),
+ this, SIGNAL(changed()));
+ connect(displayGraphicsCO, SIGNAL(activated(int)),
+ this, SIGNAL(changed()));
+}
+
+
+void PrefDisplay::apply(LyXRC & rc) const
+{
+ switch (instantPreviewCO->currentItem()) {
+ 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()) {
+ case 3: dtype = lyx::graphics::NoDisplay; break;
+ case 2: dtype = lyx::graphics::ColorDisplay; break;
+ case 1: dtype = lyx::graphics::GrayscaleDisplay; break;
+ case 0: dtype = lyx::graphics::MonochromeDisplay; break;
+ default: dtype = lyx::graphics::GrayscaleDisplay;
+ }
+ rc.display_graphics = dtype;
+
+#ifdef WITH_WARNINGS
+#warning FIXME!! The graphics cache no longer has a changeDisplay method.
+#endif
+#if 0
+ if (old_value != rc.display_graphics) {
+ lyx::graphics::GCache & gc = lyx::graphics::GCache::get();
+ gc.changeDisplay();
+ }
+#endif
+}
+
+
+void PrefDisplay::update(LyXRC const & rc)
+{
+ switch (rc.preview) {
+ case LyXRC::PREVIEW_OFF:
+ instantPreviewCO->setCurrentIndex(0);
+ break;
+ case LyXRC::PREVIEW_NO_MATH :
+ instantPreviewCO->setCurrentIndex(1);
+ break;
+ case LyXRC::PREVIEW_ON :
+ instantPreviewCO->setCurrentIndex(2);
+ break;
+ }
+
+ int item = 2;
+ switch (rc.display_graphics) {
+ case lyx::graphics::NoDisplay: item = 3; break;
+ case lyx::graphics::ColorDisplay: item = 2; break;
+ case lyx::graphics::GrayscaleDisplay: item = 1; break;
+ case lyx::graphics::MonochromeDisplay: item = 0; break;
+ default: break;
+ }
+ displayGraphicsCO->setCurrentIndex(item);
+}
+
+
+PrefPaths::PrefPaths(QPrefs * form, QWidget * parent)
+: PrefModule(string(), _("Paths"), form, parent)
+{
+ setupUi(this);
+ connect(templateDirPB, SIGNAL(clicked()), this, SLOT(select_templatedir()));
+ connect(tempDirPB, SIGNAL(clicked()), this, SLOT(select_tempdir()));
+ connect(backupDirPB, SIGNAL(clicked()), this, SLOT(select_backupdir()));
+ connect(workingDirPB, SIGNAL(clicked()), this, SLOT(select_workingdir()));
+ connect(lyxserverDirPB, SIGNAL(clicked()), this, SLOT(select_lyxpipe()));
+ connect(workingDirED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(templateDirED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(backupDirED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(tempDirED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(lyxserverDirED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(pathPrefixED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+}
+
+
+void PrefPaths::apply(LyXRC & rc) const
+{
+ rc.document_path = internal_path(workingDirED->text());
+ rc.template_path = internal_path(templateDirED->text());
+ rc.backupdir_path = internal_path(backupDirED->text());
+ rc.tempdir_path = internal_path(tempDirED->text());
+ rc.path_prefix = fromqstr(pathPrefixED->text());
+ // FIXME: should be a checkbox only
+ rc.lyxpipes = internal_path(lyxserverDirED->text());
+}
+
+
+void PrefPaths::update(LyXRC const & rc)
+{
+ workingDirED->setText(external_path(rc.document_path));
+ templateDirED->setText(external_path(rc.template_path));
+ backupDirED->setText(external_path(rc.backupdir_path));
+ tempDirED->setText(external_path(rc.tempdir_path));
+ pathPrefixED->setText(toqstr(rc.path_prefix));
+ // FIXME: should be a checkbox only
+ lyxserverDirED->setText(external_path(rc.lyxpipes));
+}
+
+// NB: the _() 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")));
+ if (!file.empty())
+ templateDirED->setText(toqstr(file));
+}
+
+
+void PrefPaths::select_tempdir()
+{
+ string file(form_->controller().browsedir(fromqstr(tempDirED->text()), _("Select a temporary directory")));
+ if (!file.empty())
+ tempDirED->setText(toqstr(file));
+}
+
+
+void PrefPaths::select_backupdir()
+{
+ string file(form_->controller().browsedir(fromqstr(backupDirED->text()), _("Select a backups directory")));
+ if (!file.empty())
+ backupDirED->setText(toqstr(file));
+}
+
+
+void PrefPaths::select_workingdir()
+{
+ string file(form_->controller().browsedir(fromqstr(workingDirED->text()), _("Select a document directory")));
+ if (!file.empty())
+ workingDirED->setText(toqstr(file));
+}
+
+
+void PrefPaths::select_lyxpipe()
+{
+ string file(form_->controller().browse(fromqstr(lyxserverDirED->text()), _("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)
+{
+ setupUi(this);
+
+ connect(persDictionaryPB, SIGNAL(clicked()), this, SLOT(select_dict()));
+#if defined (USE_ISPELL)
+ connect(spellCommandCO, SIGNAL(activated(int)),
+ this, SIGNAL(changed()));
+#else
+ spellCommandCO->setEnabled(false);
+#endif
+ connect(altLanguageED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(escapeCharactersED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(persDictionaryED, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()));
+ connect(compoundWordCB, SIGNAL(toggled(bool)),
+ this, SIGNAL(changed()));
+ connect(inputEncodingCB, SIGNAL(toggled(bool)),
+ this, SIGNAL(changed()));
+
+ spellCommandCO->insertItem(qt_("ispell"));
+ spellCommandCO->insertItem(qt_("aspell"));
+ spellCommandCO->insertItem(qt_("hspell"));
+#ifdef USE_PSPELL
+ spellCommandCO->insertItem(qt_("pspell (library)"));
+#else
+#ifdef USE_ASPELL
+ spellCommandCO->insertItem(qt_("aspell (library)"));
+#endif
+#endif
+}
+
+
+void PrefSpellchecker::apply(LyXRC & rc) const
+{
+ switch (spellCommandCO->currentItem()) {
+ case 0:
+ case 1:
+ case 2:
+ rc.use_spell_lib = false;
+ rc.isp_command = fromqstr(spellCommandCO->currentText());
+ break;
+ case 3:
+ rc.use_spell_lib = true;
+ break;
+ }
+
+ // FIXME: remove isp_use_alt_lang
+ rc.isp_alt_lang = fromqstr(altLanguageED->text());
+ rc.isp_use_alt_lang = !rc.isp_alt_lang.empty();
+ // FIXME: remove isp_use_esc_chars
+ rc.isp_esc_chars = fromqstr(escapeCharactersED->text());
+ rc.isp_use_esc_chars = !rc.isp_esc_chars.empty();
+ // FIXME: remove isp_use_pers_dict
+ rc.isp_pers_dict = internal_path(persDictionaryED->text());
+ rc.isp_use_pers_dict = !rc.isp_pers_dict.empty();
+ rc.isp_accept_compound = compoundWordCB->isChecked();
+ rc.isp_use_input_encoding = inputEncodingCB->isChecked();
+}
+
+
+void PrefSpellchecker::update(LyXRC const & rc)
+{
+ spellCommandCO->setCurrentIndex(0);
+
+ if (rc.isp_command == "ispell") {
+ spellCommandCO->setCurrentIndex(0);
+ } else if (rc.isp_command == "aspell") {
+ spellCommandCO->setCurrentIndex(1);
+ } else if (rc.isp_command == "hspell") {
+ spellCommandCO->setCurrentIndex(2);
+ }
+
+ if (rc.use_spell_lib) {
+#if defined(USE_ASPELL) || defined(USE_PSPELL)
+ spellCommandCO->setCurrentIndex(3);
+#endif
+ }
+
+ // FIXME: remove isp_use_alt_lang
+ altLanguageED->setText(toqstr(rc.isp_alt_lang));
+ // FIXME: remove isp_use_esc_chars
+ escapeCharactersED->setText(toqstr(rc.isp_esc_chars));
+ // FIXME: remove isp_use_pers_dict
+ persDictionaryED->setText(external_path(rc.isp_pers_dict));
+ compoundWordCB->setChecked(rc.isp_accept_compound);
+ inputEncodingCB->setChecked(rc.isp_use_input_encoding);
+}
+
+
+void PrefSpellchecker::select_dict()
+{
+ string file(form_->controller().browsedict(fromqstr(persDictionaryED->text())));
+ if (!file.empty())
+ persDictionaryED->setText(toqstr(file));
+}
+
+
+PrefConverters::PrefConverters(QPrefs * form, QWidget * parent)
+: PrefModule(string(), _("Converters"), form, parent)
+{
+ setupUi(this);
+
+ connect(converterNewPB, SIGNAL(clicked()),
+ this, SLOT(new_converter()));
+ connect(converterRemovePB, SIGNAL(clicked()),
+ this, SLOT(remove_converter()));
+ connect(converterModifyPB, SIGNAL(clicked()),
+ this, SLOT(modify_converter()));
+ connect(convertersLW, SIGNAL(currentRowChanged(int)),
+ this, SLOT(switch_converter(int)));
+ connect(converterFromCO, SIGNAL(activated(const QString&)),
+ this, SLOT(converter_changed()));
+ connect(converterToCO, SIGNAL(activated(const QString&)),
+ this, SLOT(converter_changed()));
+ connect(converterED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(converter_changed()));
+ connect(converterFlagED, SIGNAL(textChanged(const QString&)),
+ this, SLOT(converter_changed()));
+ connect(converterNewPB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(converterRemovePB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+ connect(converterModifyPB, SIGNAL(clicked()),
+ this, SIGNAL(changed()));
+}
+
+
+void PrefConverters::apply(LyXRC & /*rc*/) const
+{
+}
+
+
+void PrefConverters::update(LyXRC const & /*rc*/)
+{
+ updateGui();
+}
+
+
+void PrefConverters::updateGui()
+{
+ // save current selection
+ QString current = converterFromCO->currentText()
+ + " -> " + converterToCO->currentText();
+
+ converterFromCO->clear();
+ converterToCO->clear();
+
+ Formats::const_iterator cit = form_->formats().begin();
+ Formats::const_iterator end = form_->formats().end();
+ for (; cit != end; ++cit) {
+ converterFromCO->insertItem(toqstr(cit->prettyname()));
+ converterToCO->insertItem(toqstr(cit->prettyname()));
+ }
+
+ convertersLW->clear();
+
+ Converters::const_iterator ccit = form_->converters().begin();
+ Converters::const_iterator cend = form_->converters().end();
+ for (; ccit != cend; ++ccit) {
+ std::string const name = ccit->From->prettyname() + " -> "
+ + ccit->To->prettyname();
+ new QListWidgetItem(toqstr(name), convertersLW,
+ form_->converters().getNumber(ccit->From->name(), ccit->To->name()));
+ }
+ convertersLW->sortItems(Qt::AscendingOrder);
+
+ // restore selection
+ if (!current.isEmpty()) {
+ QList<QListWidgetItem *> const item =
+ convertersLW->findItems(current, Qt::MatchExactly);
+ if (item.size()>0)
+ convertersLW->setCurrentItem(item.at(0));
+ }
+ // select first element if restoring failed
+ if (convertersLW->currentRow() == -1)
+ convertersLW->setCurrentRow(0);
+
+ updateButtons();
+}
+
+
+void PrefConverters::switch_converter(int nr)
+{
+ if (nr<0)
+ return;
+
+ int const cnr = convertersLW->currentItem()->type();
+ Converter const & c(form_->converters().get(cnr));
+ converterFromCO->setCurrentIndex(form_->formats().getNumber(c.from));
+ converterToCO->setCurrentIndex(form_->formats().getNumber(c.to));
+ converterED->setText(toqstr(c.command));
+ converterFlagED->setText(toqstr(c.flags));
+
+ updateButtons();
+}
+
+
+void PrefConverters::converter_changed()
+{
+ updateButtons();
+}
+
+
+void PrefConverters::updateButtons()
+{
+ Format const & from(form_->formats().get(
+ converterFromCO->currentItem()));
+ Format const & to(form_->formats().get(
+ converterToCO->currentItem()));
+ int const sel = form_->converters().getNumber(from.name(), to.name());