X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fcontrollers%2FControlPrefs.C;h=7addfccd0616d1ed5f76ec21c8c8a96ddcb7f748;hb=76bac515268e2830054c5dd9796e3d4c3a6d0584;hp=12f6b7e07fcbef013ab929bea86810baa8aa01b9;hpb=9f4d9b92b9cf6225375fc1ce57541458746d968c;p=lyx.git diff --git a/src/frontends/controllers/ControlPrefs.C b/src/frontends/controllers/ControlPrefs.C index 12f6b7e07f..7addfccd06 100644 --- a/src/frontends/controllers/ControlPrefs.C +++ b/src/frontends/controllers/ControlPrefs.C @@ -18,30 +18,28 @@ #include "bufferlist.h" #include "gettext.h" #include "funcrequest.h" +#include "paper.h" #include "LColor.h" -#include "support/filetools.h" -#include "support/globbing.h" -#include "support/path_defines.h" +#include "support/filefilterlist.h" -#include "support/std_sstream.h" +#include -using lyx::support::AddName; -using lyx::support::FileFilterList; -using lyx::support::system_lyxdir; -using lyx::support::user_lyxdir; +using lyx::docstring; using std::ostringstream; using std::pair; using std::string; using std::vector; +using lyx::support::FileFilterList; + +namespace lyx { +namespace frontend { -extern BufferList bufferlist; ControlPrefs::ControlPrefs(Dialog & parent) : Dialog::Controller(parent), - redraw_gui_(false), update_screen_font_(false) {} @@ -49,11 +47,11 @@ ControlPrefs::ControlPrefs(Dialog & parent) bool ControlPrefs::initialiseParams(std::string const &) { rc_ = lyxrc; - formats_ = ::formats; - converters_ = ::converters; + formats_ = lyx::formats; + converters_ = theConverters(); converters_.update(formats_); + movers_ = theMovers(); colors_.clear(); - redraw_gui_ = false; update_screen_font_ = false; return true; @@ -67,13 +65,16 @@ void ControlPrefs::dispatchParams() kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str())); // FIXME: these need lfuns - bufferlist.setCurrentAuthor(rc_.user_name, rc_.user_email); + // FIXME UNICODE + theBufferList().setCurrentAuthor(from_utf8(rc_.user_name), from_utf8(rc_.user_email)); - ::formats = formats_; + lyx::formats = formats_; - ::converters = converters_; - ::converters.update(::formats); - ::converters.buildGraph(); + theConverters() = converters_; + theConverters().update(lyx::formats); + theConverters().buildGraph(); + + theMovers() = movers_; vector::const_iterator it = colors_.begin(); vector::const_iterator const end = colors_.end(); @@ -81,11 +82,6 @@ void ControlPrefs::dispatchParams() kernel().dispatch(FuncRequest(LFUN_SET_COLOR, *it)); colors_.clear(); - if (redraw_gui_) { - kernel().redrawGUI(); - redraw_gui_ = false; - } - if (update_screen_font_) { kernel().dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE)); update_screen_font_ = false; @@ -93,17 +89,11 @@ void ControlPrefs::dispatchParams() // The Save button has been pressed if (dialog().isClosing()) { - kernel().dispatch(FuncRequest(LFUN_SAVEPREFERENCES)); + kernel().dispatch(FuncRequest(LFUN_PREFERENCES_SAVE)); } } -void ControlPrefs::redrawGUI() -{ - redraw_gui_ = true; -} - - void ControlPrefs::setColor(LColor_color col, string const & hex) { colors_.push_back(lcolor.getLyXName(col) + ' ' + hex); @@ -116,58 +106,109 @@ void ControlPrefs::updateScreenFonts() } -string const ControlPrefs::browsebind(string const & file) const +docstring const ControlPrefs::browsebind(docstring const & file) const { - pair dir1(_("System Bind|#S#s"), - AddName(system_lyxdir(), "bind")); + return browseLibFile(lyx::from_ascii("bind"), file, lyx::from_ascii("bind"), + _("Choose bind file"), + FileFilterList(_("LyX bind files (*.bind)"))); +} - pair dir2(_("User Bind|#U#u"), - AddName(user_lyxdir(), "bind")); - return browseFile(file, _("Choose bind file"), - FileFilterList("*.bind"), false, dir1, dir2); +docstring const ControlPrefs::browseUI(docstring const & file) const +{ + return browseLibFile(lyx::from_ascii("ui"), file, lyx::from_ascii("ui"), + _("Choose UI file"), + FileFilterList(_("LyX UI files (*.ui)"))); } -string const ControlPrefs::browseUI(string const & file) const +docstring const ControlPrefs::browsekbmap(docstring const & file) const { - pair const dir1(_("Sys UI|#S#s"), - AddName(system_lyxdir(), "ui")); + return browseLibFile(lyx::from_ascii("kbd"), file, lyx::from_ascii("kmap"), + _("Choose keyboard map"), + FileFilterList(_("LyX keyboard maps (*.kmap)"))); +} - pair const dir2(_("User UI|#U#u"), - AddName(user_lyxdir(), "ui")); - return browseFile(file, _("Choose UI file"), - FileFilterList("*.ui"), false, dir1, dir2); +docstring const ControlPrefs::browsedict(docstring const & file) const +{ + if (lyxrc.use_spell_lib) + return browseFile(file, + _("Choose personal dictionary"), + FileFilterList(_("*.pws"))); + else + return browseFile(file, + _("Choose personal dictionary"), + FileFilterList(_("*.ispell"))); } -string const ControlPrefs::browsekbmap(string const & file) const +docstring const ControlPrefs::browse(docstring const & file, + docstring const & title) const { - pair dir(_("Key maps|#K#k"), - AddName(system_lyxdir(), "kbd")); - - return browseFile(file, _("Choose keyboard map"), - FileFilterList("*.kmap"), false, dir); + return browseFile(file, title, FileFilterList(), true); } -string const ControlPrefs::browsedict(string const & file) const +docstring const ControlPrefs::browsedir(docstring const & path, + docstring const & title) const { - return browseFile(file, _("Choose personal dictionary"), - FileFilterList("*.ispell")); + return browseDir(path, title); } -string const ControlPrefs::browse(string const & file, - string const & title) const +// We support less paper sizes than the document dialog +// Therefore this adjustment is needed. +PAPER_SIZE const ControlPrefs::toPaperSize(int i) const { - return browseFile(file, title, FileFilterList(), true); + switch (i) { + case 0: + return PAPER_DEFAULT; + case 1: + return PAPER_USLETTER; + case 2: + return PAPER_USLEGAL; + case 3: + return PAPER_USEXECUTIVE; + case 4: + return PAPER_A3; + case 5: + return PAPER_A4; + case 6: + return PAPER_A5; + case 7: + return PAPER_B5; + default: + // should not happen + return PAPER_DEFAULT; + } } -string const ControlPrefs::browsedir(string const & path, - string const & title) const +int const ControlPrefs::fromPaperSize(PAPER_SIZE papersize) const { - return browseDir(path, title); + switch (papersize) { + case PAPER_DEFAULT: + return 0; + case PAPER_USLETTER: + return 1; + case PAPER_USLEGAL: + return 2; + case PAPER_USEXECUTIVE: + return 3; + case PAPER_A3: + return 4; + case PAPER_A4: + return 5; + case PAPER_A5: + return 6; + case PAPER_B5: + return 7; + default: + // should not happen + return 0; + } } + +} // namespace frontend +} // namespace lyx