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),
45 update_screen_font_(false)
49 bool ControlPrefs::initialiseParams(std::string const &)
53 converters_ = ::converters;
54 converters_.update(formats_);
57 update_screen_font_ = false;
63 void ControlPrefs::dispatchParams()
67 kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
69 // FIXME: these need lfuns
70 bufferlist.setCurrentAuthor(rc_.user_name, rc_.user_email);
74 ::converters = converters_;
75 ::converters.update(::formats);
76 ::converters.buildGraph();
80 vector<string>::const_iterator it = colors_.begin();
81 vector<string>::const_iterator const end = colors_.end();
82 for (; it != end; ++it)
83 kernel().dispatch(FuncRequest(LFUN_SET_COLOR, *it));
86 if (update_screen_font_) {
87 kernel().dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
88 update_screen_font_ = false;
91 // The Save button has been pressed
92 if (dialog().isClosing()) {
93 kernel().dispatch(FuncRequest(LFUN_PREFERENCES_SAVE));
98 void ControlPrefs::setColor(LColor_color col, string const & hex)
100 colors_.push_back(lcolor.getLyXName(col) + ' ' + hex);
104 void ControlPrefs::updateScreenFonts()
106 update_screen_font_ = true;
110 string const ControlPrefs::browsebind(string const & file) const
113 return browseLibFile("bind", file, "bind",
114 lyx::to_utf8(_("Choose bind file")),
115 FileFilterList(lyx::to_utf8(_("LyX bind files (*.bind)"))));
119 string const ControlPrefs::browseUI(string const & file) const
122 return browseLibFile("ui", file, "ui",
123 lyx::to_utf8(_("Choose UI file")),
124 FileFilterList(lyx::to_utf8(_("LyX UI files (*.ui)"))));
128 string const ControlPrefs::browsekbmap(string const & file) const
131 return browseLibFile("kbd", file, "kmap",
132 lyx::to_utf8(_("Choose keyboard map")),
133 FileFilterList(lyx::to_utf8(_("LyX keyboard maps (*.kmap)"))));
137 string const ControlPrefs::browsedict(string const & file) const
140 return browseFile(file,
141 lyx::to_utf8(_("Choose personal dictionary")),
142 FileFilterList(lyx::to_utf8(_("*.ispell"))));
146 string const ControlPrefs::browse(string const & file,
147 string const & title) const
149 return browseFile(file, title, FileFilterList(), true);
153 string const ControlPrefs::browsedir(string const & path,
154 string const & title) const
156 return browseDir(path, title);
160 // We support less paper sizes than the document dialog
161 // Therefore this adjustment is needed.
162 PAPER_SIZE const ControlPrefs::toPaperSize(int i) const
166 return PAPER_DEFAULT;
168 return PAPER_USLETTER;
170 return PAPER_USLEGAL;
172 return PAPER_USEXECUTIVE;
183 return PAPER_DEFAULT;
188 int const ControlPrefs::fromPaperSize(PAPER_SIZE papersize) const
197 case PAPER_USEXECUTIVE:
213 } // namespace frontend