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"
19 #include "funcrequest.h"
23 #include "frontends/Application.h"
25 #include "support/filefilterlist.h"
29 using std::ostringstream;
37 using support::FileFilterList;
42 ControlPrefs::ControlPrefs(Dialog & parent)
43 : Dialog::Controller(parent),
44 update_screen_font_(false)
48 bool ControlPrefs::initialiseParams(std::string const &)
52 converters_ = ::converters;
53 converters_.update(formats_);
56 update_screen_font_ = false;
62 void ControlPrefs::dispatchParams()
66 kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
68 // FIXME: these need lfuns
69 theApp->bufferList().setCurrentAuthor(rc_.user_name, rc_.user_email);
73 ::converters = converters_;
74 ::converters.update(::formats);
75 ::converters.buildGraph();
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 string const ControlPrefs::browsebind(string const & file) const
112 return browseLibFile("bind", file, "bind",
113 lyx::to_utf8(_("Choose bind file")),
114 FileFilterList(lyx::to_utf8(_("LyX bind files (*.bind)"))));
118 string const ControlPrefs::browseUI(string const & file) const
121 return browseLibFile("ui", file, "ui",
122 lyx::to_utf8(_("Choose UI file")),
123 FileFilterList(lyx::to_utf8(_("LyX UI files (*.ui)"))));
127 string const ControlPrefs::browsekbmap(string const & file) const
130 return browseLibFile("kbd", file, "kmap",
131 lyx::to_utf8(_("Choose keyboard map")),
132 FileFilterList(lyx::to_utf8(_("LyX keyboard maps (*.kmap)"))));
136 string const ControlPrefs::browsedict(string const & file) const
139 return browseFile(file,
140 lyx::to_utf8(_("Choose personal dictionary")),
141 FileFilterList(lyx::to_utf8(_("*.ispell"))));
145 string const ControlPrefs::browse(string const & file,
146 string const & title) const
148 return browseFile(file, title, FileFilterList(), true);
152 string const ControlPrefs::browsedir(string const & path,
153 string const & title) const
155 return browseDir(path, title);
159 // We support less paper sizes than the document dialog
160 // Therefore this adjustment is needed.
161 PAPER_SIZE const ControlPrefs::toPaperSize(int i) const
165 return PAPER_DEFAULT;
167 return PAPER_USLETTER;
169 return PAPER_USLEGAL;
171 return PAPER_USEXECUTIVE;
182 return PAPER_DEFAULT;
187 int const ControlPrefs::fromPaperSize(PAPER_SIZE papersize) const
196 case PAPER_USEXECUTIVE:
212 } // namespace frontend