author | mickeyl <mickeyl> | 2004-06-22 10:36:46 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-06-22 10:36:46 (UTC) |
commit | 9c471976e750812f0af3b443964954d4b5a5ed20 (patch) (unidiff) | |
tree | c049d0b1b419a4b76aaea02d063484b4e3f1fc4e | |
parent | 9cff98cb70d8e3a69cefe718bf02720134c10bca (diff) | |
download | opie-9c471976e750812f0af3b443964954d4b5a5ed20.zip opie-9c471976e750812f0af3b443964954d4b5a5ed20.tar.gz opie-9c471976e750812f0af3b443964954d4b5a5ed20.tar.bz2 |
use stderr as default odebug output destination as pointed out by Brad
-rw-r--r-- | libopie2/opiecore/oglobalsettings.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libopie2/opiecore/oglobalsettings.cpp b/libopie2/opiecore/oglobalsettings.cpp index f34c531..89c77d7 100644 --- a/libopie2/opiecore/oglobalsettings.cpp +++ b/libopie2/opiecore/oglobalsettings.cpp | |||
@@ -1,546 +1,547 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | Inspired by the KDE globalsettings which are | 5 | Inspired by the KDE globalsettings which are |
6 | Copyright (C) 2000 David Faure <faure@kde.org> | 6 | Copyright (C) 2000 David Faure <faure@kde.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | 34 | ||
35 | #include <opie2/oglobalsettings.h> | 35 | #include <opie2/oglobalsettings.h> |
36 | #include <opie2/oconfig.h> | 36 | #include <opie2/oconfig.h> |
37 | #include <opie2/odebug.h> | ||
37 | #include <opie2/oglobal.h> | 38 | #include <opie2/oglobal.h> |
38 | 39 | ||
39 | /* QT */ | 40 | /* QT */ |
40 | 41 | ||
41 | #include <qdir.h> | 42 | #include <qdir.h> |
42 | 43 | ||
43 | /* UNIX */ | 44 | /* UNIX */ |
44 | 45 | ||
45 | #include <stdlib.h> | 46 | #include <stdlib.h> |
46 | 47 | ||
47 | 48 | ||
48 | using namespace Opie::Core; | 49 | using namespace Opie::Core; |
49 | 50 | ||
50 | QString* OGlobalSettings::s_desktopPath = 0; | 51 | QString* OGlobalSettings::s_desktopPath = 0; |
51 | QString* OGlobalSettings::s_autostartPath = 0; | 52 | QString* OGlobalSettings::s_autostartPath = 0; |
52 | QString* OGlobalSettings::s_trashPath = 0; | 53 | QString* OGlobalSettings::s_trashPath = 0; |
53 | QString* OGlobalSettings::s_documentPath = 0; | 54 | QString* OGlobalSettings::s_documentPath = 0; |
54 | QFont *OGlobalSettings::_generalFont = 0; | 55 | QFont *OGlobalSettings::_generalFont = 0; |
55 | QFont *OGlobalSettings::_fixedFont = 0; | 56 | QFont *OGlobalSettings::_fixedFont = 0; |
56 | QFont *OGlobalSettings::_toolBarFont = 0; | 57 | QFont *OGlobalSettings::_toolBarFont = 0; |
57 | QFont *OGlobalSettings::_menuFont = 0; | 58 | QFont *OGlobalSettings::_menuFont = 0; |
58 | QFont *OGlobalSettings::_windowTitleFont = 0; | 59 | QFont *OGlobalSettings::_windowTitleFont = 0; |
59 | QFont *OGlobalSettings::_taskbarFont = 0; | 60 | QFont *OGlobalSettings::_taskbarFont = 0; |
60 | 61 | ||
61 | QColor *OGlobalSettings::OpieGray = 0; | 62 | QColor *OGlobalSettings::OpieGray = 0; |
62 | QColor *OGlobalSettings::OpieHighlight = 0; | 63 | QColor *OGlobalSettings::OpieHighlight = 0; |
63 | QColor *OGlobalSettings::OpieAlternate = 0; | 64 | QColor *OGlobalSettings::OpieAlternate = 0; |
64 | 65 | ||
65 | OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0; | 66 | OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0; |
66 | 67 | ||
67 | //FIXME: Add manipulators to the accessors | 68 | //FIXME: Add manipulators to the accessors |
68 | 69 | ||
69 | int OGlobalSettings::dndEventDelay() | 70 | int OGlobalSettings::dndEventDelay() |
70 | { | 71 | { |
71 | OConfig *c = OGlobal::config(); | 72 | OConfig *c = OGlobal::config(); |
72 | OConfigGroupSaver cgs( c, "General" ); | 73 | OConfigGroupSaver cgs( c, "General" ); |
73 | return c->readNumEntry("DndDelay", 2); | 74 | return c->readNumEntry("DndDelay", 2); |
74 | } | 75 | } |
75 | 76 | ||
76 | bool OGlobalSettings::singleClick() | 77 | bool OGlobalSettings::singleClick() |
77 | { | 78 | { |
78 | OConfig *c = OGlobal::config(); | 79 | OConfig *c = OGlobal::config(); |
79 | OConfigGroupSaver cgs( c, "OPIE" ); | 80 | OConfigGroupSaver cgs( c, "OPIE" ); |
80 | return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK); | 81 | return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK); |
81 | } | 82 | } |
82 | 83 | ||
83 | bool OGlobalSettings::insertTearOffHandle() | 84 | bool OGlobalSettings::insertTearOffHandle() |
84 | { | 85 | { |
85 | OConfig *c = OGlobal::config(); | 86 | OConfig *c = OGlobal::config(); |
86 | OConfigGroupSaver cgs( c, "OPIE" ); | 87 | OConfigGroupSaver cgs( c, "OPIE" ); |
87 | return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES); | 88 | return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES); |
88 | } | 89 | } |
89 | 90 | ||
90 | bool OGlobalSettings::changeCursorOverIcon() | 91 | bool OGlobalSettings::changeCursorOverIcon() |
91 | { | 92 | { |
92 | OConfig *c = OGlobal::config(); | 93 | OConfig *c = OGlobal::config(); |
93 | OConfigGroupSaver cgs( c, "OPIE" ); | 94 | OConfigGroupSaver cgs( c, "OPIE" ); |
94 | return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR); | 95 | return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR); |
95 | } | 96 | } |
96 | 97 | ||
97 | bool OGlobalSettings::visualActivate() | 98 | bool OGlobalSettings::visualActivate() |
98 | { | 99 | { |
99 | OConfig *c = OGlobal::config(); | 100 | OConfig *c = OGlobal::config(); |
100 | OConfigGroupSaver cgs( c, "OPIE" ); | 101 | OConfigGroupSaver cgs( c, "OPIE" ); |
101 | return c->readBoolEntry("VisualActivate", OPIE_DEFAULT_VISUAL_ACTIVATE); | 102 | return c->readBoolEntry("VisualActivate", OPIE_DEFAULT_VISUAL_ACTIVATE); |
102 | } | 103 | } |
103 | 104 | ||
104 | unsigned int OGlobalSettings::visualActivateSpeed() | 105 | unsigned int OGlobalSettings::visualActivateSpeed() |
105 | { | 106 | { |
106 | OConfig *c = OGlobal::config(); | 107 | OConfig *c = OGlobal::config(); |
107 | OConfigGroupSaver cgs( c, "OPIE" ); | 108 | OConfigGroupSaver cgs( c, "OPIE" ); |
108 | return | 109 | return |
109 | c->readNumEntry( | 110 | c->readNumEntry( |
110 | "VisualActivateSpeed", | 111 | "VisualActivateSpeed", |
111 | OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED | 112 | OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED |
112 | ); | 113 | ); |
113 | } | 114 | } |
114 | 115 | ||
115 | int OGlobalSettings::autoSelectDelay() | 116 | int OGlobalSettings::autoSelectDelay() |
116 | { | 117 | { |
117 | OConfig *c = OGlobal::config(); | 118 | OConfig *c = OGlobal::config(); |
118 | OConfigGroupSaver cgs( c, "OPIE" ); | 119 | OConfigGroupSaver cgs( c, "OPIE" ); |
119 | return c->readNumEntry("AutoSelectDelay", OPIE_DEFAULT_AUTOSELECTDELAY); | 120 | return c->readNumEntry("AutoSelectDelay", OPIE_DEFAULT_AUTOSELECTDELAY); |
120 | } | 121 | } |
121 | 122 | ||
122 | OGlobalSettings::Completion OGlobalSettings::completionMode() | 123 | OGlobalSettings::Completion OGlobalSettings::completionMode() |
123 | { | 124 | { |
124 | int completion; | 125 | int completion; |
125 | OConfig *c = OGlobal::config(); | 126 | OConfig *c = OGlobal::config(); |
126 | OConfigGroupSaver cgs( c, "General" ); | 127 | OConfigGroupSaver cgs( c, "General" ); |
127 | completion = c->readNumEntry("completionMode", -1); | 128 | completion = c->readNumEntry("completionMode", -1); |
128 | if ((completion < (int) CompletionNone) || | 129 | if ((completion < (int) CompletionNone) || |
129 | (completion > (int) CompletionPopupAuto)) | 130 | (completion > (int) CompletionPopupAuto)) |
130 | { | 131 | { |
131 | completion = (int) CompletionPopup; // Default | 132 | completion = (int) CompletionPopup; // Default |
132 | } | 133 | } |
133 | return (Completion) completion; | 134 | return (Completion) completion; |
134 | } | 135 | } |
135 | 136 | ||
136 | 137 | ||
137 | bool OGlobalSettings::showContextMenusOnPress () | 138 | bool OGlobalSettings::showContextMenusOnPress () |
138 | { | 139 | { |
139 | OConfig *c = OGlobal::config(); | 140 | OConfig *c = OGlobal::config(); |
140 | OConfigGroupSaver cgs (c, "ContextMenus"); | 141 | OConfigGroupSaver cgs (c, "ContextMenus"); |
141 | 142 | ||
142 | return cgs.config()->readBoolEntry("ShowOnPress", true); | 143 | return cgs.config()->readBoolEntry("ShowOnPress", true); |
143 | } | 144 | } |
144 | 145 | ||
145 | 146 | ||
146 | int OGlobalSettings::contextMenuKey () | 147 | int OGlobalSettings::contextMenuKey () |
147 | { | 148 | { |
148 | OConfig *c = OGlobal::config(); | 149 | OConfig *c = OGlobal::config(); |
149 | OConfigGroupSaver cgs (c, "Shortcuts"); | 150 | OConfigGroupSaver cgs (c, "Shortcuts"); |
150 | 151 | ||
151 | //OShortcut cut (cgs.config()->readEntry ("PopupMenuContext", "Menu")); | 152 | //OShortcut cut (cgs.config()->readEntry ("PopupMenuContext", "Menu")); |
152 | //return cut.keyCodeQt(); | 153 | //return cut.keyCodeQt(); |
153 | 154 | ||
154 | return 0; // FIXME | 155 | return 0; // FIXME |
155 | } | 156 | } |
156 | 157 | ||
157 | 158 | ||
158 | OGlobalSettings::Debug OGlobalSettings::debugMode() | 159 | OGlobalSettings::Debug OGlobalSettings::debugMode() |
159 | { | 160 | { |
160 | OConfig *c = OGlobal::config(); | 161 | OConfig *c = OGlobal::config(); |
161 | OConfigGroupSaver cgs( c, "General" ); | 162 | OConfigGroupSaver cgs( c, "General" ); |
162 | int debug = c->readNumEntry( "debugMode", -1 ); | 163 | int debug = c->readNumEntry( "debugMode", ODEBUG_STDERR ); |
163 | if ( (debug < (int) DebugNone) || (debug > (int) DebugSocket) ) | 164 | if ( (debug < (int) DebugNone) || (debug > (int) DebugSocket) ) |
164 | { | 165 | { |
165 | debug = (int) DebugStdErr; // Default | 166 | debug = (int) DebugStdErr; // Default |
166 | } | 167 | } |
167 | return (Debug) debug; | 168 | return (Debug) debug; |
168 | } | 169 | } |
169 | 170 | ||
170 | 171 | ||
171 | QString OGlobalSettings::debugOutput() | 172 | QString OGlobalSettings::debugOutput() |
172 | { | 173 | { |
173 | OConfig *c = OGlobal::config(); | 174 | OConfig *c = OGlobal::config(); |
174 | OConfigGroupSaver cgs( c, "General" ); | 175 | OConfigGroupSaver cgs( c, "General" ); |
175 | QString deflt = QString::null; | 176 | QString deflt = QString::null; |
176 | switch( debugMode() ) | 177 | switch( debugMode() ) |
177 | { | 178 | { |
178 | case DebugNone: break; // no additional information needed | 179 | case DebugNone: break; // no additional information needed |
179 | case DebugFiles: deflt = "/var/log/opiedebug.log"; break; // file to save output in | 180 | case DebugFiles: deflt = "/var/log/opiedebug.log"; break; // file to save output in |
180 | case DebugMsgBox: break; // no additional information needed | 181 | case DebugMsgBox: break; // no additional information needed |
181 | case DebugStdErr: break; // no additional information needed | 182 | case DebugStdErr: break; // no additional information needed |
182 | case DebugSysLog: break; // no additional information needed | 183 | case DebugSysLog: break; // no additional information needed |
183 | case DebugSocket: deflt = "127.0.0.1:8913"; break; // address to send packets to | 184 | case DebugSocket: deflt = "127.0.0.1:8913"; break; // address to send packets to |
184 | } | 185 | } |
185 | 186 | ||
186 | return c->readEntry( "debugOutput"+ QString::number(debugMode()), deflt ); | 187 | return c->readEntry( "debugOutput"+ QString::number(debugMode()), deflt ); |
187 | } | 188 | } |
188 | 189 | ||
189 | 190 | ||
190 | QColor OGlobalSettings::toolBarHighlightColor() | 191 | QColor OGlobalSettings::toolBarHighlightColor() |
191 | { | 192 | { |
192 | initColors(); | 193 | initColors(); |
193 | OConfig *c = OGlobal::config(); | 194 | OConfig *c = OGlobal::config(); |
194 | OConfigGroupSaver cgs( c, QString::fromLatin1("Toolbar style") ); | 195 | OConfigGroupSaver cgs( c, QString::fromLatin1("Toolbar style") ); |
195 | return c->readColorEntry("HighlightColor", OpieHighlight); | 196 | return c->readColorEntry("HighlightColor", OpieHighlight); |
196 | } | 197 | } |
197 | 198 | ||
198 | QColor OGlobalSettings::inactiveTitleColor() | 199 | QColor OGlobalSettings::inactiveTitleColor() |
199 | { | 200 | { |
200 | if (!OpieGray) OpieGray = new QColor(220, 220, 220); | 201 | if (!OpieGray) OpieGray = new QColor(220, 220, 220); |
201 | OConfig *c = OGlobal::config(); | 202 | OConfig *c = OGlobal::config(); |
202 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); | 203 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); |
203 | return c->readColorEntry( "inactiveBackground", OpieGray ); | 204 | return c->readColorEntry( "inactiveBackground", OpieGray ); |
204 | } | 205 | } |
205 | 206 | ||
206 | QColor OGlobalSettings::inactiveTextColor() | 207 | QColor OGlobalSettings::inactiveTextColor() |
207 | { | 208 | { |
208 | OConfig *c = OGlobal::config(); | 209 | OConfig *c = OGlobal::config(); |
209 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); | 210 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); |
210 | return c->readColorEntry( "inactiveForeground", &Qt::darkGray ); | 211 | return c->readColorEntry( "inactiveForeground", &Qt::darkGray ); |
211 | } | 212 | } |
212 | 213 | ||
213 | QColor OGlobalSettings::activeTitleColor() | 214 | QColor OGlobalSettings::activeTitleColor() |
214 | { | 215 | { |
215 | initColors(); | 216 | initColors(); |
216 | OConfig *c = OGlobal::config(); | 217 | OConfig *c = OGlobal::config(); |
217 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); | 218 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); |
218 | return c->readColorEntry( "activeBackground", OpieHighlight); | 219 | return c->readColorEntry( "activeBackground", OpieHighlight); |
219 | } | 220 | } |
220 | 221 | ||
221 | QColor OGlobalSettings::activeTextColor() | 222 | QColor OGlobalSettings::activeTextColor() |
222 | { | 223 | { |
223 | OConfig *c = OGlobal::config(); | 224 | OConfig *c = OGlobal::config(); |
224 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); | 225 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); |
225 | return c->readColorEntry( "activeForeground", &Qt::white ); | 226 | return c->readColorEntry( "activeForeground", &Qt::white ); |
226 | } | 227 | } |
227 | 228 | ||
228 | int OGlobalSettings::contrast() | 229 | int OGlobalSettings::contrast() |
229 | { | 230 | { |
230 | OConfig *c = OGlobal::config(); | 231 | OConfig *c = OGlobal::config(); |
231 | OConfigGroupSaver cgs( c, QString::fromLatin1("OPIE") ); | 232 | OConfigGroupSaver cgs( c, QString::fromLatin1("OPIE") ); |
232 | return c->readNumEntry( "contrast", 7 ); | 233 | return c->readNumEntry( "contrast", 7 ); |
233 | } | 234 | } |
234 | 235 | ||
235 | // following functions should work in OPIE - how to sync with appearance changes? | 236 | // following functions should work in OPIE - how to sync with appearance changes? |
236 | 237 | ||
237 | QColor OGlobalSettings::baseColor() | 238 | QColor OGlobalSettings::baseColor() |
238 | { | 239 | { |
239 | OConfig *c = OGlobal::config(); | 240 | OConfig *c = OGlobal::config(); |
240 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); | 241 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); |
241 | return c->readColorEntry( "Base", &Qt::white ); | 242 | return c->readColorEntry( "Base", &Qt::white ); |
242 | } | 243 | } |
243 | 244 | ||
244 | QColor OGlobalSettings::textColor() | 245 | QColor OGlobalSettings::textColor() |
245 | { | 246 | { |
246 | OConfig *c = OGlobal::config(); | 247 | OConfig *c = OGlobal::config(); |
247 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); | 248 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); |
248 | return c->readColorEntry( "Text", &Qt::black ); | 249 | return c->readColorEntry( "Text", &Qt::black ); |
249 | } | 250 | } |
250 | 251 | ||
251 | QColor OGlobalSettings::highlightedTextColor() | 252 | QColor OGlobalSettings::highlightedTextColor() |
252 | { | 253 | { |
253 | OConfig *c = OGlobal::config(); | 254 | OConfig *c = OGlobal::config(); |
254 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); | 255 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); |
255 | return c->readColorEntry( "HighlightedText", &Qt::white ); | 256 | return c->readColorEntry( "HighlightedText", &Qt::white ); |
256 | } | 257 | } |
257 | 258 | ||
258 | QColor OGlobalSettings::highlightColor() | 259 | QColor OGlobalSettings::highlightColor() |
259 | { | 260 | { |
260 | initColors(); | 261 | initColors(); |
261 | OConfig *c = OGlobal::config(); | 262 | OConfig *c = OGlobal::config(); |
262 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); | 263 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); |
263 | return c->readColorEntry( "Highlight", OpieHighlight ); | 264 | return c->readColorEntry( "Highlight", OpieHighlight ); |
264 | } | 265 | } |
265 | 266 | ||
266 | QColor OGlobalSettings::alternateBackgroundColor() | 267 | QColor OGlobalSettings::alternateBackgroundColor() |
267 | { | 268 | { |
268 | initColors(); | 269 | initColors(); |
269 | OConfig *c = OGlobal::config(); | 270 | OConfig *c = OGlobal::config(); |
270 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); | 271 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); |
271 | *OpieAlternate = calculateAlternateBackgroundColor( baseColor() ); | 272 | *OpieAlternate = calculateAlternateBackgroundColor( baseColor() ); |
272 | return c->readColorEntry( "alternateBackground", OpieAlternate ); | 273 | return c->readColorEntry( "alternateBackground", OpieAlternate ); |
273 | } | 274 | } |
274 | 275 | ||
275 | QColor OGlobalSettings::calculateAlternateBackgroundColor(const QColor& base) | 276 | QColor OGlobalSettings::calculateAlternateBackgroundColor(const QColor& base) |
276 | { | 277 | { |
277 | if (base == Qt::white) | 278 | if (base == Qt::white) |
278 | return QColor(238,246,255); | 279 | return QColor(238,246,255); |
279 | else | 280 | else |
280 | { | 281 | { |
281 | int h, s, v; | 282 | int h, s, v; |
282 | base.hsv( &h, &s, &v ); | 283 | base.hsv( &h, &s, &v ); |
283 | if (v > 128) | 284 | if (v > 128) |
284 | return base.dark(106); | 285 | return base.dark(106); |
285 | else if (base != Qt::black) | 286 | else if (base != Qt::black) |
286 | return base.light(110); | 287 | return base.light(110); |
287 | 288 | ||
288 | return QColor(32,32,32); | 289 | return QColor(32,32,32); |
289 | } | 290 | } |
290 | } | 291 | } |
291 | 292 | ||
292 | QColor OGlobalSettings::linkColor() | 293 | QColor OGlobalSettings::linkColor() |
293 | { | 294 | { |
294 | initColors(); | 295 | initColors(); |
295 | OConfig *c = OGlobal::config(); | 296 | OConfig *c = OGlobal::config(); |
296 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); | 297 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); |
297 | return c->readColorEntry( "linkColor", OpieGray ); | 298 | return c->readColorEntry( "linkColor", OpieGray ); |
298 | } | 299 | } |
299 | 300 | ||
300 | QColor OGlobalSettings::visitedLinkColor() | 301 | QColor OGlobalSettings::visitedLinkColor() |
301 | { | 302 | { |
302 | OConfig *c = OGlobal::config(); | 303 | OConfig *c = OGlobal::config(); |
303 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); | 304 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); |
304 | return c->readColorEntry( "visitedLinkColor", &Qt::magenta ); | 305 | return c->readColorEntry( "visitedLinkColor", &Qt::magenta ); |
305 | } | 306 | } |
306 | 307 | ||
307 | // FIXME: font stuff currently uses a different format in OPIE, so the | 308 | // FIXME: font stuff currently uses a different format in OPIE, so the |
308 | // functions below are not yet applicable. The whole font stuff for OPIE | 309 | // functions below are not yet applicable. The whole font stuff for OPIE |
309 | // has to be revised anyway | 310 | // has to be revised anyway |
310 | 311 | ||
311 | QFont OGlobalSettings::generalFont() | 312 | QFont OGlobalSettings::generalFont() |
312 | { | 313 | { |
313 | if (_generalFont) | 314 | if (_generalFont) |
314 | return *_generalFont; | 315 | return *_generalFont; |
315 | 316 | ||
316 | _generalFont = new QFont("helvetica", 10); | 317 | _generalFont = new QFont("helvetica", 10); |
317 | _generalFont->setPixelSize(10); | 318 | _generalFont->setPixelSize(10); |
318 | _generalFont->setStyleHint(QFont::SansSerif); | 319 | _generalFont->setStyleHint(QFont::SansSerif); |
319 | 320 | ||
320 | OConfig *c = OGlobal::config(); | 321 | OConfig *c = OGlobal::config(); |
321 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); | 322 | OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); |
322 | *_generalFont = c->readFontEntry("font", _generalFont); | 323 | *_generalFont = c->readFontEntry("font", _generalFont); |
323 | 324 | ||
324 | return *_generalFont; | 325 | return *_generalFont; |
325 | } | 326 | } |
326 | 327 | ||
327 | QFont OGlobalSettings::fixedFont() | 328 | QFont OGlobalSettings::fixedFont() |
328 | { | 329 | { |
329 | if (_fixedFont) | 330 | if (_fixedFont) |
330 | return *_fixedFont; | 331 | return *_fixedFont; |
331 | 332 | ||
332 | _fixedFont = new QFont("courier", 12); | 333 | _fixedFont = new QFont("courier", 12); |
333 | _fixedFont->setPixelSize(12); | 334 | _fixedFont->setPixelSize(12); |
334 | _fixedFont->setStyleHint(QFont::TypeWriter); | 335 | _fixedFont->setStyleHint(QFont::TypeWriter); |
335 | 336 | ||
336 | OConfig *c = OGlobal::config(); | 337 | OConfig *c = OGlobal::config(); |
337 | OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); | 338 | OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); |
338 | *_fixedFont = c->readFontEntry("fixed", _fixedFont); | 339 | *_fixedFont = c->readFontEntry("fixed", _fixedFont); |
339 | 340 | ||
340 | return *_fixedFont; | 341 | return *_fixedFont; |
341 | } | 342 | } |
342 | 343 | ||
343 | QFont OGlobalSettings::toolBarFont() | 344 | QFont OGlobalSettings::toolBarFont() |
344 | { | 345 | { |
345 | if(_toolBarFont) | 346 | if(_toolBarFont) |
346 | return *_toolBarFont; | 347 | return *_toolBarFont; |
347 | 348 | ||
348 | _toolBarFont = new QFont("helvetica", 10); | 349 | _toolBarFont = new QFont("helvetica", 10); |
349 | _toolBarFont->setPixelSize(10); | 350 | _toolBarFont->setPixelSize(10); |
350 | _toolBarFont->setStyleHint(QFont::SansSerif); | 351 | _toolBarFont->setStyleHint(QFont::SansSerif); |
351 | 352 | ||
352 | OConfig *c = OGlobal::config(); | 353 | OConfig *c = OGlobal::config(); |
353 | OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); | 354 | OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); |
354 | *_toolBarFont = c->readFontEntry("toolBarFont", _toolBarFont); | 355 | *_toolBarFont = c->readFontEntry("toolBarFont", _toolBarFont); |
355 | 356 | ||
356 | return *_toolBarFont; | 357 | return *_toolBarFont; |
357 | } | 358 | } |
358 | 359 | ||
359 | QFont OGlobalSettings::menuFont() | 360 | QFont OGlobalSettings::menuFont() |
360 | { | 361 | { |
361 | if(_menuFont) | 362 | if(_menuFont) |
362 | return *_menuFont; | 363 | return *_menuFont; |
363 | 364 | ||
364 | _menuFont = new QFont("helvetica", 12); | 365 | _menuFont = new QFont("helvetica", 12); |
365 | _menuFont->setPixelSize(12); | 366 | _menuFont->setPixelSize(12); |
366 | _menuFont->setStyleHint(QFont::SansSerif); | 367 | _menuFont->setStyleHint(QFont::SansSerif); |
367 | 368 | ||
368 | OConfig *c = OGlobal::config(); | 369 | OConfig *c = OGlobal::config(); |
369 | OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); | 370 | OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); |
370 | *_menuFont = c->readFontEntry("menuFont", _menuFont); | 371 | *_menuFont = c->readFontEntry("menuFont", _menuFont); |
371 | 372 | ||
372 | return *_menuFont; | 373 | return *_menuFont; |
373 | } | 374 | } |
374 | 375 | ||
375 | QFont OGlobalSettings::windowTitleFont() | 376 | QFont OGlobalSettings::windowTitleFont() |
376 | { | 377 | { |
377 | if(_windowTitleFont) | 378 | if(_windowTitleFont) |
378 | return *_windowTitleFont; | 379 | return *_windowTitleFont; |
379 | 380 | ||
380 | _windowTitleFont = new QFont("helvetica", 12, QFont::Bold); | 381 | _windowTitleFont = new QFont("helvetica", 12, QFont::Bold); |
381 | _windowTitleFont->setPixelSize(12); | 382 | _windowTitleFont->setPixelSize(12); |
382 | _windowTitleFont->setStyleHint(QFont::SansSerif); | 383 | _windowTitleFont->setStyleHint(QFont::SansSerif); |
383 | 384 | ||
384 | OConfig *c = OGlobal::config(); | 385 | OConfig *c = OGlobal::config(); |
385 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); | 386 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); |
386 | *_windowTitleFont = c->readFontEntry("activeFont", _windowTitleFont); // inconsistency | 387 | *_windowTitleFont = c->readFontEntry("activeFont", _windowTitleFont); // inconsistency |
387 | 388 | ||
388 | return *_windowTitleFont; | 389 | return *_windowTitleFont; |
389 | } | 390 | } |
390 | 391 | ||
391 | QFont OGlobalSettings::taskbarFont() | 392 | QFont OGlobalSettings::taskbarFont() |
392 | { | 393 | { |
393 | if(_taskbarFont) | 394 | if(_taskbarFont) |
394 | return *_taskbarFont; | 395 | return *_taskbarFont; |
395 | 396 | ||
396 | _taskbarFont = new QFont("helvetica", 8); | 397 | _taskbarFont = new QFont("helvetica", 8); |
397 | _taskbarFont->setPixelSize(8); | 398 | _taskbarFont->setPixelSize(8); |
398 | _taskbarFont->setStyleHint(QFont::SansSerif); | 399 | _taskbarFont->setStyleHint(QFont::SansSerif); |
399 | 400 | ||
400 | OConfig *c = OGlobal::config(); | 401 | OConfig *c = OGlobal::config(); |
401 | OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); | 402 | OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); |
402 | *_taskbarFont = c->readFontEntry("taskbarFont", _taskbarFont); | 403 | *_taskbarFont = c->readFontEntry("taskbarFont", _taskbarFont); |
403 | 404 | ||
404 | return *_taskbarFont; | 405 | return *_taskbarFont; |
405 | } | 406 | } |
406 | 407 | ||
407 | // FIXME: the whole path stuff has to be revised for OPIE | 408 | // FIXME: the whole path stuff has to be revised for OPIE |
408 | 409 | ||
409 | void OGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here. | 410 | void OGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here. |
410 | { | 411 | { |
411 | if ( s_desktopPath != 0 ) | 412 | if ( s_desktopPath != 0 ) |
412 | return; | 413 | return; |
413 | 414 | ||
414 | s_desktopPath = new QString(); | 415 | s_desktopPath = new QString(); |
415 | s_autostartPath = new QString(); | 416 | s_autostartPath = new QString(); |
416 | s_trashPath = new QString(); | 417 | s_trashPath = new QString(); |
417 | s_documentPath = new QString(); | 418 | s_documentPath = new QString(); |
418 | 419 | ||
419 | OConfig *config = OGlobal::config(); | 420 | OConfig *config = OGlobal::config(); |
420 | //bool dollarExpansion = config->isDollarExpansion(); | 421 | //bool dollarExpansion = config->isDollarExpansion(); |
421 | //config->setDollarExpansion(true); | 422 | //config->setDollarExpansion(true); |
422 | OConfigGroupSaver cgs( config, "Paths" ); | 423 | OConfigGroupSaver cgs( config, "Paths" ); |
423 | 424 | ||
424 | // Desktop Path | 425 | // Desktop Path |
425 | *s_desktopPath = QDir::homeDirPath() + "/" + "Desktop" + "/"; | 426 | *s_desktopPath = QDir::homeDirPath() + "/" + "Desktop" + "/"; |
426 | *s_desktopPath = config->readEntry( "Desktop", *s_desktopPath); | 427 | *s_desktopPath = config->readEntry( "Desktop", *s_desktopPath); |
427 | if ( (*s_desktopPath)[0] != '/' ) | 428 | if ( (*s_desktopPath)[0] != '/' ) |
428 | s_desktopPath->prepend( QDir::homeDirPath() + "/" ); | 429 | s_desktopPath->prepend( QDir::homeDirPath() + "/" ); |
429 | *s_desktopPath = QDir::cleanDirPath( *s_desktopPath ); | 430 | *s_desktopPath = QDir::cleanDirPath( *s_desktopPath ); |
430 | if ( s_desktopPath->right(1) != "/") | 431 | if ( s_desktopPath->right(1) != "/") |
431 | *s_desktopPath += "/"; | 432 | *s_desktopPath += "/"; |
432 | 433 | ||
433 | // Trash Path | 434 | // Trash Path |
434 | *s_trashPath = *s_desktopPath + QObject::tr("Trash") + "/"; | 435 | *s_trashPath = *s_desktopPath + QObject::tr("Trash") + "/"; |
435 | *s_trashPath = config->readEntry( "Trash" , *s_trashPath); | 436 | *s_trashPath = config->readEntry( "Trash" , *s_trashPath); |
436 | if ( (*s_trashPath)[0] != '/' ) | 437 | if ( (*s_trashPath)[0] != '/' ) |
437 | s_trashPath->prepend( QDir::homeDirPath() + "/" ); | 438 | s_trashPath->prepend( QDir::homeDirPath() + "/" ); |
438 | *s_trashPath = QDir::cleanDirPath( *s_trashPath ); | 439 | *s_trashPath = QDir::cleanDirPath( *s_trashPath ); |
439 | if ( s_trashPath->right(1) != "/") | 440 | if ( s_trashPath->right(1) != "/") |
440 | *s_trashPath += "/"; | 441 | *s_trashPath += "/"; |
441 | // We need to save it in any case, in case the language changes later on, | 442 | // We need to save it in any case, in case the language changes later on, |
442 | if ( !config->hasKey( "Trash" ) ) | 443 | if ( !config->hasKey( "Trash" ) ) |
443 | { | 444 | { |
444 | //config->writePathEntry( "Trash", *s_trashPath, true, true ); | 445 | //config->writePathEntry( "Trash", *s_trashPath, true, true ); |
445 | config->writeEntry( "Trash", *s_trashPath ); | 446 | config->writeEntry( "Trash", *s_trashPath ); |
446 | //config->sync(); | 447 | //config->sync(); |
447 | } | 448 | } |
448 | 449 | ||
449 | /* // Autostart Path | 450 | /* // Autostart Path |
450 | *s_autostartPath = OGlobal::dirs()->localkdedir() + "Autostart" + "/"; | 451 | *s_autostartPath = OGlobal::dirs()->localkdedir() + "Autostart" + "/"; |
451 | *s_autostartPath = config->readEntry( "Autostart" , *s_autostartPath); | 452 | *s_autostartPath = config->readEntry( "Autostart" , *s_autostartPath); |
452 | if ( (*s_autostartPath)[0] != '/' ) | 453 | if ( (*s_autostartPath)[0] != '/' ) |
453 | s_autostartPath->prepend( QDir::homeDirPath() + "/" ); | 454 | s_autostartPath->prepend( QDir::homeDirPath() + "/" ); |
454 | *s_autostartPath = QDir::cleanDirPath( *s_autostartPath ); | 455 | *s_autostartPath = QDir::cleanDirPath( *s_autostartPath ); |
455 | if ( s_autostartPath->right(1) != "/") | 456 | if ( s_autostartPath->right(1) != "/") |
456 | *s_autostartPath += "/"; | 457 | *s_autostartPath += "/"; |
457 | */ | 458 | */ |
458 | // Document Path | 459 | // Document Path |
459 | *s_documentPath = QString::null; | 460 | *s_documentPath = QString::null; |
460 | *s_documentPath = config->readEntry( "Documents" , *s_documentPath); | 461 | *s_documentPath = config->readEntry( "Documents" , *s_documentPath); |
461 | if ( (*s_documentPath)[0] != '/' ) | 462 | if ( (*s_documentPath)[0] != '/' ) |
462 | s_documentPath->prepend( QDir::homeDirPath() + "/" ); | 463 | s_documentPath->prepend( QDir::homeDirPath() + "/" ); |
463 | *s_documentPath = QDir::cleanDirPath( *s_documentPath ); | 464 | *s_documentPath = QDir::cleanDirPath( *s_documentPath ); |
464 | if ( s_documentPath->right(1) != "/") | 465 | if ( s_documentPath->right(1) != "/") |
465 | *s_documentPath += "/"; | 466 | *s_documentPath += "/"; |
466 | 467 | ||
467 | //config->setDollarExpansion(dollarExpansion); | 468 | //config->setDollarExpansion(dollarExpansion); |
468 | 469 | ||
469 | // Make sure this app gets the notifications about those paths | 470 | // Make sure this app gets the notifications about those paths |
470 | //if (kapp) | 471 | //if (kapp) |
471 | //kapp->addKipcEventMask(KIPC::SettingsChanged); | 472 | //kapp->addKipcEventMask(KIPC::SettingsChanged); |
472 | } | 473 | } |
473 | 474 | ||
474 | void OGlobalSettings::initColors() | 475 | void OGlobalSettings::initColors() |
475 | { | 476 | { |
476 | if ( !OpieHighlight ) OpieHighlight = new QColor( 156, 118, 32 ); | 477 | if ( !OpieHighlight ) OpieHighlight = new QColor( 156, 118, 32 ); |
477 | if ( !OpieAlternate ) OpieAlternate = new QColor( 238, 246, 255 ); | 478 | if ( !OpieAlternate ) OpieAlternate = new QColor( 238, 246, 255 ); |
478 | if ( !OpieGray ) OpieGray = new QColor( 220, 210, 215 ); | 479 | if ( !OpieGray ) OpieGray = new QColor( 220, 210, 215 ); |
479 | } | 480 | } |
480 | 481 | ||
481 | void OGlobalSettings::rereadFontSettings() | 482 | void OGlobalSettings::rereadFontSettings() |
482 | { | 483 | { |
483 | delete _generalFont; | 484 | delete _generalFont; |
484 | _generalFont = 0L; | 485 | _generalFont = 0L; |
485 | delete _fixedFont; | 486 | delete _fixedFont; |
486 | _fixedFont = 0L; | 487 | _fixedFont = 0L; |
487 | delete _menuFont; | 488 | delete _menuFont; |
488 | _menuFont = 0L; | 489 | _menuFont = 0L; |
489 | delete _toolBarFont; | 490 | delete _toolBarFont; |
490 | _toolBarFont = 0L; | 491 | _toolBarFont = 0L; |
491 | delete _windowTitleFont; | 492 | delete _windowTitleFont; |
492 | _windowTitleFont = 0L; | 493 | _windowTitleFont = 0L; |
493 | delete _taskbarFont; | 494 | delete _taskbarFont; |
494 | _taskbarFont = 0L; | 495 | _taskbarFont = 0L; |
495 | } | 496 | } |
496 | 497 | ||
497 | void OGlobalSettings::rereadPathSettings() | 498 | void OGlobalSettings::rereadPathSettings() |
498 | { | 499 | { |
499 | qDebug( "OGlobalSettings::rereadPathSettings" ); | 500 | qDebug( "OGlobalSettings::rereadPathSettings" ); |
500 | delete s_autostartPath; | 501 | delete s_autostartPath; |
501 | s_autostartPath = 0L; | 502 | s_autostartPath = 0L; |
502 | delete s_trashPath; | 503 | delete s_trashPath; |
503 | s_trashPath = 0L; | 504 | s_trashPath = 0L; |
504 | delete s_desktopPath; | 505 | delete s_desktopPath; |
505 | s_desktopPath = 0L; | 506 | s_desktopPath = 0L; |
506 | delete s_documentPath; | 507 | delete s_documentPath; |
507 | s_documentPath = 0L; | 508 | s_documentPath = 0L; |
508 | } | 509 | } |
509 | 510 | ||
510 | OGlobalSettings::OMouseSettings & OGlobalSettings::mouseSettings() | 511 | OGlobalSettings::OMouseSettings & OGlobalSettings::mouseSettings() |
511 | { | 512 | { |
512 | if ( ! s_mouseSettings ) | 513 | if ( ! s_mouseSettings ) |
513 | { | 514 | { |
514 | s_mouseSettings = new OMouseSettings; | 515 | s_mouseSettings = new OMouseSettings; |
515 | OMouseSettings & s = *s_mouseSettings; // for convenience | 516 | OMouseSettings & s = *s_mouseSettings; // for convenience |
516 | 517 | ||
517 | OConfigGroupSaver cgs( OGlobal::config(), "Mouse" ); | 518 | OConfigGroupSaver cgs( OGlobal::config(), "Mouse" ); |
518 | QString setting = OGlobal::config()->readEntry("MouseButtonMapping"); | 519 | QString setting = OGlobal::config()->readEntry("MouseButtonMapping"); |
519 | if (setting == "RightHanded") | 520 | if (setting == "RightHanded") |
520 | s.handed = OMouseSettings::RightHanded; | 521 | s.handed = OMouseSettings::RightHanded; |
521 | else if (setting == "LeftHanded") | 522 | else if (setting == "LeftHanded") |
522 | s.handed = OMouseSettings::LeftHanded; | 523 | s.handed = OMouseSettings::LeftHanded; |
523 | else | 524 | else |
524 | { | 525 | { |
525 | 526 | ||
526 | // FIXME: Implement for Opie / Qt Embedded | 527 | // FIXME: Implement for Opie / Qt Embedded |
527 | 528 | ||
528 | } | 529 | } |
529 | } | 530 | } |
530 | return *s_mouseSettings; | 531 | return *s_mouseSettings; |
531 | } | 532 | } |
532 | 533 | ||
533 | void OGlobalSettings::rereadMouseSettings() | 534 | void OGlobalSettings::rereadMouseSettings() |
534 | { | 535 | { |
535 | delete s_mouseSettings; | 536 | delete s_mouseSettings; |
536 | s_mouseSettings = 0L; | 537 | s_mouseSettings = 0L; |
537 | } | 538 | } |
538 | 539 | ||
539 | // FIXME: This won't be necessary, or will it? :-D | 540 | // FIXME: This won't be necessary, or will it? :-D |
540 | 541 | ||
541 | bool OGlobalSettings::isMultiHead() | 542 | bool OGlobalSettings::isMultiHead() |
542 | { | 543 | { |
543 | QCString multiHead = getenv("OPIE_MULTIHEAD"); | 544 | QCString multiHead = getenv("OPIE_MULTIHEAD"); |
544 | if (!multiHead.isEmpty()) { | 545 | if (!multiHead.isEmpty()) { |
545 | return (multiHead.lower() == "true"); | 546 | return (multiHead.lower() == "true"); |
546 | } | 547 | } |