3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
16 #include "ColorCache.h"
17 #include "FileDialog.h"
18 #include "GuiApplication.h"
19 #include "GuiFontExample.h"
20 #include "GuiFontLoader.h"
21 #include "GuiKeySymbol.h"
22 #include "qt_helpers.h"
23 #include "Validator.h"
26 #include "BufferList.h"
29 #include "ConverterCache.h"
30 #include "FontEnums.h"
31 #include "FuncRequest.h"
33 #include "KeySequence.h"
35 #include "LyXAction.h"
37 #include "PanelStack.h"
39 #include "SpellChecker.h"
41 #include "support/debug.h"
42 #include "support/FileName.h"
43 #include "support/filetools.h"
44 #include "support/gettext.h"
45 #include "support/lassert.h"
46 #include "support/lstrings.h"
47 #include "support/Messages.h"
48 #include "support/os.h"
49 #include "support/Package.h"
51 #include "graphics/GraphicsTypes.h"
53 #include "frontends/alert.h"
54 #include "frontends/Application.h"
55 #include "frontends/FontLoader.h"
57 #include <QAbstractItemModel>
59 #include <QColorDialog>
60 #include <QFontDatabase>
61 #include <QHeaderView>
63 #include <QMessageBox>
64 #include <QPixmapCache>
65 #include <QPushButton>
68 #include <QTreeWidget>
69 #include <QTreeWidgetItem>
79 using namespace lyx::support;
80 using namespace lyx::support::os;
85 /////////////////////////////////////////////////////////////////////
89 /////////////////////////////////////////////////////////////////////
91 /** Launch a file dialog and return the chosen file.
92 filename: a suggested filename.
93 title: the title of the dialog.
95 dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
97 QString browseFile(QString const & filename,
98 QString const & title,
99 QStringList const & filters,
101 QString const & label1 = QString(),
102 QString const & dir1 = QString(),
103 QString const & label2 = QString(),
104 QString const & dir2 = QString(),
105 QString const & fallback_dir = QString())
107 QString lastPath = ".";
108 if (!filename.isEmpty())
109 lastPath = onlyPath(filename);
110 else if(!fallback_dir.isEmpty())
111 lastPath = fallback_dir;
113 FileDialog dlg(title);
114 dlg.setButton2(label1, dir1);
115 dlg.setButton2(label2, dir2);
117 FileDialog::Result result;
120 result = dlg.save(lastPath, filters, onlyFileName(filename));
122 result = dlg.open(lastPath, filters, onlyFileName(filename));
124 return result.second;
128 /** Wrapper around browseFile which tries to provide a filename
129 * relative to the user or system directory. The dir, name and ext
130 * parameters have the same meaning as in the
131 * support::LibFileSearch function.
133 QString browseLibFile(QString const & dir,
134 QString const & name,
136 QString const & title,
137 QStringList const & filters)
140 QString const label1 = qt_("System files|#S#s");
142 toqstr(addName(package().system_support().absFileName(), fromqstr(dir)));
144 QString const label2 = qt_("User files|#U#u");
146 toqstr(addName(package().user_support().absFileName(), fromqstr(dir)));
148 QString const result = browseFile(toqstr(
149 libFileSearch(dir, name, ext).absFileName()),
150 title, filters, false, dir1, dir2, QString(), QString(), dir1);
152 // remove the extension if it is the default one
154 if (getExtension(result) == ext)
155 noextresult = removeExtension(result);
157 noextresult = result;
159 // remove the directory, if it is the default one
160 QString const file = onlyFileName(noextresult);
161 if (toqstr(libFileSearch(dir, file, ext).absFileName()) == result)
168 /** Launch a file dialog and return the chosen directory.
169 pathname: a suggested pathname.
170 title: the title of the dialog.
171 dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
173 QString browseDir(QString const & pathname,
174 QString const & title,
175 QString const & label1 = QString(),
176 QString const & dir1 = QString(),
177 QString const & label2 = QString(),
178 QString const & dir2 = QString())
180 QString lastPath = ".";
181 if (!pathname.isEmpty())
182 lastPath = onlyPath(pathname);
184 FileDialog dlg(title);
185 dlg.setButton1(label1, dir1);
186 dlg.setButton2(label2, dir2);
188 FileDialog::Result const result =
189 dlg.opendir(lastPath, onlyFileName(pathname));
191 return result.second;
195 } // namespace frontend
198 QString browseRelToParent(QString const & filename, QString const & relpath,
199 QString const & title, QStringList const & filters, bool save,
200 QString const & label1, QString const & dir1,
201 QString const & label2, QString const & dir2)
203 QString const fname = makeAbsPath(filename, relpath);
205 QString const outname =
206 frontend::browseFile(fname, title, filters, save, label1, dir1, label2, dir2);
208 QString const reloutname =
209 toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(relpath)));
211 if (reloutname.startsWith("../"))
218 QString browseRelToSub(QString const & filename, QString const & relpath,
219 QString const & title, QStringList const & filters, bool save,
220 QString const & label1, QString const & dir1,
221 QString const & label2, QString const & dir2)
223 QString const fname = makeAbsPath(filename, relpath);
225 QString const outname =
226 frontend::browseFile(fname, title, filters, save, label1, dir1, label2, dir2);
228 QString const reloutname =
229 toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(relpath)));
231 QString testname = reloutname;
232 testname.remove(QRegExp("^(\\.\\./)+"));
234 if (testname.contains("/"))
242 /////////////////////////////////////////////////////////////////////
246 /////////////////////////////////////////////////////////////////////
250 QString const catLookAndFeel = N_("Look & Feel");
251 QString const catEditing = N_("Editing");
252 QString const catLanguage = N_("Language Settings");
253 QString const catOutput = N_("Output");
254 QString const catFiles = N_("File Handling");
256 static void parseFontName(QString const & mangled0,
257 string & name, string & foundry)
259 string mangled = fromqstr(mangled0);
260 size_t const idx = mangled.find('[');
261 if (idx == string::npos || idx == 0) {
265 name = mangled.substr(0, idx - 1),
266 foundry = mangled.substr(idx + 1, mangled.size() - idx - 2);
271 static void setComboxFont(QComboBox * cb, string const & family,
272 string const & foundry)
274 QString fontname = toqstr(family);
275 if (!foundry.empty())
276 fontname += " [" + toqstr(foundry) + ']';
278 for (int i = 0; i != cb->count(); ++i) {
279 if (cb->itemText(i) == fontname) {
280 cb->setCurrentIndex(i);
285 // Try matching without foundry name
287 // We count in reverse in order to prefer the Xft foundry
288 for (int i = cb->count(); --i >= 0;) {
289 string name, foundry;
290 parseFontName(cb->itemText(i), name, foundry);
291 if (compare_ascii_no_case(name, family) == 0) {
292 cb->setCurrentIndex(i);
297 // family alone can contain e.g. "Helvetica [Adobe]"
298 string tmpname, tmpfoundry;
299 parseFontName(toqstr(family), tmpname, tmpfoundry);
301 // We count in reverse in order to prefer the Xft foundry
302 for (int i = cb->count(); --i >= 0; ) {
303 string name, foundry;
304 parseFontName(cb->itemText(i), name, foundry);
305 if (compare_ascii_no_case(name, foundry) == 0) {
306 cb->setCurrentIndex(i);
311 // Bleh, default fonts, and the names couldn't be found. Hack
316 QString const font_family = toqstr(family);
317 if (font_family == guiApp->romanFontName()) {
318 font.setStyleHint(QFont::Serif);
319 font.setFamily(font_family);
320 } else if (font_family == guiApp->sansFontName()) {
321 font.setStyleHint(QFont::SansSerif);
322 font.setFamily(font_family);
323 } else if (font_family == guiApp->typewriterFontName()) {
324 font.setStyleHint(QFont::TypeWriter);
325 font.setFamily(font_family);
327 LYXERR0("FAILED to find the default font: '"
328 << foundry << "', '" << family << '\'');
332 QFontInfo info(font);
333 string default_font_name, dummyfoundry;
334 parseFontName(info.family(), default_font_name, dummyfoundry);
335 LYXERR0("Apparent font is " << default_font_name);
337 for (int i = 0; i < cb->count(); ++i) {
338 LYXERR0("Looking at " << cb->itemText(i));
339 if (compare_ascii_no_case(fromqstr(cb->itemText(i)),
340 default_font_name) == 0) {
341 cb->setCurrentIndex(i);
346 LYXERR0("FAILED to find the font: '"
347 << foundry << "', '" << family << '\'');
351 /////////////////////////////////////////////////////////////////////
355 /////////////////////////////////////////////////////////////////////
357 class StrftimeValidator : public QValidator
360 StrftimeValidator(QWidget *);
361 QValidator::State validate(QString & input, int & pos) const;
365 StrftimeValidator::StrftimeValidator(QWidget * parent)
371 QValidator::State StrftimeValidator::validate(QString & input, int & /*pos*/) const
373 if (is_valid_strftime(fromqstr(input)))
374 return QValidator::Acceptable;
376 return QValidator::Intermediate;
380 /////////////////////////////////////////////////////////////////////
384 /////////////////////////////////////////////////////////////////////
386 PrefOutput::PrefOutput(GuiPreferences * form)
387 : PrefModule(catOutput, N_("General"), form)
391 DateED->setValidator(new StrftimeValidator(DateED));
392 dviCB->setValidator(new NoNewLineValidator(dviCB));
393 pdfCB->setValidator(new NoNewLineValidator(pdfCB));
395 connect(DateED, SIGNAL(textChanged(QString)),
396 this, SIGNAL(changed()));
397 connect(plaintextLinelengthSB, SIGNAL(valueChanged(int)),
398 this, SIGNAL(changed()));
399 connect(overwriteCO, SIGNAL(activated(int)),
400 this, SIGNAL(changed()));
401 connect(dviCB, SIGNAL(editTextChanged(QString)),
402 this, SIGNAL(changed()));
403 connect(pdfCB, SIGNAL(editTextChanged(QString)),
404 this, SIGNAL(changed()));
405 connect(printerPaperTypeED, SIGNAL(textChanged(QString)),
406 this, SIGNAL(changed()));
407 connect(printerLandscapeED, SIGNAL(textChanged(QString)),
408 this, SIGNAL(changed()));
409 connect(printerPaperSizeED, SIGNAL(textChanged(QString)),
410 this, SIGNAL(changed()));
412 printerPaperTypeED->setValidator(new NoNewLineValidator(printerPaperTypeED));
413 printerLandscapeED->setValidator(new NoNewLineValidator(printerLandscapeED));
414 printerPaperSizeED->setValidator(new NoNewLineValidator(printerPaperSizeED));
417 dviCB->addItem("xdvi -sourceposition '$$n:\\ $$t' $$o");
418 dviCB->addItem("yap -1 -s \"$$n $$t\" $$o");
419 dviCB->addItem("okular --unique \"$$o#src:$$n $$f\"");
420 dviCB->addItem("synctex view -i $$n:0:$$t -o $$o -x \"evince -i %{page+1} $$o\"");
422 pdfCB->addItem("CMCDDE SUMATRA control [ForwardSearch(\\\"$$o\\\",\\\"$$t\\\",$$n,0,0,1)]");
423 pdfCB->addItem("SumatraPDF -reuse-instance \"$$o\" -forward-search \"$$t\" $$n");
424 pdfCB->addItem("synctex view -i $$n:0:$$t -o $$o -x \"xpdf -raise -remote $$t.tmp $$o %{page+1}\"");
425 pdfCB->addItem("okular --unique \"$$o#src:$$n $$f\"");
426 pdfCB->addItem("qpdfview --unique \"$$o#src:$$f:$$n:0\"");
427 pdfCB->addItem("synctex view -i $$n:0:$$t -o $$o -x \"evince -i %{page+1} $$o\"");
428 pdfCB->addItem("/Applications/Skim.app/Contents/SharedSupport/displayline $$n $$o $$t");
432 void PrefOutput::on_DateED_textChanged(const QString &)
434 QString t = DateED->text();
436 bool valid = DateED->validator()->validate(t, p)
437 == QValidator::Acceptable;
438 setValid(DateLA, valid);
442 void PrefOutput::applyRC(LyXRC & rc) const
444 rc.date_insert_format = fromqstr(DateED->text());
445 rc.plaintext_linelen = plaintextLinelengthSB->value();
446 rc.forward_search_dvi = fromqstr(dviCB->currentText());
447 rc.forward_search_pdf = fromqstr(pdfCB->currentText());
449 switch (overwriteCO->currentIndex()) {
451 rc.export_overwrite = NO_FILES;
454 rc.export_overwrite = MAIN_FILE;
457 rc.export_overwrite = ALL_FILES;
461 rc.print_paper_flag = fromqstr(printerPaperTypeED->text());
462 rc.print_landscape_flag = fromqstr(printerLandscapeED->text());
463 rc.print_paper_dimension_flag = fromqstr(printerPaperSizeED->text());
467 void PrefOutput::updateRC(LyXRC const & rc)
469 DateED->setText(toqstr(rc.date_insert_format));
470 plaintextLinelengthSB->setValue(rc.plaintext_linelen);
471 dviCB->setEditText(toqstr(rc.forward_search_dvi));
472 pdfCB->setEditText(toqstr(rc.forward_search_pdf));
474 switch (rc.export_overwrite) {
476 overwriteCO->setCurrentIndex(0);
479 overwriteCO->setCurrentIndex(1);
482 overwriteCO->setCurrentIndex(2);
486 printerPaperTypeED->setText(toqstr(rc.print_paper_flag));
487 printerLandscapeED->setText(toqstr(rc.print_landscape_flag));
488 printerPaperSizeED->setText(toqstr(rc.print_paper_dimension_flag));
492 /////////////////////////////////////////////////////////////////////
496 /////////////////////////////////////////////////////////////////////
498 PrefInput::PrefInput(GuiPreferences * form)
499 : PrefModule(catEditing, N_("Keyboard/Mouse"), form)
503 connect(keymapCB, SIGNAL(clicked()),
504 this, SIGNAL(changed()));
505 connect(firstKeymapED, SIGNAL(textChanged(QString)),
506 this, SIGNAL(changed()));
507 connect(secondKeymapED, SIGNAL(textChanged(QString)),
508 this, SIGNAL(changed()));
509 connect(mouseWheelSpeedSB, SIGNAL(valueChanged(double)),
510 this, SIGNAL(changed()));
511 connect(scrollzoomEnableCB, SIGNAL(clicked()),
512 this, SIGNAL(changed()));
513 connect(scrollzoomValueCO, SIGNAL(activated(int)),
514 this, SIGNAL(changed()));
515 connect(dontswapCB, SIGNAL(toggled(bool)),
516 this, SIGNAL(changed()));
517 connect(mmPasteCB, SIGNAL(toggled(bool)),
518 this, SIGNAL(changed()));
520 // reveal checkbox for switching Ctrl and Meta on Mac:
523 #if QT_VERSION > 0x040600
527 dontswapCB->setVisible(swapcb);
531 void PrefInput::applyRC(LyXRC & rc) const
533 // FIXME: can derive CB from the two EDs
534 rc.use_kbmap = keymapCB->isChecked();
535 rc.primary_kbmap = internal_path(fromqstr(firstKeymapED->text()));
536 rc.secondary_kbmap = internal_path(fromqstr(secondKeymapED->text()));
537 rc.mouse_wheel_speed = mouseWheelSpeedSB->value();
538 if (scrollzoomEnableCB->isChecked()) {
539 switch (scrollzoomValueCO->currentIndex()) {
541 rc.scroll_wheel_zoom = LyXRC::SCROLL_WHEEL_ZOOM_CTRL;
544 rc.scroll_wheel_zoom = LyXRC::SCROLL_WHEEL_ZOOM_SHIFT;
547 rc.scroll_wheel_zoom = LyXRC::SCROLL_WHEEL_ZOOM_ALT;
551 rc.scroll_wheel_zoom = LyXRC::SCROLL_WHEEL_ZOOM_OFF;
553 rc.mac_dontswap_ctrl_meta = dontswapCB->isChecked();
554 rc.mouse_middlebutton_paste = mmPasteCB->isChecked();
558 void PrefInput::updateRC(LyXRC const & rc)
560 // FIXME: can derive CB from the two EDs
561 keymapCB->setChecked(rc.use_kbmap);
562 firstKeymapED->setText(toqstr(external_path(rc.primary_kbmap)));
563 secondKeymapED->setText(toqstr(external_path(rc.secondary_kbmap)));
564 mouseWheelSpeedSB->setValue(rc.mouse_wheel_speed);
565 switch (rc.scroll_wheel_zoom) {
566 case LyXRC::SCROLL_WHEEL_ZOOM_OFF:
567 scrollzoomEnableCB->setChecked(false);
569 case LyXRC::SCROLL_WHEEL_ZOOM_CTRL:
570 scrollzoomEnableCB->setChecked(true);
571 scrollzoomValueCO->setCurrentIndex(0);
573 case LyXRC::SCROLL_WHEEL_ZOOM_SHIFT:
574 scrollzoomEnableCB->setChecked(true);
575 scrollzoomValueCO->setCurrentIndex(1);
577 case LyXRC::SCROLL_WHEEL_ZOOM_ALT:
578 scrollzoomEnableCB->setChecked(true);
579 scrollzoomValueCO->setCurrentIndex(2);
582 dontswapCB->setChecked(rc.mac_dontswap_ctrl_meta);
583 mmPasteCB->setChecked(rc.mouse_middlebutton_paste);
587 QString PrefInput::testKeymap(QString const & keymap)
589 return form_->browsekbmap(internalPath(keymap));
593 void PrefInput::on_firstKeymapPB_clicked(bool)
595 QString const file = testKeymap(firstKeymapED->text());
597 firstKeymapED->setText(file);
601 void PrefInput::on_secondKeymapPB_clicked(bool)
603 QString const file = testKeymap(secondKeymapED->text());
605 secondKeymapED->setText(file);
609 void PrefInput::on_keymapCB_toggled(bool keymap)
611 firstKeymapLA->setEnabled(keymap);
612 secondKeymapLA->setEnabled(keymap);
613 firstKeymapED->setEnabled(keymap);
614 secondKeymapED->setEnabled(keymap);
615 firstKeymapPB->setEnabled(keymap);
616 secondKeymapPB->setEnabled(keymap);
620 void PrefInput::on_scrollzoomEnableCB_toggled(bool enabled)
622 scrollzoomValueCO->setEnabled(enabled);
626 /////////////////////////////////////////////////////////////////////
630 /////////////////////////////////////////////////////////////////////
632 PrefCompletion::PrefCompletion(GuiPreferences * form)
633 : PrefModule(catEditing, N_("Input Completion"), form)
637 connect(inlineDelaySB, SIGNAL(valueChanged(double)),
638 this, SIGNAL(changed()));
639 connect(inlineMathCB, SIGNAL(clicked()),
640 this, SIGNAL(changed()));
641 connect(inlineTextCB, SIGNAL(clicked()),
642 this, SIGNAL(changed()));
643 connect(inlineDotsCB, SIGNAL(clicked()),
644 this, SIGNAL(changed()));
645 connect(popupDelaySB, SIGNAL(valueChanged(double)),
646 this, SIGNAL(changed()));
647 connect(popupMathCB, SIGNAL(clicked()),
648 this, SIGNAL(changed()));
649 connect(autocorrectionCB, SIGNAL(clicked()),
650 this, SIGNAL(changed()));
651 connect(popupTextCB, SIGNAL(clicked()),
652 this, SIGNAL(changed()));
653 connect(popupAfterCompleteCB, SIGNAL(clicked()),
654 this, SIGNAL(changed()));
655 connect(cursorTextCB, SIGNAL(clicked()),
656 this, SIGNAL(changed()));
657 connect(minlengthSB, SIGNAL(valueChanged(int)),
658 this, SIGNAL(changed()));
662 void PrefCompletion::on_inlineTextCB_clicked()
668 void PrefCompletion::on_popupTextCB_clicked()
674 void PrefCompletion::enableCB()
676 cursorTextCB->setEnabled(
677 popupTextCB->isChecked() || inlineTextCB->isChecked());
681 void PrefCompletion::applyRC(LyXRC & rc) const
683 rc.completion_inline_delay = inlineDelaySB->value();
684 rc.completion_inline_math = inlineMathCB->isChecked();
685 rc.completion_inline_text = inlineTextCB->isChecked();
686 rc.completion_inline_dots = inlineDotsCB->isChecked() ? 13 : -1;
687 rc.completion_popup_delay = popupDelaySB->value();
688 rc.completion_popup_math = popupMathCB->isChecked();
689 rc.autocorrection_math = autocorrectionCB->isChecked();
690 rc.completion_popup_text = popupTextCB->isChecked();
691 rc.completion_cursor_text = cursorTextCB->isChecked();
692 rc.completion_popup_after_complete =
693 popupAfterCompleteCB->isChecked();
694 rc.completion_minlength = minlengthSB->value();
698 void PrefCompletion::updateRC(LyXRC const & rc)
700 inlineDelaySB->setValue(rc.completion_inline_delay);
701 inlineMathCB->setChecked(rc.completion_inline_math);
702 inlineTextCB->setChecked(rc.completion_inline_text);
703 inlineDotsCB->setChecked(rc.completion_inline_dots != -1);
704 popupDelaySB->setValue(rc.completion_popup_delay);
705 popupMathCB->setChecked(rc.completion_popup_math);
706 autocorrectionCB->setChecked(rc.autocorrection_math);
707 popupTextCB->setChecked(rc.completion_popup_text);
708 cursorTextCB->setChecked(rc.completion_cursor_text);
709 popupAfterCompleteCB->setChecked(rc.completion_popup_after_complete);
711 minlengthSB->setValue(rc.completion_minlength);
716 /////////////////////////////////////////////////////////////////////
720 /////////////////////////////////////////////////////////////////////
722 PrefLatex::PrefLatex(GuiPreferences * form)
723 : PrefModule(catOutput, N_("LaTeX"), form)
727 latexEncodingED->setValidator(new NoNewLineValidator(latexEncodingED));
728 latexDviPaperED->setValidator(new NoNewLineValidator(latexDviPaperED));
729 latexBibtexED->setValidator(new NoNewLineValidator(latexBibtexED));
730 latexJBibtexED->setValidator(new NoNewLineValidator(latexJBibtexED));
731 latexIndexED->setValidator(new NoNewLineValidator(latexIndexED));
732 latexJIndexED->setValidator(new NoNewLineValidator(latexJIndexED));
733 latexNomenclED->setValidator(new NoNewLineValidator(latexNomenclED));
734 latexChecktexED->setValidator(new NoNewLineValidator(latexChecktexED));
736 connect(latexEncodingCB, SIGNAL(clicked()),
737 this, SIGNAL(changed()));
738 connect(latexEncodingED, SIGNAL(textChanged(QString)),
739 this, SIGNAL(changed()));
740 connect(latexChecktexED, SIGNAL(textChanged(QString)),
741 this, SIGNAL(changed()));
742 connect(latexBibtexCO, SIGNAL(activated(int)),
743 this, SIGNAL(changed()));
744 connect(latexBibtexED, SIGNAL(textChanged(QString)),
745 this, SIGNAL(changed()));
746 connect(latexJBibtexED, SIGNAL(textChanged(QString)),
747 this, SIGNAL(changed()));
748 connect(latexIndexCO, SIGNAL(activated(int)),
749 this, SIGNAL(changed()));
750 connect(latexIndexED, SIGNAL(textChanged(QString)),
751 this, SIGNAL(changed()));
752 connect(latexJIndexED, SIGNAL(textChanged(QString)),
753 this, SIGNAL(changed()));
754 connect(latexAutoresetCB, SIGNAL(clicked()),
755 this, SIGNAL(changed()));
756 connect(latexDviPaperED, SIGNAL(textChanged(QString)),
757 this, SIGNAL(changed()));
758 connect(latexNomenclED, SIGNAL(textChanged(QString)),
759 this, SIGNAL(changed()));
761 #if defined(__CYGWIN__) || defined(_WIN32)
762 pathCB->setVisible(true);
763 connect(pathCB, SIGNAL(clicked()),
764 this, SIGNAL(changed()));
766 pathCB->setVisible(false);
771 void PrefLatex::on_latexEncodingCB_stateChanged(int state)
773 latexEncodingED->setEnabled(state == Qt::Checked);
777 void PrefLatex::on_latexBibtexCO_activated(int n)
779 QString const bibtex = latexBibtexCO->itemData(n).toString();
780 if (bibtex.isEmpty()) {
781 latexBibtexED->clear();
782 latexBibtexOptionsLA->setText(qt_("Co&mmand:"));
785 for (LyXRC::CommandSet::const_iterator it = bibtex_alternatives.begin();
786 it != bibtex_alternatives.end(); ++it) {
787 QString const bib = toqstr(*it);
788 int ind = bib.indexOf(" ");
789 QString sel_command = bib.left(ind);
790 QString sel_options = ind < 0 ? QString() : bib.mid(ind + 1);
791 if (bibtex == sel_command) {
793 latexBibtexED->clear();
795 latexBibtexED->setText(sel_options.trimmed());
798 latexBibtexOptionsLA->setText(qt_("&Options:"));
802 void PrefLatex::on_latexIndexCO_activated(int n)
804 QString const index = latexIndexCO->itemData(n).toString();
805 if (index.isEmpty()) {
806 latexIndexED->clear();
807 latexIndexOptionsLA->setText(qt_("Co&mmand:"));
810 for (LyXRC::CommandSet::const_iterator it = index_alternatives.begin();
811 it != index_alternatives.end(); ++it) {
812 QString const idx = toqstr(*it);
813 int ind = idx.indexOf(" ");
814 QString sel_command = idx.left(ind);
815 QString sel_options = ind < 0 ? QString() : idx.mid(ind + 1);
816 if (index == sel_command) {
818 latexIndexED->clear();
820 latexIndexED->setText(sel_options.trimmed());
823 latexIndexOptionsLA->setText(qt_("Op&tions:"));
827 void PrefLatex::applyRC(LyXRC & rc) const
829 // If bibtex is not empty, bibopt contains the options, otherwise
830 // it is a customized bibtex command with options.
831 QString const bibtex = latexBibtexCO->itemData(
832 latexBibtexCO->currentIndex()).toString();
833 QString const bibopt = latexBibtexED->text();
834 if (bibtex.isEmpty())
835 rc.bibtex_command = fromqstr(bibopt);
836 else if (bibopt.isEmpty())
837 rc.bibtex_command = fromqstr(bibtex);
839 rc.bibtex_command = fromqstr(bibtex) + " " + fromqstr(bibopt);
841 // If index is not empty, idxopt contains the options, otherwise
842 // it is a customized index command with options.
843 QString const index = latexIndexCO->itemData(
844 latexIndexCO->currentIndex()).toString();
845 QString const idxopt = latexIndexED->text();
847 rc.index_command = fromqstr(idxopt);
848 else if (idxopt.isEmpty())
849 rc.index_command = fromqstr(index);
851 rc.index_command = fromqstr(index) + " " + fromqstr(idxopt);
853 if (latexEncodingCB->isChecked())
854 rc.fontenc = fromqstr(latexEncodingED->text());
856 rc.fontenc = "default";
857 rc.chktex_command = fromqstr(latexChecktexED->text());
858 rc.jbibtex_command = fromqstr(latexJBibtexED->text());
859 rc.jindex_command = fromqstr(latexJIndexED->text());
860 rc.nomencl_command = fromqstr(latexNomenclED->text());
861 rc.auto_reset_options = latexAutoresetCB->isChecked();
862 rc.view_dvi_paper_option = fromqstr(latexDviPaperED->text());
863 #if defined(__CYGWIN__) || defined(_WIN32)
864 rc.windows_style_tex_paths = pathCB->isChecked();
869 void PrefLatex::updateRC(LyXRC const & rc)
871 latexBibtexCO->clear();
873 latexBibtexCO->addItem(qt_("Custom"), QString());
874 for (LyXRC::CommandSet::const_iterator it = rc.bibtex_alternatives.begin();
875 it != rc.bibtex_alternatives.end(); ++it) {
876 QString const command = toqstr(*it).left(toqstr(*it).indexOf(" "));
877 latexBibtexCO->addItem(command, command);
880 bibtex_alternatives = rc.bibtex_alternatives;
882 QString const bib = toqstr(rc.bibtex_command);
883 int ind = bib.indexOf(" ");
884 QString sel_command = bib.left(ind);
885 QString sel_options = ind < 0 ? QString() : bib.mid(ind + 1);
887 int pos = latexBibtexCO->findData(sel_command);
889 latexBibtexCO->setCurrentIndex(pos);
890 latexBibtexED->setText(sel_options.trimmed());
891 latexBibtexOptionsLA->setText(qt_("&Options:"));
893 latexBibtexED->setText(toqstr(rc.bibtex_command));
894 latexBibtexCO->setCurrentIndex(0);
895 latexBibtexOptionsLA->setText(qt_("Co&mmand:"));
898 latexIndexCO->clear();
900 latexIndexCO->addItem(qt_("Custom"), QString());
901 for (LyXRC::CommandSet::const_iterator it = rc.index_alternatives.begin();
902 it != rc.index_alternatives.end(); ++it) {
903 QString const command = toqstr(*it).left(toqstr(*it).indexOf(" "));
904 latexIndexCO->addItem(command, command);
907 index_alternatives = rc.index_alternatives;
909 QString const idx = toqstr(rc.index_command);
910 ind = idx.indexOf(" ");
911 sel_command = idx.left(ind);
912 sel_options = ind < 0 ? QString() : idx.mid(ind + 1);
914 pos = latexIndexCO->findData(sel_command);
916 latexIndexCO->setCurrentIndex(pos);
917 latexIndexED->setText(sel_options.trimmed());
918 latexIndexOptionsLA->setText(qt_("Op&tions:"));
920 latexIndexED->setText(toqstr(rc.index_command));
921 latexIndexCO->setCurrentIndex(0);
922 latexIndexOptionsLA->setText(qt_("Co&mmand:"));
925 if (rc.fontenc == "default") {
926 latexEncodingCB->setChecked(false);
927 latexEncodingED->setEnabled(false);
929 latexEncodingCB->setChecked(true);
930 latexEncodingED->setEnabled(true);
931 latexEncodingED->setText(toqstr(rc.fontenc));
933 latexChecktexED->setText(toqstr(rc.chktex_command));
934 latexJBibtexED->setText(toqstr(rc.jbibtex_command));
935 latexJIndexED->setText(toqstr(rc.jindex_command));
936 latexNomenclED->setText(toqstr(rc.nomencl_command));
937 latexAutoresetCB->setChecked(rc.auto_reset_options);
938 latexDviPaperED->setText(toqstr(rc.view_dvi_paper_option));
939 #if defined(__CYGWIN__) || defined(_WIN32)
940 pathCB->setChecked(rc.windows_style_tex_paths);
945 /////////////////////////////////////////////////////////////////////
949 /////////////////////////////////////////////////////////////////////
951 PrefScreenFonts::PrefScreenFonts(GuiPreferences * form)
952 : PrefModule(catLookAndFeel, N_("Screen Fonts"), form)
956 connect(screenRomanCO, SIGNAL(activated(QString)),
957 this, SLOT(selectRoman(QString)));
958 connect(screenSansCO, SIGNAL(activated(QString)),
959 this, SLOT(selectSans(QString)));
960 connect(screenTypewriterCO, SIGNAL(activated(QString)),
961 this, SLOT(selectTypewriter(QString)));
963 QFontDatabase fontdb;
964 QStringList families(fontdb.families());
965 for (QStringList::Iterator it = families.begin(); it != families.end(); ++it) {
966 screenRomanCO->addItem(*it);
967 screenSansCO->addItem(*it);
968 screenTypewriterCO->addItem(*it);
970 connect(screenRomanCO, SIGNAL(activated(QString)),
971 this, SIGNAL(changed()));
972 connect(screenSansCO, SIGNAL(activated(QString)),
973 this, SIGNAL(changed()));
974 connect(screenTypewriterCO, SIGNAL(activated(QString)),
975 this, SIGNAL(changed()));
976 connect(screenZoomSB, SIGNAL(valueChanged(int)),
977 this, SIGNAL(changed()));
978 connect(screenTinyED, SIGNAL(textChanged(QString)),
979 this, SIGNAL(changed()));
980 connect(screenSmallestED, SIGNAL(textChanged(QString)),
981 this, SIGNAL(changed()));
982 connect(screenSmallerED, SIGNAL(textChanged(QString)),
983 this, SIGNAL(changed()));
984 connect(screenSmallED, SIGNAL(textChanged(QString)),
985 this, SIGNAL(changed()));
986 connect(screenNormalED, SIGNAL(textChanged(QString)),
987 this, SIGNAL(changed()));
988 connect(screenLargeED, SIGNAL(textChanged(QString)),
989 this, SIGNAL(changed()));
990 connect(screenLargerED, SIGNAL(textChanged(QString)),
991 this, SIGNAL(changed()));
992 connect(screenLargestED, SIGNAL(textChanged(QString)),
993 this, SIGNAL(changed()));
994 connect(screenHugeED, SIGNAL(textChanged(QString)),
995 this, SIGNAL(changed()));
996 connect(screenHugerED, SIGNAL(textChanged(QString)),
997 this, SIGNAL(changed()));
998 connect(pixmapCacheCB, SIGNAL(toggled(bool)),
999 this, SIGNAL(changed()));
1001 screenTinyED->setValidator(new QDoubleValidator(screenTinyED));
1002 screenSmallestED->setValidator(new QDoubleValidator(screenSmallestED));
1003 screenSmallerED->setValidator(new QDoubleValidator(screenSmallerED));
1004 screenSmallED->setValidator(new QDoubleValidator(screenSmallED));
1005 screenNormalED->setValidator(new QDoubleValidator(screenNormalED));
1006 screenLargeED->setValidator(new QDoubleValidator(screenLargeED));
1007 screenLargerED->setValidator(new QDoubleValidator(screenLargerED));
1008 screenLargestED->setValidator(new QDoubleValidator(screenLargestED));
1009 screenHugeED->setValidator(new QDoubleValidator(screenHugeED));
1010 screenHugerED->setValidator(new QDoubleValidator(screenHugerED));
1014 void PrefScreenFonts::applyRC(LyXRC & rc) const
1016 LyXRC const oldrc = rc;
1018 parseFontName(screenRomanCO->currentText(),
1019 rc.roman_font_name, rc.roman_font_foundry);
1020 parseFontName(screenSansCO->currentText(),
1021 rc.sans_font_name, rc.sans_font_foundry);
1022 parseFontName(screenTypewriterCO->currentText(),
1023 rc.typewriter_font_name, rc.typewriter_font_foundry);
1025 rc.zoom = screenZoomSB->value();
1026 rc.font_sizes[FONT_SIZE_TINY] = widgetToDoubleStr(screenTinyED);
1027 rc.font_sizes[FONT_SIZE_SCRIPT] = widgetToDoubleStr(screenSmallestED);
1028 rc.font_sizes[FONT_SIZE_FOOTNOTE] = widgetToDoubleStr(screenSmallerED);
1029 rc.font_sizes[FONT_SIZE_SMALL] = widgetToDoubleStr(screenSmallED);
1030 rc.font_sizes[FONT_SIZE_NORMAL] = widgetToDoubleStr(screenNormalED);
1031 rc.font_sizes[FONT_SIZE_LARGE] = widgetToDoubleStr(screenLargeED);
1032 rc.font_sizes[FONT_SIZE_LARGER] = widgetToDoubleStr(screenLargerED);
1033 rc.font_sizes[FONT_SIZE_LARGEST] = widgetToDoubleStr(screenLargestED);
1034 rc.font_sizes[FONT_SIZE_HUGE] = widgetToDoubleStr(screenHugeED);
1035 rc.font_sizes[FONT_SIZE_HUGER] = widgetToDoubleStr(screenHugerED);
1036 rc.use_pixmap_cache = pixmapCacheCB->isChecked();
1038 if (rc.font_sizes != oldrc.font_sizes
1039 || rc.roman_font_name != oldrc.roman_font_name
1040 || rc.sans_font_name != oldrc.sans_font_name
1041 || rc.typewriter_font_name != oldrc.typewriter_font_name
1042 || rc.zoom != oldrc.zoom) {
1043 // The global QPixmapCache is used in GuiPainter to cache text
1044 // painting so we must reset it in case any of the above
1045 // parameter is changed.
1046 QPixmapCache::clear();
1047 guiApp->fontLoader().update();
1048 form_->updateScreenFonts();
1053 void PrefScreenFonts::updateRC(LyXRC const & rc)
1055 setComboxFont(screenRomanCO, rc.roman_font_name,
1056 rc.roman_font_foundry);
1057 setComboxFont(screenSansCO, rc.sans_font_name,
1058 rc.sans_font_foundry);
1059 setComboxFont(screenTypewriterCO, rc.typewriter_font_name,
1060 rc.typewriter_font_foundry);
1062 selectRoman(screenRomanCO->currentText());
1063 selectSans(screenSansCO->currentText());
1064 selectTypewriter(screenTypewriterCO->currentText());
1066 screenZoomSB->setValue(rc.zoom);
1067 updateScreenFontSizes(rc);
1069 pixmapCacheCB->setChecked(rc.use_pixmap_cache);
1070 #if defined(Q_WS_X11) || defined(QPA_XCB)
1071 pixmapCacheCB->setEnabled(false);
1077 void PrefScreenFonts::updateScreenFontSizes(LyXRC const & rc)
1079 doubleToWidget(screenTinyED, rc.font_sizes[FONT_SIZE_TINY]);
1080 doubleToWidget(screenSmallestED, rc.font_sizes[FONT_SIZE_SCRIPT]);
1081 doubleToWidget(screenSmallerED, rc.font_sizes[FONT_SIZE_FOOTNOTE]);
1082 doubleToWidget(screenSmallED, rc.font_sizes[FONT_SIZE_SMALL]);
1083 doubleToWidget(screenNormalED, rc.font_sizes[FONT_SIZE_NORMAL]);
1084 doubleToWidget(screenLargeED, rc.font_sizes[FONT_SIZE_LARGE]);
1085 doubleToWidget(screenLargerED, rc.font_sizes[FONT_SIZE_LARGER]);
1086 doubleToWidget(screenLargestED, rc.font_sizes[FONT_SIZE_LARGEST]);
1087 doubleToWidget(screenHugeED, rc.font_sizes[FONT_SIZE_HUGE]);
1088 doubleToWidget(screenHugerED, rc.font_sizes[FONT_SIZE_HUGER]);
1092 void PrefScreenFonts::selectRoman(const QString & name)
1094 screenRomanFE->set(QFont(name), name);
1098 void PrefScreenFonts::selectSans(const QString & name)
1100 screenSansFE->set(QFont(name), name);
1104 void PrefScreenFonts::selectTypewriter(const QString & name)
1106 screenTypewriterFE->set(QFont(name), name);
1110 /////////////////////////////////////////////////////////////////////
1114 /////////////////////////////////////////////////////////////////////
1117 PrefColors::PrefColors(GuiPreferences * form)
1118 : PrefModule(catLookAndFeel, N_("Colors"), form)
1122 // FIXME: all of this initialization should be put into the controller.
1123 // See http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg113301.html
1124 // for some discussion of why that is not trivial.
1125 QPixmap icon(32, 32);
1126 for (int i = 0; i < Color_ignore; ++i) {
1127 ColorCode lc = static_cast<ColorCode>(i);
1128 if (lc == Color_none
1129 || lc == Color_black
1130 || lc == Color_white
1132 || lc == Color_brown
1134 || lc == Color_darkgray
1136 || lc == Color_green
1137 || lc == Color_lightgray
1139 || lc == Color_magenta
1140 || lc == Color_olive
1141 || lc == Color_orange
1143 || lc == Color_purple
1146 || lc == Color_violet
1147 || lc == Color_yellow
1148 || lc == Color_inherit
1149 || lc == Color_ignore)
1151 lcolors_.push_back(lc);
1153 qSort(lcolors_.begin(), lcolors_.end(), ColorSorter);
1154 vector<ColorCode>::const_iterator cit = lcolors_.begin();
1155 vector<ColorCode>::const_iterator const end = lcolors_.end();
1156 for (; cit != end; ++cit) {
1157 (void) new QListWidgetItem(QIcon(icon),
1158 toqstr(lcolor.getGUIName(*cit)), lyxObjectsLW);
1160 curcolors_.resize(lcolors_.size());
1161 newcolors_.resize(lcolors_.size());
1162 // End initialization
1164 connect(colorChangePB, SIGNAL(clicked()),
1165 this, SLOT(changeColor()));
1166 connect(lyxObjectsLW, SIGNAL(itemSelectionChanged()),
1167 this, SLOT(changeLyxObjectsSelection()));
1168 connect(lyxObjectsLW, SIGNAL(itemActivated(QListWidgetItem*)),
1169 this, SLOT(changeColor()));
1170 connect(syscolorsCB, SIGNAL(toggled(bool)),
1171 this, SIGNAL(changed()));
1172 connect(syscolorsCB, SIGNAL(toggled(bool)),
1173 this, SLOT(changeSysColor()));
1177 void PrefColors::applyRC(LyXRC & rc) const
1181 for (unsigned int i = 0; i < lcolors_.size(); ++i)
1182 if (curcolors_[i] != newcolors_[i])
1183 form_->setColor(lcolors_[i], newcolors_[i]);
1184 rc.use_system_colors = syscolorsCB->isChecked();
1186 if (oldrc.use_system_colors != rc.use_system_colors)
1187 guiApp->colorCache().clear();
1191 void PrefColors::updateRC(LyXRC const & rc)
1193 for (unsigned int i = 0; i < lcolors_.size(); ++i) {
1194 QColor color = QColor(guiApp->colorCache().get(lcolors_[i], false));
1195 QPixmap coloritem(32, 32);
1196 coloritem.fill(color);
1197 lyxObjectsLW->item(i)->setIcon(QIcon(coloritem));
1198 newcolors_[i] = curcolors_[i] = color.name();
1200 syscolorsCB->setChecked(rc.use_system_colors);
1201 changeLyxObjectsSelection();
1205 void PrefColors::changeColor()
1207 int const row = lyxObjectsLW->currentRow();
1213 QString const color = newcolors_[row];
1214 QColor c = QColorDialog::getColor(QColor(color), qApp->focusWidget());
1216 if (c.isValid() && c.name() != color) {
1217 newcolors_[row] = c.name();
1218 QPixmap coloritem(32, 32);
1220 lyxObjectsLW->currentItem()->setIcon(QIcon(coloritem));
1226 void PrefColors::changeSysColor()
1228 for (int row = 0 ; row < lyxObjectsLW->count() ; ++row) {
1229 // skip colors that are taken from system palette
1230 bool const hide = syscolorsCB->isChecked()
1231 && guiApp->colorCache().isSystem(lcolors_[row]);
1233 lyxObjectsLW->item(row)->setHidden(hide);
1238 void PrefColors::changeLyxObjectsSelection()
1240 colorChangePB->setDisabled(lyxObjectsLW->currentRow() < 0);
1244 /////////////////////////////////////////////////////////////////////
1248 /////////////////////////////////////////////////////////////////////
1250 PrefDisplay::PrefDisplay(GuiPreferences * form)
1251 : PrefModule(catLookAndFeel, N_("Display"), form)
1254 connect(displayGraphicsCB, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
1255 connect(instantPreviewCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
1256 connect(previewSizeSB, SIGNAL(valueChanged(double)), this, SIGNAL(changed()));
1257 connect(paragraphMarkerCB, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
1261 void PrefDisplay::on_instantPreviewCO_currentIndexChanged(int index)
1263 previewSizeSB->setEnabled(index != 0);
1267 void PrefDisplay::applyRC(LyXRC & rc) const
1269 switch (instantPreviewCO->currentIndex()) {
1271 rc.preview = LyXRC::PREVIEW_OFF;
1274 if (rc.preview != LyXRC::PREVIEW_NO_MATH) {
1275 rc.preview = LyXRC::PREVIEW_NO_MATH;
1276 form_->updatePreviews();
1280 if (rc.preview != LyXRC::PREVIEW_ON) {
1281 rc.preview = LyXRC::PREVIEW_ON;
1282 form_->updatePreviews();
1287 rc.display_graphics = displayGraphicsCB->isChecked();
1288 rc.preview_scale_factor = previewSizeSB->value();
1289 rc.paragraph_markers = paragraphMarkerCB->isChecked();
1291 // FIXME!! The graphics cache no longer has a changeDisplay method.
1293 if (old_value != rc.display_graphics) {
1294 graphics::GCache & gc = graphics::GCache::get();
1301 void PrefDisplay::updateRC(LyXRC const & rc)
1303 switch (rc.preview) {
1304 case LyXRC::PREVIEW_OFF:
1305 instantPreviewCO->setCurrentIndex(0);
1307 case LyXRC::PREVIEW_NO_MATH :
1308 instantPreviewCO->setCurrentIndex(1);
1310 case LyXRC::PREVIEW_ON :
1311 instantPreviewCO->setCurrentIndex(2);
1315 displayGraphicsCB->setChecked(rc.display_graphics);
1316 previewSizeSB->setValue(rc.preview_scale_factor);
1317 paragraphMarkerCB->setChecked(rc.paragraph_markers);
1318 previewSizeSB->setEnabled(
1320 && rc.preview != LyXRC::PREVIEW_OFF);
1324 /////////////////////////////////////////////////////////////////////
1328 /////////////////////////////////////////////////////////////////////
1330 PrefPaths::PrefPaths(GuiPreferences * form)
1331 : PrefModule(QString(), N_("Paths"), form)
1335 connect(workingDirPB, SIGNAL(clicked()), this, SLOT(selectWorkingdir()));
1336 connect(workingDirED, SIGNAL(textChanged(QString)),
1337 this, SIGNAL(changed()));
1339 connect(templateDirPB, SIGNAL(clicked()), this, SLOT(selectTemplatedir()));
1340 connect(templateDirED, SIGNAL(textChanged(QString)),
1341 this, SIGNAL(changed()));
1343 connect(exampleDirPB, SIGNAL(clicked()), this, SLOT(selectExampledir()));
1344 connect(exampleDirED, SIGNAL(textChanged(QString)),
1345 this, SIGNAL(changed()));
1347 connect(backupDirPB, SIGNAL(clicked()), this, SLOT(selectBackupdir()));
1348 connect(backupDirED, SIGNAL(textChanged(QString)),
1349 this, SIGNAL(changed()));
1351 connect(lyxserverDirPB, SIGNAL(clicked()), this, SLOT(selectLyxPipe()));
1352 connect(lyxserverDirED, SIGNAL(textChanged(QString)),
1353 this, SIGNAL(changed()));
1355 connect(thesaurusDirPB, SIGNAL(clicked()), this, SLOT(selectThesaurusdir()));
1356 connect(thesaurusDirED, SIGNAL(textChanged(QString)),
1357 this, SIGNAL(changed()));
1359 connect(tempDirPB, SIGNAL(clicked()), this, SLOT(selectTempdir()));
1360 connect(tempDirED, SIGNAL(textChanged(QString)),
1361 this, SIGNAL(changed()));
1363 #if defined(USE_HUNSPELL)
1364 connect(hunspellDirPB, SIGNAL(clicked()), this, SLOT(selectHunspelldir()));
1365 connect(hunspellDirED, SIGNAL(textChanged(QString)),
1366 this, SIGNAL(changed()));
1368 hunspellDirPB->setEnabled(false);
1369 hunspellDirED->setEnabled(false);
1372 connect(pathPrefixED, SIGNAL(textChanged(QString)),
1373 this, SIGNAL(changed()));
1375 connect(texinputsPrefixED, SIGNAL(textChanged(QString)),
1376 this, SIGNAL(changed()));
1378 pathPrefixED->setValidator(new NoNewLineValidator(pathPrefixED));
1379 texinputsPrefixED->setValidator(new NoNewLineValidator(texinputsPrefixED));
1383 void PrefPaths::applyRC(LyXRC & rc) const
1385 rc.document_path = internal_path(fromqstr(workingDirED->text()));
1386 rc.example_path = internal_path(fromqstr(exampleDirED->text()));
1387 rc.template_path = internal_path(fromqstr(templateDirED->text()));
1388 rc.backupdir_path = internal_path(fromqstr(backupDirED->text()));
1389 rc.tempdir_path = internal_path(fromqstr(tempDirED->text()));
1390 rc.thesaurusdir_path = internal_path(fromqstr(thesaurusDirED->text()));
1391 rc.hunspelldir_path = internal_path(fromqstr(hunspellDirED->text()));
1392 rc.path_prefix = internal_path_list(fromqstr(pathPrefixED->text()));
1393 rc.texinputs_prefix = internal_path_list(fromqstr(texinputsPrefixED->text()));
1394 // FIXME: should be a checkbox only
1395 rc.lyxpipes = internal_path(fromqstr(lyxserverDirED->text()));
1399 void PrefPaths::updateRC(LyXRC const & rc)
1401 workingDirED->setText(toqstr(external_path(rc.document_path)));
1402 exampleDirED->setText(toqstr(external_path(rc.example_path)));
1403 templateDirED->setText(toqstr(external_path(rc.template_path)));
1404 backupDirED->setText(toqstr(external_path(rc.backupdir_path)));
1405 tempDirED->setText(toqstr(external_path(rc.tempdir_path)));
1406 thesaurusDirED->setText(toqstr(external_path(rc.thesaurusdir_path)));
1407 hunspellDirED->setText(toqstr(external_path(rc.hunspelldir_path)));
1408 pathPrefixED->setText(toqstr(external_path_list(rc.path_prefix)));
1409 texinputsPrefixED->setText(toqstr(external_path_list(rc.texinputs_prefix)));
1410 // FIXME: should be a checkbox only
1411 lyxserverDirED->setText(toqstr(external_path(rc.lyxpipes)));
1415 void PrefPaths::selectExampledir()
1417 QString file = browseDir(internalPath(exampleDirED->text()),
1418 qt_("Select directory for example files"));
1419 if (!file.isEmpty())
1420 exampleDirED->setText(file);
1424 void PrefPaths::selectTemplatedir()
1426 QString file = browseDir(internalPath(templateDirED->text()),
1427 qt_("Select a document templates directory"));
1428 if (!file.isEmpty())
1429 templateDirED->setText(file);
1433 void PrefPaths::selectTempdir()
1435 QString file = browseDir(internalPath(tempDirED->text()),
1436 qt_("Select a temporary directory"));
1437 if (!file.isEmpty())
1438 tempDirED->setText(file);
1442 void PrefPaths::selectBackupdir()
1444 QString file = browseDir(internalPath(backupDirED->text()),
1445 qt_("Select a backups directory"));
1446 if (!file.isEmpty())
1447 backupDirED->setText(file);
1451 void PrefPaths::selectWorkingdir()
1453 QString file = browseDir(internalPath(workingDirED->text()),
1454 qt_("Select a document directory"));
1455 if (!file.isEmpty())
1456 workingDirED->setText(file);
1460 void PrefPaths::selectThesaurusdir()
1462 QString file = browseDir(internalPath(thesaurusDirED->text()),
1463 qt_("Set the path to the thesaurus dictionaries"));
1464 if (!file.isEmpty())
1465 thesaurusDirED->setText(file);
1469 void PrefPaths::selectHunspelldir()
1471 QString file = browseDir(internalPath(hunspellDirED->text()),
1472 qt_("Set the path to the Hunspell dictionaries"));
1473 if (!file.isEmpty())
1474 hunspellDirED->setText(file);
1478 void PrefPaths::selectLyxPipe()
1480 QString file = form_->browse(internalPath(lyxserverDirED->text()),
1481 qt_("Give a filename for the LyX server pipe"));
1482 if (!file.isEmpty())
1483 lyxserverDirED->setText(file);
1487 /////////////////////////////////////////////////////////////////////
1491 /////////////////////////////////////////////////////////////////////
1493 PrefSpellchecker::PrefSpellchecker(GuiPreferences * form)
1494 : PrefModule(catLanguage, N_("Spellchecker"), form)
1498 // FIXME: this check should test the target platform (darwin)
1499 #if defined(USE_MACOSX_PACKAGING)
1500 spellcheckerCB->addItem(qt_("Native"), QString("native"));
1501 #define CONNECT_APPLESPELL
1503 #undef CONNECT_APPLESPELL
1505 #if defined(USE_ASPELL)
1506 spellcheckerCB->addItem(qt_("Aspell"), QString("aspell"));
1508 #if defined(USE_ENCHANT)
1509 spellcheckerCB->addItem(qt_("Enchant"), QString("enchant"));
1511 #if defined(USE_HUNSPELL)
1512 spellcheckerCB->addItem(qt_("Hunspell"), QString("hunspell"));
1515 #if defined(CONNECT_APPLESPELL) || defined(USE_ASPELL) || defined(USE_ENCHANT) || defined(USE_HUNSPELL)
1516 connect(spellcheckerCB, SIGNAL(currentIndexChanged(int)),
1517 this, SIGNAL(changed()));
1518 connect(altLanguageED, SIGNAL(textChanged(QString)),
1519 this, SIGNAL(changed()));
1520 connect(escapeCharactersED, SIGNAL(textChanged(QString)),
1521 this, SIGNAL(changed()));
1522 connect(compoundWordCB, SIGNAL(clicked()),
1523 this, SIGNAL(changed()));
1524 connect(spellcheckContinuouslyCB, SIGNAL(clicked()),
1525 this, SIGNAL(changed()));
1526 connect(spellcheckNotesCB, SIGNAL(clicked()),
1527 this, SIGNAL(changed()));
1529 altLanguageED->setValidator(new NoNewLineValidator(altLanguageED));
1530 escapeCharactersED->setValidator(new NoNewLineValidator(escapeCharactersED));
1532 spellcheckerCB->setEnabled(false);
1533 altLanguageED->setEnabled(false);
1534 escapeCharactersED->setEnabled(false);
1535 compoundWordCB->setEnabled(false);
1536 spellcheckContinuouslyCB->setEnabled(false);
1537 spellcheckNotesCB->setEnabled(false);
1542 void PrefSpellchecker::applyRC(LyXRC & rc) const
1544 string const speller = fromqstr(spellcheckerCB->
1545 itemData(spellcheckerCB->currentIndex()).toString());
1546 if (!speller.empty())
1547 rc.spellchecker = speller;
1548 rc.spellchecker_alt_lang = fromqstr(altLanguageED->text());
1549 rc.spellchecker_esc_chars = fromqstr(escapeCharactersED->text());
1550 rc.spellchecker_accept_compound = compoundWordCB->isChecked();
1551 rc.spellcheck_continuously = spellcheckContinuouslyCB->isChecked();
1552 rc.spellcheck_notes = spellcheckNotesCB->isChecked();
1556 void PrefSpellchecker::updateRC(LyXRC const & rc)
1558 spellcheckerCB->setCurrentIndex(
1559 spellcheckerCB->findData(toqstr(rc.spellchecker)));
1560 altLanguageED->setText(toqstr(rc.spellchecker_alt_lang));
1561 escapeCharactersED->setText(toqstr(rc.spellchecker_esc_chars));
1562 compoundWordCB->setChecked(rc.spellchecker_accept_compound);
1563 spellcheckContinuouslyCB->setChecked(rc.spellcheck_continuously);
1564 spellcheckNotesCB->setChecked(rc.spellcheck_notes);
1568 void PrefSpellchecker::on_spellcheckerCB_currentIndexChanged(int index)
1570 QString spellchecker = spellcheckerCB->itemData(index).toString();
1572 compoundWordCB->setEnabled(spellchecker == QString("aspell"));
1577 /////////////////////////////////////////////////////////////////////
1581 /////////////////////////////////////////////////////////////////////
1584 PrefConverters::PrefConverters(GuiPreferences * form)
1585 : PrefModule(catFiles, N_("Converters"), form)
1589 connect(converterNewPB, SIGNAL(clicked()),
1590 this, SLOT(updateConverter()));
1591 connect(converterRemovePB, SIGNAL(clicked()),
1592 this, SLOT(removeConverter()));
1593 connect(converterModifyPB, SIGNAL(clicked()),
1594 this, SLOT(updateConverter()));
1595 connect(convertersLW, SIGNAL(currentRowChanged(int)),
1596 this, SLOT(switchConverter()));
1597 connect(converterFromCO, SIGNAL(activated(QString)),
1598 this, SLOT(changeConverter()));
1599 connect(converterToCO, SIGNAL(activated(QString)),
1600 this, SLOT(changeConverter()));
1601 connect(converterED, SIGNAL(textEdited(QString)),
1602 this, SLOT(changeConverter()));
1603 connect(converterFlagED, SIGNAL(textEdited(QString)),
1604 this, SLOT(changeConverter()));
1605 connect(converterNewPB, SIGNAL(clicked()),
1606 this, SIGNAL(changed()));
1607 connect(converterRemovePB, SIGNAL(clicked()),
1608 this, SIGNAL(changed()));
1609 connect(converterModifyPB, SIGNAL(clicked()),
1610 this, SIGNAL(changed()));
1611 connect(maxAgeLE, SIGNAL(textEdited(QString)),
1612 this, SIGNAL(changed()));
1613 connect(needauthForbiddenCB, SIGNAL(toggled(bool)),
1614 this, SIGNAL(changed()));
1615 connect(needauthCB, SIGNAL(toggled(bool)),
1616 this, SIGNAL(changed()));
1618 converterED->setValidator(new NoNewLineValidator(converterED));
1619 converterFlagED->setValidator(new NoNewLineValidator(converterFlagED));
1620 maxAgeLE->setValidator(new QDoubleValidator(maxAgeLE));
1621 //converterDefGB->setFocusProxy(convertersLW);
1625 void PrefConverters::applyRC(LyXRC & rc) const
1627 rc.use_converter_cache = cacheCB->isChecked();
1628 rc.use_converter_needauth_forbidden = needauthForbiddenCB->isChecked();
1629 rc.use_converter_needauth = needauthCB->isChecked();
1630 rc.converter_cache_maxage = int(widgetToDouble(maxAgeLE) * 86400.0);
1634 void PrefConverters::updateRC(LyXRC const & rc)
1636 cacheCB->setChecked(rc.use_converter_cache);
1637 needauthForbiddenCB->setChecked(rc.use_converter_needauth_forbidden);
1638 needauthCB->setChecked(rc.use_converter_needauth);
1640 doubleToWidget(maxAgeLE, (double(rc.converter_cache_maxage) / 86400.0), 'g', 6);
1645 void PrefConverters::updateGui()
1647 QString const pattern("%1 -> %2");
1648 form_->formats().sort();
1649 form_->converters().update(form_->formats());
1650 // save current selection
1653 .arg(converterFromCO->currentText())
1654 .arg(converterToCO->currentText());
1656 converterFromCO->clear();
1657 converterToCO->clear();
1659 for (Format const & f : form_->formats()) {
1660 QString const name = toqstr(translateIfPossible(f.prettyname()));
1661 converterFromCO->addItem(name);
1662 converterToCO->addItem(name);
1665 // currentRowChanged(int) is also triggered when updating the listwidget
1666 // block signals to avoid unnecessary calls to switchConverter()
1667 convertersLW->blockSignals(true);
1668 convertersLW->clear();
1670 for (Converter const & c : form_->converters()) {
1671 QString const name =
1673 .arg(toqstr(translateIfPossible(c.From()->prettyname())))
1674 .arg(toqstr(translateIfPossible(c.To()->prettyname())));
1675 int type = form_->converters().getNumber(c.From()->name(),
1677 new QListWidgetItem(name, convertersLW, type);
1679 convertersLW->sortItems(Qt::AscendingOrder);
1680 convertersLW->blockSignals(false);
1682 // restore selection
1683 if (current != pattern.arg(QString()).arg(QString())) {
1684 QList<QListWidgetItem *> const item =
1685 convertersLW->findItems(current, Qt::MatchExactly);
1686 if (!item.isEmpty())
1687 convertersLW->setCurrentItem(item.at(0));
1690 // select first element if restoring failed
1691 if (convertersLW->currentRow() == -1)
1692 convertersLW->setCurrentRow(0);
1698 void PrefConverters::switchConverter()
1700 int const cnr = convertersLW->currentItem()->type();
1701 Converter const & c(form_->converters().get(cnr));
1702 converterFromCO->setCurrentIndex(form_->formats().getNumber(c.from()));
1703 converterToCO->setCurrentIndex(form_->formats().getNumber(c.to()));
1704 converterED->setText(toqstr(c.command()));
1705 converterFlagED->setText(toqstr(c.flags()));
1711 void PrefConverters::changeConverter()
1717 void PrefConverters::updateButtons()
1719 if (form_->formats().empty())
1721 Format const & from = form_->formats().get(converterFromCO->currentIndex());
1722 Format const & to = form_->formats().get(converterToCO->currentIndex());
1723 int const sel = form_->converters().getNumber(from.name(), to.name());
1724 bool const known = sel >= 0;
1725 bool const valid = !(converterED->text().isEmpty()
1726 || from.name() == to.name());
1731 if (convertersLW->count() > 0) {
1732 int const cnr = convertersLW->currentItem()->type();
1733 Converter const & c = form_->converters().get(cnr);
1734 old_command = c.command();
1735 old_flag = c.flags();
1738 string const new_command = fromqstr(converterED->text());
1739 string const new_flag = fromqstr(converterFlagED->text());
1741 bool modified = (old_command != new_command || old_flag != new_flag);
1743 converterModifyPB->setEnabled(valid && known && modified);
1744 converterNewPB->setEnabled(valid && !known);
1745 converterRemovePB->setEnabled(known);
1747 maxAgeLE->setEnabled(cacheCB->isChecked());
1748 maxAgeLA->setEnabled(cacheCB->isChecked());
1753 // specify unique from/to or it doesn't appear. This is really bad UI
1754 // this is why we can use the same function for both new and modify
1755 void PrefConverters::updateConverter()
1757 Format const & from = form_->formats().get(converterFromCO->currentIndex());
1758 Format const & to = form_->formats().get(converterToCO->currentIndex());
1759 string const flags = fromqstr(converterFlagED->text());
1760 string const command = fromqstr(converterED->text());
1762 Converter const * old =
1763 form_->converters().getConverter(from.name(), to.name());
1764 form_->converters().add(from.name(), to.name(), command, flags);
1767 form_->converters().updateLast(form_->formats());
1771 // Remove all files created by this converter from the cache, since
1772 // the modified converter might create different files.
1773 ConverterCache::get().remove_all(from.name(), to.name());
1777 void PrefConverters::removeConverter()
1779 Format const & from = form_->formats().get(converterFromCO->currentIndex());
1780 Format const & to = form_->formats().get(converterToCO->currentIndex());
1781 form_->converters().erase(from.name(), to.name());
1785 // Remove all files created by this converter from the cache, since
1786 // a possible new converter might create different files.
1787 ConverterCache::get().remove_all(from.name(), to.name());
1791 void PrefConverters::on_cacheCB_stateChanged(int state)
1793 maxAgeLE->setEnabled(state == Qt::Checked);
1794 maxAgeLA->setEnabled(state == Qt::Checked);
1799 void PrefConverters::on_needauthForbiddenCB_toggled(bool checked)
1801 needauthCB->setEnabled(!checked);
1805 /////////////////////////////////////////////////////////////////////
1809 /////////////////////////////////////////////////////////////////////
1811 class FormatValidator : public QValidator
1814 FormatValidator(QWidget *, Formats const & f);
1815 void fixup(QString & input) const;
1816 QValidator::State validate(QString & input, int & pos) const;
1818 virtual QString toString(Format const & format) const = 0;
1820 Formats const & formats_;
1824 FormatValidator::FormatValidator(QWidget * parent, Formats const & f)
1825 : QValidator(parent), formats_(f)
1830 void FormatValidator::fixup(QString & input) const
1832 Formats::const_iterator cit = formats_.begin();
1833 Formats::const_iterator end = formats_.end();
1834 for (; cit != end; ++cit) {
1835 QString const name = toString(*cit);
1836 if (distance(formats_.begin(), cit) == nr()) {
1844 QValidator::State FormatValidator::validate(QString & input, int & /*pos*/) const
1846 Formats::const_iterator cit = formats_.begin();
1847 Formats::const_iterator end = formats_.end();
1848 bool unknown = true;
1849 for (; unknown && cit != end; ++cit) {
1850 QString const name = toString(*cit);
1851 if (distance(formats_.begin(), cit) != nr())
1852 unknown = name != input;
1855 if (unknown && !input.isEmpty())
1856 return QValidator::Acceptable;
1858 return QValidator::Intermediate;
1862 int FormatValidator::nr() const
1864 QComboBox * p = qobject_cast<QComboBox *>(parent());
1865 return p->itemData(p->currentIndex()).toInt();
1869 /////////////////////////////////////////////////////////////////////
1871 // FormatNameValidator
1873 /////////////////////////////////////////////////////////////////////
1875 class FormatNameValidator : public FormatValidator
1878 FormatNameValidator(QWidget * parent, Formats const & f)
1879 : FormatValidator(parent, f)
1882 QString toString(Format const & format) const
1884 return toqstr(format.name());
1889 /////////////////////////////////////////////////////////////////////
1891 // FormatPrettynameValidator
1893 /////////////////////////////////////////////////////////////////////
1895 class FormatPrettynameValidator : public FormatValidator
1898 FormatPrettynameValidator(QWidget * parent, Formats const & f)
1899 : FormatValidator(parent, f)
1902 QString toString(Format const & format) const
1904 return toqstr(translateIfPossible(format.prettyname()));
1909 /////////////////////////////////////////////////////////////////////
1913 /////////////////////////////////////////////////////////////////////
1915 PrefFileformats::PrefFileformats(GuiPreferences * form)
1916 : PrefModule(catFiles, N_("File Formats"), form)
1920 formatED->setValidator(new FormatNameValidator(formatsCB, form_->formats()));
1921 formatsCB->setValidator(new FormatPrettynameValidator(formatsCB, form_->formats()));
1922 extensionsED->setValidator(new NoNewLineValidator(extensionsED));
1923 shortcutED->setValidator(new NoNewLineValidator(shortcutED));
1924 editorED->setValidator(new NoNewLineValidator(editorED));
1925 viewerED->setValidator(new NoNewLineValidator(viewerED));
1926 copierED->setValidator(new NoNewLineValidator(copierED));
1928 connect(documentCB, SIGNAL(clicked()),
1929 this, SLOT(setFlags()));
1930 connect(vectorCB, SIGNAL(clicked()),
1931 this, SLOT(setFlags()));
1932 connect(exportMenuCB, SIGNAL(clicked()),
1933 this, SLOT(setFlags()));
1934 connect(formatsCB->lineEdit(), SIGNAL(editingFinished()),
1935 this, SLOT(updatePrettyname()));
1936 connect(formatsCB->lineEdit(), SIGNAL(textEdited(QString)),
1937 this, SIGNAL(changed()));
1938 connect(defaultFormatCB, SIGNAL(activated(QString)),
1939 this, SIGNAL(changed()));
1940 connect(defaultOTFFormatCB, SIGNAL(activated(QString)),
1941 this, SIGNAL(changed()));
1942 connect(viewerCO, SIGNAL(activated(int)),
1943 this, SIGNAL(changed()));
1944 connect(editorCO, SIGNAL(activated(int)),
1945 this, SIGNAL(changed()));
1951 string const l10n_shortcut(docstring const & prettyname, string const & shortcut)
1953 if (shortcut.empty())
1956 string l10n_format =
1957 to_utf8(_(to_utf8(prettyname) + '|' + shortcut));
1958 return split(l10n_format, '|');
1964 void PrefFileformats::applyRC(LyXRC & rc) const
1966 QString const default_format = defaultFormatCB->itemData(
1967 defaultFormatCB->currentIndex()).toString();
1968 rc.default_view_format = fromqstr(default_format);
1969 QString const default_otf_format = defaultOTFFormatCB->itemData(
1970 defaultOTFFormatCB->currentIndex()).toString();
1971 rc.default_otf_view_format = fromqstr(default_otf_format);
1975 void PrefFileformats::updateRC(LyXRC const & rc)
1977 viewer_alternatives = rc.viewer_alternatives;
1978 editor_alternatives = rc.editor_alternatives;
1979 bool const init = defaultFormatCB->currentText().isEmpty();
1983 defaultFormatCB->findData(toqstr(rc.default_view_format));
1984 defaultFormatCB->setCurrentIndex(pos);
1985 pos = defaultOTFFormatCB->findData(toqstr(rc.default_otf_view_format));
1986 defaultOTFFormatCB->setCurrentIndex(pos);
1987 defaultOTFFormatCB->setCurrentIndex(pos);
1992 void PrefFileformats::updateView()
1994 QString const current = formatsCB->currentText();
1995 QString const current_def = defaultFormatCB->currentText();
1996 QString const current_def_otf = defaultOTFFormatCB->currentText();
1998 // update comboboxes with formats
1999 formatsCB->blockSignals(true);
2000 defaultFormatCB->blockSignals(true);
2001 defaultOTFFormatCB->blockSignals(true);
2003 defaultFormatCB->clear();
2004 defaultOTFFormatCB->clear();
2005 form_->formats().sort();
2006 for (Format const & f : form_->formats()) {
2007 QString const prettyname = toqstr(translateIfPossible(f.prettyname()));
2008 formatsCB->addItem(prettyname,
2009 QVariant(form_->formats().getNumber(f.name())));
2010 if (f.viewer().empty())
2012 if (form_->converters().isReachable("xhtml", f.name())
2013 || form_->converters().isReachable("dviluatex", f.name())
2014 || form_->converters().isReachable("luatex", f.name())
2015 || form_->converters().isReachable("xetex", f.name())) {
2016 defaultFormatCB->addItem(prettyname,
2017 QVariant(toqstr(f.name())));
2018 defaultOTFFormatCB->addItem(prettyname,
2019 QVariant(toqstr(f.name())));
2020 } else if (form_->converters().isReachable("latex", f.name())
2021 || form_->converters().isReachable("pdflatex", f.name()))
2022 defaultFormatCB->addItem(prettyname,
2023 QVariant(toqstr(f.name())));
2026 // restore selections
2027 int item = formatsCB->findText(current, Qt::MatchExactly);
2028 formatsCB->setCurrentIndex(item < 0 ? 0 : item);
2029 on_formatsCB_currentIndexChanged(item < 0 ? 0 : item);
2030 item = defaultFormatCB->findText(current_def, Qt::MatchExactly);
2031 defaultFormatCB->setCurrentIndex(item < 0 ? 0 : item);
2032 item = defaultOTFFormatCB->findText(current_def_otf, Qt::MatchExactly);
2033 defaultOTFFormatCB->setCurrentIndex(item < 0 ? 0 : item);
2034 formatsCB->blockSignals(false);
2035 defaultFormatCB->blockSignals(false);
2036 defaultOTFFormatCB->blockSignals(false);
2040 void PrefFileformats::on_formatsCB_currentIndexChanged(int i)
2042 if (form_->formats().empty())
2044 int const nr = formatsCB->itemData(i).toInt();
2045 Format const f = form_->formats().get(nr);
2047 formatED->setText(toqstr(f.name()));
2048 copierED->setText(toqstr(form_->movers().command(f.name())));
2049 extensionsED->setText(toqstr(f.extensions()));
2050 mimeED->setText(toqstr(f.mime()));
2051 shortcutED->setText(
2052 toqstr(l10n_shortcut(f.prettyname(), f.shortcut())));
2053 documentCB->setChecked((f.documentFormat()));
2054 vectorCB->setChecked((f.vectorFormat()));
2055 exportMenuCB->setChecked((f.inExportMenu()));
2056 exportMenuCB->setEnabled((f.documentFormat()));
2062 void PrefFileformats::setFlags()
2064 int flags = Format::none;
2065 if (documentCB->isChecked())
2066 flags |= Format::document;
2067 if (vectorCB->isChecked())
2068 flags |= Format::vector;
2069 if (exportMenuCB->isChecked())
2070 flags |= Format::export_menu;
2071 currentFormat().setFlags(flags);
2072 exportMenuCB->setEnabled(documentCB->isChecked());
2077 void PrefFileformats::on_copierED_textEdited(const QString & s)
2079 string const fmt = fromqstr(formatED->text());
2080 form_->movers().set(fmt, fromqstr(s));
2085 void PrefFileformats::on_extensionsED_textEdited(const QString & s)
2087 currentFormat().setExtensions(fromqstr(s));
2092 void PrefFileformats::on_viewerED_textEdited(const QString & s)
2094 currentFormat().setViewer(fromqstr(s));
2099 void PrefFileformats::on_editorED_textEdited(const QString & s)
2101 currentFormat().setEditor(fromqstr(s));
2106 void PrefFileformats::on_mimeED_textEdited(const QString & s)
2108 currentFormat().setMime(fromqstr(s));
2113 void PrefFileformats::on_shortcutED_textEdited(const QString & s)
2115 string const new_shortcut = fromqstr(s);
2116 if (new_shortcut == l10n_shortcut(currentFormat().prettyname(),
2117 currentFormat().shortcut()))
2119 currentFormat().setShortcut(new_shortcut);
2124 void PrefFileformats::on_formatED_editingFinished()
2126 string const newname = fromqstr(formatED->displayText());
2127 string const oldname = currentFormat().name();
2128 if (newname == oldname)
2130 if (form_->converters().formatIsUsed(oldname)) {
2131 Alert::error(_("Format in use"),
2132 _("You cannot change a format's short name "
2133 "if the format is used by a converter. "
2134 "Please remove the converter first."));
2139 currentFormat().setName(newname);
2144 void PrefFileformats::on_formatED_textChanged(const QString &)
2146 QString t = formatED->text();
2148 bool valid = formatED->validator()->validate(t, p) == QValidator::Acceptable;
2149 setValid(formatLA, valid);
2153 void PrefFileformats::on_formatsCB_editTextChanged(const QString &)
2155 QString t = formatsCB->currentText();
2157 bool valid = formatsCB->validator()->validate(t, p) == QValidator::Acceptable;
2158 setValid(formatsLA, valid);
2162 void PrefFileformats::updatePrettyname()
2164 QString const newname = formatsCB->currentText();
2165 if (newname == toqstr(translateIfPossible(currentFormat().prettyname())))
2168 currentFormat().setPrettyname(qstring_to_ucs4(newname));
2176 void updateComboBox(LyXRC::Alternatives const & alts,
2177 string const & fmt, QComboBox * combo)
2179 LyXRC::Alternatives::const_iterator it =
2181 if (it != alts.end()) {
2182 LyXRC::CommandSet const & cmds = it->second;
2183 LyXRC::CommandSet::const_iterator sit =
2185 LyXRC::CommandSet::const_iterator const sen =
2187 for (; sit != sen; ++sit) {
2188 QString const qcmd = toqstr(*sit);
2189 combo->addItem(qcmd, qcmd);
2196 void PrefFileformats::updateViewers()
2198 Format const f = currentFormat();
2199 viewerCO->blockSignals(true);
2201 viewerCO->addItem(qt_("None"), QString());
2202 updateComboBox(viewer_alternatives, f.name(), viewerCO);
2203 viewerCO->addItem(qt_("Custom"), QString("custom viewer"));
2204 viewerCO->blockSignals(false);
2206 int pos = viewerCO->findData(toqstr(f.viewer()));
2209 viewerED->setEnabled(false);
2210 viewerCO->setCurrentIndex(pos);
2212 viewerED->setEnabled(true);
2213 viewerED->setText(toqstr(f.viewer()));
2214 viewerCO->setCurrentIndex(viewerCO->findData(toqstr("custom viewer")));
2219 void PrefFileformats::updateEditors()
2221 Format const f = currentFormat();
2222 editorCO->blockSignals(true);
2224 editorCO->addItem(qt_("None"), QString());
2225 updateComboBox(editor_alternatives, f.name(), editorCO);
2226 editorCO->addItem(qt_("Custom"), QString("custom editor"));
2227 editorCO->blockSignals(false);
2229 int pos = editorCO->findData(toqstr(f.editor()));
2232 editorED->setEnabled(false);
2233 editorCO->setCurrentIndex(pos);
2235 editorED->setEnabled(true);
2236 editorED->setText(toqstr(f.editor()));
2237 editorCO->setCurrentIndex(editorCO->findData(toqstr("custom editor")));
2242 void PrefFileformats::on_viewerCO_currentIndexChanged(int i)
2244 bool const custom = viewerCO->itemData(i).toString() == "custom viewer";
2245 viewerED->setEnabled(custom);
2247 currentFormat().setViewer(fromqstr(viewerCO->itemData(i).toString()));
2251 void PrefFileformats::on_editorCO_currentIndexChanged(int i)
2253 bool const custom = editorCO->itemData(i).toString() == "custom editor";
2254 editorED->setEnabled(custom);
2256 currentFormat().setEditor(fromqstr(editorCO->itemData(i).toString()));
2260 Format & PrefFileformats::currentFormat()
2262 int const i = formatsCB->currentIndex();
2263 int const nr = formatsCB->itemData(i).toInt();
2264 return form_->formats().get(nr);
2268 void PrefFileformats::on_formatNewPB_clicked()
2270 form_->formats().add("", "", docstring(), "", "", "", "", Format::none);
2272 formatsCB->setCurrentIndex(0);
2273 formatsCB->setFocus(Qt::OtherFocusReason);
2277 void PrefFileformats::on_formatRemovePB_clicked()
2279 int const i = formatsCB->currentIndex();
2280 int const nr = formatsCB->itemData(i).toInt();
2281 string const current_text = form_->formats().get(nr).name();
2282 if (form_->converters().formatIsUsed(current_text)) {
2283 Alert::error(_("Format in use"),
2284 _("Cannot remove a Format used by a Converter. "
2285 "Remove the converter first."));
2289 form_->formats().erase(current_text);
2292 on_formatsCB_editTextChanged(formatsCB->currentText());
2297 /////////////////////////////////////////////////////////////////////
2301 /////////////////////////////////////////////////////////////////////
2303 PrefLanguage::PrefLanguage(GuiPreferences * form)
2304 : PrefModule(catLanguage, N_("Language"), form)
2308 connect(visualCursorRB, SIGNAL(clicked()),
2309 this, SIGNAL(changed()));
2310 connect(logicalCursorRB, SIGNAL(clicked()),
2311 this, SIGNAL(changed()));
2312 connect(markForeignCB, SIGNAL(clicked()),
2313 this, SIGNAL(changed()));
2314 connect(autoBeginCB, SIGNAL(clicked()),
2315 this, SIGNAL(changed()));
2316 connect(autoEndCB, SIGNAL(clicked()),
2317 this, SIGNAL(changed()));
2318 connect(languagePackageCO, SIGNAL(activated(int)),
2319 this, SIGNAL(changed()));
2320 connect(languagePackageED, SIGNAL(textChanged(QString)),
2321 this, SIGNAL(changed()));
2322 connect(globalCB, SIGNAL(clicked()),
2323 this, SIGNAL(changed()));
2324 connect(startCommandED, SIGNAL(textChanged(QString)),
2325 this, SIGNAL(changed()));
2326 connect(endCommandED, SIGNAL(textChanged(QString)),
2327 this, SIGNAL(changed()));
2328 connect(uiLanguageCO, SIGNAL(activated(int)),
2329 this, SIGNAL(changed()));
2330 connect(defaultDecimalPointLE, SIGNAL(textChanged(QString)),
2331 this, SIGNAL(changed()));
2332 connect(defaultLengthUnitCO, SIGNAL(activated(int)),
2333 this, SIGNAL(changed()));
2335 languagePackageED->setValidator(new NoNewLineValidator(languagePackageED));
2336 startCommandED->setValidator(new NoNewLineValidator(startCommandED));
2337 endCommandED->setValidator(new NoNewLineValidator(endCommandED));
2339 defaultDecimalPointLE->setInputMask("X; ");
2340 defaultDecimalPointLE->setMaxLength(1);
2342 defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::CM]), Length::CM);
2343 defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::IN]), Length::IN);
2345 QAbstractItemModel * language_model = guiApp->languageModel();
2346 language_model->sort(0);
2347 uiLanguageCO->blockSignals(true);
2348 uiLanguageCO->clear();
2349 uiLanguageCO->addItem(qt_("Default"), toqstr("auto"));
2350 for (int i = 0; i != language_model->rowCount(); ++i) {
2351 QModelIndex index = language_model->index(i, 0);
2352 // Filter the list based on the available translation and add
2353 // each language code only once
2354 string const name = fromqstr(index.data(Qt::UserRole).toString());
2355 Language const * lang = languages.getLanguage(name);
2358 // never remove the currently selected language
2359 if (name != form->rc().gui_language
2360 && name != lyxrc.gui_language
2361 && (!Messages::available(lang->code())
2362 || !lang->hasGuiSupport()))
2364 uiLanguageCO->addItem(index.data(Qt::DisplayRole).toString(),
2365 index.data(Qt::UserRole).toString());
2367 uiLanguageCO->blockSignals(false);
2371 void PrefLanguage::on_uiLanguageCO_currentIndexChanged(int)
2373 QMessageBox::information(this, qt_("LyX needs to be restarted!"),
2374 qt_("The change of user interface language will be fully "
2375 "effective only after a restart."));
2379 void PrefLanguage::on_languagePackageCO_currentIndexChanged(int i)
2381 languagePackageED->setEnabled(i == 2);
2385 void PrefLanguage::applyRC(LyXRC & rc) const
2387 rc.visual_cursor = visualCursorRB->isChecked();
2388 rc.mark_foreign_language = markForeignCB->isChecked();
2389 rc.language_auto_begin = autoBeginCB->isChecked();
2390 rc.language_auto_end = autoEndCB->isChecked();
2391 int const p = languagePackageCO->currentIndex();
2393 rc.language_package_selection = LyXRC::LP_AUTO;
2395 rc.language_package_selection = LyXRC::LP_BABEL;
2397 rc.language_package_selection = LyXRC::LP_CUSTOM;
2399 rc.language_package_selection = LyXRC::LP_NONE;
2400 rc.language_custom_package = fromqstr(languagePackageED->text());
2401 rc.language_global_options = globalCB->isChecked();
2402 rc.language_command_begin = fromqstr(startCommandED->text());
2403 rc.language_command_end = fromqstr(endCommandED->text());
2404 rc.gui_language = fromqstr(
2405 uiLanguageCO->itemData(uiLanguageCO->currentIndex()).toString());
2406 rc.default_decimal_point = fromqstr(defaultDecimalPointLE->text());
2407 rc.default_length_unit = (Length::UNIT) defaultLengthUnitCO->itemData(defaultLengthUnitCO->currentIndex()).toInt();
2411 void PrefLanguage::updateRC(LyXRC const & rc)
2413 if (rc.visual_cursor)
2414 visualCursorRB->setChecked(true);
2416 logicalCursorRB->setChecked(true);
2417 markForeignCB->setChecked(rc.mark_foreign_language);
2418 autoBeginCB->setChecked(rc.language_auto_begin);
2419 autoEndCB->setChecked(rc.language_auto_end);
2420 languagePackageCO->setCurrentIndex(rc.language_package_selection);
2421 languagePackageED->setText(toqstr(rc.language_custom_package));
2422 languagePackageED->setEnabled(languagePackageCO->currentIndex() == 2);
2423 globalCB->setChecked(rc.language_global_options);
2424 startCommandED->setText(toqstr(rc.language_command_begin));
2425 endCommandED->setText(toqstr(rc.language_command_end));
2426 defaultDecimalPointLE->setText(toqstr(rc.default_decimal_point));
2427 int pos = defaultLengthUnitCO->findData(int(rc.default_length_unit));
2428 defaultLengthUnitCO->setCurrentIndex(pos);
2430 pos = uiLanguageCO->findData(toqstr(rc.gui_language));
2431 uiLanguageCO->blockSignals(true);
2432 uiLanguageCO->setCurrentIndex(pos);
2433 uiLanguageCO->blockSignals(false);
2437 /////////////////////////////////////////////////////////////////////
2439 // PrefUserInterface
2441 /////////////////////////////////////////////////////////////////////
2443 PrefUserInterface::PrefUserInterface(GuiPreferences * form)
2444 : PrefModule(catLookAndFeel, N_("User Interface"), form)
2448 connect(uiFilePB, SIGNAL(clicked()),
2449 this, SLOT(selectUi()));
2450 connect(uiFileED, SIGNAL(textChanged(QString)),
2451 this, SIGNAL(changed()));
2452 connect(iconSetCO, SIGNAL(activated(int)),
2453 this, SIGNAL(changed()));
2454 connect(useSystemThemeIconsCB, SIGNAL(clicked()),
2455 this, SIGNAL(changed()));
2456 connect(lastfilesSB, SIGNAL(valueChanged(int)),
2457 this, SIGNAL(changed()));
2458 connect(tooltipCB, SIGNAL(toggled(bool)),
2459 this, SIGNAL(changed()));
2460 lastfilesSB->setMaximum(maxlastfiles);
2462 iconSetCO->addItem(qt_("Default"), QString());
2463 iconSetCO->addItem(qt_("Classic"), "classic");
2464 iconSetCO->addItem(qt_("Oxygen"), "oxygen");
2466 #if (!(defined Q_WS_X11 || defined(QPA_XCB)) || QT_VERSION < 0x040600)
2467 useSystemThemeIconsCB->hide();
2472 void PrefUserInterface::applyRC(LyXRC & rc) const
2474 rc.icon_set = fromqstr(iconSetCO->itemData(
2475 iconSetCO->currentIndex()).toString());
2477 rc.ui_file = internal_path(fromqstr(uiFileED->text()));
2478 rc.use_system_theme_icons = useSystemThemeIconsCB->isChecked();
2479 rc.num_lastfiles = lastfilesSB->value();
2480 rc.use_tooltip = tooltipCB->isChecked();
2484 void PrefUserInterface::updateRC(LyXRC const & rc)
2486 int iconset = iconSetCO->findData(toqstr(rc.icon_set));
2489 iconSetCO->setCurrentIndex(iconset);
2490 useSystemThemeIconsCB->setChecked(rc.use_system_theme_icons);
2491 uiFileED->setText(toqstr(external_path(rc.ui_file)));
2492 lastfilesSB->setValue(rc.num_lastfiles);
2493 tooltipCB->setChecked(rc.use_tooltip);
2497 void PrefUserInterface::selectUi()
2499 QString file = form_->browseUI(internalPath(uiFileED->text()));
2500 if (!file.isEmpty())
2501 uiFileED->setText(file);
2505 /////////////////////////////////////////////////////////////////////
2507 // PrefDocumentHandling
2509 /////////////////////////////////////////////////////////////////////
2511 PrefDocHandling::PrefDocHandling(GuiPreferences * form)
2512 : PrefModule(catLookAndFeel, N_("Document Handling"), form)
2516 connect(autoSaveCB, SIGNAL(toggled(bool)),
2517 autoSaveSB, SLOT(setEnabled(bool)));
2518 connect(autoSaveCB, SIGNAL(toggled(bool)),
2519 TextLabel1, SLOT(setEnabled(bool)));
2520 connect(openDocumentsInTabsCB, SIGNAL(clicked()),
2521 this, SIGNAL(changed()));
2522 connect(singleInstanceCB, SIGNAL(clicked()),
2523 this, SIGNAL(changed()));
2524 connect(singleCloseTabButtonCB, SIGNAL(clicked()),
2525 this, SIGNAL(changed()));
2526 connect(closeLastViewCO, SIGNAL(activated(int)),
2527 this, SIGNAL(changed()));
2528 connect(restoreCursorCB, SIGNAL(clicked()),
2529 this, SIGNAL(changed()));
2530 connect(loadSessionCB, SIGNAL(clicked()),
2531 this, SIGNAL(changed()));
2532 connect(allowGeometrySessionCB, SIGNAL(clicked()),
2533 this, SIGNAL(changed()));
2534 connect(autoSaveSB, SIGNAL(valueChanged(int)),
2535 this, SIGNAL(changed()));
2536 connect(autoSaveCB, SIGNAL(clicked()),
2537 this, SIGNAL(changed()));
2538 connect(backupCB, SIGNAL(clicked()),
2539 this, SIGNAL(changed()));
2540 connect(saveCompressedCB, SIGNAL(clicked()),
2541 this, SIGNAL(changed()));
2542 connect(saveOriginCB, SIGNAL(clicked()),
2543 this, SIGNAL(changed()));
2547 void PrefDocHandling::applyRC(LyXRC & rc) const
2549 rc.use_lastfilepos = restoreCursorCB->isChecked();
2550 rc.load_session = loadSessionCB->isChecked();
2551 rc.allow_geometry_session = allowGeometrySessionCB->isChecked();
2552 rc.autosave = autoSaveCB->isChecked() ? autoSaveSB->value() * 60 : 0;
2553 rc.make_backup = backupCB->isChecked();
2554 rc.save_compressed = saveCompressedCB->isChecked();
2555 rc.save_origin = saveOriginCB->isChecked();
2556 rc.open_buffers_in_tabs = openDocumentsInTabsCB->isChecked();
2557 rc.single_instance = singleInstanceCB->isChecked();
2558 rc.single_close_tab_button = singleCloseTabButtonCB->isChecked();
2560 switch (closeLastViewCO->currentIndex()) {
2562 rc.close_buffer_with_last_view = "yes";
2565 rc.close_buffer_with_last_view = "no";
2568 rc.close_buffer_with_last_view = "ask";
2576 void PrefDocHandling::updateRC(LyXRC const & rc)
2578 restoreCursorCB->setChecked(rc.use_lastfilepos);
2579 loadSessionCB->setChecked(rc.load_session);
2580 allowGeometrySessionCB->setChecked(rc.allow_geometry_session);
2581 // convert to minutes
2582 bool autosave = rc.autosave > 0;
2583 int mins = rc.autosave / 60;
2586 autoSaveSB->setValue(mins);
2587 autoSaveCB->setChecked(autosave);
2588 autoSaveSB->setEnabled(autosave);
2589 backupCB->setChecked(rc.make_backup);
2590 saveCompressedCB->setChecked(rc.save_compressed);
2591 saveOriginCB->setChecked(rc.save_origin);
2592 openDocumentsInTabsCB->setChecked(rc.open_buffers_in_tabs);
2593 singleInstanceCB->setChecked(rc.single_instance && !rc.lyxpipes.empty());
2594 singleInstanceCB->setEnabled(!rc.lyxpipes.empty());
2595 singleCloseTabButtonCB->setChecked(rc.single_close_tab_button);
2596 if (rc.close_buffer_with_last_view == "yes")
2597 closeLastViewCO->setCurrentIndex(0);
2598 else if (rc.close_buffer_with_last_view == "no")
2599 closeLastViewCO->setCurrentIndex(1);
2600 else if (rc.close_buffer_with_last_view == "ask")
2601 closeLastViewCO->setCurrentIndex(2);
2605 void PrefDocHandling::on_clearSessionPB_clicked()
2607 guiApp->clearSession();
2612 /////////////////////////////////////////////////////////////////////
2616 /////////////////////////////////////////////////////////////////////
2618 PrefEdit::PrefEdit(GuiPreferences * form)
2619 : PrefModule(catEditing, N_("Control"), form)
2623 connect(cursorFollowsCB, SIGNAL(clicked()),
2624 this, SIGNAL(changed()));
2625 connect(scrollBelowCB, SIGNAL(clicked()),
2626 this, SIGNAL(changed()));
2627 connect(macLikeCursorMovementCB, SIGNAL(clicked()),
2628 this, SIGNAL(changed()));
2629 connect(sortEnvironmentsCB, SIGNAL(clicked()),
2630 this, SIGNAL(changed()));
2631 connect(groupEnvironmentsCB, SIGNAL(clicked()),
2632 this, SIGNAL(changed()));
2633 connect(macroEditStyleCO, SIGNAL(activated(int)),
2634 this, SIGNAL(changed()));
2635 connect(cursorWidthSB, SIGNAL(valueChanged(int)),
2636 this, SIGNAL(changed()));
2637 connect(fullscreenLimitGB, SIGNAL(clicked()),
2638 this, SIGNAL(changed()));
2639 connect(fullscreenWidthSB, SIGNAL(valueChanged(int)),
2640 this, SIGNAL(changed()));
2641 connect(toggleTabbarCB, SIGNAL(toggled(bool)),
2642 this, SIGNAL(changed()));
2643 connect(toggleMenubarCB, SIGNAL(toggled(bool)),
2644 this, SIGNAL(changed()));
2645 connect(toggleScrollbarCB, SIGNAL(toggled(bool)),
2646 this, SIGNAL(changed()));
2647 connect(toggleStatusbarCB, SIGNAL(toggled(bool)),
2648 this, SIGNAL(changed()));
2649 connect(toggleToolbarsCB, SIGNAL(toggled(bool)),
2650 this, SIGNAL(changed()));
2654 void PrefEdit::applyRC(LyXRC & rc) const
2656 rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked();
2657 rc.scroll_below_document = scrollBelowCB->isChecked();
2658 rc.mac_like_cursor_movement = macLikeCursorMovementCB->isChecked();
2659 rc.sort_layouts = sortEnvironmentsCB->isChecked();
2660 rc.group_layouts = groupEnvironmentsCB->isChecked();
2661 switch (macroEditStyleCO->currentIndex()) {
2662 case 0: rc.macro_edit_style = LyXRC::MACRO_EDIT_INLINE_BOX; break;
2663 case 1: rc.macro_edit_style = LyXRC::MACRO_EDIT_INLINE; break;
2664 case 2: rc.macro_edit_style = LyXRC::MACRO_EDIT_LIST; break;
2666 rc.cursor_width = cursorWidthSB->value();
2667 rc.full_screen_toolbars = toggleToolbarsCB->isChecked();
2668 rc.full_screen_scrollbar = toggleScrollbarCB->isChecked();
2669 rc.full_screen_statusbar = toggleStatusbarCB->isChecked();
2670 rc.full_screen_tabbar = toggleTabbarCB->isChecked();
2671 rc.full_screen_menubar = toggleMenubarCB->isChecked();
2672 rc.full_screen_width = fullscreenWidthSB->value();
2673 rc.full_screen_limit = fullscreenLimitGB->isChecked();
2677 void PrefEdit::updateRC(LyXRC const & rc)
2679 cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
2680 scrollBelowCB->setChecked(rc.scroll_below_document);
2681 macLikeCursorMovementCB->setChecked(rc.mac_like_cursor_movement);
2682 sortEnvironmentsCB->setChecked(rc.sort_layouts);
2683 groupEnvironmentsCB->setChecked(rc.group_layouts);
2684 macroEditStyleCO->setCurrentIndex(rc.macro_edit_style);
2685 cursorWidthSB->setValue(rc.cursor_width);
2686 toggleScrollbarCB->setChecked(rc.full_screen_scrollbar);
2687 toggleStatusbarCB->setChecked(rc.full_screen_statusbar);
2688 toggleToolbarsCB->setChecked(rc.full_screen_toolbars);
2689 toggleTabbarCB->setChecked(rc.full_screen_tabbar);
2690 toggleMenubarCB->setChecked(rc.full_screen_menubar);
2691 fullscreenWidthSB->setValue(rc.full_screen_width);
2692 fullscreenLimitGB->setChecked(rc.full_screen_limit);
2696 /////////////////////////////////////////////////////////////////////
2700 /////////////////////////////////////////////////////////////////////
2703 GuiShortcutDialog::GuiShortcutDialog(QWidget * parent) : QDialog(parent)
2705 Ui::shortcutUi::setupUi(this);
2706 QDialog::setModal(true);
2710 PrefShortcuts::PrefShortcuts(GuiPreferences * form)
2711 : PrefModule(catEditing, N_("Shortcuts"), form),
2712 editItem_(0), mathItem_(0), bufferItem_(0), layoutItem_(0),
2717 shortcutsTW->setColumnCount(2);
2718 shortcutsTW->headerItem()->setText(0, qt_("Function"));
2719 shortcutsTW->headerItem()->setText(1, qt_("Shortcut"));
2720 shortcutsTW->setSortingEnabled(true);
2721 // Multi-selection can be annoying.
2722 // shortcutsTW->setSelectionMode(QAbstractItemView::MultiSelection);
2724 connect(bindFilePB, SIGNAL(clicked()),
2725 this, SLOT(selectBind()));
2726 connect(bindFileED, SIGNAL(textChanged(QString)),
2727 this, SIGNAL(changed()));
2729 shortcut_ = new GuiShortcutDialog(this);
2730 shortcut_bc_.setPolicy(ButtonPolicy::OkCancelPolicy);
2731 shortcut_bc_.setOK(shortcut_->okPB);
2732 shortcut_bc_.setCancel(shortcut_->cancelPB);
2734 connect(shortcut_->okPB, SIGNAL(clicked()),
2735 this, SIGNAL(changed()));
2736 connect(shortcut_->cancelPB, SIGNAL(clicked()),
2737 shortcut_, SLOT(reject()));
2738 connect(shortcut_->clearPB, SIGNAL(clicked()),
2739 this, SLOT(shortcutClearPressed()));
2740 connect(shortcut_->removePB, SIGNAL(clicked()),
2741 this, SLOT(shortcutRemovePressed()));
2742 connect(shortcut_->okPB, SIGNAL(clicked()),
2743 this, SLOT(shortcutOkPressed()));
2744 connect(shortcut_->cancelPB, SIGNAL(clicked()),
2745 this, SLOT(shortcutCancelPressed()));
2749 void PrefShortcuts::applyRC(LyXRC & rc) const
2751 rc.bind_file = internal_path(fromqstr(bindFileED->text()));
2752 // write user_bind and user_unbind to .lyx/bind/user.bind
2753 FileName bind_dir(addPath(package().user_support().absFileName(), "bind"));
2754 if (!bind_dir.exists() && !bind_dir.createDirectory(0777)) {
2755 lyxerr << "LyX could not create the user bind directory '"
2756 << bind_dir << "'. All user-defined key bindings will be lost." << endl;
2759 if (!bind_dir.isDirWritable()) {
2760 lyxerr << "LyX could not write to the user bind directory '"
2761 << bind_dir << "'. All user-defined key bindings will be lost." << endl;
2764 FileName user_bind_file(bind_dir.absFileName() + "/user.bind");
2765 user_unbind_.write(user_bind_file.toFilesystemEncoding(), false, true);
2766 user_bind_.write(user_bind_file.toFilesystemEncoding(), true, false);
2767 // immediately apply the keybindings. Why this is not done before?
2768 // The good thing is that the menus are updated automatically.
2769 theTopLevelKeymap().clear();
2770 theTopLevelKeymap().read("site");
2771 theTopLevelKeymap().read(rc.bind_file, 0, KeyMap::Fallback);
2772 theTopLevelKeymap().read("user", 0, KeyMap::MissingOK);
2776 void PrefShortcuts::updateRC(LyXRC const & rc)
2778 bindFileED->setText(toqstr(external_path(rc.bind_file)));
2780 system_bind_.clear();
2782 user_unbind_.clear();
2783 system_bind_.read("site");
2784 system_bind_.read(rc.bind_file);
2785 // \unbind in user.bind is added to user_unbind_
2786 user_bind_.read("user", &user_unbind_, KeyMap::MissingOK);
2787 updateShortcutsTW();
2791 void PrefShortcuts::updateShortcutsTW()
2793 shortcutsTW->clear();
2795 editItem_ = new QTreeWidgetItem(shortcutsTW);
2796 editItem_->setText(0, qt_("Cursor, Mouse and Editing Functions"));
2797 editItem_->setFlags(editItem_->flags() & ~Qt::ItemIsSelectable);
2799 mathItem_ = new QTreeWidgetItem(shortcutsTW);
2800 mathItem_->setText(0, qt_("Mathematical Symbols"));
2801 mathItem_->setFlags(mathItem_->flags() & ~Qt::ItemIsSelectable);
2803 bufferItem_ = new QTreeWidgetItem(shortcutsTW);
2804 bufferItem_->setText(0, qt_("Document and Window"));
2805 bufferItem_->setFlags(bufferItem_->flags() & ~Qt::ItemIsSelectable);
2807 layoutItem_ = new QTreeWidgetItem(shortcutsTW);
2808 layoutItem_->setText(0, qt_("Font, Layouts and Textclasses"));
2809 layoutItem_->setFlags(layoutItem_->flags() & ~Qt::ItemIsSelectable);
2811 systemItem_ = new QTreeWidgetItem(shortcutsTW);
2812 systemItem_->setText(0, qt_("System and Miscellaneous"));
2813 systemItem_->setFlags(systemItem_->flags() & ~Qt::ItemIsSelectable);
2815 // listBindings(unbound=true) lists all bound and unbound lfuns
2816 // Items in this list is tagged by its source.
2817 KeyMap::BindingList bindinglist = system_bind_.listBindings(true,
2819 KeyMap::BindingList user_bindinglist = user_bind_.listBindings(false,
2821 KeyMap::BindingList user_unbindinglist = user_unbind_.listBindings(false,
2822 KeyMap::UserUnbind);
2823 bindinglist.insert(bindinglist.end(), user_bindinglist.begin(),
2824 user_bindinglist.end());
2825 bindinglist.insert(bindinglist.end(), user_unbindinglist.begin(),
2826 user_unbindinglist.end());
2828 KeyMap::BindingList::const_iterator it = bindinglist.begin();
2829 KeyMap::BindingList::const_iterator it_end = bindinglist.end();
2830 for (; it != it_end; ++it)
2831 insertShortcutItem(it->request, it->sequence, it->tag);
2833 shortcutsTW->sortItems(0, Qt::AscendingOrder);
2834 on_shortcutsTW_itemSelectionChanged();
2835 on_searchLE_textEdited();
2836 shortcutsTW->resizeColumnToContents(0);
2841 KeyMap::ItemType PrefShortcuts::itemType(QTreeWidgetItem & item)
2843 return static_cast<KeyMap::ItemType>(item.data(0, Qt::UserRole).toInt());
2848 bool PrefShortcuts::isAlwaysHidden(QTreeWidgetItem & item)
2850 // Hide rebound system settings that are empty
2851 return itemType(item) == KeyMap::UserUnbind && item.text(1).isEmpty();
2855 void PrefShortcuts::setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag)
2857 item->setData(0, Qt::UserRole, QVariant(tag));
2861 case KeyMap::System:
2863 case KeyMap::UserBind:
2866 case KeyMap::UserUnbind:
2867 font.setStrikeOut(true);
2869 // this item is not displayed now.
2870 case KeyMap::UserExtraUnbind:
2871 font.setStrikeOut(true);
2874 item->setHidden(isAlwaysHidden(*item));
2875 item->setFont(1, font);
2879 QTreeWidgetItem * PrefShortcuts::insertShortcutItem(FuncRequest const & lfun,
2880 KeySequence const & seq, KeyMap::ItemType tag)
2882 FuncCode const action = lfun.action();
2883 string const action_name = lyxaction.getActionName(action);
2884 QString const lfun_name = toqstr(from_utf8(action_name)
2885 + ' ' + lfun.argument());
2886 QString const shortcut = toqstr(seq.print(KeySequence::ForGui));
2888 QTreeWidgetItem * newItem = 0;
2889 // for unbind items, try to find an existing item in the system bind list
2890 if (tag == KeyMap::UserUnbind) {
2891 QList<QTreeWidgetItem*> const items = shortcutsTW->findItems(lfun_name,
2892 Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 0);
2893 for (int i = 0; i < items.size(); ++i) {
2894 if (items[i]->text(1) == shortcut) {
2899 // if not found, this unbind item is KeyMap::UserExtraUnbind
2900 // Such an item is not displayed to avoid confusion (what is
2901 // unmatched removed?).
2907 switch(lyxaction.getActionType(action)) {
2908 case LyXAction::Hidden:
2910 case LyXAction::Edit:
2911 newItem = new QTreeWidgetItem(editItem_);
2913 case LyXAction::Math:
2914 newItem = new QTreeWidgetItem(mathItem_);
2916 case LyXAction::Buffer:
2917 newItem = new QTreeWidgetItem(bufferItem_);
2919 case LyXAction::Layout:
2920 newItem = new QTreeWidgetItem(layoutItem_);
2922 case LyXAction::System:
2923 newItem = new QTreeWidgetItem(systemItem_);
2926 // this should not happen
2927 newItem = new QTreeWidgetItem(shortcutsTW);
2931 newItem->setText(0, lfun_name);
2932 newItem->setText(1, shortcut);
2933 // record BindFile representation to recover KeySequence when needed.
2934 newItem->setData(1, Qt::UserRole, toqstr(seq.print(KeySequence::BindFile)));
2935 setItemType(newItem, tag);
2940 void PrefShortcuts::on_shortcutsTW_itemSelectionChanged()
2942 QList<QTreeWidgetItem*> items = shortcutsTW->selectedItems();
2943 removePB->setEnabled(!items.isEmpty() && !items[0]->text(1).isEmpty());
2944 modifyPB->setEnabled(!items.isEmpty());
2945 if (items.isEmpty())
2948 if (itemType(*items[0]) == KeyMap::UserUnbind)
2949 removePB->setText(qt_("Res&tore"));
2951 removePB->setText(qt_("Remo&ve"));
2955 void PrefShortcuts::on_shortcutsTW_itemDoubleClicked()
2961 void PrefShortcuts::modifyShortcut()
2963 QTreeWidgetItem * item = shortcutsTW->currentItem();
2964 if (item->flags() & Qt::ItemIsSelectable) {
2965 shortcut_->lfunLE->setText(item->text(0));
2966 save_lfun_ = item->text(0).trimmed();
2967 shortcut_->shortcutWG->setText(item->text(1));
2969 seq.parse(fromqstr(item->data(1, Qt::UserRole).toString()));
2970 shortcut_->shortcutWG->setKeySequence(seq);
2971 shortcut_->shortcutWG->setFocus();
2977 void PrefShortcuts::unhideEmpty(QString const & lfun, bool select)
2979 // list of items that match lfun
2980 QList<QTreeWidgetItem*> items = shortcutsTW->findItems(lfun,
2981 Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 0);
2982 for (int i = 0; i < items.size(); ++i) {
2983 QTreeWidgetItem * item = items[i];
2984 if (isAlwaysHidden(*item)) {
2985 setItemType(item, KeyMap::System);
2987 shortcutsTW->setCurrentItem(item);
2994 void PrefShortcuts::removeShortcut()
2996 // it seems that only one item can be selected, but I am
2997 // removing all selected items anyway.
2998 QList<QTreeWidgetItem*> items = shortcutsTW->selectedItems();
2999 for (int i = 0; i < items.size(); ++i) {
3000 string shortcut = fromqstr(items[i]->data(1, Qt::UserRole).toString());
3001 string lfun = fromqstr(items[i]->text(0));
3002 FuncRequest func = lyxaction.lookupFunc(lfun);
3004 switch (itemType(*items[i])) {
3005 case KeyMap::System: {
3006 // for system bind, we do not touch the item
3007 // but add an user unbind item
3008 user_unbind_.bind(shortcut, func);
3009 setItemType(items[i], KeyMap::UserUnbind);
3010 removePB->setText(qt_("Res&tore"));
3013 case KeyMap::UserBind: {
3014 // for user_bind, we remove this bind
3015 QTreeWidgetItem * parent = items[i]->parent();
3016 int itemIdx = parent->indexOfChild(items[i]);
3017 parent->takeChild(itemIdx);
3019 shortcutsTW->scrollToItem(parent->child(itemIdx - 1));
3021 shortcutsTW->scrollToItem(parent);
3022 user_bind_.unbind(shortcut, func);
3023 // If this user binding hid an empty system binding, unhide the
3024 // latter and select it.
3025 unhideEmpty(items[i]->text(0), true);
3028 case KeyMap::UserUnbind: {
3029 // for user_unbind, we remove the unbind, and the item
3030 // become KeyMap::System again.
3032 seq.parse(shortcut);
3033 // Ask the user to replace current binding
3034 if (!validateNewShortcut(func, seq, QString()))
3036 user_unbind_.unbind(shortcut, func);
3037 setItemType(items[i], KeyMap::System);
3038 removePB->setText(qt_("Remo&ve"));
3041 case KeyMap::UserExtraUnbind: {
3042 // for user unbind that is not in system bind file,
3043 // remove this unbind file
3044 QTreeWidgetItem * parent = items[i]->parent();
3045 parent->takeChild(parent->indexOfChild(items[i]));
3046 user_unbind_.unbind(shortcut, func);
3053 void PrefShortcuts::deactivateShortcuts(QList<QTreeWidgetItem*> const & items)
3055 for (int i = 0; i < items.size(); ++i) {
3056 string shortcut = fromqstr(items[i]->data(1, Qt::UserRole).toString());
3057 string lfun = fromqstr(items[i]->text(0));
3058 FuncRequest func = lyxaction.lookupFunc(lfun);
3060 switch (itemType(*items[i])) {
3061 case KeyMap::System:
3062 // for system bind, we do not touch the item
3063 // but add an user unbind item
3064 user_unbind_.bind(shortcut, func);
3065 setItemType(items[i], KeyMap::UserUnbind);
3068 case KeyMap::UserBind: {
3069 // for user_bind, we remove this bind
3070 QTreeWidgetItem * parent = items[i]->parent();
3071 int itemIdx = parent->indexOfChild(items[i]);
3072 parent->takeChild(itemIdx);
3073 user_bind_.unbind(shortcut, func);
3074 unhideEmpty(items[i]->text(0), false);
3084 void PrefShortcuts::selectBind()
3086 QString file = form_->browsebind(internalPath(bindFileED->text()));
3087 if (!file.isEmpty()) {
3088 bindFileED->setText(file);
3089 system_bind_ = KeyMap();
3090 system_bind_.read(fromqstr(file));
3091 updateShortcutsTW();
3096 void PrefShortcuts::on_modifyPB_pressed()
3102 void PrefShortcuts::on_newPB_pressed()
3104 shortcut_->lfunLE->clear();
3105 shortcut_->shortcutWG->reset();
3106 save_lfun_ = QString();
3111 void PrefShortcuts::on_removePB_pressed()
3118 void PrefShortcuts::on_searchLE_textEdited()
3120 if (searchLE->text().isEmpty()) {
3121 // show all hidden items
3122 QTreeWidgetItemIterator it(shortcutsTW, QTreeWidgetItemIterator::Hidden);
3124 shortcutsTW->setItemHidden(*it, isAlwaysHidden(**it));
3125 // close all categories
3126 for (int i = 0; i < shortcutsTW->topLevelItemCount(); ++i)
3127 shortcutsTW->collapseItem(shortcutsTW->topLevelItem(i));
3130 // search both columns
3131 QList<QTreeWidgetItem *> matched = shortcutsTW->findItems(searchLE->text(),
3132 Qt::MatchFlags(Qt::MatchContains | Qt::MatchRecursive), 0);
3133 matched += shortcutsTW->findItems(searchLE->text(),
3134 Qt::MatchFlags(Qt::MatchContains | Qt::MatchRecursive), 1);
3136 // hide everyone (to avoid searching in matched QList repeatedly
3137 QTreeWidgetItemIterator it(shortcutsTW, QTreeWidgetItemIterator::Selectable);
3139 shortcutsTW->setItemHidden(*it++, true);
3140 // show matched items
3141 for (int i = 0; i < matched.size(); ++i)
3142 if (!isAlwaysHidden(*matched[i])) {
3143 shortcutsTW->setItemHidden(matched[i], false);
3144 shortcutsTW->setItemExpanded(matched[i]->parent(), true);
3149 docstring makeCmdString(FuncRequest const & f)
3151 docstring actionStr = from_ascii(lyxaction.getActionName(f.action()));
3152 if (!f.argument().empty())
3153 actionStr += " " + f.argument();
3158 FuncRequest PrefShortcuts::currentBinding(KeySequence const & k)
3160 FuncRequest res = user_bind_.getBinding(k);
3161 if (res.action() != LFUN_UNKNOWN_ACTION)
3163 res = system_bind_.getBinding(k);
3164 // Check if it is unbound. Note: user_unbind_ can only unbind one
3165 // FuncRequest per key sequence.
3166 if (user_unbind_.getBinding(k) == res)
3167 return FuncRequest::unknown;
3172 bool PrefShortcuts::validateNewShortcut(FuncRequest const & func,
3173 KeySequence const & k,
3174 QString const & lfun_to_modify)
3176 if (func.action() == LFUN_UNKNOWN_ACTION) {
3177 Alert::error(_("Failed to create shortcut"),
3178 _("Unknown or invalid LyX function"));
3182 // It is not currently possible to bind Hidden lfuns such as self-insert. In
3183 // the future, to remove this limitation, see GuiPrefs::insertShortcutItem
3184 // and how it is used in GuiPrefs::shortcutOkPressed.
3185 if (lyxaction.getActionType(func.action()) == LyXAction::Hidden) {
3186 Alert::error(_("Failed to create shortcut"),
3187 _("This LyX function is hidden and cannot be bound."));
3191 if (k.length() == 0) {
3192 Alert::error(_("Failed to create shortcut"),
3193 _("Invalid or empty key sequence"));
3197 FuncRequest oldBinding = currentBinding(k);
3198 if (oldBinding == func)
3199 // nothing to change
3202 // make sure this key isn't already bound---and, if so, prompt user
3203 // (exclude the lfun the user already wants to modify)
3204 docstring const action_string = makeCmdString(oldBinding);
3205 if (oldBinding.action() != LFUN_UNKNOWN_ACTION
3206 && lfun_to_modify != toqstr(action_string)) {
3207 docstring const new_action_string = makeCmdString(func);
3208 docstring const text = bformat(_("Shortcut `%1$s' is already bound to "
3210 "Are you sure you want to unbind the "
3211 "current shortcut and bind it to %3$s?"),
3212 k.print(KeySequence::ForGui), action_string,
3214 int ret = Alert::prompt(_("Redefine shortcut?"),
3215 text, 0, 1, _("&Redefine"), _("&Cancel"));
3218 QString const sequence_text = toqstr(k.print(KeySequence::ForGui));
3219 QList<QTreeWidgetItem*> items = shortcutsTW->findItems(sequence_text,
3220 Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 1);
3221 deactivateShortcuts(items);
3227 void PrefShortcuts::shortcutOkPressed()
3229 QString const new_lfun = shortcut_->lfunLE->text();
3230 FuncRequest func = lyxaction.lookupFunc(fromqstr(new_lfun));
3231 KeySequence k = shortcut_->shortcutWG->getKeySequence();
3233 // save_lfun_ contains the text of the lfun to modify, if the user clicked
3234 // "modify", or is empty if they clicked "new" (which I do not really like)
3235 if (!validateNewShortcut(func, k, save_lfun_))
3238 if (!save_lfun_.isEmpty()) {
3239 // real modification of the lfun's shortcut,
3240 // so remove the previous one
3241 QList<QTreeWidgetItem*> to_modify = shortcutsTW->selectedItems();
3242 deactivateShortcuts(to_modify);
3245 shortcut_->accept();
3247 QTreeWidgetItem * item = insertShortcutItem(func, k, KeyMap::UserBind);
3249 user_bind_.bind(&k, func);
3250 shortcutsTW->sortItems(0, Qt::AscendingOrder);
3251 shortcutsTW->setItemExpanded(item->parent(), true);
3252 shortcutsTW->setCurrentItem(item);
3253 shortcutsTW->scrollToItem(item);
3255 Alert::error(_("Failed to create shortcut"),
3256 _("Can not insert shortcut to the list"));
3262 void PrefShortcuts::shortcutCancelPressed()
3264 shortcut_->shortcutWG->reset();
3268 void PrefShortcuts::shortcutClearPressed()
3270 shortcut_->shortcutWG->reset();
3274 void PrefShortcuts::shortcutRemovePressed()
3276 shortcut_->shortcutWG->removeFromSequence();
3280 /////////////////////////////////////////////////////////////////////
3284 /////////////////////////////////////////////////////////////////////
3286 PrefIdentity::PrefIdentity(GuiPreferences * form)
3287 : PrefModule(QString(), N_("Identity"), form)
3291 connect(nameED, SIGNAL(textChanged(QString)),
3292 this, SIGNAL(changed()));
3293 connect(emailED, SIGNAL(textChanged(QString)),
3294 this, SIGNAL(changed()));
3296 nameED->setValidator(new NoNewLineValidator(nameED));
3297 emailED->setValidator(new NoNewLineValidator(emailED));
3301 void PrefIdentity::applyRC(LyXRC & rc) const
3303 rc.user_name = fromqstr(nameED->text());
3304 rc.user_email = fromqstr(emailED->text());
3308 void PrefIdentity::updateRC(LyXRC const & rc)
3310 nameED->setText(toqstr(rc.user_name));
3311 emailED->setText(toqstr(rc.user_email));
3316 /////////////////////////////////////////////////////////////////////
3320 /////////////////////////////////////////////////////////////////////
3322 GuiPreferences::GuiPreferences(GuiView & lv)
3323 : GuiDialog(lv, "prefs", qt_("Preferences")), update_screen_font_(false),
3324 update_previews_(false)
3328 QDialog::setModal(false);
3330 connect(savePB, SIGNAL(clicked()), this, SLOT(slotOK()));
3331 connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
3332 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
3333 connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
3335 addModule(new PrefUserInterface(this));
3336 addModule(new PrefDocHandling(this));
3337 addModule(new PrefEdit(this));
3338 addModule(new PrefShortcuts(this));
3339 PrefScreenFonts * screenfonts = new PrefScreenFonts(this);
3340 connect(this, SIGNAL(prefsApplied(LyXRC const &)),
3341 screenfonts, SLOT(updateScreenFontSizes(LyXRC const &)));
3342 addModule(screenfonts);
3343 addModule(new PrefColors(this));
3344 addModule(new PrefDisplay(this));
3345 addModule(new PrefInput(this));
3346 addModule(new PrefCompletion(this));
3348 addModule(new PrefPaths(this));
3350 addModule(new PrefIdentity(this));
3352 addModule(new PrefLanguage(this));
3353 addModule(new PrefSpellchecker(this));
3355 //for strftime validator
3356 PrefOutput * output = new PrefOutput(this);
3358 addModule(new PrefLatex(this));
3360 PrefConverters * converters = new PrefConverters(this);
3361 PrefFileformats * formats = new PrefFileformats(this);
3362 connect(formats, SIGNAL(formatsChanged()),
3363 converters, SLOT(updateGui()));
3364 addModule(converters);
3367 prefsPS->setCurrentPanel("User Interface");
3368 // FIXME: hack to work around resizing bug in Qt >= 4.2
3369 // bug verified with Qt 4.2.{0-3} (JSpitzm)
3370 #if QT_VERSION >= 0x040200
3371 prefsPS->updateGeometry();
3374 bc().setPolicy(ButtonPolicy::PreferencesPolicy);
3376 bc().setApply(applyPB);
3377 bc().setCancel(closePB);
3378 bc().setRestore(restorePB);
3380 // initialize the strftime validator
3381 bc().addCheckedLineEdit(output->DateED);
3385 void GuiPreferences::addModule(PrefModule * module)
3387 LASSERT(module, return);
3388 if (module->category().isEmpty())
3389 prefsPS->addPanel(module, module->title());
3391 prefsPS->addPanel(module, module->title(), module->category());
3392 connect(module, SIGNAL(changed()), this, SLOT(change_adaptor()));
3393 modules_.push_back(module);
3397 void GuiPreferences::change_adaptor()
3403 void GuiPreferences::applyRC(LyXRC & rc) const
3405 size_t end = modules_.size();
3406 for (size_t i = 0; i != end; ++i)
3407 modules_[i]->applyRC(rc);
3411 void GuiPreferences::updateRC(LyXRC const & rc)
3413 size_t const end = modules_.size();
3414 for (size_t i = 0; i != end; ++i)
3415 modules_[i]->updateRC(rc);
3419 void GuiPreferences::applyView()
3425 bool GuiPreferences::initialiseParams(string const &)
3428 formats_ = lyx::formats;
3429 converters_ = theConverters();
3430 converters_.update(formats_);
3431 movers_ = theMovers();
3433 update_screen_font_ = false;
3434 update_previews_ = false;
3437 // Make sure that the bc is in the INITIAL state
3438 if (bc().policy().buttonStatus(ButtonPolicy::RESTORE))
3445 void GuiPreferences::dispatchParams()
3448 rc_.write(ss, true);
3449 dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
3450 // issue prefsApplied signal. This will update the
3451 // localized screen font sizes.
3453 // FIXME: these need lfuns
3455 Author const & author =
3456 Author(from_utf8(rc_.user_name), from_utf8(rc_.user_email));
3457 theBufferList().recordCurrentAuthor(author);
3459 lyx::formats = formats_;
3461 theConverters() = converters_;
3462 theConverters().update(lyx::formats);
3463 theConverters().buildGraph();
3464 theBufferList().invalidateConverterCache();
3466 theMovers() = movers_;
3468 vector<string>::const_iterator it = colors_.begin();
3469 vector<string>::const_iterator const end = colors_.end();
3470 for (; it != end; ++it)
3471 dispatch(FuncRequest(LFUN_SET_COLOR, *it));
3474 if (update_screen_font_) {
3475 dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
3476 // resets flag in case second apply in same dialog
3477 update_screen_font_ = false;
3480 if (update_previews_) {
3481 // resets flag in case second apply in same dialog
3482 theBufferList().updatePreviews();
3483 update_previews_ = false;
3486 // The Save button has been pressed
3488 dispatch(FuncRequest(LFUN_PREFERENCES_SAVE));
3492 void GuiPreferences::setColor(ColorCode col, QString const & hex)
3494 colors_.push_back(lcolor.getLyXName(col) + ' ' + fromqstr(hex));
3498 void GuiPreferences::updateScreenFonts()
3500 update_screen_font_ = true;
3504 void GuiPreferences::updatePreviews()
3506 update_previews_ = true;
3510 QString GuiPreferences::browsebind(QString const & file) const
3512 return browseLibFile("bind", file, "bind", qt_("Choose bind file"),
3513 QStringList(qt_("LyX bind files (*.bind)")));
3517 QString GuiPreferences::browseUI(QString const & file) const
3519 return browseLibFile("ui", file, "ui", qt_("Choose UI file"),
3520 QStringList(qt_("LyX UI files (*.ui)")));
3524 QString GuiPreferences::browsekbmap(QString const & file) const
3526 return browseLibFile("kbd", file, "kmap", qt_("Choose keyboard map"),
3527 QStringList(qt_("LyX keyboard maps (*.kmap)")));
3531 QString GuiPreferences::browse(QString const & file,
3532 QString const & title) const
3534 return browseFile(file, title, QStringList(), true);
3538 Dialog * createGuiPreferences(GuiView & lv) { return new GuiPreferences(lv); }
3541 } // namespace frontend
3544 #include "moc_GuiPrefs.cpp"