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"
30 using std::ostringstream;
34 using lyx::support::FileFilterList;
41 ControlPrefs::ControlPrefs(Dialog & parent)
42 : Dialog::Controller(parent),
43 update_screen_font_(false)
47 bool ControlPrefs::initialiseParams(std::string const &)
50 formats_ = lyx::formats;
51 converters_ = lyx::converters;
52 converters_.update(formats_);
53 movers_ = lyx::movers;
55 update_screen_font_ = false;
61 void ControlPrefs::dispatchParams()
65 kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
67 // FIXME: these need lfuns
68 theBufferList().setCurrentAuthor(rc_.user_name, rc_.user_email);
70 lyx::formats = formats_;
72 lyx::converters = converters_;
73 lyx::converters.update(lyx::formats);
74 lyx::converters.buildGraph();
76 lyx::movers = movers_;
78 vector<string>::const_iterator it = colors_.begin();
79 vector<string>::const_iterator const end = colors_.end();
80 for (; it != end; ++it)
81 kernel().dispatch(FuncRequest(LFUN_SET_COLOR, *it));
84 if (update_screen_font_) {
85 kernel().dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
86 update_screen_font_ = false;
89 // The Save button has been pressed
90 if (dialog().isClosing()) {
91 kernel().dispatch(FuncRequest(LFUN_PREFERENCES_SAVE));
96 void ControlPrefs::setColor(LColor_color col, string const & hex)
98 colors_.push_back(lcolor.getLyXName(col) + ' ' + hex);
102 void ControlPrefs::updateScreenFonts()
104 update_screen_font_ = true;
108 docstring const ControlPrefs::browsebind(docstring const & file) const
110 return browseLibFile(lyx::from_ascii("bind"), file, lyx::from_ascii("bind"),
111 _("Choose bind file"),
112 FileFilterList(_("LyX bind files (*.bind)")));
116 docstring const ControlPrefs::browseUI(docstring const & file) const
118 return browseLibFile(lyx::from_ascii("ui"), file, lyx::from_ascii("ui"),
120 FileFilterList(_("LyX UI files (*.ui)")));
124 docstring const ControlPrefs::browsekbmap(docstring const & file) const
126 return browseLibFile(lyx::from_ascii("kbd"), file, lyx::from_ascii("kmap"),
127 _("Choose keyboard map"),
128 FileFilterList(_("LyX keyboard maps (*.kmap)")));
132 docstring const ControlPrefs::browsedict(docstring const & file) const
134 return browseFile(file,
135 _("Choose personal dictionary"),
136 FileFilterList(_("*.ispell")));
140 docstring const ControlPrefs::browse(docstring const & file,
141 docstring const & title) const
143 return browseFile(file, title, FileFilterList(), true);
147 docstring const ControlPrefs::browsedir(docstring const & path,
148 docstring const & title) const
150 return browseDir(path, title);
154 // We support less paper sizes than the document dialog
155 // Therefore this adjustment is needed.
156 PAPER_SIZE const ControlPrefs::toPaperSize(int i) const
160 return PAPER_DEFAULT;
162 return PAPER_USLETTER;
164 return PAPER_USLEGAL;
166 return PAPER_USEXECUTIVE;
177 return PAPER_DEFAULT;
182 int const ControlPrefs::fromPaperSize(PAPER_SIZE papersize) const
191 case PAPER_USEXECUTIVE:
207 } // namespace frontend