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

kdecore

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

kdecore

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

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |