2 * \file ControlPrefs.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "ControlPrefs.h"
15 #include "frontend_helpers.h"
17 #include "BufferList.h"
19 #include "FuncRequest.h"
23 #include "support/FileFilterList.h"
27 using std::ostringstream;
31 using lyx::support::FileFilterList;
38 ControlPrefs::ControlPrefs(Dialog & parent)
40 update_screen_font_(false)
44 bool ControlPrefs::initialiseParams(std::string const &)
47 formats_ = lyx::formats;
48 converters_ = theConverters();
49 converters_.update(formats_);
50 movers_ = theMovers();
52 update_screen_font_ = false;
58 void ControlPrefs::dispatchParams()
62 dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
63 // FIXME: these need lfuns
65 theBufferList().setCurrentAuthor(from_utf8(rc_.user_name), from_utf8(rc_.user_email));
67 lyx::formats = formats_;
69 theConverters() = converters_;
70 theConverters().update(lyx::formats);
71 theConverters().buildGraph();
73 theMovers() = movers_;
75 vector<string>::const_iterator it = colors_.begin();
76 vector<string>::const_iterator const end = colors_.end();
77 for (; it != end; ++it)
78 dispatch(FuncRequest(LFUN_SET_COLOR, *it));
81 if (update_screen_font_) {
82 dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
83 update_screen_font_ = false;
86 // The Save button has been pressed
87 if (dialog().isClosing()) {
88 dispatch(FuncRequest(LFUN_PREFERENCES_SAVE));
93 void ControlPrefs::setColor(Color_color col, string const & hex)
95 colors_.push_back(lcolor.getLyXName(col) + ' ' + hex);
99 void ControlPrefs::updateScreenFonts()
101 update_screen_font_ = true;
105 docstring const ControlPrefs::browsebind(docstring const & file) const
107 return browseLibFile(from_ascii("bind"), file, from_ascii("bind"),
108 _("Choose bind file"),
109 FileFilterList(_("LyX bind files (*.bind)")));
113 docstring const ControlPrefs::browseUI(docstring const & file) const
115 return browseLibFile(from_ascii("ui"), file, from_ascii("ui"),
117 FileFilterList(_("LyX UI files (*.ui)")));
121 docstring const ControlPrefs::browsekbmap(docstring const & file) const
123 return browseLibFile(from_ascii("kbd"), file, from_ascii("kmap"),
124 _("Choose keyboard map"),
125 FileFilterList(_("LyX keyboard maps (*.kmap)")));
129 docstring const ControlPrefs::browsedict(docstring const & file) const
131 if (lyxrc.use_spell_lib)
132 return browseFile(file,
133 _("Choose personal dictionary"),
134 FileFilterList(_("*.pws")));
136 return browseFile(file,
137 _("Choose personal dictionary"),
138 FileFilterList(_("*.ispell")));
142 docstring const ControlPrefs::browse(docstring const & file,
143 docstring const & title) const
145 return browseFile(file, title, FileFilterList(), true);
149 docstring const ControlPrefs::browsedir(docstring const & path,
150 docstring const & title) const
152 return browseDir(path, title);
156 // We support less paper sizes than the document dialog
157 // Therefore this adjustment is needed.
158 PAPER_SIZE ControlPrefs::toPaperSize(int i) const
162 return PAPER_DEFAULT;
164 return PAPER_USLETTER;
166 return PAPER_USLEGAL;
168 return PAPER_USEXECUTIVE;
179 return PAPER_DEFAULT;
184 int ControlPrefs::fromPaperSize(PAPER_SIZE papersize) const
193 case PAPER_USEXECUTIVE:
209 } // namespace frontend