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

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