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

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.8.13
This website is maintained by Timothy Pearson.