• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • tdecore
tdeglobalsettings.cpp
1/* This file is part of the KDE libraries
2 Copyright (C) 2000 David Faure <faure@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*/
18#include "config.h"
19#include "tdeglobalsettings.h"
20
21#include <tqdir.h>
22#include <tqpixmap.h>
23#include <tqfontdatabase.h>
24#include <tqcursor.h>
25
26#include <tdeconfig.h>
27#include <ksimpleconfig.h>
28#include <tdeapplication.h>
29
30#include <kipc.h>
31
32#ifdef TQ_WS_WIN
33#include <windows.h>
34#include "qt_windows.h"
35#include <win32_utils.h>
36static TQRgb qt_colorref2qrgb(COLORREF col)
37{
38 return tqRgb(GetRValue(col),GetGValue(col),GetBValue(col));
39}
40#endif
41
42#include <kdebug.h>
43#include <tdeglobal.h>
44#include <tdeshortcut.h>
45#include <tdestandarddirs.h>
46#include <kcharsets.h>
47#include <tdeaccel.h>
48#include <tdelocale.h>
49#include <tqfontinfo.h>
50#include <stdlib.h>
51#include <kprotocolinfo.h>
52
53#include <tqtextcodec.h>
54#include <tqtextstream.h>
55#include <tqfile.h>
56
57#ifdef TQ_WS_X11
58#include <X11/Xlib.h>
59#endif
60
61TQString* TDEGlobalSettings::s_desktopPath = 0;
62TQString* TDEGlobalSettings::s_autostartPath = 0;
63TQString* TDEGlobalSettings::s_trashPath = 0;
64TQString* TDEGlobalSettings::s_documentPath = 0;
65TQString* TDEGlobalSettings::s_videosPath = 0;
66TQString* TDEGlobalSettings::s_musicPath = 0;
67TQString* TDEGlobalSettings::s_downloadPath = 0;
68TQString* TDEGlobalSettings::s_picturesPath = 0;
69TQString* TDEGlobalSettings::s_templatesPath = 0;
70TQString* TDEGlobalSettings::s_publicSharePath = 0;
71TQFont *TDEGlobalSettings::_generalFont = 0;
72TQFont *TDEGlobalSettings::_fixedFont = 0;
73TQFont *TDEGlobalSettings::_toolBarFont = 0;
74TQFont *TDEGlobalSettings::_menuFont = 0;
75TQFont *TDEGlobalSettings::_windowTitleFont = 0;
76TQFont *TDEGlobalSettings::_taskbarFont = 0;
77TQFont *TDEGlobalSettings::_largeFont = 0;
78TQColor *TDEGlobalSettings::_trinity4Blue = 0;
79TQColor *TDEGlobalSettings::_inactiveBackground = 0;
80TQColor *TDEGlobalSettings::_inactiveForeground = 0;
81TQColor *TDEGlobalSettings::_activeBackground = 0;
82TQColor *TDEGlobalSettings::_buttonBackground = 0;
83TQColor *TDEGlobalSettings::_selectBackground = 0;
84TQColor *TDEGlobalSettings::_linkColor = 0;
85TQColor *TDEGlobalSettings::_visitedLinkColor = 0;
86TQColor *TDEGlobalSettings::alternateColor = 0;
87
88TDEGlobalSettings::KMouseSettings *TDEGlobalSettings::s_mouseSettings = 0;
89
90// Helper function for reading xdg user dirs.
91// Returns sane values in case the user dir file can't be read
92static void readXdgUserDirs(TQString *desktop, TQString *documents, TQString *download, TQString *music,
93 TQString *pictures, TQString *publicShare, TQString *templates, TQString *videos)
94{
95 TQFile dirsFile(TQDir::homeDirPath() + "/.config/user-dirs.dirs");
96 if (dirsFile.open(IO_ReadOnly))
97 {
98 // set the codec for the current locale
99 TQTextStream stream(&dirsFile);
100 stream.setCodec(TQTextCodec::codecForLocale());
101
102 while (!stream.atEnd())
103 {
104 TQString line = stream.readLine();
105 if (line.startsWith("XDG_DESKTOP_DIR="))
106 {
107 *desktop = line.remove("XDG_DESKTOP_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
108 }
109 else if (line.startsWith("XDG_DOCUMENTS_DIR="))
110 {
111 *documents = line.remove("XDG_DOCUMENTS_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
112 }
113 else if (line.startsWith("XDG_DOWNLOAD_DIR="))
114 {
115 *download = line.remove("XDG_DOWNLOAD_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
116 }
117 else if (line.startsWith("XDG_MUSIC_DIR="))
118 {
119 *music = line.remove("XDG_MUSIC_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
120 }
121 else if (line.startsWith("XDG_PICTURES_DIR="))
122 {
123 *pictures = line.remove("XDG_PICTURES_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
124 }
125 else if (line.startsWith("XDG_PUBLICSHARE_DIR="))
126 {
127 *publicShare = line.remove("XDG_PUBLICSHARE_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
128 }
129 else if (line.startsWith("XDG_TEMPLATES_DIR="))
130 {
131 *templates = line.remove("XDG_TEMPLATES_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
132 }
133 else if (line.startsWith("XDG_VIDEOS_DIR="))
134 {
135 *videos = line.remove("XDG_VIDEOS_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
136 }
137 }
138 dirsFile.close();
139 }
140
141 // Use sane values in case some paths are missing
142 if (desktop->isEmpty())
143 {
144 *desktop = TQDir::homeDirPath() + "/" + "Desktop" + "/";
145 if (!TQDir(*desktop).exists())
146 {
147 *desktop = TQDir::homeDirPath() + "/" + i18n("Desktop") + "/";
148 }
149 }
150 if (documents->isEmpty())
151 {
152 *documents = TQDir::homeDirPath() + "/" + "Documents" + "/";
153 if (!TQDir(*documents).exists())
154 {
155 *documents = TQDir::homeDirPath() + "/" + i18n("Documents") + "/";
156 }
157 }
158 if (download->isEmpty())
159 {
160 *download = TQDir::homeDirPath() + "/" + "Downloads" + "/";
161 if (!TQDir(*download).exists())
162 {
163 *download = TQDir::homeDirPath() + "/" + i18n("Downloads") + "/";
164 }
165 }
166 if (music->isEmpty())
167 {
168 *music = TQDir::homeDirPath() + "/" + "Music" + "/";
169 if (!TQDir(*music).exists())
170 {
171 *music = TQDir::homeDirPath() + "/" + i18n("Music") + "/";
172 }
173 }
174 if (pictures->isEmpty())
175 {
176 *pictures = TQDir::homeDirPath() + "/" + "Pictures" + "/";
177 if (!TQDir(*pictures).exists())
178 {
179 *pictures = TQDir::homeDirPath() + "/" + i18n("Pictures") + "/";
180 }
181 }
182 if (publicShare->isEmpty())
183 {
184 *publicShare = TQDir::homeDirPath() + "/" + "Public" + "/";
185 if (!TQDir(*publicShare).exists())
186 {
187 *publicShare = TQDir::homeDirPath() + "/" + i18n("Public") + "/";
188 }
189 }
190 if (templates->isEmpty())
191 {
192 *templates = TQDir::homeDirPath() + "/" + "Templates" + "/";
193 if (!TQDir(*templates).exists())
194 {
195 *templates = TQDir::homeDirPath() + "/" + i18n("Templates") + "/";
196 }
197 }
198 if (videos->isEmpty())
199 {
200 *videos = TQDir::homeDirPath() + "/" + "Videos" + "/";
201 if (!TQDir(*videos).exists())
202 {
203 *videos = TQDir::homeDirPath() + "/" + i18n("Videos") + "/";
204 }
205 }
206}
207
208static void checkAndCreateXdgFolder(const TQString &folder, const TQString &path, TDEConfig *config)
209{
210 bool pathOk = true;
211 if (!TQDir(path).exists())
212 {
213 if (!TDEStandardDirs::makeDir(path))
214 {
215 pathOk = false;
216 }
217 }
218
219 if (pathOk)
220 {
221 config->writePathEntry(folder, '"' + path + '"', true, false, false, false );
222 }
223}
224
225int TDEGlobalSettings::dndEventDelay()
226{
227 TDEConfigGroup g( TDEGlobal::config(), "General" );
228 return g.readNumEntry("StartDragDist", TQApplication::startDragDistance());
229}
230
231bool TDEGlobalSettings::singleClick()
232{
233 TDEConfigGroup g( TDEGlobal::config(), "KDE" );
234 return g.readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK);
235}
236
237bool TDEGlobalSettings::iconUseRoundedRect()
238{
239 TDEConfigGroup g( TDEGlobal::config(), "KDE" );
240 return g.readBoolEntry("IconUseRoundedRect", KDE_DEFAULT_ICONTEXTROUNDED);
241}
242
243TDEGlobalSettings::TearOffHandle TDEGlobalSettings::insertTearOffHandle()
244{
245 int tearoff;
246 bool effectsenabled;
247 TDEConfigGroup g( TDEGlobal::config(), "KDE" );
248 effectsenabled = g.readBoolEntry( "EffectsEnabled", false);
249 tearoff = g.readNumEntry("InsertTearOffHandle", KDE_DEFAULT_INSERTTEAROFFHANDLES);
250 return effectsenabled ? (TearOffHandle) tearoff : Disable;
251}
252
253bool TDEGlobalSettings::changeCursorOverIcon()
254{
255 TDEConfigGroup g( TDEGlobal::config(), "KDE" );
256 return g.readBoolEntry("ChangeCursor", KDE_DEFAULT_CHANGECURSOR);
257}
258
259bool TDEGlobalSettings::visualActivate()
260{
261 TDEConfigGroup g( TDEGlobal::config(), "KDE" );
262 return g.readBoolEntry("VisualActivate", KDE_DEFAULT_VISUAL_ACTIVATE);
263}
264
265unsigned int TDEGlobalSettings::visualActivateSpeed()
266{
267 TDEConfigGroup g( TDEGlobal::config(), "KDE" );
268 return
269 g.readNumEntry(
270 "VisualActivateSpeed",
271 KDE_DEFAULT_VISUAL_ACTIVATE_SPEED
272 );
273}
274
275
276
277int TDEGlobalSettings::autoSelectDelay()
278{
279 TDEConfigGroup g( TDEGlobal::config(), "KDE" );
280 return g.readNumEntry("AutoSelectDelay", KDE_DEFAULT_AUTOSELECTDELAY);
281}
282
283TDEGlobalSettings::Completion TDEGlobalSettings::completionMode()
284{
285 int completion;
286 TDEConfigGroup g( TDEGlobal::config(), "General" );
287 completion = g.readNumEntry("completionMode", -1);
288 if ((completion < (int) CompletionNone) ||
289 (completion > (int) CompletionPopupAuto))
290 {
291 completion = (int) CompletionPopup; // Default
292 }
293 return (Completion) completion;
294}
295
296bool TDEGlobalSettings::showContextMenusOnPress ()
297{
298 TDEConfigGroup g(TDEGlobal::config(), "ContextMenus");
299 return g.readBoolEntry("ShowOnPress", true);
300}
301
302int TDEGlobalSettings::contextMenuKey ()
303{
304 TDEConfigGroup g(TDEGlobal::config(), "Shortcuts");
305 TDEShortcut cut (g.readEntry ("PopupMenuContext", "Menu"));
306 return cut.keyCodeQt();
307}
308
309TQColor TDEGlobalSettings::toolBarHighlightColor()
310{
311 initColors();
312 TDEConfigGroup g( TDEGlobal::config(), "Toolbar style" );
313 return g.readColorEntry("HighlightColor", _trinity4Blue);
314}
315
316TQColor TDEGlobalSettings::inactiveTitleColor()
317{
318#ifdef TQ_WS_WIN
319 return qt_colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTION));
320#else
321 if (!_inactiveBackground)
322 _inactiveBackground = new TQColor(157, 170, 186);
323 TDEConfigGroup g( TDEGlobal::config(), "WM" );
324 return g.readColorEntry( "inactiveBackground", _inactiveBackground );
325#endif
326}
327
328TQColor TDEGlobalSettings::inactiveTextColor()
329{
330#ifdef TQ_WS_WIN
331 return qt_colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTIONTEXT));
332#else
333 if (!_inactiveForeground)
334 _inactiveForeground = new TQColor(221,221,221);
335 TDEConfigGroup g( TDEGlobal::config(), "WM" );
336 return g.readColorEntry( "inactiveForeground", _inactiveForeground );
337#endif
338}
339
340TQColor TDEGlobalSettings::activeTitleColor()
341{
342#ifdef TQ_WS_WIN
343 return qt_colorref2qrgb(GetSysColor(COLOR_ACTIVECAPTION));
344#else
345 initColors();
346 if (!_activeBackground)
347 _activeBackground = new TQColor(65,142,220);
348 TDEConfigGroup g( TDEGlobal::config(), "WM" );
349 return g.readColorEntry( "activeBackground", _activeBackground);
350#endif
351}
352
353TQColor TDEGlobalSettings::activeTextColor()
354{
355#ifdef TQ_WS_WIN
356 return qt_colorref2qrgb(GetSysColor(COLOR_CAPTIONTEXT));
357#else
358 TDEConfigGroup g( TDEGlobal::config(), "WM" );
359 return g.readColorEntry( "activeForeground", &TQt::white );
360#endif
361}
362
363int TDEGlobalSettings::contrast()
364{
365 TDEConfigGroup g( TDEGlobal::config(), "KDE" );
366 return g.readNumEntry( "contrast", 7 );
367}
368
369TQColor TDEGlobalSettings::buttonBackground()
370{
371 if (!_buttonBackground)
372 _buttonBackground = new TQColor(221,223,228);
373 TDEConfigGroup g( TDEGlobal::config(), "General" );
374 return g.readColorEntry( "buttonBackground", _buttonBackground );
375}
376
377TQColor TDEGlobalSettings::buttonTextColor()
378{
379 TDEConfigGroup g( TDEGlobal::config(), "General" );
380 return g.readColorEntry( "buttonForeground", &TQt::black );
381}
382
383// IMPORTANT:
384// This function should be kept in sync with
385// TDEApplication::tdedisplaySetPalette()
386TQColor TDEGlobalSettings::baseColor()
387{
388 TDEConfigGroup g( TDEGlobal::config(), "General" );
389 return g.readColorEntry( "windowBackground", &TQt::white );
390}
391
392// IMPORTANT:
393// This function should be kept in sync with
394// TDEApplication::tdedisplaySetPalette()
395TQColor TDEGlobalSettings::textColor()
396{
397 TDEConfigGroup g( TDEGlobal::config(), "General" );
398 return g.readColorEntry( "windowForeground", &TQt::black );
399}
400
401// IMPORTANT:
402// This function should be kept in sync with
403// TDEApplication::tdedisplaySetPalette()
404TQColor TDEGlobalSettings::highlightedTextColor()
405{
406 TDEConfigGroup g( TDEGlobal::config(), "General" );
407 return g.readColorEntry( "selectForeground", &TQt::white );
408}
409
410// IMPORTANT:
411// This function should be kept in sync with
412// TDEApplication::tdedisplaySetPalette()
413TQColor TDEGlobalSettings::highlightColor()
414{
415 initColors();
416 if (!_selectBackground)
417 _selectBackground = new TQColor(103,141,178);
418 TDEConfigGroup g( TDEGlobal::config(), "General" );
419 return g.readColorEntry( "selectBackground", _selectBackground );
420}
421
422TQColor TDEGlobalSettings::alternateBackgroundColor()
423{
424 initColors();
425 TDEConfigGroup g( TDEGlobal::config(), "General" );
426 *alternateColor = calculateAlternateBackgroundColor( baseColor() );
427 return g.readColorEntry( "alternateBackground", alternateColor );
428}
429
430TQColor TDEGlobalSettings::calculateAlternateBackgroundColor(const TQColor& base)
431{
432 if (base == TQt::white)
433 return TQColor(238,246,255);
434 else
435 {
436 int h, s, v;
437 base.hsv( &h, &s, &v );
438 if (v > 128)
439 return base.dark(106);
440 else if (base != TQt::black)
441 return base.light(110);
442
443 return TQColor(32,32,32);
444 }
445}
446
447bool TDEGlobalSettings::shadeSortColumn()
448{
449 TDEConfigGroup g( TDEGlobal::config(), "General" );
450 return g.readBoolEntry( "shadeSortColumn", KDE_DEFAULT_SHADE_SORT_COLUMN );
451}
452
453TQColor TDEGlobalSettings::linkColor()
454{
455 initColors();
456 if (!_linkColor)
457 _linkColor = new TQColor(0,0,238);
458 TDEConfigGroup g( TDEGlobal::config(), "General" );
459 return g.readColorEntry( "linkColor", _linkColor );
460}
461
462TQColor TDEGlobalSettings::visitedLinkColor()
463{
464 if (!_visitedLinkColor)
465 _visitedLinkColor = new TQColor(82,24,139);
466 TDEConfigGroup g( TDEGlobal::config(), "General" );
467 return g.readColorEntry( "visitedLinkColor", _visitedLinkColor );
468}
469
470TQFont TDEGlobalSettings::generalFont()
471{
472 if (_generalFont)
473 return *_generalFont;
474
475 // Sync default with tdebase/kcontrol/fonts/fonts.cpp
476 _generalFont = new TQFont("Sans Serif", 10);
477 _generalFont->setPointSize(10);
478 _generalFont->setStyleHint(TQFont::SansSerif);
479
480 TDEConfigGroup g( TDEGlobal::config(), "General" );
481 *_generalFont = g.readFontEntry("font", _generalFont);
482
483 return *_generalFont;
484}
485
486TQFont TDEGlobalSettings::fixedFont()
487{
488 if (_fixedFont)
489 return *_fixedFont;
490
491 // Sync default with tdebase/kcontrol/fonts/fonts.cpp
492 _fixedFont = new TQFont("Monospace", 10);
493 _fixedFont->setPointSize(10);
494 _fixedFont->setStyleHint(TQFont::TypeWriter);
495
496 TDEConfigGroup g( TDEGlobal::config(), "General" );
497 *_fixedFont = g.readFontEntry("fixed", _fixedFont);
498
499 return *_fixedFont;
500}
501
502TQFont TDEGlobalSettings::toolBarFont()
503{
504 if(_toolBarFont)
505 return *_toolBarFont;
506
507 // Sync default with tdebase/kcontrol/fonts/fonts.cpp
508 _toolBarFont = new TQFont("Sans Serif", 10);
509 _toolBarFont->setPointSize(10);
510 _toolBarFont->setStyleHint(TQFont::SansSerif);
511
512 TDEConfigGroup g( TDEGlobal::config(), "General" );
513 *_toolBarFont = g.readFontEntry("toolBarFont", _toolBarFont);
514
515 return *_toolBarFont;
516}
517
518TQFont TDEGlobalSettings::menuFont()
519{
520 if(_menuFont)
521 return *_menuFont;
522
523 // Sync default with tdebase/kcontrol/fonts/fonts.cpp
524 _menuFont = new TQFont("Sans Serif", 10);
525 _menuFont->setPointSize(10);
526 _menuFont->setStyleHint(TQFont::SansSerif);
527
528 TDEConfigGroup g( TDEGlobal::config(), "General" );
529 *_menuFont = g.readFontEntry("menuFont", _menuFont);
530
531 return *_menuFont;
532}
533
534TQFont TDEGlobalSettings::windowTitleFont()
535{
536 if(_windowTitleFont)
537 return *_windowTitleFont;
538
539 // Sync default with tdebase/kcontrol/fonts/fonts.cpp
540 _windowTitleFont = new TQFont("Sans Serif", 9, TQFont::Bold);
541 _windowTitleFont->setPointSize(10);
542 _windowTitleFont->setStyleHint(TQFont::SansSerif);
543
544 TDEConfigGroup g( TDEGlobal::config(), "WM" );
545 *_windowTitleFont = g.readFontEntry("activeFont", _windowTitleFont); // inconsistency
546
547 return *_windowTitleFont;
548}
549
550TQFont TDEGlobalSettings::taskbarFont()
551{
552 if(_taskbarFont)
553 return *_taskbarFont;
554
555 // Sync default with tdebase/kcontrol/fonts/fonts.cpp
556 _taskbarFont = new TQFont("Sans Serif", 10);
557 _taskbarFont->setPointSize(10);
558 _taskbarFont->setStyleHint(TQFont::SansSerif);
559
560 TDEConfigGroup g( TDEGlobal::config(), "General" );
561 *_taskbarFont = g.readFontEntry("taskbarFont", _taskbarFont);
562
563 return *_taskbarFont;
564}
565
566
567TQFont TDEGlobalSettings::largeFont(const TQString &text)
568{
569 TQFontDatabase db;
570 TQStringList fam = db.families();
571
572 // Move a bunch of preferred fonts to the front.
573 if (fam.remove("Arial"))
574 fam.prepend("Arial");
575 if (fam.remove("Verdana"))
576 fam.prepend("Verdana");
577 if (fam.remove("Tahoma"))
578 fam.prepend("Tahoma");
579 if (fam.remove("Lucida Sans"))
580 fam.prepend("Lucida Sans");
581 if (fam.remove("Lucidux Sans"))
582 fam.prepend("Lucidux Sans");
583 if (fam.remove("Nimbus Sans"))
584 fam.prepend("Nimbus Sans");
585 if (fam.remove("Gothic I"))
586 fam.prepend("Gothic I");
587
588 if (_largeFont)
589 fam.prepend(_largeFont->family());
590
591 for(TQStringList::ConstIterator it = fam.begin();
592 it != fam.end(); ++it)
593 {
594 if (db.isSmoothlyScalable(*it) && !db.isFixedPitch(*it))
595 {
596 TQFont font(*it);
597 font.setPixelSize(75);
598 TQFontMetrics metrics(font);
599 int h = metrics.height();
600 if ((h < 60) || ( h > 90))
601 continue;
602
603 bool ok = true;
604 for(unsigned int i = 0; i < text.length(); i++)
605 {
606 if (!metrics.inFont(text[i]))
607 {
608 ok = false;
609 break;
610 }
611 }
612 if (!ok)
613 continue;
614
615 font.setPointSize(48);
616 _largeFont = new TQFont(font);
617 return *_largeFont;
618 }
619 }
620 _largeFont = new TQFont(TDEGlobalSettings::generalFont());
621 _largeFont->setPointSize(48);
622 return *_largeFont;
623}
624
625void TDEGlobalSettings::initStatic()
626{
627 // The method is primarily to ensure backward compatibility of the API.
628 // Don't put anything else here.
629 initPaths();
630}
631
632void TDEGlobalSettings::initPaths()
633{
634 if (s_desktopPath)
635 {
636 return;
637 }
638
639 s_autostartPath = new TQString();
640 s_trashPath = new TQString();
641 s_desktopPath = new TQString();
642 s_documentPath = new TQString();
643 s_downloadPath = new TQString();
644 s_musicPath = new TQString();
645 s_picturesPath = new TQString();
646 s_publicSharePath = new TQString();
647 s_templatesPath = new TQString();
648 s_videosPath = new TQString();
649
650 TDEConfigGroup g( TDEGlobal::config(), "Paths" );
651
652 // Read xdg folder paths
653 readXdgUserDirs(s_desktopPath, s_documentPath, s_downloadPath, s_musicPath,
654 s_picturesPath, s_publicSharePath, s_templatesPath, s_videosPath);
655
656 *s_desktopPath = TQDir::cleanDirPath(*s_desktopPath);
657 if (!s_desktopPath->endsWith("/"))
658 s_desktopPath->append('/');
659
660 *s_documentPath = TQDir::cleanDirPath(*s_documentPath);
661 if (!s_documentPath->endsWith("/"))
662 s_documentPath->append('/');
663
664 *s_downloadPath = TQDir::cleanDirPath(*s_downloadPath);
665 if (!s_downloadPath->endsWith("/"))
666 s_downloadPath->append('/');
667
668 *s_musicPath = TQDir::cleanDirPath(*s_musicPath);
669 if (!s_musicPath->endsWith("/"))
670 s_musicPath->append('/');
671
672 *s_picturesPath = TQDir::cleanDirPath(*s_picturesPath);
673 if (!s_picturesPath->endsWith("/"))
674 s_picturesPath->append('/');
675
676 *s_publicSharePath = TQDir::cleanDirPath(*s_publicSharePath);
677 if (!s_publicSharePath->endsWith("/"))
678 s_publicSharePath->append('/');
679
680 *s_templatesPath = TQDir::cleanDirPath(*s_templatesPath);
681 if (!s_templatesPath->endsWith("/"))
682 s_templatesPath->append('/');
683
684 *s_videosPath = TQDir::cleanDirPath(*s_videosPath);
685 if (!s_videosPath->endsWith("/"))
686 s_videosPath->append('/');
687
688 // Trash Path - TODO remove in KDE4 (tdeio_trash can't use it for interoperability reasons)
689 *s_trashPath = *s_desktopPath + i18n("Trash") + "/";
690 *s_trashPath = g.readPathEntry( "Trash" , *s_trashPath);
691 *s_trashPath = TQDir::cleanDirPath( *s_trashPath );
692 if ( !s_trashPath->endsWith("/") )
693 s_trashPath->append('/');
694 // We need to save it in any case, in case the language changes later on,
695 if ( !g.hasKey( "Trash" ) )
696 {
697 g.writePathEntry( "Trash", *s_trashPath, true, true );
698 g.sync();
699 }
700
701 // Create folders if they do not exists.
702 TDEConfig *xdgconfig = new TDEConfig(TQDir::homeDirPath()+"/.config/user-dirs.dirs");
703 checkAndCreateXdgFolder("XDG_DESKTOP_DIR", *s_desktopPath, xdgconfig);
704 checkAndCreateXdgFolder("XDG_DOCUMENTS_DIR", *s_documentPath, xdgconfig);
705 checkAndCreateXdgFolder("XDG_DOWNLOAD_DIR", *s_downloadPath, xdgconfig);
706 checkAndCreateXdgFolder("XDG_MUSIC_DIR", *s_musicPath, xdgconfig);
707 checkAndCreateXdgFolder("XDG_PICTURES_DIR", *s_picturesPath, xdgconfig);
708 checkAndCreateXdgFolder("XDG_PUBLICSHARE_DIR", *s_publicSharePath, xdgconfig);
709 checkAndCreateXdgFolder("XDG_TEMPLATES_DIR", *s_templatesPath, xdgconfig);
710 checkAndCreateXdgFolder("XDG_VIDEOS_DIR", *s_videosPath, xdgconfig);
711 xdgconfig->sync();
712
713 // Autostart Path
714 *s_autostartPath = TDEGlobal::dirs()->localtdedir() + "Autostart/";
715 *s_autostartPath = g.readPathEntry( "Autostart" , *s_autostartPath);
716 *s_autostartPath = TQDir::cleanDirPath( *s_autostartPath );
717 if (!s_autostartPath->endsWith("/"))
718 {
719 s_autostartPath->append('/');
720 }
721 if (!TQDir(*s_autostartPath).exists())
722 {
723 TDEStandardDirs::makeDir(*s_autostartPath);
724 }
725
726 // Make sure this app gets the notifications about those paths
727 if (tdeApp)
728 tdeApp->addKipcEventMask(KIPC::SettingsChanged);
729}
730
731void TDEGlobalSettings::initColors()
732{
733 if (!_trinity4Blue) {
734 if (TQPixmap::defaultDepth() > 8)
735 _trinity4Blue = new TQColor(103,141,178);
736 else
737 _trinity4Blue = new TQColor(0, 0, 192);
738 }
739 if (!alternateColor)
740 alternateColor = new TQColor(237, 244, 249);
741}
742
743void TDEGlobalSettings::rereadFontSettings()
744{
745 delete _generalFont;
746 _generalFont = 0L;
747 delete _fixedFont;
748 _fixedFont = 0L;
749 delete _menuFont;
750 _menuFont = 0L;
751 delete _toolBarFont;
752 _toolBarFont = 0L;
753 delete _windowTitleFont;
754 _windowTitleFont = 0L;
755 delete _taskbarFont;
756 _taskbarFont = 0L;
757}
758
759void TDEGlobalSettings::rereadPathSettings()
760{
761 kdDebug() << "TDEGlobalSettings::rereadPathSettings" << endl;
762 delete s_autostartPath;
763 s_autostartPath = 0L;
764 delete s_trashPath;
765 s_trashPath = 0L;
766 delete s_desktopPath;
767 s_desktopPath = 0L;
768 delete s_documentPath;
769 s_documentPath = 0L;
770 delete s_downloadPath;
771 s_downloadPath = 0L;
772 delete s_musicPath;
773 s_musicPath = 0L;
774 delete s_picturesPath;
775 s_picturesPath = 0L;
776 delete s_publicSharePath;
777 s_publicSharePath = 0L;
778 delete s_templatesPath;
779 s_templatesPath = 0L;
780 delete s_videosPath;
781 s_videosPath = 0L;
782}
783
784TDEGlobalSettings::KMouseSettings & TDEGlobalSettings::mouseSettings()
785{
786 if ( ! s_mouseSettings )
787 {
788 s_mouseSettings = new KMouseSettings;
789 KMouseSettings & s = *s_mouseSettings; // for convenience
790
791#ifndef TQ_WS_WIN
792 TDEConfigGroup g( TDEGlobal::config(), "Mouse" );
793 TQString setting = g.readEntry("MouseButtonMapping");
794 if (setting == "RightHanded")
795 s.handed = KMouseSettings::RightHanded;
796 else if (setting == "LeftHanded")
797 s.handed = KMouseSettings::LeftHanded;
798 else
799 {
800#ifdef TQ_WS_X11
801 // get settings from X server
802 // This is a simplified version of the code in input/mouse.cpp
803 // Keep in sync !
804 s.handed = KMouseSettings::RightHanded;
805 unsigned char map[20];
806 int num_buttons = XGetPointerMapping(tdeApp->getDisplay(), map, 20);
807 if( num_buttons == 2 )
808 {
809 if ( (int)map[0] == 1 && (int)map[1] == 2 )
810 s.handed = KMouseSettings::RightHanded;
811 else if ( (int)map[0] == 2 && (int)map[1] == 1 )
812 s.handed = KMouseSettings::LeftHanded;
813 }
814 else if( num_buttons >= 3 )
815 {
816 if ( (int)map[0] == 1 && (int)map[2] == 3 )
817 s.handed = KMouseSettings::RightHanded;
818 else if ( (int)map[0] == 3 && (int)map[2] == 1 )
819 s.handed = KMouseSettings::LeftHanded;
820 }
821#else
822 // FIXME(E): Implement in Qt Embedded
823#endif
824 }
825#endif //TQ_WS_WIN
826 }
827#ifdef TQ_WS_WIN
828 //not cached
829 s_mouseSettings->handed = (GetSystemMetrics(SM_SWAPBUTTON) ? KMouseSettings::LeftHanded : KMouseSettings::RightHanded);
830#endif
831 return *s_mouseSettings;
832}
833
834void TDEGlobalSettings::rereadMouseSettings()
835{
836#ifndef TQ_WS_WIN
837 delete s_mouseSettings;
838 s_mouseSettings = 0L;
839#endif
840}
841
842bool TDEGlobalSettings::isMultiHead()
843{
844#ifdef TQ_WS_WIN
845 return GetSystemMetrics(SM_CMONITORS) > 1;
846#else
847 TQCString multiHead = getenv("TDE_MULTIHEAD");
848 if (!multiHead.isEmpty()) {
849 return (multiHead.lower() == "true");
850 }
851 return false;
852#endif
853}
854
855bool TDEGlobalSettings::wheelMouseZooms()
856{
857 TDEConfigGroup g( TDEGlobal::config(), "KDE" );
858 return g.readBoolEntry( "WheelMouseZooms", KDE_DEFAULT_WHEEL_ZOOM );
859}
860
861TQRect TDEGlobalSettings::splashScreenDesktopGeometry()
862{
863 TQDesktopWidget *dw = TQApplication::desktop();
864
865 if (dw->isVirtualDesktop()) {
866 TDEConfigGroup group(TDEGlobal::config(), "Windows");
867 int scr = group.readNumEntry("Unmanaged", -3);
868 if (group.readBoolEntry("XineramaEnabled", true) && scr != -2) {
869 if (scr == -3)
870 scr = dw->screenNumber(TQCursor::pos());
871 return dw->screenGeometry(scr);
872 } else {
873 return dw->geometry();
874 }
875 } else {
876 return dw->geometry();
877 }
878}
879
880TQRect TDEGlobalSettings::desktopGeometry(const TQPoint& point)
881{
882 TQDesktopWidget *dw = TQApplication::desktop();
883
884 if (dw->isVirtualDesktop()) {
885 TDEConfigGroup group(TDEGlobal::config(), "Windows");
886 if (group.readBoolEntry("XineramaEnabled", true) &&
887 group.readBoolEntry("XineramaPlacementEnabled", true)) {
888 return dw->screenGeometry(dw->screenNumber(point));
889 } else {
890 return dw->geometry();
891 }
892 } else {
893 return dw->geometry();
894 }
895}
896
897TQRect TDEGlobalSettings::desktopGeometry(TQWidget* w)
898{
899 TQDesktopWidget *dw = TQApplication::desktop();
900
901 if (dw->isVirtualDesktop()) {
902 TDEConfigGroup group(TDEGlobal::config(), "Windows");
903 if (group.readBoolEntry("XineramaEnabled", true) &&
904 group.readBoolEntry("XineramaPlacementEnabled", true)) {
905 if (w)
906 return dw->screenGeometry(dw->screenNumber(w));
907 else return dw->screenGeometry(-1);
908 } else {
909 return dw->geometry();
910 }
911 } else {
912 return dw->geometry();
913 }
914}
915
916bool TDEGlobalSettings::showIconsOnPushButtons()
917{
918 TDEConfigGroup g( TDEGlobal::config(), "KDE" );
919 return g.readBoolEntry("ShowIconsOnPushButtons",
920 KDE_DEFAULT_ICON_ON_PUSHBUTTON);
921}
922
923bool TDEGlobalSettings::showFilePreview(const KURL &url)
924{
925 TDEConfigGroup g(TDEGlobal::config(), "PreviewSettings");
926 TQString protocol = url.protocol();
927 bool defaultSetting = KProtocolInfo::showFilePreview( protocol );
928 return g.readBoolEntry(protocol, defaultSetting );
929}
930
931bool TDEGlobalSettings::showKonqIconActivationEffect()
932{
933 TDEConfigGroup g( TDEGlobal::config(), "KDE" );
934 return g.readBoolEntry("ShowKonqIconActivationEffect",
935 KDE_DEFAULT_KONQ_ACTIVATION_EFFECT);
936}
937
938bool TDEGlobalSettings::opaqueResize()
939{
940 TDEConfigGroup g( TDEGlobal::config(), "KDE" );
941 return g.readBoolEntry("OpaqueResize",
942 KDE_DEFAULT_OPAQUE_RESIZE);
943}
944
945int TDEGlobalSettings::buttonLayout()
946{
947 TDEConfigGroup g( TDEGlobal::config(), "KDE" );
948 return g.readNumEntry("ButtonLayout",
949 KDE_DEFAULT_BUTTON_LAYOUT);
950}
KURL
Represents and parses a URL.
Definition: kurl.h:128
KURL::protocol
TQString protocol() const
Returns the protocol for the URL.
Definition: kurl.h:367
TDEConfigBase::readEntry
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
Definition: tdeconfigbase.cpp:221
TDEConfigBase::readColorEntry
TQColor readColorEntry(const TQString &pKey, const TQColor *pDefault=0L) const
Reads a TQColor entry.
Definition: tdeconfigbase.cpp:947
TDEConfigBase::readNumEntry
int readNumEntry(const TQString &pKey, int nDefault=0) const
Reads a numerical value.
Definition: tdeconfigbase.cpp:613
TDEConfigBase::readBoolEntry
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
Reads a boolean entry.
Definition: tdeconfigbase.cpp:748
TDEConfigBase::writePathEntry
void writePathEntry(const TQString &pKey, const TQString &path, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Writes a file path.
Definition: tdeconfigbase.cpp:1093
TDEConfigBase::sync
virtual void sync()
Flushes all changes that currently reside only in memory back to disk / permanent storage.
Definition: tdeconfigbase.cpp:1738
TDEConfigBase::readFontEntry
TQFont readFontEntry(const TQString &pKey, const TQFont *pDefault=0L) const
Reads a TQFont value.
Definition: tdeconfigbase.cpp:775
TDEConfigGroup
A TDEConfigBase derived class for one specific group in a TDEConfig object.
Definition: tdeconfigbase.h:2127
TDEConfig
Access KDE Configuration entries.
Definition: tdeconfig.h:44
TDEGlobalSettings::iconUseRoundedRect
static bool iconUseRoundedRect()
Returns whether icon text is drawn in a rounded style.
Definition: tdeglobalsettings.cpp:237
TDEGlobalSettings::showIconsOnPushButtons
static bool showIconsOnPushButtons()
This function determines if the user wishes to see icons on the push buttons.
Definition: tdeglobalsettings.cpp:916
TDEGlobalSettings::inactiveTextColor
static TQColor inactiveTextColor()
The default color to use for inactive texts.
Definition: tdeglobalsettings.cpp:328
TDEGlobalSettings::menuFont
static TQFont menuFont()
Returns the default menu font.
Definition: tdeglobalsettings.cpp:518
TDEGlobalSettings::baseColor
static TQColor baseColor()
Returns the default base (background) color.
Definition: tdeglobalsettings.cpp:386
TDEGlobalSettings::linkColor
static TQColor linkColor()
Returns the default link color.
Definition: tdeglobalsettings.cpp:453
TDEGlobalSettings::showContextMenusOnPress
static bool showContextMenusOnPress()
Returns the KDE setting for context menus.
Definition: tdeglobalsettings.cpp:296
TDEGlobalSettings::generalFont
static TQFont generalFont()
Returns the default general font.
Definition: tdeglobalsettings.cpp:470
TDEGlobalSettings::showFilePreview
static bool showFilePreview(const KURL &)
This function determines if the user wishes to see previews for the selected url.
Definition: tdeglobalsettings.cpp:923
TDEGlobalSettings::highlightedTextColor
static TQColor highlightedTextColor()
Returns the default color for highlighted text.
Definition: tdeglobalsettings.cpp:404
TDEGlobalSettings::shadeSortColumn
static bool shadeSortColumn()
Returns if the sorted column in a TDEListView shall be drawn with a shaded background color.
Definition: tdeglobalsettings.cpp:447
TDEGlobalSettings::isMultiHead
static bool isMultiHead()
Returns if the user specified multihead.
Definition: tdeglobalsettings.cpp:842
TDEGlobalSettings::highlightColor
static TQColor highlightColor()
Returns the default color for text highlights.
Definition: tdeglobalsettings.cpp:413
TDEGlobalSettings::buttonBackground
static TQColor buttonBackground()
Returns the button background color.
Definition: tdeglobalsettings.cpp:369
TDEGlobalSettings::showKonqIconActivationEffect
static bool showKonqIconActivationEffect()
This function determines if the user wishes to see icon activation effects in Konqueror or KDesktop.
Definition: tdeglobalsettings.cpp:931
TDEGlobalSettings::Completion
Completion
This enum describes the completion mode used for by the TDECompletion class.
Definition: tdeglobalsettings.h:178
TDEGlobalSettings::CompletionNone
@ CompletionNone
No completion is used.
Definition: tdeglobalsettings.h:182
TDEGlobalSettings::CompletionPopup
@ CompletionPopup
Lists all possible matches in a popup list-box to choose from.
Definition: tdeglobalsettings.h:198
TDEGlobalSettings::CompletionPopupAuto
@ CompletionPopupAuto
Lists all possible matches in a popup list-box to choose from, and automatically fill the result when...
Definition: tdeglobalsettings.h:203
TDEGlobalSettings::toolBarHighlightColor
static TQColor toolBarHighlightColor()
The default color to use when highlighting toolbar buttons.
Definition: tdeglobalsettings.cpp:309
TDEGlobalSettings::changeCursorOverIcon
static bool changeCursorOverIcon()
Checks whether the cursor changes over icons.
Definition: tdeglobalsettings.cpp:253
TDEGlobalSettings::contrast
static int contrast()
Returns the contrast for borders.
Definition: tdeglobalsettings.cpp:363
TDEGlobalSettings::buttonLayout
static int buttonLayout()
The layout scheme to use for dialog buttons.
Definition: tdeglobalsettings.cpp:945
TDEGlobalSettings::fixedFont
static TQFont fixedFont()
Returns the default fixed font.
Definition: tdeglobalsettings.cpp:486
TDEGlobalSettings::activeTextColor
static TQColor activeTextColor()
The default color to use for active texts.
Definition: tdeglobalsettings.cpp:353
TDEGlobalSettings::visualActivateSpeed
static unsigned int visualActivateSpeed()
Returns the speed of the visual activation feedback.
Definition: tdeglobalsettings.cpp:265
TDEGlobalSettings::calculateAlternateBackgroundColor
static TQColor calculateAlternateBackgroundColor(const TQColor &base)
Calculates a color based on base to be used as alternating color for e.g.
Definition: tdeglobalsettings.cpp:430
TDEGlobalSettings::opaqueResize
static bool opaqueResize()
Whether the user wishes to use opaque resizing.
Definition: tdeglobalsettings.cpp:938
TDEGlobalSettings::largeFont
static TQFont largeFont(const TQString &text=TQString::null)
Returns a font of approx.
Definition: tdeglobalsettings.cpp:567
TDEGlobalSettings::alternateBackgroundColor
static TQColor alternateBackgroundColor()
Returns the alternate background color used by TDEListView with TDEListViewItem.
Definition: tdeglobalsettings.cpp:422
TDEGlobalSettings::autoSelectDelay
static int autoSelectDelay()
Returns the KDE setting for the auto-select option.
Definition: tdeglobalsettings.cpp:277
TDEGlobalSettings::activeTitleColor
static TQColor activeTitleColor()
The default color to use for active titles.
Definition: tdeglobalsettings.cpp:340
TDEGlobalSettings::mouseSettings
static KMouseSettings & mouseSettings()
This returns the current mouse settings.
Definition: tdeglobalsettings.cpp:784
TDEGlobalSettings::textColor
static TQColor textColor()
Returns the default text color.
Definition: tdeglobalsettings.cpp:395
TDEGlobalSettings::visitedLinkColor
static TQColor visitedLinkColor()
Returns the default color for visited links.
Definition: tdeglobalsettings.cpp:462
TDEGlobalSettings::singleClick
static bool singleClick()
Returns whether KDE runs in single (default) or double click mode.
Definition: tdeglobalsettings.cpp:231
TDEGlobalSettings::splashScreenDesktopGeometry
static TQRect splashScreenDesktopGeometry()
This function returns the desktop geometry for an application's splash screen.
Definition: tdeglobalsettings.cpp:861
TDEGlobalSettings::insertTearOffHandle
static TearOffHandle insertTearOffHandle()
Returns whether tear-off handles are inserted in TDEPopupMenus.
Definition: tdeglobalsettings.cpp:243
TDEGlobalSettings::TearOffHandle
TearOffHandle
This enum describes the return type for insertTearOffHandle() whether to insert a handle or not.
Definition: tdeglobalsettings.h:117
TDEGlobalSettings::Disable
@ Disable
disable tear-off handles
Definition: tdeglobalsettings.h:118
TDEGlobalSettings::visualActivate
static bool visualActivate()
Checks whether to show feedback when in item (specifically an icon) is activated.
Definition: tdeglobalsettings.cpp:259
TDEGlobalSettings::contextMenuKey
static int contextMenuKey()
Returns the KDE setting for the shortcut key to open context menus.
Definition: tdeglobalsettings.cpp:302
TDEGlobalSettings::completionMode
static Completion completionMode()
Returns the preferred completion mode setting.
Definition: tdeglobalsettings.cpp:283
TDEGlobalSettings::wheelMouseZooms
static bool wheelMouseZooms()
Typically, TQScrollView derived classes can be scrolled fast by holding down the Ctrl-button during w...
Definition: tdeglobalsettings.cpp:855
TDEGlobalSettings::toolBarFont
static TQFont toolBarFont()
Returns the default toolbar font.
Definition: tdeglobalsettings.cpp:502
TDEGlobalSettings::buttonTextColor
static TQColor buttonTextColor()
Returns the button text color.
Definition: tdeglobalsettings.cpp:377
TDEGlobalSettings::desktopGeometry
static TQRect desktopGeometry(const TQPoint &point)
This function returns the desktop geometry for an application that needs to set the geometry of a wid...
Definition: tdeglobalsettings.cpp:880
TDEGlobalSettings::inactiveTitleColor
static TQColor inactiveTitleColor()
The default color to use for inactive titles.
Definition: tdeglobalsettings.cpp:316
TDEGlobalSettings::dndEventDelay
static int dndEventDelay()
Returns a threshold in pixels for drag & drop operations.
Definition: tdeglobalsettings.cpp:225
TDEGlobalSettings::windowTitleFont
static TQFont windowTitleFont()
Returns the default window title font.
Definition: tdeglobalsettings.cpp:534
TDEGlobalSettings::taskbarFont
static TQFont taskbarFont()
Returns the default taskbar font.
Definition: tdeglobalsettings.cpp:550
TDEGlobal::config
static TDEConfig * config()
Returns the general config object.
Definition: tdeglobal.cpp:65
TDEGlobal::dirs
static TDEStandardDirs * dirs()
Returns the application standard dirs object.
Definition: tdeglobal.cpp:58
TDELocale::i18n
TQString i18n(const char *text)
i18n is the function that does everything you need to translate a string.
Definition: tdelocale.cpp:1976
TDEShortcut
The TDEShortcut class is used to represent a keyboard shortcut to an action.
Definition: tdeshortcut.h:544
TDEStandardDirs::localtdedir
TQString localtdedir() const
Returns the toplevel directory in which TDEStandardDirs will store things.
Definition: tdestandarddirs.cpp:1669
TDEStandardDirs::makeDir
static bool makeDir(const TQString &dir, int mode=0755)
Recursively creates still-missing directories in the given path.
Definition: tdestandarddirs.cpp:1176
endl
kndbgstream & endl(kndbgstream &s)
Does nothing.
Definition: kdebug.h:583
TDEGlobalSettings::KMouseSettings
Describes the mouse settings.
Definition: tdeglobalsettings.h:217
tdelocale.h

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.