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"
18 #include "BufferList.h"
20 #include "FuncRequest.h"
24 #include "support/FileFilterList.h"
28 using std::ostringstream;
32 using lyx::support::FileFilterList;
39 ControlPrefs::ControlPrefs(Dialog & parent)
40 : Dialog::Controller(parent),
41 update_screen_font_(false)
45 bool ControlPrefs::initialiseParams(std::string const &)
48 formats_ = lyx::formats;
49 converters_ = theConverters();
50 converters_.update(formats_);
51 movers_ = theMovers();
53 update_screen_font_ = false;
59 void ControlPrefs::dispatchParams()
63 kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
65 // FIXME: these need lfuns
67 theBufferList().setCurrentAuthor(from_utf8(rc_.user_name), from_utf8(rc_.user_email));
69 lyx::formats = formats_;
71 theConverters() = converters_;
72 theConverters().update(lyx::formats);
73 theConverters().buildGraph();
75 theMovers() = movers_;
77 vector<string>::const_iterator it = colors_.begin();
78 vector<string>::const_iterator const end = colors_.end();
79 for (; it != end; ++it)
80 kernel().dispatch(FuncRequest(LFUN_SET_COLOR, *it));
83 if (update_screen_font_) {
84 kernel().dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
85 update_screen_font_ = false;
88 // The Save button has been pressed
89 if (dialog().isClosing()) {
90 kernel().dispatch(FuncRequest(LFUN_PREFERENCES_SAVE));
95 void ControlPrefs::setColor(Color_color col, string const & hex)
97 colors_.push_back(lcolor.getLyXName(col) + ' ' + hex);
101 void ControlPrefs::updateScreenFonts()
103 update_screen_font_ = true;
107 docstring const ControlPrefs::browsebind(docstring const & file) const
109 return browseLibFile(from_ascii("bind"), file, from_ascii("bind"),
110 _("Choose bind file"),
111 FileFilterList(_("LyX bind files (*.bind)")));
115 docstring const ControlPrefs::browseUI(docstring const & file) const
117 return browseLibFile(from_ascii("ui"), file, from_ascii("ui"),
119 FileFilterList(_("LyX UI files (*.ui)")));
123 docstring const ControlPrefs::browsekbmap(docstring const & file) const
125 return browseLibFile(from_ascii("kbd"), file, from_ascii("kmap"),
126 _("Choose keyboard map"),
127 FileFilterList(_("LyX keyboard maps (*.kmap)")));
131 docstring const ControlPrefs::browsedict(docstring const & file) const
133 if (lyxrc.use_spell_lib)
134 return browseFile(file,
135 _("Choose personal dictionary"),
136 FileFilterList(_("*.pws")));
138 return browseFile(file,
139 _("Choose personal dictionary"),
140 FileFilterList(_("*.ispell")));
144 docstring const ControlPrefs::browse(docstring const & file,
145 docstring const & title) const
147 return browseFile(file, title, FileFilterList(), true);
151 docstring const ControlPrefs::browsedir(docstring const & path,
152 docstring const & title) const
154 return browseDir(path, title);
158 // We support less paper sizes than the document dialog
159 // Therefore this adjustment is needed.
160 PAPER_SIZE const ControlPrefs::toPaperSize(int i) const
164 return PAPER_DEFAULT;
166 return PAPER_USLETTER;
168 return PAPER_USLEGAL;
170 return PAPER_USEXECUTIVE;
181 return PAPER_DEFAULT;
186 int const ControlPrefs::fromPaperSize(PAPER_SIZE papersize) const
195 case PAPER_USEXECUTIVE:
211 } // namespace frontend