Diffstat (limited to 'libopie2/opiecore/oglobalsettings.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/oglobalsettings.h | 368 |
1 files changed, 368 insertions, 0 deletions
diff --git a/libopie2/opiecore/oglobalsettings.h b/libopie2/opiecore/oglobalsettings.h new file mode 100644 index 0000000..6481251 --- a/dev/null +++ b/libopie2/opiecore/oglobalsettings.h | |||
@@ -0,0 +1,368 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
4 | Inspired by KDE OGlobalSettings | ||
5 | Copyright (C) 2000 David Faure <faure@kde.org> | ||
6 | =. | ||
7 | .=l. | ||
8 | .>+-= | ||
9 | _;:, .> :=|. This program is free software; you can | ||
10 | .> <`_, > . <= redistribute it and/or modify it under | ||
11 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
12 | .="- .-=="i, .._ License as published by the Free Software | ||
13 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
14 | ._= =} : or (at your option) any later version. | ||
15 | .%`+i> _;_. | ||
16 | .i_,=:_. -<s. This program is distributed in the hope that | ||
17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
18 | : .. .:, . . . without even the implied warranty of | ||
19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
21 | ..}^=.= = ; Library General Public License for more | ||
22 | ++= -. .` .: details. | ||
23 | : = ...= . :.=- | ||
24 | -. .:....=;==+<; You should have received a copy of the GNU | ||
25 | -_. . . )=. = Library General Public License along with | ||
26 | -- :-=` this library; see the file COPYING.LIB. | ||
27 | If not, write to the Free Software Foundation, | ||
28 | Inc., 59 Temple Place - Suite 330, | ||
29 | Boston, MA 02111-1307, USA. | ||
30 | */ | ||
31 | |||
32 | #ifndef OGLOBALSETTINGS_H | ||
33 | #define OGLOBALSETTINGS_H | ||
34 | |||
35 | #include <qstring.h> | ||
36 | #include <qcolor.h> | ||
37 | #include <qfont.h> | ||
38 | |||
39 | #define OPIE_DEFAULT_SINGLECLICK true | ||
40 | #define OPIE_DEFAULT_INSERTTEAROFFHANDLES true | ||
41 | #define OPIE_DEFAULT_AUTOSELECTDELAY -1 | ||
42 | #define OPIE_DEFAULT_CHANGECURSOR true | ||
43 | #define OPIE_DEFAULT_LARGE_CURSOR false | ||
44 | #define OPIE_DEFAULT_VISUAL_ACTIVATE true | ||
45 | #define OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED 50 | ||
46 | |||
47 | //FIXME: There's still a whole lot of stuff in here which has to be revised | ||
48 | //FIXME: before public usage... lack of time to do it at once - so it will | ||
49 | //FIXME: happen step-by-step. ML. | ||
50 | |||
51 | /** | ||
52 | * Access the OPIE global configuration settings. | ||
53 | * | ||
54 | */ | ||
55 | class OGlobalSettings | ||
56 | { | ||
57 | public: | ||
58 | |||
59 | /** | ||
60 | * Returns a threshold in pixels for drag & drop operations. | ||
61 | * As long as the mouse movement has not exceeded this number | ||
62 | * of pixels in either X or Y direction no drag operation may | ||
63 | * be started. This prevents spurious drags when the user intended | ||
64 | * to click on something but moved the mouse a bit while doing so. | ||
65 | * | ||
66 | * For this to work you must save the position of the mouse (oldPos) | ||
67 | * in the @ref QWidget::mousePressEvent(). | ||
68 | * When the position of the mouse (newPos) | ||
69 | * in a @ref QWidget::mouseMoveEvent() exceeds this threshold | ||
70 | * you may start a drag | ||
71 | * which should originate from oldPos. | ||
72 | * | ||
73 | * Example code: | ||
74 | * <pre> | ||
75 | * void OColorCells::mousePressEvent( QMouseEvent *e ) | ||
76 | * { | ||
77 | * mOldPos = e->pos(); | ||
78 | * } | ||
79 | * | ||
80 | * void OColorCells::mouseMoveEvent( QMouseEvent *e ) | ||
81 | * { | ||
82 | * if( !(e->state() && LeftButton)) return; | ||
83 | * | ||
84 | * int delay = OGlobalSettings::dndEventDelay(); | ||
85 | * QPoint newPos = e->pos(); | ||
86 | * if(newPos.x() > mOldPos.x()+delay || newPos.x() < mOldPos.x()-delay || | ||
87 | * newPos.y() > mOldPos.y()+delay || newPos.y() < mOldPos.y()-delay) | ||
88 | * { | ||
89 | * // Drag color object | ||
90 | * int cell = posToCell(mOldPos); // Find color at mOldPos | ||
91 | * if ((cell != -1) && colors[cell].isValid()) | ||
92 | * { | ||
93 | * OColorDrag *d = OColorDrag::makeDrag( colors[cell], this); | ||
94 | * d->dragCopy(); | ||
95 | * } | ||
96 | * } | ||
97 | * } | ||
98 | * </pre> | ||
99 | * | ||
100 | */ | ||
101 | |||
102 | static int dndEventDelay(); | ||
103 | |||
104 | /** | ||
105 | * Returns whether OPIE runs in single (default) or double click | ||
106 | * mode. | ||
107 | * | ||
108 | * @return @p true if single click mode, or @p false if double click mode. | ||
109 | * | ||
110 | * see @ref http://opie.handhelds.org/documentation/standards/opie/style/mouse/index.html | ||
111 | **/ | ||
112 | static bool singleClick(); | ||
113 | |||
114 | /** | ||
115 | * Returns whether tear-off handles are inserted in OPopupMenus. | ||
116 | **/ | ||
117 | static bool insertTearOffHandle(); | ||
118 | |||
119 | /** | ||
120 | * @return the OPIE setting for "change cursor over icon" | ||
121 | */ | ||
122 | static bool changeCursorOverIcon(); | ||
123 | |||
124 | /** | ||
125 | * @return whether to show some feedback when an item (specifically an | ||
126 | * icon) is activated. | ||
127 | */ | ||
128 | static bool visualActivate(); | ||
129 | static unsigned int visualActivateSpeed(); | ||
130 | |||
131 | /** | ||
132 | * Returns the OPIE setting for the auto-select option | ||
133 | * | ||
134 | * @return the auto-select delay or -1 if auto-select is disabled. | ||
135 | */ | ||
136 | static int autoSelectDelay(); | ||
137 | |||
138 | /** | ||
139 | * Returns the OPIE setting for the shortcut key to open | ||
140 | * context menus. | ||
141 | * | ||
142 | * @return the key that pops up context menus. | ||
143 | */ | ||
144 | static int contextMenuKey(); | ||
145 | |||
146 | /** | ||
147 | * Returns the OPIE setting for context menus. | ||
148 | * | ||
149 | * @return whether context menus should be shown on button press | ||
150 | * or button release (click). | ||
151 | */ | ||
152 | static bool showContextMenusOnPress (); | ||
153 | |||
154 | /** | ||
155 | * This enum describes the completion mode used for by the @ref OCompletion class. | ||
156 | * See <a href="http://opie.handhelds.org/documentation/standards/opie/style/keys/completion.html"> | ||
157 | * the styleguide</a>. | ||
158 | **/ | ||
159 | enum Completion { | ||
160 | /** | ||
161 | * No completion is used. | ||
162 | */ | ||
163 | CompletionNone=1, | ||
164 | /** | ||
165 | * Text is automatically filled in whenever possible. | ||
166 | */ | ||
167 | CompletionAuto, | ||
168 | /** | ||
169 | * Same as automatic except shortest match is used for completion. | ||
170 | */ | ||
171 | CompletionMan, | ||
172 | /** | ||
173 | * Complete text much in the same way as a typical *nix shell would. | ||
174 | */ | ||
175 | CompletionShell, | ||
176 | /** | ||
177 | * Lists all possible matches in a popup list-box to choose from. | ||
178 | */ | ||
179 | CompletionPopup, | ||
180 | /** | ||
181 | * Lists all possible matches in a popup list-box to choose from, and automatically | ||
182 | * fill the result whenever possible. | ||
183 | */ | ||
184 | CompletionPopupAuto | ||
185 | }; | ||
186 | /** | ||
187 | * Returns the preferred completion mode setting. | ||
188 | * | ||
189 | * @return @ref Completion. Default is @p CompletionPopup. | ||
190 | */ | ||
191 | static Completion completionMode(); | ||
192 | |||
193 | /** | ||
194 | * This enum describes the debug mode used for by the @ref odbgstream class. | ||
195 | * See <a href="http://opie.handhelds.org/documentation/standards/opie/style/debug/debug.html"> | ||
196 | * the styleguide</a>. | ||
197 | **/ | ||
198 | enum Debug { | ||
199 | /** | ||
200 | * Debug messages are ignored. | ||
201 | */ | ||
202 | DebugNone=-1, | ||
203 | /** | ||
204 | * Debug output is sent to files /var/log/***. | ||
205 | */ | ||
206 | DebugFiles=0, | ||
207 | /** | ||
208 | * Debug output is written in a QMessageBox. | ||
209 | */ | ||
210 | DebugMsgBox=1, | ||
211 | /** | ||
212 | * Debug output is sent to stderr. | ||
213 | */ | ||
214 | DebugStdErr=2, | ||
215 | /** | ||
216 | * Debug output is sent to syslog. | ||
217 | */ | ||
218 | DebugSysLog=3, | ||
219 | /** | ||
220 | * Debug output is sent via udp over a socket. | ||
221 | */ | ||
222 | DebugSocket=4 | ||
223 | }; | ||
224 | /** | ||
225 | * Returns the preferred debug mode setting. | ||
226 | * | ||
227 | * @return @ref Debug. Default is @p DebugStdErr. | ||
228 | */ | ||
229 | static Debug debugMode(); | ||
230 | |||
231 | /** | ||
232 | * Returns additional information for debug output (dependent on the debug mode). | ||
233 | * | ||
234 | * @return Additional debug output information. | ||
235 | */ | ||
236 | static QString debugOutput(); | ||
237 | /** | ||
238 | * This is a structure containing the possible mouse settings. | ||
239 | */ | ||
240 | struct OMouseSettings | ||
241 | { | ||
242 | enum { RightHanded = 0, LeftHanded = 1 }; | ||
243 | int handed; // left or right | ||
244 | }; | ||
245 | |||
246 | /** | ||
247 | * This returns the current mouse settings. | ||
248 | */ | ||
249 | static OMouseSettings & mouseSettings(); | ||
250 | |||
251 | /** | ||
252 | * The path to the desktop directory of the current user. | ||
253 | */ | ||
254 | static QString desktopPath() { initStatic(); return *s_desktopPath; } | ||
255 | |||
256 | /** | ||
257 | * The path to the autostart directory of the current user. | ||
258 | */ | ||
259 | static QString autostartPath() { initStatic(); return *s_autostartPath; } | ||
260 | |||
261 | /** | ||
262 | * The path to the trash directory of the current user. | ||
263 | */ | ||
264 | static QString trashPath() { initStatic(); return *s_trashPath; } | ||
265 | |||
266 | /** | ||
267 | * The path where documents are stored of the current user. | ||
268 | */ | ||
269 | static QString documentPath() { initStatic(); return *s_documentPath; } | ||
270 | |||
271 | |||
272 | /** | ||
273 | * The default color to use when highlighting toolbar buttons | ||
274 | */ | ||
275 | static QColor toolBarHighlightColor(); | ||
276 | static QColor inactiveTitleColor(); | ||
277 | static QColor inactiveTextColor(); | ||
278 | static QColor activeTitleColor(); | ||
279 | static QColor activeTextColor(); | ||
280 | static int contrast(); | ||
281 | |||
282 | /** | ||
283 | * The default colors to use for text and links. | ||
284 | */ | ||
285 | static QColor baseColor(); // Similair to QColorGroup::base() | ||
286 | static QColor textColor(); // Similair to QColorGroup::text() | ||
287 | static QColor linkColor(); | ||
288 | static QColor visitedLinkColor(); | ||
289 | static QColor highlightedTextColor(); // Similair to QColorGroup::hightlightedText() | ||
290 | static QColor highlightColor(); // Similair to QColorGroup::highlight() | ||
291 | |||
292 | /** | ||
293 | * Returns the alternate background color used by @ref OListView with | ||
294 | * @ref OListViewItem. Any other list that uses alternating background | ||
295 | * colors should use this too, to obey to the user's preferences. Returns | ||
296 | * an invalid color if the user doesn't want alternating backgrounds. | ||
297 | * @see #calculateAlternateBackgroundColor | ||
298 | */ | ||
299 | static QColor alternateBackgroundColor(); | ||
300 | /** | ||
301 | * Calculates a color based on @p base to be used as alternating | ||
302 | * color for e.g. listviews. | ||
303 | * @see #alternateBackgroundColor | ||
304 | */ | ||
305 | static QColor calculateAlternateBackgroundColor(const QColor& base); | ||
306 | |||
307 | |||
308 | static QFont generalFont(); | ||
309 | static QFont fixedFont(); | ||
310 | static QFont toolBarFont(); | ||
311 | static QFont menuFont(); | ||
312 | static QFont windowTitleFont(); | ||
313 | static QFont taskbarFont(); | ||
314 | |||
315 | /** | ||
316 | * Returns if the user specified multihead. In case the display | ||
317 | * has multiple screens, the return value of this function specifies | ||
318 | * if the user wants OPIE to run on all of them or just on the primary | ||
319 | */ | ||
320 | static bool isMultiHead(); | ||
321 | |||
322 | private: | ||
323 | /** | ||
324 | * reads in all paths from kdeglobals | ||
325 | */ | ||
326 | static void initStatic(); | ||
327 | /** | ||
328 | * initialise kde2Blue | ||
329 | */ | ||
330 | static void initColors(); | ||
331 | /** | ||
332 | * drop cached values for fonts (called by OApplication) | ||
333 | */ | ||
334 | static void rereadFontSettings(); | ||
335 | /** | ||
336 | * drop cached values for paths (called by OApplication) | ||
337 | */ | ||
338 | static void rereadPathSettings(); | ||
339 | /** | ||
340 | * drop cached values for mouse settings (called by OApplication) | ||
341 | */ | ||
342 | static void rereadMouseSettings(); | ||
343 | |||
344 | |||
345 | static QString* s_desktopPath; | ||
346 | static QString* s_autostartPath; | ||
347 | static QString* s_trashPath; | ||
348 | static QString* s_documentPath; | ||
349 | static QFont *_generalFont; | ||
350 | static QFont *_fixedFont; | ||
351 | static QFont *_toolBarFont; | ||
352 | static QFont *_menuFont; | ||
353 | static QFont *_windowTitleFont; | ||
354 | static QFont *_taskbarFont; | ||
355 | static QColor * kde2Gray; | ||
356 | static QColor * kde2Blue; | ||
357 | static QColor * kde2AlternateColor; | ||
358 | static OMouseSettings *s_mouseSettings; | ||
359 | |||
360 | static QColor * OpieGray; | ||
361 | static QColor * OpieBlue; | ||
362 | static QColor * OpieAlternate; | ||
363 | static QColor * OpieHighlight; | ||
364 | |||
365 | friend class OApplication; | ||
366 | }; | ||
367 | |||
368 | #endif | ||