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_ = theConverters();
52 converters_.update(formats_);
53 movers_ = theMovers();
55 update_screen_font_ = false;
61 void ControlPrefs::dispatchParams()
65 kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
67 // FIXME: these need lfuns
69 theBufferList().setCurrentAuthor(from_utf8(rc_.user_name), from_utf8(rc_.user_email));
71 lyx::formats = formats_;
73 theConverters() = converters_;
74 theConverters().update(lyx::formats);
75 theConverters().buildGraph();
77 theMovers() = movers_;
79 vector<string>::const_iterator it = colors_.begin();
80 vector<string>::const_iterator const end = colors_.end();
81 for (; it != end; ++it)
82 kernel().dispatch(FuncRequest(LFUN_SET_COLOR, *it));
85 if (update_screen_font_) {
86 kernel().dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
87 update_screen_font_ = false;
90 // The Save button has been pressed
91 if (dialog().isClosing()) {
92 kernel().dispatch(FuncRequest(LFUN_PREFERENCES_SAVE));
97 void ControlPrefs::setColor(LColor_color col, string const & hex)
99 colors_.push_back(lcolor.getLyXName(col) + ' ' + hex);
103 void ControlPrefs::updateScreenFonts()
105 update_screen_font_ = true;
109 docstring const ControlPrefs::browsebind(docstring const & file) const
111 return browseLibFile(lyx::from_ascii("bind"), file, lyx::from_ascii("bind"),
112 _("Choose bind file"),
113 FileFilterList(_("LyX bind files (*.bind)")));
117 docstring const ControlPrefs::browseUI(docstring const & file) const
119 return browseLibFile(lyx::from_ascii("ui"), file, lyx::from_ascii("ui"),
121 FileFilterList(_("LyX UI files (*.ui)")));
125 docstring const ControlPrefs::browsekbmap(docstring const & file) const
127 return browseLibFile(lyx::from_ascii("kbd"), file, lyx::from_ascii("kmap"),
128 _("Choose keyboard map"),
129 FileFilterList(_("LyX keyboard maps (*.kmap)")));
133 docstring const ControlPrefs::browsedict(docstring const & file) const
135 if (lyxrc.use_spell_lib)
136 return browseFile(file,
137 _("Choose personal dictionary"),
138 FileFilterList(_("*.pws")));
140 return browseFile(file,
141 _("Choose personal dictionary"),
142 FileFilterList(_("*.ispell")));
146 docstring const ControlPrefs::browse(docstring const & file,
147 docstring const & title) const
149 return browseFile(file, title, FileFilterList(), true);
153 docstring const ControlPrefs::browsedir(docstring const & path,
154 docstring 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