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 "helper_funcs.h"
18 #include "bufferlist.h"
20 #include "funcrequest.h"
24 #include "support/filefilterlist.h"
28 using std::ostringstream;
34 extern BufferList bufferlist;
38 using support::FileFilterList;
43 ControlPrefs::ControlPrefs(Dialog & parent)
44 : Dialog::Controller(parent),
46 update_screen_font_(false)
50 bool ControlPrefs::initialiseParams(std::string const &)
54 converters_ = ::converters;
55 converters_.update(formats_);
59 update_screen_font_ = false;
65 void ControlPrefs::dispatchParams()
69 kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
71 // FIXME: these need lfuns
72 bufferlist.setCurrentAuthor(rc_.user_name, rc_.user_email);
76 ::converters = converters_;
77 ::converters.update(::formats);
78 ::converters.buildGraph();
82 vector<string>::const_iterator it = colors_.begin();
83 vector<string>::const_iterator const end = colors_.end();
84 for (; it != end; ++it)
85 kernel().dispatch(FuncRequest(LFUN_SET_COLOR, *it));
93 if (update_screen_font_) {
94 kernel().dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
95 update_screen_font_ = false;
98 // The Save button has been pressed
99 if (dialog().isClosing()) {
100 kernel().dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
105 void ControlPrefs::redrawGUI()
111 void ControlPrefs::setColor(LColor_color col, string const & hex)
113 colors_.push_back(lcolor.getLyXName(col) + ' ' + hex);
117 void ControlPrefs::updateScreenFonts()
119 update_screen_font_ = true;
123 string const ControlPrefs::browsebind(string const & file) const
125 return browseLibFile("bind", file, "bind", _("Choose bind file"),
126 FileFilterList(_("LyX bind files (*.bind)")));
130 string const ControlPrefs::browseUI(string const & file) const
132 return browseLibFile("ui", file, "ui", _("Choose UI file"),
133 FileFilterList(_("LyX UI files (*.ui)")));
137 string const ControlPrefs::browsekbmap(string const & file) const
139 return browseLibFile("kbd", file, "kmap", _("Choose keyboard map"),
140 FileFilterList(_("LyX keyboard maps (*.kmap)")));
144 string const ControlPrefs::browsedict(string const & file) const
146 return browseFile(file, _("Choose personal dictionary"),
147 FileFilterList(_("*.ispell")));
151 string const ControlPrefs::browse(string const & file,
152 string const & title) const
154 return browseFile(file, title, FileFilterList(), true);
158 string const ControlPrefs::browsedir(string const & path,
159 string const & title) const
161 return browseDir(path, title);
165 // We support less paper sizes than the document dialog
166 // Therefore this adjustment is needed.
167 PAPER_SIZE const ControlPrefs::toPaperSize(int i) const
171 return PAPER_DEFAULT;
173 return PAPER_USLETTER;
175 return PAPER_USLEGAL;
177 return PAPER_USEXECUTIVE;
188 return PAPER_DEFAULT;
193 int const ControlPrefs::fromPaperSize(PAPER_SIZE papersize) const
202 case PAPER_USEXECUTIVE:
218 } // namespace frontend