• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • sources
  • kde-4.14
  • kdelibs
  • kdeui
  • kernel
kglobalsettings.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2000, 2006 David Faure <faure@kde.org>
3  Copyright 2008 Friedrich W. H. Kossebau <kossebau@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "kglobalsettings.h"
21 #include <config.h>
22 
23 #include <kconfig.h>
24 
25 #include <kdebug.h>
26 #include <kglobal.h>
27 #include <klocale.h>
28 #include <kstandarddirs.h>
29 #include <kprotocolinfo.h>
30 #include <kcolorscheme.h>
31 
32 #include <kstyle.h>
33 
34 #include <QtGui/QColor>
35 #include <QtGui/QCursor>
36 #include <QtGui/QDesktopWidget>
37 #include <QtCore/QDir>
38 #include <QtGui/QFont>
39 #include <QtGui/QFontDatabase>
40 #include <QtGui/QFontInfo>
41 #include <QtGui/QKeySequence>
42 #include <QtGui/QPixmap>
43 #include <QtGui/QPixmapCache>
44 #include <QApplication>
45 #include <QtDBus/QtDBus>
46 #include <QtGui/QStyleFactory>
47 #include <QDesktopServices>
48 #include "qplatformdefs.h"
49 
50 // next two needed so we can set their palettes
51 #include <QtGui/QToolTip>
52 #include <QtGui/QWhatsThis>
53 
54 #ifdef Q_WS_WIN
55 #include <windows.h>
56 #include <kkernel_win.h>
57 
58 static QRgb qt_colorref2qrgb(COLORREF col)
59 {
60  return qRgb(GetRValue(col),GetGValue(col),GetBValue(col));
61 }
62 #endif
63 #ifdef Q_WS_X11
64 #include <X11/Xlib.h>
65 #ifdef HAVE_XCURSOR
66 #include <X11/Xcursor/Xcursor.h>
67 #endif
68 #include "fixx11h.h"
69 #include <QX11Info>
70 #endif
71 
72 #include <stdlib.h>
73 #include <kconfiggroup.h>
74 
75 
76 //static QColor *_buttonBackground = 0;
77 static KGlobalSettings::GraphicEffects _graphicEffects = KGlobalSettings::NoEffects;
78 
79 // TODO: merge this with KGlobalSettings::Private
80 //
81 // F. Kossebau: KDE5: think to make all methods static and not expose an object,
82 // making KGlobalSettings rather a namespace
83 // D. Faure: how would people connect to signals, then?
84 class KGlobalSettingsData
85 {
86  public:
87  // if adding a new type here also add an entry to DefaultFontData
88  enum FontTypes
89  {
90  GeneralFont = 0,
91  FixedFont,
92  ToolbarFont,
93  MenuFont,
94  WindowTitleFont,
95  TaskbarFont ,
96  SmallestReadableFont,
97  FontTypesCount
98  };
99 
100  public:
101  KGlobalSettingsData();
102  ~KGlobalSettingsData();
103 
104  public:
105  static KGlobalSettingsData* self();
106 
107  public: // access, is not const due to caching
108  QFont font( FontTypes fontType );
109  QFont largeFont( const QString& text );
110  KGlobalSettings::KMouseSettings& mouseSettings();
111 
112  public:
113  void dropFontSettingsCache();
114  void dropMouseSettingsCache();
115 
116  protected:
117  QFont* mFonts[FontTypesCount];
118  QFont* mLargeFont;
119  KGlobalSettings::KMouseSettings* mMouseSettings;
120 };
121 
122 KGlobalSettingsData::KGlobalSettingsData()
123  : mLargeFont( 0 ),
124  mMouseSettings( 0 )
125 {
126  for( int i=0; i<FontTypesCount; ++i )
127  mFonts[i] = 0;
128 }
129 
130 KGlobalSettingsData::~KGlobalSettingsData()
131 {
132  for( int i=0; i<FontTypesCount; ++i )
133  delete mFonts[i];
134  delete mLargeFont;
135 
136  delete mMouseSettings;
137 }
138 
139 K_GLOBAL_STATIC( KGlobalSettingsData, globalSettingsDataSingleton )
140 
141 inline KGlobalSettingsData* KGlobalSettingsData::self()
142 {
143  return globalSettingsDataSingleton;
144 }
145 
146 
147 class KGlobalSettings::Private
148 {
149  public:
150  Private(KGlobalSettings *q)
151  : q(q), activated(false), paletteCreated(false)
152  {
153  kdeFullSession = !qgetenv("KDE_FULL_SESSION").isEmpty();
154  }
155 
156  QPalette createApplicationPalette(const KSharedConfigPtr &config);
157  QPalette createNewApplicationPalette(const KSharedConfigPtr &config);
158  void _k_slotNotifyChange(int, int);
159 
160  void propagateQtSettings();
161  void kdisplaySetPalette();
162  void kdisplaySetStyle();
163  void kdisplaySetFont();
164  void applyGUIStyle();
165 
177  void applyCursorTheme();
178 
179  static void reloadStyleSettings();
180 
181  KGlobalSettings *q;
182  bool activated;
183  bool paletteCreated;
184  bool kdeFullSession;
185  QPalette applicationPalette;
186 };
187 
188 KGlobalSettings* KGlobalSettings::self()
189 {
190  K_GLOBAL_STATIC(KGlobalSettings, s_self)
191  return s_self;
192 }
193 
194 KGlobalSettings::KGlobalSettings()
195  : QObject(0), d(new Private(this))
196 {
197 }
198 
199 KGlobalSettings::~KGlobalSettings()
200 {
201  delete d;
202 }
203 
204 void KGlobalSettings::activate()
205 {
206  activate(ApplySettings | ListenForChanges);
207 }
208 
209 void KGlobalSettings::activate(ActivateOptions options)
210 {
211  if (!d->activated) {
212  d->activated = true;
213 
214  if (options & ListenForChanges) {
215  QDBusConnection::sessionBus().connect( QString(), "/KGlobalSettings", "org.kde.KGlobalSettings",
216  "notifyChange", this, SLOT(_k_slotNotifyChange(int,int)) );
217  }
218 
219  if (options & ApplySettings) {
220  d->kdisplaySetStyle(); // implies palette setup
221  d->kdisplaySetFont();
222  d->propagateQtSettings();
223  }
224  }
225 }
226 
227 int KGlobalSettings::dndEventDelay()
228 {
229  KConfigGroup g( KGlobal::config(), "General" );
230  return g.readEntry("StartDragDist", QApplication::startDragDistance());
231 }
232 
233 bool KGlobalSettings::singleClick()
234 {
235  KConfigGroup g( KGlobal::config(), "KDE" );
236  return g.readEntry("SingleClick", KDE_DEFAULT_SINGLECLICK );
237 }
238 
239 bool KGlobalSettings::smoothScroll()
240 {
241  KConfigGroup g( KGlobal::config(), "KDE" );
242  return g.readEntry("SmoothScroll", KDE_DEFAULT_SMOOTHSCROLL );
243 }
244 
245 KGlobalSettings::TearOffHandle KGlobalSettings::insertTearOffHandle()
246 {
247  int tearoff;
248  bool effectsenabled;
249  KConfigGroup g( KGlobal::config(), "KDE" );
250  effectsenabled = g.readEntry( "EffectsEnabled", false);
251  tearoff = g.readEntry("InsertTearOffHandle", KDE_DEFAULT_INSERTTEAROFFHANDLES);
252  return effectsenabled ? (TearOffHandle) tearoff : Disable;
253 }
254 
255 bool KGlobalSettings::changeCursorOverIcon()
256 {
257  KConfigGroup g( KGlobal::config(), "KDE" );
258  return g.readEntry("ChangeCursor", KDE_DEFAULT_CHANGECURSOR);
259 }
260 
261 int KGlobalSettings::autoSelectDelay()
262 {
263  KConfigGroup g( KGlobal::config(), "KDE" );
264  return g.readEntry("AutoSelectDelay", KDE_DEFAULT_AUTOSELECTDELAY);
265 }
266 
267 KGlobalSettings::Completion KGlobalSettings::completionMode()
268 {
269  int completion;
270  KConfigGroup g( KGlobal::config(), "General" );
271  completion = g.readEntry("completionMode", -1);
272  if ((completion < (int) CompletionNone) ||
273  (completion > (int) CompletionPopupAuto))
274  {
275  completion = (int) CompletionPopup; // Default
276  }
277  return (Completion) completion;
278 }
279 
280 bool KGlobalSettings::showContextMenusOnPress ()
281 {
282  KConfigGroup g(KGlobal::config(), "ContextMenus");
283  return g.readEntry("ShowOnPress", true);
284 }
285 
286 #ifndef KDE_NO_DEPRECATED
287 int KGlobalSettings::contextMenuKey ()
288 {
289  KConfigGroup g(KGlobal::config(), "Shortcuts");
290  QString s = g.readEntry ("PopupMenuContext", "Menu");
291 
292  // this is a bit of a code duplication with KShortcut,
293  // but seeing as that is all in kdeui these days there's little choice.
294  // this is faster for what we're really after here anyways
295  // (less allocations, only processing the first item always, etc)
296  if (s == QLatin1String("none")) {
297  return QKeySequence()[0];
298  }
299 
300  const QStringList shortCuts = s.split(';');
301 
302  if (shortCuts.count() < 1) {
303  return QKeySequence()[0];
304  }
305 
306  s = shortCuts.at(0);
307 
308  if ( s.startsWith( QLatin1String("default(") ) ) {
309  s = s.mid( 8, s.length() - 9 );
310  }
311 
312  return QKeySequence::fromString(s)[0];
313 }
314 #endif
315 
316 // NOTE: keep this in sync with kdebase/workspace/kcontrol/colors/colorscm.cpp
317 QColor KGlobalSettings::inactiveTitleColor()
318 {
319 #ifdef Q_WS_WIN
320  return qt_colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTION));
321 #else
322  KConfigGroup g( KGlobal::config(), "WM" );
323  return g.readEntry( "inactiveBackground", QColor(224,223,222) );
324 #endif
325 }
326 
327 // NOTE: keep this in sync with kdebase/workspace/kcontrol/colors/colorscm.cpp
328 QColor KGlobalSettings::inactiveTextColor()
329 {
330 #ifdef Q_WS_WIN
331  return qt_colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTIONTEXT));
332 #else
333  KConfigGroup g( KGlobal::config(), "WM" );
334  return g.readEntry( "inactiveForeground", QColor(75,71,67) );
335 #endif
336 }
337 
338 // NOTE: keep this in sync with kdebase/workspace/kcontrol/colors/colorscm.cpp
339 QColor KGlobalSettings::activeTitleColor()
340 {
341 #ifdef Q_WS_WIN
342  return qt_colorref2qrgb(GetSysColor(COLOR_ACTIVECAPTION));
343 #else
344  KConfigGroup g( KGlobal::config(), "WM" );
345  return g.readEntry( "activeBackground", QColor(48,174,232));
346 #endif
347 }
348 
349 // NOTE: keep this in sync with kdebase/workspace/kcontrol/colors/colorscm.cpp
350 QColor KGlobalSettings::activeTextColor()
351 {
352 #ifdef Q_WS_WIN
353  return qt_colorref2qrgb(GetSysColor(COLOR_CAPTIONTEXT));
354 #else
355  KConfigGroup g( KGlobal::config(), "WM" );
356  return g.readEntry( "activeForeground", QColor(255,255,255) );
357 #endif
358 }
359 
360 int KGlobalSettings::contrast()
361 {
362  KConfigGroup g( KGlobal::config(), "KDE" );
363  return g.readEntry( "contrast", 7 );
364 }
365 
366 qreal KGlobalSettings::contrastF(const KSharedConfigPtr &config)
367 {
368  if (config) {
369  KConfigGroup g( config, "KDE" );
370  return 0.1 * g.readEntry( "contrast", 7 );
371  }
372  return 0.1 * (qreal)contrast();
373 }
374 
375 bool KGlobalSettings::shadeSortColumn()
376 {
377  KConfigGroup g( KGlobal::config(), "General" );
378  return g.readEntry( "shadeSortColumn", KDE_DEFAULT_SHADE_SORT_COLUMN );
379 }
380 
381 bool KGlobalSettings::allowDefaultBackgroundImages()
382 {
383  KConfigGroup g( KGlobal::config(), "General" );
384  return g.readEntry( "allowDefaultBackgroundImages", KDE_DEFAULT_ALLOW_DEFAULT_BACKGROUND_IMAGES );
385 }
386 
387 struct KFontData
388 {
389  const char* ConfigGroupKey;
390  const char* ConfigKey;
391  const char* FontName;
392  int Size;
393  int Weight;
394  QFont::StyleHint StyleHint;
395 };
396 
397 // NOTE: keep in sync with kdebase/workspace/kcontrol/fonts/fonts.cpp
398 static const char GeneralId[] = "General";
399 static const char DefaultFont[] = "Sans Serif";
400 #ifdef Q_WS_MAC
401 static const char DefaultMacFont[] = "Lucida Grande";
402 #endif
403 
404 static const KFontData DefaultFontData[KGlobalSettingsData::FontTypesCount] =
405 {
406 #ifdef Q_WS_MAC
407  { GeneralId, "font", DefaultMacFont, 13, -1, QFont::SansSerif },
408  { GeneralId, "fixed", "Monaco", 10, -1, QFont::TypeWriter },
409  { GeneralId, "toolBarFont", DefaultMacFont, 11, -1, QFont::SansSerif },
410  { GeneralId, "menuFont", DefaultMacFont, 13, -1, QFont::SansSerif },
411 #elif defined(Q_WS_MAEMO_5) || defined(MEEGO_EDITION_HARMATTAN)
412  { GeneralId, "font", DefaultFont, 16, -1, QFont::SansSerif },
413  { GeneralId, "fixed", "Monospace", 16, -1, QFont::TypeWriter },
414  { GeneralId, "toolBarFont", DefaultFont, 16, -1, QFont::SansSerif },
415  { GeneralId, "menuFont", DefaultFont, 16, -1, QFont::SansSerif },
416 #else
417  { GeneralId, "font", DefaultFont, 9, -1, QFont::SansSerif },
418  { GeneralId, "fixed", "Monospace", 9, -1, QFont::TypeWriter },
419  { GeneralId, "toolBarFont", DefaultFont, 8, -1, QFont::SansSerif },
420  { GeneralId, "menuFont", DefaultFont, 9, -1, QFont::SansSerif },
421 #endif
422  { "WM", "activeFont", DefaultFont, 8, -1, QFont::SansSerif },
423  { GeneralId, "taskbarFont", DefaultFont, 9, -1, QFont::SansSerif },
424  { GeneralId, "smallestReadableFont", DefaultFont, 8, -1, QFont::SansSerif }
425 };
426 
427 QFont KGlobalSettingsData::font( FontTypes fontType )
428 {
429  QFont* cachedFont = mFonts[fontType];
430 
431  if (!cachedFont)
432  {
433  const KFontData& fontData = DefaultFontData[fontType];
434  cachedFont = new QFont( fontData.FontName, fontData.Size, fontData.Weight );
435  cachedFont->setStyleHint( fontData.StyleHint );
436 
437  const KConfigGroup configGroup( KGlobal::config(), fontData.ConfigGroupKey );
438  *cachedFont = configGroup.readEntry( fontData.ConfigKey, *cachedFont );
439 
440  mFonts[fontType] = cachedFont;
441  }
442 
443  return *cachedFont;
444 }
445 
446 QFont KGlobalSettings::generalFont()
447 {
448  return KGlobalSettingsData::self()->font( KGlobalSettingsData::GeneralFont );
449 }
450 QFont KGlobalSettings::fixedFont()
451 {
452  return KGlobalSettingsData::self()->font( KGlobalSettingsData::FixedFont );
453 }
454 QFont KGlobalSettings::toolBarFont()
455 {
456  return KGlobalSettingsData::self()->font( KGlobalSettingsData::ToolbarFont );
457 }
458 QFont KGlobalSettings::menuFont()
459 {
460  return KGlobalSettingsData::self()->font( KGlobalSettingsData::MenuFont );
461 }
462 QFont KGlobalSettings::windowTitleFont()
463 {
464  return KGlobalSettingsData::self()->font( KGlobalSettingsData::WindowTitleFont );
465 }
466 QFont KGlobalSettings::taskbarFont()
467 {
468  return KGlobalSettingsData::self()->font( KGlobalSettingsData::TaskbarFont );
469 }
470 QFont KGlobalSettings::smallestReadableFont()
471 {
472  return KGlobalSettingsData::self()->font( KGlobalSettingsData::SmallestReadableFont );
473 }
474 
475 
476 QFont KGlobalSettingsData::largeFont( const QString& text )
477 {
478  QFontDatabase db;
479  QStringList fam = db.families();
480 
481  // Move a bunch of preferred fonts to the front.
482  // most preferred last
483  static const char* const PreferredFontNames[] =
484  {
485  "Arial",
486  "Sans Serif",
487  "Verdana",
488  "Tahoma",
489  "Lucida Sans",
490  "Lucidux Sans",
491  "Nimbus Sans",
492  "Gothic I"
493  };
494  static const unsigned int PreferredFontNamesCount = sizeof(PreferredFontNames)/sizeof(const char*);
495  for( unsigned int i=0; i<PreferredFontNamesCount; ++i )
496  {
497  const QString fontName (PreferredFontNames[i]);
498  if (fam.removeAll(fontName)>0)
499  fam.prepend(fontName);
500  }
501 
502  if (mLargeFont) {
503  fam.prepend(mLargeFont->family());
504  delete mLargeFont;
505  }
506 
507  for(QStringList::ConstIterator it = fam.constBegin();
508  it != fam.constEnd(); ++it)
509  {
510  if (db.isSmoothlyScalable(*it) && !db.isFixedPitch(*it))
511  {
512  QFont font(*it);
513  font.setPixelSize(75);
514  QFontMetrics metrics(font);
515  int h = metrics.height();
516  if ((h < 60) || ( h > 90))
517  continue;
518 
519  bool ok = true;
520  for(int i = 0; i < text.length(); i++)
521  {
522  if (!metrics.inFont(text[i]))
523  {
524  ok = false;
525  break;
526  }
527  }
528  if (!ok)
529  continue;
530 
531  font.setPointSize(48);
532  mLargeFont = new QFont(font);
533  return *mLargeFont;
534  }
535  }
536  mLargeFont = new QFont( font(GeneralFont) );
537  mLargeFont->setPointSize(48);
538  return *mLargeFont;
539 }
540 QFont KGlobalSettings::largeFont( const QString& text )
541 {
542  return KGlobalSettingsData::self()->largeFont( text );
543 }
544 
545 void KGlobalSettingsData::dropFontSettingsCache()
546 {
547  for( int i=0; i<FontTypesCount; ++i )
548  {
549  delete mFonts[i];
550  mFonts[i] = 0;
551  }
552  delete mLargeFont;
553  mLargeFont = 0;
554 }
555 
556 KGlobalSettings::KMouseSettings& KGlobalSettingsData::mouseSettings()
557 {
558  if (!mMouseSettings)
559  {
560  mMouseSettings = new KGlobalSettings::KMouseSettings;
561  KGlobalSettings::KMouseSettings& s = *mMouseSettings; // for convenience
562 
563 #ifndef Q_WS_WIN
564  KConfigGroup g( KGlobal::config(), "Mouse" );
565  QString setting = g.readEntry("MouseButtonMapping");
566  if (setting == "RightHanded")
567  s.handed = KGlobalSettings::KMouseSettings::RightHanded;
568  else if (setting == "LeftHanded")
569  s.handed = KGlobalSettings::KMouseSettings::LeftHanded;
570  else
571  {
572 #ifdef Q_WS_X11
573  // get settings from X server
574  // This is a simplified version of the code in input/mouse.cpp
575  // Keep in sync !
576  s.handed = KGlobalSettings::KMouseSettings::RightHanded;
577  unsigned char map[20];
578  int num_buttons = XGetPointerMapping(QX11Info::display(), map, 20);
579  if( num_buttons == 2 )
580  {
581  if ( (int)map[0] == 1 && (int)map[1] == 2 )
582  s.handed = KGlobalSettings::KMouseSettings::RightHanded;
583  else if ( (int)map[0] == 2 && (int)map[1] == 1 )
584  s.handed = KGlobalSettings::KMouseSettings::LeftHanded;
585  }
586  else if( num_buttons >= 3 )
587  {
588  if ( (int)map[0] == 1 && (int)map[2] == 3 )
589  s.handed = KGlobalSettings::KMouseSettings::RightHanded;
590  else if ( (int)map[0] == 3 && (int)map[2] == 1 )
591  s.handed = KGlobalSettings::KMouseSettings::LeftHanded;
592  }
593 #else
594  // FIXME: Implement on other platforms
595 #endif
596  }
597 #endif //Q_WS_WIN
598  }
599 #ifdef Q_WS_WIN
600  //not cached
601 #ifndef _WIN32_WCE
602  mMouseSettings->handed = (GetSystemMetrics(SM_SWAPBUTTON) ?
603  KGlobalSettings::KMouseSettings::LeftHanded :
604  KGlobalSettings::KMouseSettings::RightHanded);
605 #else
606 // There is no mice under wince
607  mMouseSettings->handed =KGlobalSettings::KMouseSettings::RightHanded;
608 #endif
609 #endif
610  return *mMouseSettings;
611 }
612 // KDE5: make this a const return?
613 KGlobalSettings::KMouseSettings & KGlobalSettings::mouseSettings()
614 {
615  return KGlobalSettingsData::self()->mouseSettings();
616 }
617 
618 void KGlobalSettingsData::dropMouseSettingsCache()
619 {
620 #ifndef Q_WS_WIN
621  delete mMouseSettings;
622  mMouseSettings = 0;
623 #endif
624 }
625 
626 QString KGlobalSettings::desktopPath()
627 {
628  QString path = QDesktopServices::storageLocation( QDesktopServices::DesktopLocation );
629  return path.isEmpty() ? QDir::homePath() : path;
630 }
631 
632 // Autostart is not a XDG path, so we have our own code for it.
633 QString KGlobalSettings::autostartPath()
634 {
635  QString s_autostartPath;
636  KConfigGroup g( KGlobal::config(), "Paths" );
637  s_autostartPath = KGlobal::dirs()->localkdedir() + "Autostart/";
638  s_autostartPath = g.readPathEntry( "Autostart" , s_autostartPath );
639  s_autostartPath = QDir::cleanPath( s_autostartPath );
640  if ( !s_autostartPath.endsWith( '/' ) ) {
641  s_autostartPath.append( QLatin1Char( '/' ) );
642  }
643  return s_autostartPath;
644 }
645 
646 QString KGlobalSettings::documentPath()
647 {
648  QString path = QDesktopServices::storageLocation( QDesktopServices::DocumentsLocation );
649  return path.isEmpty() ? QDir::homePath() : path;
650 }
651 
652 QString KGlobalSettings::downloadPath()
653 {
654  // Qt 4.x does not have QDesktopServices::DownloadLocation, so we do our own xdg reading.
655  QString defaultDownloadPath = QDir::homePath() + "/Downloads";
656  QString downloadPath = defaultDownloadPath;
657 #ifndef Q_WS_WIN
658  const QString xdgUserDirs = KGlobal::dirs()->localxdgconfdir() + QLatin1String( "user-dirs.dirs" );
659  if( QFile::exists( xdgUserDirs ) ) {
660  KConfig xdgUserConf( xdgUserDirs, KConfig::SimpleConfig );
661  KConfigGroup g( &xdgUserConf, "" );
662  downloadPath = g.readPathEntry( "XDG_DOWNLOAD_DIR", downloadPath ).remove( '"' );
663  if ( downloadPath.isEmpty() ) {
664  downloadPath = defaultDownloadPath;
665  }
666  }
667 #endif
668  downloadPath = QDir::cleanPath( downloadPath );
669  QDir().mkpath(downloadPath);
670  if ( !downloadPath.endsWith( '/' ) ) {
671  downloadPath.append( QLatin1Char( '/' ) );
672  }
673  return downloadPath;
674 }
675 
676 QString KGlobalSettings::videosPath()
677 {
678  QString path = QDesktopServices::storageLocation( QDesktopServices::MoviesLocation );
679  return path.isEmpty() ? QDir::homePath() : path;
680 }
681 
682 QString KGlobalSettings::picturesPath()
683 {
684  QString path = QDesktopServices::storageLocation( QDesktopServices::PicturesLocation );
685  return path.isEmpty() ? QDir::homePath() :path;
686 }
687 
688 QString KGlobalSettings::musicPath()
689 {
690  QString path = QDesktopServices::storageLocation( QDesktopServices::MusicLocation );
691  return path.isEmpty() ? QDir::homePath() : path;
692 }
693 
694 bool KGlobalSettings::isMultiHead()
695 {
696 #ifdef Q_WS_WIN
697  return GetSystemMetrics(SM_CMONITORS) > 1;
698 #else
699  QByteArray multiHead = qgetenv("KDE_MULTIHEAD");
700  if (!multiHead.isEmpty()) {
701  return (multiHead.toLower() == "true");
702  }
703  return false;
704 #endif
705 }
706 
707 bool KGlobalSettings::wheelMouseZooms()
708 {
709  KConfigGroup g( KGlobal::config(), "KDE" );
710  return g.readEntry( "WheelMouseZooms", KDE_DEFAULT_WHEEL_ZOOM );
711 }
712 
713 QRect KGlobalSettings::splashScreenDesktopGeometry()
714 {
715  QDesktopWidget *dw = QApplication::desktop();
716 
717  if (dw->isVirtualDesktop()) {
718  KConfigGroup group(KGlobal::config(), "Windows");
719  int scr = group.readEntry("Unmanaged", -3);
720  if (group.readEntry("XineramaEnabled", true) && scr != -2) {
721  if (scr == -3)
722  scr = dw->screenNumber(QCursor::pos());
723  return dw->screenGeometry(scr);
724  } else {
725  return dw->geometry();
726  }
727  } else {
728  return dw->geometry();
729  }
730 }
731 
732 QRect KGlobalSettings::desktopGeometry(const QPoint& point)
733 {
734  QDesktopWidget *dw = QApplication::desktop();
735 
736  if (dw->isVirtualDesktop()) {
737  KConfigGroup group(KGlobal::config(), "Windows");
738  if (group.readEntry("XineramaEnabled", true) &&
739  group.readEntry("XineramaPlacementEnabled", true)) {
740  return dw->screenGeometry(dw->screenNumber(point));
741  } else {
742  return dw->geometry();
743  }
744  } else {
745  return dw->geometry();
746  }
747 }
748 
749 QRect KGlobalSettings::desktopGeometry(const QWidget* w)
750 {
751  QDesktopWidget *dw = QApplication::desktop();
752 
753  if (dw->isVirtualDesktop()) {
754  KConfigGroup group(KGlobal::config(), "Windows");
755  if (group.readEntry("XineramaEnabled", true) &&
756  group.readEntry("XineramaPlacementEnabled", true)) {
757  if (w)
758  return dw->screenGeometry(dw->screenNumber(w));
759  else return dw->screenGeometry(-1);
760  } else {
761  return dw->geometry();
762  }
763  } else {
764  return dw->geometry();
765  }
766 }
767 
768 bool KGlobalSettings::showIconsOnPushButtons()
769 {
770  KConfigGroup g( KGlobal::config(), "KDE" );
771  return g.readEntry("ShowIconsOnPushButtons",
772  KDE_DEFAULT_ICON_ON_PUSHBUTTON);
773 }
774 
775 bool KGlobalSettings::naturalSorting()
776 {
777  KConfigGroup g( KGlobal::config(), "KDE" );
778  return g.readEntry("NaturalSorting",
779  KDE_DEFAULT_NATURAL_SORTING);
780 }
781 
782 KGlobalSettings::GraphicEffects KGlobalSettings::graphicEffectsLevel()
783 {
784  // This variable stores whether _graphicEffects has the default value because it has not been
785  // loaded yet, or if it has been loaded from the user settings or defaults and contains a valid
786  // value.
787  static bool _graphicEffectsInitialized = false;
788 
789  if (!_graphicEffectsInitialized) {
790  _graphicEffectsInitialized = true;
791  Private::reloadStyleSettings();
792  }
793 
794  return _graphicEffects;
795 }
796 
797 KGlobalSettings::GraphicEffects KGlobalSettings::graphicEffectsLevelDefault()
798 {
799  // For now, let always enable animations by default. The plan is to make
800  // this code a bit smarter. (ereslibre)
801 
802  return ComplexAnimationEffects;
803 }
804 
805 bool KGlobalSettings::showFilePreview(const KUrl &url)
806 {
807  KConfigGroup g(KGlobal::config(), "PreviewSettings");
808  QString protocol = url.protocol();
809  bool defaultSetting = KProtocolInfo::showFilePreview( protocol );
810  return g.readEntry(protocol, defaultSetting );
811 }
812 
813 bool KGlobalSettings::opaqueResize()
814 {
815  KConfigGroup g( KGlobal::config(), "KDE" );
816  return g.readEntry("OpaqueResize", KDE_DEFAULT_OPAQUE_RESIZE);
817 }
818 
819 int KGlobalSettings::buttonLayout()
820 {
821  KConfigGroup g( KGlobal::config(), "KDE" );
822  return g.readEntry("ButtonLayout", KDE_DEFAULT_BUTTON_LAYOUT);
823 }
824 
825 void KGlobalSettings::emitChange(ChangeType changeType, int arg)
826 {
827  QDBusMessage message = QDBusMessage::createSignal("/KGlobalSettings", "org.kde.KGlobalSettings", "notifyChange" );
828  QList<QVariant> args;
829  args.append(static_cast<int>(changeType));
830  args.append(arg);
831  message.setArguments(args);
832  QDBusConnection::sessionBus().send(message);
833 #ifdef Q_WS_X11
834  if (qApp && qApp->type() != QApplication::Tty) {
835  //notify non-kde qt applications of the change
836  extern void qt_x11_apply_settings_in_all_apps();
837  qt_x11_apply_settings_in_all_apps();
838  }
839 #endif
840 }
841 
842 void KGlobalSettings::Private::_k_slotNotifyChange(int changeType, int arg)
843 {
844  switch(changeType) {
845  case StyleChanged:
846  if (activated) {
847  KGlobal::config()->reparseConfiguration();
848  kdisplaySetStyle();
849  }
850  break;
851 
852  case ToolbarStyleChanged:
853  KGlobal::config()->reparseConfiguration();
854  emit q->toolbarAppearanceChanged(arg);
855  break;
856 
857  case PaletteChanged:
858  if (activated) {
859  KGlobal::config()->reparseConfiguration();
860  paletteCreated = false;
861  kdisplaySetPalette();
862  }
863  break;
864 
865  case FontChanged:
866  KGlobal::config()->reparseConfiguration();
867  KGlobalSettingsData::self()->dropFontSettingsCache();
868  if (activated) {
869  kdisplaySetFont();
870  }
871  break;
872 
873  case SettingsChanged: {
874  KGlobal::config()->reparseConfiguration();
875  SettingsCategory category = static_cast<SettingsCategory>(arg);
876  if (category == SETTINGS_QT) {
877  if (activated) {
878  propagateQtSettings();
879  }
880  } else {
881  switch (category) {
882  case SETTINGS_STYLE:
883  reloadStyleSettings();
884  break;
885  case SETTINGS_MOUSE:
886  KGlobalSettingsData::self()->dropMouseSettingsCache();
887  break;
888  case SETTINGS_LOCALE:
889  KGlobal::locale()->reparseConfiguration();
890  break;
891  default:
892  break;
893  }
894  emit q->settingsChanged(category);
895  }
896  break;
897  }
898  case IconChanged:
899  QPixmapCache::clear();
900  KGlobal::config()->reparseConfiguration();
901  emit q->iconChanged(arg);
902  break;
903 
904  case CursorChanged:
905  applyCursorTheme();
906  break;
907 
908  case BlockShortcuts:
909  // FIXME KAccel port
910  //KGlobalAccel::blockShortcuts(arg);
911  emit q->blockShortcuts(arg); // see kwin
912  break;
913 
914  case NaturalSortingChanged:
915  emit q->naturalSortingChanged();
916  break;
917 
918  default:
919  kWarning(240) << "Unknown type of change in KGlobalSettings::slotNotifyChange: " << changeType;
920  }
921 }
922 
923 // Set by KApplication
924 QString kde_overrideStyle;
925 
926 void KGlobalSettings::Private::applyGUIStyle()
927 {
928  //Platform plugin only loaded on X11 systems
929 #ifdef Q_WS_X11
930  if (!kde_overrideStyle.isEmpty()) {
931  const QLatin1String currentStyleName(qApp->style()->metaObject()->className());
932  if (0 != kde_overrideStyle.compare(currentStyleName, Qt::CaseInsensitive) &&
933  0 != (QString(kde_overrideStyle + QLatin1String("Style"))).compare(currentStyleName, Qt::CaseInsensitive)) {
934  qApp->setStyle(kde_overrideStyle);
935  }
936  } else {
937  emit q->kdisplayStyleChanged();
938  }
939 #else
940  const QLatin1String currentStyleName(qApp->style()->metaObject()->className());
941 
942  if (kde_overrideStyle.isEmpty()) {
943  const QString &defaultStyle = KStyle::defaultStyle();
944  const KConfigGroup pConfig(KGlobal::config(), "General");
945  const QString &styleStr = pConfig.readEntry("widgetStyle", defaultStyle);
946 
947  if (styleStr.isEmpty() ||
948  // check whether we already use the correct style to return then
949  // (workaround for Qt misbehavior to avoid double style initialization)
950  0 == (QString(styleStr + QLatin1String("Style"))).compare(currentStyleName, Qt::CaseInsensitive) ||
951  0 == styleStr.compare(currentStyleName, Qt::CaseInsensitive)) {
952  return;
953  }
954 
955  QStyle* sp = QStyleFactory::create( styleStr );
956  if (sp && currentStyleName == sp->metaObject()->className()) {
957  delete sp;
958  return;
959  }
960 
961  // If there is no default style available, try falling back any available style
962  if ( !sp && styleStr != defaultStyle)
963  sp = QStyleFactory::create( defaultStyle );
964  if ( !sp )
965  sp = QStyleFactory::create( QStyleFactory::keys().first() );
966  qApp->setStyle(sp);
967  } else if (0 != kde_overrideStyle.compare(currentStyleName, Qt::CaseInsensitive) &&
968  0 != (QString(kde_overrideStyle + QLatin1String("Style"))).compare(currentStyleName, Qt::CaseInsensitive)) {
969  qApp->setStyle(kde_overrideStyle);
970  }
971  emit q->kdisplayStyleChanged();
972 #endif //Q_WS_X11
973 }
974 
975 QPalette KGlobalSettings::createApplicationPalette(const KSharedConfigPtr &config)
976 {
977  return self()->d->createApplicationPalette(config);
978 }
979 
980 QPalette KGlobalSettings::createNewApplicationPalette(const KSharedConfigPtr &config)
981 {
982  return self()->d->createNewApplicationPalette(config);
983 }
984 
985 QPalette KGlobalSettings::Private::createApplicationPalette(const KSharedConfigPtr &config)
986 {
987  // This method is typically called once by KQGuiPlatformPlugin::palette and once again
988  // by kdisplaySetPalette(), so we cache the palette to save time.
989  if (config == KGlobal::config() && paletteCreated) {
990  return applicationPalette;
991  }
992  return createNewApplicationPalette(config);
993 }
994 
995 QPalette KGlobalSettings::Private::createNewApplicationPalette(const KSharedConfigPtr &config)
996 {
997  QPalette palette;
998 
999  QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
1000  QPalette::Disabled };
1001 
1002  // TT thinks tooltips shouldn't use active, so we use our active colors for all states
1003  KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
1004 
1005  for ( int i = 0; i < 3 ; i++ ) {
1006  QPalette::ColorGroup state = states[i];
1007  KColorScheme schemeView(state, KColorScheme::View, config);
1008  KColorScheme schemeWindow(state, KColorScheme::Window, config);
1009  KColorScheme schemeButton(state, KColorScheme::Button, config);
1010  KColorScheme schemeSelection(state, KColorScheme::Selection, config);
1011 
1012  palette.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
1013  palette.setBrush( state, QPalette::Window, schemeWindow.background() );
1014  palette.setBrush( state, QPalette::Base, schemeView.background() );
1015  palette.setBrush( state, QPalette::Text, schemeView.foreground() );
1016  palette.setBrush( state, QPalette::Button, schemeButton.background() );
1017  palette.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
1018  palette.setBrush( state, QPalette::Highlight, schemeSelection.background() );
1019  palette.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
1020  palette.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
1021  palette.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
1022 
1023  palette.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
1024  palette.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
1025  palette.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
1026  palette.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
1027  palette.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
1028 
1029  palette.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
1030  palette.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
1031  palette.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
1032  }
1033 
1034  if (config == KGlobal::config()) {
1035  paletteCreated = true;
1036  applicationPalette = palette;
1037  }
1038 
1039  return palette;
1040 }
1041 
1042 void KGlobalSettings::Private::kdisplaySetPalette()
1043 {
1044 #if !defined(Q_WS_MAEMO_5) && !defined(Q_OS_WINCE) && !defined(MEEGO_EDITION_HARMATTAN)
1045  if (!kdeFullSession) {
1046  return;
1047  }
1048 
1049  if (qApp->type() == QApplication::GuiClient) {
1050  QApplication::setPalette( q->createApplicationPalette() );
1051  }
1052  emit q->kdisplayPaletteChanged();
1053  emit q->appearanceChanged();
1054 #endif
1055 }
1056 
1057 
1058 void KGlobalSettings::Private::kdisplaySetFont()
1059 {
1060 #if !defined(Q_WS_MAEMO_5) && !defined(Q_OS_WINCE) && !defined(MEEGO_EDITION_HARMATTAN)
1061  if (!kdeFullSession) {
1062  return;
1063  }
1064 
1065  if (qApp->type() == QApplication::GuiClient) {
1066  KGlobalSettingsData* data = KGlobalSettingsData::self();
1067 
1068  QApplication::setFont( data->font(KGlobalSettingsData::GeneralFont) );
1069  const QFont menuFont = data->font( KGlobalSettingsData::MenuFont );
1070  QApplication::setFont( menuFont, "QMenuBar" );
1071  QApplication::setFont( menuFont, "QMenu" );
1072  QApplication::setFont( menuFont, "KPopupTitle" );
1073  QApplication::setFont( data->font(KGlobalSettingsData::ToolbarFont), "QToolBar" );
1074  }
1075  emit q->kdisplayFontChanged();
1076  emit q->appearanceChanged();
1077 #endif
1078 }
1079 
1080 
1081 void KGlobalSettings::Private::kdisplaySetStyle()
1082 {
1083  if (qApp->type() == QApplication::GuiClient) {
1084  applyGUIStyle();
1085 
1086  // Reread palette from config file.
1087  kdisplaySetPalette();
1088  }
1089 }
1090 
1091 
1092 void KGlobalSettings::Private::reloadStyleSettings()
1093 {
1094  KConfigGroup g( KGlobal::config(), "KDE-Global GUI Settings" );
1095 
1096  // Asking for hasKey we do not ask for graphicEffectsLevelDefault() that can
1097  // contain some very slow code. If we can save that time, do it. (ereslibre)
1098 
1099  if (g.hasKey("GraphicEffectsLevel")) {
1100  _graphicEffects = ((GraphicEffects) g.readEntry("GraphicEffectsLevel", QVariant((int) NoEffects)).toInt());
1101 
1102  return;
1103  }
1104 
1105  _graphicEffects = KGlobalSettings::graphicEffectsLevelDefault();
1106 }
1107 
1108 
1109 void KGlobalSettings::Private::applyCursorTheme()
1110 {
1111 #if defined(Q_WS_X11) && defined(HAVE_XCURSOR)
1112  KConfig config("kcminputrc");
1113  KConfigGroup g(&config, "Mouse");
1114 
1115  QString theme = g.readEntry("cursorTheme", QString());
1116  int size = g.readEntry("cursorSize", -1);
1117 
1118  // Default cursor size is 16 points
1119  if (size == -1)
1120  {
1121  QApplication *app = static_cast<QApplication*>(QApplication::instance());
1122  size = app->desktop()->screen(0)->logicalDpiY() * 16 / 72;
1123  }
1124 
1125  // Note that in X11R7.1 and earlier, calling XcursorSetTheme()
1126  // with a NULL theme would cause Xcursor to use "default", but
1127  // in 7.2 and later it will cause it to revert to the theme that
1128  // was configured when the application was started.
1129  XcursorSetTheme(QX11Info::display(), theme.isNull() ?
1130  "default" : QFile::encodeName(theme));
1131  XcursorSetDefaultSize(QX11Info::display(), size);
1132 
1133  emit q->cursorChanged();
1134 #endif
1135 }
1136 
1137 
1138 void KGlobalSettings::Private::propagateQtSettings()
1139 {
1140  KConfigGroup cg( KGlobal::config(), "KDE" );
1141 #ifndef Q_WS_WIN
1142  int num = cg.readEntry("CursorBlinkRate", QApplication::cursorFlashTime());
1143  if ((num != 0) && (num < 200))
1144  num = 200;
1145  if (num > 2000)
1146  num = 2000;
1147  QApplication::setCursorFlashTime(num);
1148 #else
1149  int num;
1150 #endif
1151  num = cg.readEntry("DoubleClickInterval", QApplication::doubleClickInterval());
1152  QApplication::setDoubleClickInterval(num);
1153  num = cg.readEntry("StartDragTime", QApplication::startDragTime());
1154  QApplication::setStartDragTime(num);
1155  num = cg.readEntry("StartDragDist", QApplication::startDragDistance());
1156  QApplication::setStartDragDistance(num);
1157  num = cg.readEntry("WheelScrollLines", QApplication::wheelScrollLines());
1158  QApplication::setWheelScrollLines(num);
1159  bool showIcons = cg.readEntry("ShowIconsInMenuItems", !QApplication::testAttribute(Qt::AA_DontShowIconsInMenus));
1160  QApplication::setAttribute(Qt::AA_DontShowIconsInMenus, !showIcons);
1161 
1162  // KDE5: this seems fairly pointless
1163  emit q->settingsChanged(SETTINGS_QT);
1164 }
1165 
1166 #include "kglobalsettings.moc"
KGlobalSettings::shadeSortColumn
static bool shadeSortColumn()
Returns if the sorted column in a K3ListView shall be drawn with a shaded background color...
Definition: kglobalsettings.cpp:375
QPalette::setBrush
void setBrush(ColorRole role, const QBrush &brush)
message
void message(KMessage::MessageType messageType, const QString &text, const QString &caption=QString())
KConfigGroup::readPathEntry
QString readPathEntry(const QString &pKey, const QString &aDefault) const
KGlobalSettings::downloadPath
static QString downloadPath()
The path where download are stored of the current user.
Definition: kglobalsettings.cpp:652
KSharedPtr< KSharedConfig >
KGlobalSettings::ComplexAnimationEffects
GUI with complex animations enabled.
Definition: kglobalsettings.h:468
KGlobalSettings::KMouseSettings::LeftHanded
Definition: kglobalsettings.h:219
KGlobalSettings::taskbarFont
static QFont taskbarFont()
Returns the default taskbar font.
Definition: kglobalsettings.cpp:466
QWidget
KGlobalSettings::emitChange
static void emitChange(ChangeType changeType, int arg=0)
Notifies all KDE applications on the current display of a change.
Definition: kglobalsettings.cpp:825
QString::append
QString & append(QChar ch)
QDesktopWidget::screenGeometry
const QRect screenGeometry(int screen) const
QApplication::doubleClickInterval
int doubleClickInterval()
KDE_DEFAULT_BUTTON_LAYOUT
#define KDE_DEFAULT_BUTTON_LAYOUT
Definition: kglobalsettings.h:40
KDE_DEFAULT_WHEEL_ZOOM
#define KDE_DEFAULT_WHEEL_ZOOM
Definition: kglobalsettings.h:33
KColorScheme::LightShade
The light color is lighter than dark() or shadow() and contrasts with the base color.
Definition: kcolorscheme.h:280
kdebug.h
KGlobalSettings::allowDefaultBackgroundImages
static bool allowDefaultBackgroundImages()
Returns if default background images are allowed by the color scheme.
Definition: kglobalsettings.cpp:381
QByteArray::toLower
QByteArray toLower() const
QPalette::setColor
void setColor(ColorGroup group, ColorRole role, const QColor &color)
QByteArray
group
kglobalsettings.h
KGlobalSettings::singleClick
static bool singleClick()
Returns whether KDE runs in single (default) or double click mode.
Definition: kglobalsettings.cpp:233
KGlobalSettings::createNewApplicationPalette
static QPalette createNewApplicationPalette(const KSharedConfigPtr &config=KSharedConfigPtr())
Used to obtain the QPalette that will be used to set the application palette.
Definition: kglobalsettings.cpp:980
KGlobalSettings::desktopPath
static QString desktopPath()
The path to the desktop directory of the current user.
Definition: kglobalsettings.cpp:626
QString::split
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
QApplication::setFont
void setFont(const QFont &font, const char *className)
kde_overrideStyle
QString kde_overrideStyle
Definition: kglobalsettings.cpp:924
QX11Info::display
Display * display()
KDE_DEFAULT_SINGLECLICK
#define KDE_DEFAULT_SINGLECLICK
Definition: kglobalsettings.h:27
QFont
K_GLOBAL_STATIC
#define K_GLOBAL_STATIC(TYPE, NAME)
kconfig.h
KGlobalSettings::ChangeType
ChangeType
An identifier for change signals.
Definition: kglobalsettings.h:543
KColorScheme::Selection
Selected items in views.
Definition: kcolorscheme.h:109
QList::at
const T & at(int i) const
DefaultFont
static const char DefaultFont[]
Definition: kglobalsettings.cpp:399
QApplication
KGlobal::dirs
KStandardDirs * dirs()
KStyle::defaultStyle
static QString defaultStyle()
Returns the default widget style.
Definition: kstyle.cpp:360
QByteArray::isEmpty
bool isEmpty() const
QObject::metaObject
virtual const QMetaObject * metaObject() const
KGlobalSettings::Disable
disable tear-off handles
Definition: kglobalsettings.h:131
QFontDatabase::isSmoothlyScalable
bool isSmoothlyScalable(const QString &family, const QString &style) const
KGlobalSettings::inactiveTitleColor
static QColor inactiveTitleColor()
The default color to use for inactive titles.
Definition: kglobalsettings.cpp:317
KGlobalSettings::opaqueResize
static bool opaqueResize()
Whether the user wishes to use opaque resizing.
Definition: kglobalsettings.cpp:813
KColorScheme::Tooltip
Tooltips.
Definition: kcolorscheme.h:118
KConfig::SimpleConfig
KGlobalSettings::desktopGeometry
static QRect desktopGeometry(const QPoint &point)
This function returns the desktop geometry for an application that needs to set the geometry of a wid...
Definition: kglobalsettings.cpp:732
QDBusConnection::sessionBus
QDBusConnection sessionBus()
QPoint
QFontMetrics
KGlobalSettings::showContextMenusOnPress
static bool showContextMenusOnPress()
Returns the KDE setting for context menus.
Definition: kglobalsettings.cpp:280
QCoreApplication::setAttribute
void setAttribute(Qt::ApplicationAttribute attribute, bool on)
QFile::exists
bool exists() const
QDesktopWidget::isVirtualDesktop
bool isVirtualDesktop() const
QString::remove
QString & remove(int position, int n)
KGlobalSettings::self
static KGlobalSettings * self()
Return the KGlobalSettings singleton.
Definition: kglobalsettings.cpp:188
KDE_DEFAULT_OPAQUE_RESIZE
#define KDE_DEFAULT_OPAQUE_RESIZE
Definition: kglobalsettings.h:39
klocale.h
QDir::homePath
QString homePath()
DefaultMacFont
static const char DefaultMacFont[]
Definition: kglobalsettings.cpp:401
KGlobalSettings::NoEffects
GUI with no effects at all.
Definition: kglobalsettings.h:465
KColorScheme::Window
Non-editable window elements; for example, menus.
Definition: kcolorscheme.h:93
QDesktopWidget::screenNumber
int screenNumber(const QWidget *widget) const
KUrl
_graphicEffects
static KGlobalSettings::GraphicEffects _graphicEffects
Definition: kglobalsettings.cpp:77
QWidget::geometry
geometry
KGlobal::config
KSharedConfigPtr config()
QString::isNull
bool isNull() const
KGlobalSettings::~KGlobalSettings
~KGlobalSettings()
Definition: kglobalsettings.cpp:199
KColorScheme::DarkShade
The dark color is in between mid() and shadow().
Definition: kcolorscheme.h:292
KColorScheme::MidlightShade
The midlight color is in between base() and light().
Definition: kcolorscheme.h:284
QApplication::cursorFlashTime
int cursorFlashTime()
QRect
KDE_DEFAULT_SMOOTHSCROLL
#define KDE_DEFAULT_SMOOTHSCROLL
Definition: kglobalsettings.h:28
QStyleFactory::keys
QStringList keys()
KGlobalSettings::contrast
static int contrast()
Returns the contrast for borders.
Definition: kglobalsettings.cpp:360
kglobal.h
QList::count
int count(const T &value) const
QList::append
void append(const T &value)
KGlobalSettings::activeTitleColor
static QColor activeTitleColor()
The default color to use for active titles.
Definition: kglobalsettings.cpp:339
KGlobalSettings::videosPath
static QString videosPath()
The path where videos are stored of the current user.
Definition: kglobalsettings.cpp:676
QKeySequence::fromString
QKeySequence fromString(const QString &str, SequenceFormat format)
QDesktopWidget
KGlobalSettings::createApplicationPalette
static QPalette createApplicationPalette(const KSharedConfigPtr &config=KSharedConfigPtr())
Used to obtain the QPalette that will be used to set the application palette.
Definition: kglobalsettings.cpp:975
KGlobalSettings::contrastF
static qreal contrastF(const KSharedConfigPtr &config=KSharedConfigPtr())
Returns the contrast for borders as a floating point value.
Definition: kglobalsettings.cpp:366
QObject
QStyle
QDesktopServices::storageLocation
QString storageLocation(StandardLocation type)
QApplication::setPalette
void setPalette(const QPalette &palette, const char *className)
KLocale::reparseConfiguration
void reparseConfiguration()
KGlobalSettings::buttonLayout
static int buttonLayout()
The layout scheme to use for dialog buttons.
Definition: kglobalsettings.cpp:819
KUrl::protocol
QString protocol() const
QDBusMessage::createSignal
QDBusMessage createSignal(const QString &path, const QString &interface, const QString &name)
KColorScheme::LinkText
Fourth color; use for (unvisited) links.
Definition: kcolorscheme.h:221
KDE_DEFAULT_CHANGECURSOR
#define KDE_DEFAULT_CHANGECURSOR
Definition: kglobalsettings.h:31
QDBusConnection::send
bool send(const QDBusMessage &message) const
QString::isEmpty
bool isEmpty() const
KGlobalSettings::KMouseSettings
Describes the mouse settings.
Definition: kglobalsettings.h:217
QList::removeAll
int removeAll(const T &value)
KGlobalSettings::wheelMouseZooms
static bool wheelMouseZooms()
Typically, QScrollView derived classes can be scrolled fast by holding down the Ctrl-button during wh...
Definition: kglobalsettings.cpp:707
QString::startsWith
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
KDE_DEFAULT_NATURAL_SORTING
#define KDE_DEFAULT_NATURAL_SORTING
Definition: kglobalsettings.h:43
KGlobalSettings::TearOffHandle
TearOffHandle
This enum describes the return type for insertTearOffHandle() whether to insert a handle or not...
Definition: kglobalsettings.h:130
QStyleFactory::create
QStyle * create(const QString &key)
KColorScheme::AlternateBackground
Alternate background; for example, for use in lists.
Definition: kcolorscheme.h:141
QPixmapCache::clear
void clear()
QString::endsWith
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
KGlobalSettings::activeTextColor
static QColor activeTextColor()
The default color to use for active texts.
Definition: kglobalsettings.cpp:350
QCoreApplication::instance
QCoreApplication * instance()
KColorScheme::VisitedText
Fifth color; used for (visited) links.
Definition: kcolorscheme.h:229
KGlobalSettings::windowTitleFont
static QFont windowTitleFont()
Returns the default window title font.
Definition: kglobalsettings.cpp:462
KColorScheme::ShadowShade
The shadow color is darker than light() or midlight() and contrasts the base color.
Definition: kcolorscheme.h:297
QString
QList< QVariant >
KColorScheme::View
Views; for example, frames, input fields, etc.
Definition: kcolorscheme.h:87
QtConcurrent::map
QFuture< void > map(Sequence &sequence, MapFunction function)
QColor
KGlobalSettings::graphicEffectsLevelDefault
static GraphicEffects graphicEffectsLevelDefault()
This function determines the default level of effects on the GUI depending on the system capabilities...
Definition: kglobalsettings.cpp:797
QStringList
KGlobalSettings::KMouseSettings::RightHanded
Definition: kglobalsettings.h:219
KStandardDirs::localxdgconfdir
QString localxdgconfdir() const
qt_colorref2qrgb
static QRgb qt_colorref2qrgb(COLORREF col)
Definition: kglobalsettings.cpp:58
QPaintDevice::logicalDpiY
int logicalDpiY() const
kkernel_win.h
QDesktopWidget::screen
QWidget * screen(int screen)
KGlobalSettings::showIconsOnPushButtons
static bool showIconsOnPushButtons()
This function determines if the user wishes to see icons on the push buttons.
Definition: kglobalsettings.cpp:768
kprotocolinfo.h
KGlobalSettings
Access the KDE global configuration.
Definition: kglobalsettings.h:58
KGlobalSettings::documentPath
static QString documentPath()
The path where documents are stored of the current user.
Definition: kglobalsettings.cpp:646
KProtocolInfo::showFilePreview
static bool showFilePreview(const QString &protocol)
QLatin1Char
fixx11h.h
DefaultFontData
static const KFontData DefaultFontData[KGlobalSettingsData::FontTypesCount]
Definition: kglobalsettings.cpp:404
KGlobalSettings::autostartPath
static QString autostartPath()
The path to the autostart directory of the current user.
Definition: kglobalsettings.cpp:633
KColorScheme::Button
Buttons and button-like controls.
Definition: kcolorscheme.h:101
QMetaObject::className
const char * className() const
KGlobalSettings::ApplySettings
Make all globally applicable settings take effect.
Definition: kglobalsettings.h:568
QFont::setStyleHint
void setStyleHint(StyleHint hint, StyleStrategy strategy)
KStandardGuiItem::ok
KGuiItem ok()
Returns the 'Ok' gui item.
Definition: kstandardguiitem.cpp:107
KGlobalSettings::CompletionPopup
Lists all possible matches in a popup list-box to choose from.
Definition: kglobalsettings.h:199
KGlobal::locale
KLocale * locale()
KGlobalSettings::largeFont
static QFont largeFont(const QString &text=QString())
Returns a font of approx.
Definition: kglobalsettings.cpp:540
QDir
KConfigGroup
KGlobalSettings::changeCursorOverIcon
static bool changeCursorOverIcon()
Checks whether the cursor changes over icons.
Definition: kglobalsettings.cpp:255
QDir::cleanPath
QString cleanPath(const QString &path)
KConfig
QApplication::startDragTime
int startDragTime()
KGlobalSettings::generalFont
static QFont generalFont()
Returns the default general font.
Definition: kglobalsettings.cpp:446
QString::mid
QString mid(int position, int n) const
QCursor::pos
QPoint pos()
QDBusMessage
KGlobalSettings::CompletionNone
No completion is used.
Definition: kglobalsettings.h:183
KGlobalSettings::inactiveTextColor
static QColor inactiveTextColor()
The default color to use for inactive texts.
Definition: kglobalsettings.cpp:328
KGlobalSettings::contextMenuKey
static int contextMenuKey()
Returns the KDE setting for the shortcut key to open context menus.
Definition: kglobalsettings.cpp:287
KGlobalSettings::menuFont
static QFont menuFont()
Returns the default menu font.
Definition: kglobalsettings.cpp:458
QLatin1String
QKeySequence
QApplication::desktop
QDesktopWidget * desktop()
KGlobalSettings::toolBarFont
static QFont toolBarFont()
Returns the default toolbar font.
Definition: kglobalsettings.cpp:454
KGlobalSettings::splashScreenDesktopGeometry
static QRect splashScreenDesktopGeometry()
This function returns the desktop geometry for an application's splash screen.
Definition: kglobalsettings.cpp:713
QFontDatabase::families
QStringList families(WritingSystem writingSystem) const
KColorScheme
A set of methods used to work with colors.
Definition: kcolorscheme.h:71
KDE_DEFAULT_ALLOW_DEFAULT_BACKGROUND_IMAGES
#define KDE_DEFAULT_ALLOW_DEFAULT_BACKGROUND_IMAGES
Definition: kglobalsettings.h:42
kstandarddirs.h
KConfig::reparseConfiguration
void reparseConfiguration()
KGlobalSettings::insertTearOffHandle
static TearOffHandle insertTearOffHandle()
Returns whether tear-off handles are inserted in KMenus.
Definition: kglobalsettings.cpp:245
KGlobalSettings::isMultiHead
static bool isMultiHead()
Returns if the user specified multihead.
Definition: kglobalsettings.cpp:694
QList::ConstIterator
typedef ConstIterator
KGlobalSettings::autoSelectDelay
static int autoSelectDelay()
Returns the KDE setting for the auto-select option.
Definition: kglobalsettings.cpp:261
QApplication::wheelScrollLines
int wheelScrollLines()
KGlobalSettings::Completion
Completion
This enum describes the completion mode used for by the KCompletion class.
Definition: kglobalsettings.h:179
GeneralId
static const char GeneralId[]
Definition: kglobalsettings.cpp:398
QString::length
int length() const
KStandardDirs::localkdedir
QString localkdedir() const
kWarning
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
QDBusMessage::setArguments
void setArguments(const QList< QVariant > &arguments)
QList::prepend
void prepend(const T &value)
KGlobalSettings::activate
void activate()
Makes all globally applicable settings take effect and starts listening for changes to these settings...
Definition: kglobalsettings.cpp:204
KGlobalSettings::KMouseSettings::handed
int handed
Definition: kglobalsettings.h:220
KGlobalSettings::mouseSettings
static KMouseSettings & mouseSettings()
This returns the current mouse settings.
Definition: kglobalsettings.cpp:613
KGlobalSettings::graphicEffectsLevel
static GraphicEffects graphicEffectsLevel()
This function determines the desired level of effects on the GUI.
Definition: kglobalsettings.cpp:782
KGlobalSettings::showFilePreview
static bool showFilePreview(const KUrl &)
This function determines if the user wishes to see previews for the selected url. ...
Definition: kglobalsettings.cpp:805
QList::constEnd
const_iterator constEnd() const
KGlobalSettings::completionMode
static Completion completionMode()
Returns the preferred completion mode setting.
Definition: kglobalsettings.cpp:267
QList::constBegin
const_iterator constBegin() const
QDBusConnection::connect
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
QFontDatabase::isFixedPitch
bool isFixedPitch(const QString &family, const QString &style) const
KGlobalSettings::picturesPath
static QString picturesPath()
The path where pictures are stored of the current user.
Definition: kglobalsettings.cpp:682
QCoreApplication::testAttribute
bool testAttribute(Qt::ApplicationAttribute attribute)
QString::compare
int compare(const QString &other) const
KColorScheme::MidShade
The mid color is in between base() and dark().
Definition: kcolorscheme.h:288
KDE_DEFAULT_INSERTTEAROFFHANDLES
#define KDE_DEFAULT_INSERTTEAROFFHANDLES
Definition: kglobalsettings.h:29
KGlobalSettings::dndEventDelay
static int dndEventDelay()
Returns a threshold in pixels for drag & drop operations.
Definition: kglobalsettings.cpp:227
KDE_DEFAULT_AUTOSELECTDELAY
#define KDE_DEFAULT_AUTOSELECTDELAY
Definition: kglobalsettings.h:30
KConfigGroup::readEntry
T readEntry(const QString &key, const T &aDefault) const
KStandardShortcut::completion
const KShortcut & completion()
Complete text in input widgets.
Definition: kstandardshortcut.cpp:363
QFontDatabase
kcolorscheme.h
KGlobalSettings::smallestReadableFont
static QFont smallestReadableFont()
Returns the smallest readable font.
Definition: kglobalsettings.cpp:470
QPalette
KGlobalSettings::CompletionPopupAuto
Lists all possible matches in a popup list-box to choose from, and automatically fill the result when...
Definition: kglobalsettings.h:204
QFile::encodeName
QByteArray encodeName(const QString &fileName)
KGlobalSettings::ListenForChanges
Listen for changes to the settings.
Definition: kglobalsettings.h:569
kstyle.h
KGlobalSettings::musicPath
static QString musicPath()
The path where music are stored of the current user.
Definition: kglobalsettings.cpp:688
KGlobalSettings::smoothScroll
static bool smoothScroll()
Returns if item views should force smooth scrolling.
Definition: kglobalsettings.cpp:239
KDE_DEFAULT_ICON_ON_PUSHBUTTON
#define KDE_DEFAULT_ICON_ON_PUSHBUTTON
Definition: kglobalsettings.h:35
KGlobalSettings::fixedFont
static QFont fixedFont()
Returns the default fixed font.
Definition: kglobalsettings.cpp:450
kconfiggroup.h
QDir::mkpath
bool mkpath(const QString &dirPath) const
KDE_DEFAULT_SHADE_SORT_COLUMN
#define KDE_DEFAULT_SHADE_SORT_COLUMN
Definition: kglobalsettings.h:41
QApplication::startDragDistance
int startDragDistance()
KGlobalSettings::naturalSorting
static bool naturalSorting()
Returns true, if user visible strings should be sorted in a natural way: image 1.jpg image 2...
Definition: kglobalsettings.cpp:775
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal