]> git.lyx.org Git - features.git/blob - src/frontends/controllers/ControlPrefs.C
Removed all redundant using directives from the source.
[features.git] / src / frontends / controllers / ControlPrefs.C
1 /**
2  * \file ControlPrefs.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "ControlPrefs.h"
14
15 #include "helper_funcs.h"
16 #include "ViewBase.h"
17
18 #include "bufferlist.h"
19 #include "converter.h"
20 #include "format.h"
21 #include "gettext.h"
22 #include "funcrequest.h"
23 #include "lfuns.h"
24
25 #include "frontends/Dialogs.h"
26 #include "frontends/LyXView.h"
27
28 #include "support/filetools.h"
29 #include "support/path_defines.h"
30
31 #include <utility>
32
33 using namespace lyx::support;
34
35 using std::pair;
36
37
38 extern BufferList bufferlist;
39
40 ControlPrefs::ControlPrefs(LyXView & lv, Dialogs & d)
41         : ControlDialogBI(lv, d)
42 {}
43
44
45 void ControlPrefs::setParams()
46 {
47         rc_ = lyxrc;
48 }
49
50
51 void ControlPrefs::apply()
52 {
53         view().apply();
54         lyxrc = rc_;
55
56         bufferlist.setCurrentAuthor(rc_.user_name, rc_.user_email);
57
58         // The Save button has been pressed
59         if (isClosing()) {
60                 lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
61         }
62 }
63
64
65 string const ControlPrefs::browsebind(string const & file)
66 {
67         string dir  = AddName(system_lyxdir(), "bind");
68         // FIXME: stupid name
69         string name = _("System Bind|#S#s");
70         pair<string,string> dir1(name, dir);
71
72         dir = AddName(user_lyxdir(), "bind");
73         // FIXME: stupid name
74         name = _("User Bind|#U#u");
75         pair<string,string> dir2(name, dir);
76
77         return browseFile(file, _("Choose bind file"), "*.bind", false, dir1, dir2);
78 }
79
80
81 string const ControlPrefs::browseUI(string const & file)
82 {
83         string dir  = AddName(system_lyxdir(), "ui");
84         // FIXME: stupid name
85         string name = _("Sys UI|#S#s");
86         pair<string,string> dir1(name, dir);
87
88         dir = AddName(user_lyxdir(), "ui");
89         // FIXME: stupid name
90         name = _("User UI|#U#u");
91         pair<string,string> dir2(name, dir);
92
93         return browseFile(file, _("Choose UI file"), "*.ui", false, dir1, dir2);
94 }
95
96
97 string const ControlPrefs::browsekbmap(string const & file)
98 {
99         string const dir = AddName(system_lyxdir(), "kbd");
100         string const name = _("Key maps|#K#k");
101         pair<string, string> dir1(name, dir);
102
103         return browseFile(file, _("Choose keyboard map"), "*.kmap", false, dir1);
104 }
105
106
107 string const ControlPrefs::browsedict(string const & file)
108 {
109         return browseFile(file, _("Choose personal dictionary"), "*.ispell");
110 }
111
112
113 string const ControlPrefs::browse(string const & file, string const & title)
114 {
115         return browseFile(file, title, "*", true);
116 }
117
118
119 string const ControlPrefs::browsedir(string const & path, string const & title)
120 {
121         return browseDir(path, title);
122 }
123
124
125 void ControlPrefs::redrawGUI()
126 {
127         // we must be sure to get the new values first
128         lyxrc = rc_;
129
130         lv_.getDialogs().redrawGUI();
131 }
132
133
134 void ControlPrefs::setColor(LColor::color col, string const & hex)
135 {
136         string const s = lcolor.getLyXName(col) + ' ' + hex;
137         lv_.dispatch(FuncRequest(LFUN_SET_COLOR, s));
138 }
139
140
141 void ControlPrefs::updateScreenFonts()
142 {
143         // we must be sure to get the new values first
144         lyxrc = rc_;
145
146         lv_.dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
147 }
148
149
150 void ControlPrefs::setConverters(Converters const & conv)
151 {
152         converters = conv;
153         converters.update(formats);
154         converters.buildGraph();
155 }
156
157
158 void ControlPrefs::setFormats(Formats const & form)
159 {
160         formats = form;
161 }