00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "config.h"
00019 #include "kglobalsettings.h"
00020
00021 #include <qdir.h>
00022 #include <qpixmap.h>
00023 #include <qfontdatabase.h>
00024 #include <qcursor.h>
00025
00026 #include <kconfig.h>
00027 #include <ksimpleconfig.h>
00028 #include <kapplication.h>
00029
00030 #include <kipc.h>
00031
00032 #ifdef Q_WS_WIN
00033 #include <windows.h>
00034 #include "qt_windows.h"
00035 #include <win32_utils.h>
00036 static QRgb qt_colorref2qrgb(COLORREF col)
00037 {
00038 return qRgb(GetRValue(col),GetGValue(col),GetBValue(col));
00039 }
00040 #endif
00041
00042 #include <kdebug.h>
00043 #include <kglobal.h>
00044 #include <kshortcut.h>
00045 #include <kstandarddirs.h>
00046 #include <kcharsets.h>
00047 #include <kaccel.h>
00048 #include <klocale.h>
00049 #include <qfontinfo.h>
00050 #include <stdlib.h>
00051 #include <kprotocolinfo.h>
00052
00053 #include <qtextcodec.h>
00054 #include <qtextstream.h>
00055 #include <qfile.h>
00056
00057 #ifdef Q_WS_X11
00058 #include <X11/Xlib.h>
00059 #endif
00060
00061 QString* KGlobalSettings::s_desktopPath = 0;
00062 QString* KGlobalSettings::s_autostartPath = 0;
00063 QString* KGlobalSettings::s_trashPath = 0;
00064 QString* KGlobalSettings::s_documentPath = 0;
00065 QFont *KGlobalSettings::_generalFont = 0;
00066 QFont *KGlobalSettings::_fixedFont = 0;
00067 QFont *KGlobalSettings::_toolBarFont = 0;
00068 QFont *KGlobalSettings::_menuFont = 0;
00069 QFont *KGlobalSettings::_windowTitleFont = 0;
00070 QFont *KGlobalSettings::_taskbarFont = 0;
00071 QFont *KGlobalSettings::_largeFont = 0;
00072 QColor *KGlobalSettings::_kde34Blue = 0;
00073 QColor *KGlobalSettings::_inactiveBackground = 0;
00074 QColor *KGlobalSettings::_inactiveForeground = 0;
00075 QColor *KGlobalSettings::_activeBackground = 0;
00076 QColor *KGlobalSettings::_buttonBackground = 0;
00077 QColor *KGlobalSettings::_selectBackground = 0;
00078 QColor *KGlobalSettings::_linkColor = 0;
00079 QColor *KGlobalSettings::_visitedLinkColor = 0;
00080 QColor *KGlobalSettings::alternateColor = 0;
00081
00082 KGlobalSettings::KMouseSettings *KGlobalSettings::s_mouseSettings = 0;
00083
00084
00085
00086 void readXdgUserDirs(QString *desktop, QString *documents)
00087 {
00088 QFile f( QDir::homeDirPath() + "/.config/user-dirs.dirs" );
00089
00090 if (!f.open(IO_ReadOnly))
00091 return;
00092
00093
00094 QTextStream s(&f);
00095 s.setCodec( QTextCodec::codecForLocale() );
00096
00097 QString line = s.readLine();
00098 while (!line.isNull())
00099 {
00100 if (line.startsWith("XDG_DESKTOP_DIR="))
00101 *desktop = line.remove("XDG_DESKTOP_DIR=").remove("\"").replace("$HOME", QDir::homeDirPath());
00102 else if (line.startsWith("XDG_DOCUMENTS_DIR="))
00103 *documents = line.remove("XDG_DOCUMENTS_DIR=").remove("\"").replace("$HOME", QDir::homeDirPath());
00104
00105 line = s.readLine();
00106 }
00107 }
00108
00109 int KGlobalSettings::dndEventDelay()
00110 {
00111 KConfigGroup g( KGlobal::config(), "General" );
00112 return g.readNumEntry("StartDragDist", QApplication::startDragDistance());
00113 }
00114
00115 bool KGlobalSettings::singleClick()
00116 {
00117 KConfigGroup g( KGlobal::config(), "KDE" );
00118 return g.readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK);
00119 }
00120
00121 KGlobalSettings::TearOffHandle KGlobalSettings::insertTearOffHandle()
00122 {
00123 int tearoff;
00124 bool effectsenabled;
00125 KConfigGroup g( KGlobal::config(), "KDE" );
00126 effectsenabled = g.readBoolEntry( "EffectsEnabled", false);
00127 tearoff = g.readNumEntry("InsertTearOffHandle", KDE_DEFAULT_INSERTTEAROFFHANDLES);
00128 return effectsenabled ? (TearOffHandle) tearoff : Disable;
00129 }
00130
00131 bool KGlobalSettings::changeCursorOverIcon()
00132 {
00133 KConfigGroup g( KGlobal::config(), "KDE" );
00134 return g.readBoolEntry("ChangeCursor", KDE_DEFAULT_CHANGECURSOR);
00135 }
00136
00137 bool KGlobalSettings::visualActivate()
00138 {
00139 KConfigGroup g( KGlobal::config(), "KDE" );
00140 return g.readBoolEntry("VisualActivate", KDE_DEFAULT_VISUAL_ACTIVATE);
00141 }
00142
00143 unsigned int KGlobalSettings::visualActivateSpeed()
00144 {
00145 KConfigGroup g( KGlobal::config(), "KDE" );
00146 return
00147 g.readNumEntry(
00148 "VisualActivateSpeed",
00149 KDE_DEFAULT_VISUAL_ACTIVATE_SPEED
00150 );
00151 }
00152
00153
00154
00155 int KGlobalSettings::autoSelectDelay()
00156 {
00157 KConfigGroup g( KGlobal::config(), "KDE" );
00158 return g.readNumEntry("AutoSelectDelay", KDE_DEFAULT_AUTOSELECTDELAY);
00159 }
00160
00161 KGlobalSettings::Completion KGlobalSettings::completionMode()
00162 {
00163 int completion;
00164 KConfigGroup g( KGlobal::config(), "General" );
00165 completion = g.readNumEntry("completionMode", -1);
00166 if ((completion < (int) CompletionNone) ||
00167 (completion > (int) CompletionPopupAuto))
00168 {
00169 completion = (int) CompletionPopup;
00170 }
00171 return (Completion) completion;
00172 }
00173
00174 bool KGlobalSettings::showContextMenusOnPress ()
00175 {
00176 KConfigGroup g(KGlobal::config(), "ContextMenus");
00177 return g.readBoolEntry("ShowOnPress", true);
00178 }
00179
00180 int KGlobalSettings::contextMenuKey ()
00181 {
00182 KConfigGroup g(KGlobal::config(), "Shortcuts");
00183 KShortcut cut (g.readEntry ("PopupMenuContext", "Menu"));
00184 return cut.keyCodeQt();
00185 }
00186
00187 QColor KGlobalSettings::toolBarHighlightColor()
00188 {
00189 initColors();
00190 KConfigGroup g( KGlobal::config(), "Toolbar style" );
00191 return g.readColorEntry("HighlightColor", _kde34Blue);
00192 }
00193
00194 QColor KGlobalSettings::inactiveTitleColor()
00195 {
00196 #ifdef Q_WS_WIN
00197 return qt_colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTION));
00198 #else
00199 if (!_inactiveBackground)
00200 _inactiveBackground = new QColor(157, 170, 186);
00201 KConfigGroup g( KGlobal::config(), "WM" );
00202 return g.readColorEntry( "inactiveBackground", _inactiveBackground );
00203 #endif
00204 }
00205
00206 QColor KGlobalSettings::inactiveTextColor()
00207 {
00208 #ifdef Q_WS_WIN
00209 return qt_colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTIONTEXT));
00210 #else
00211 if (!_inactiveForeground)
00212 _inactiveForeground = new QColor(221,221,221);
00213 KConfigGroup g( KGlobal::config(), "WM" );
00214 return g.readColorEntry( "inactiveForeground", _inactiveForeground );
00215 #endif
00216 }
00217
00218 QColor KGlobalSettings::activeTitleColor()
00219 {
00220 #ifdef Q_WS_WIN
00221 return qt_colorref2qrgb(GetSysColor(COLOR_ACTIVECAPTION));
00222 #else
00223 initColors();
00224 if (!_activeBackground)
00225 _activeBackground = new QColor(65,142,220);
00226 KConfigGroup g( KGlobal::config(), "WM" );
00227 return g.readColorEntry( "activeBackground", _activeBackground);
00228 #endif
00229 }
00230
00231 QColor KGlobalSettings::activeTextColor()
00232 {
00233 #ifdef Q_WS_WIN
00234 return qt_colorref2qrgb(GetSysColor(COLOR_CAPTIONTEXT));
00235 #else
00236 KConfigGroup g( KGlobal::config(), "WM" );
00237 return g.readColorEntry( "activeForeground", &Qt::white );
00238 #endif
00239 }
00240
00241 int KGlobalSettings::contrast()
00242 {
00243 KConfigGroup g( KGlobal::config(), "KDE" );
00244 return g.readNumEntry( "contrast", 7 );
00245 }
00246
00247 QColor KGlobalSettings::buttonBackground()
00248 {
00249 if (!_buttonBackground)
00250 _buttonBackground = new QColor(221,223,228);
00251 KConfigGroup g( KGlobal::config(), "General" );
00252 return g.readColorEntry( "buttonBackground", _buttonBackground );
00253 }
00254
00255 QColor KGlobalSettings::buttonTextColor()
00256 {
00257 KConfigGroup g( KGlobal::config(), "General" );
00258 return g.readColorEntry( "buttonForeground", &Qt::black );
00259 }
00260
00261
00262
00263
00264 QColor KGlobalSettings::baseColor()
00265 {
00266 KConfigGroup g( KGlobal::config(), "General" );
00267 return g.readColorEntry( "windowBackground", &Qt::white );
00268 }
00269
00270
00271
00272
00273 QColor KGlobalSettings::textColor()
00274 {
00275 KConfigGroup g( KGlobal::config(), "General" );
00276 return g.readColorEntry( "windowForeground", &Qt::black );
00277 }
00278
00279
00280
00281
00282 QColor KGlobalSettings::highlightedTextColor()
00283 {
00284 KConfigGroup g( KGlobal::config(), "General" );
00285 return g.readColorEntry( "selectForeground", &Qt::white );
00286 }
00287
00288
00289
00290
00291 QColor KGlobalSettings::highlightColor()
00292 {
00293 initColors();
00294 if (!_selectBackground)
00295 _selectBackground = new QColor(103,141,178);
00296 KConfigGroup g( KGlobal::config(), "General" );
00297 return g.readColorEntry( "selectBackground", _selectBackground );
00298 }
00299
00300 QColor KGlobalSettings::alternateBackgroundColor()
00301 {
00302 initColors();
00303 KConfigGroup g( KGlobal::config(), "General" );
00304 *alternateColor = calculateAlternateBackgroundColor( baseColor() );
00305 return g.readColorEntry( "alternateBackground", alternateColor );
00306 }
00307
00308 QColor KGlobalSettings::calculateAlternateBackgroundColor(const QColor& base)
00309 {
00310 if (base == Qt::white)
00311 return QColor(238,246,255);
00312 else
00313 {
00314 int h, s, v;
00315 base.hsv( &h, &s, &v );
00316 if (v > 128)
00317 return base.dark(106);
00318 else if (base != Qt::black)
00319 return base.light(110);
00320
00321 return QColor(32,32,32);
00322 }
00323 }
00324
00325 bool KGlobalSettings::shadeSortColumn()
00326 {
00327 KConfigGroup g( KGlobal::config(), "General" );
00328 return g.readBoolEntry( "shadeSortColumn", KDE_DEFAULT_SHADE_SORT_COLUMN );
00329 }
00330
00331 QColor KGlobalSettings::linkColor()
00332 {
00333 initColors();
00334 if (!_linkColor)
00335 _linkColor = new QColor(0,0,238);
00336 KConfigGroup g( KGlobal::config(), "General" );
00337 return g.readColorEntry( "linkColor", _linkColor );
00338 }
00339
00340 QColor KGlobalSettings::visitedLinkColor()
00341 {
00342 if (!_visitedLinkColor)
00343 _visitedLinkColor = new QColor(82,24,139);
00344 KConfigGroup g( KGlobal::config(), "General" );
00345 return g.readColorEntry( "visitedLinkColor", _visitedLinkColor );
00346 }
00347
00348 QFont KGlobalSettings::generalFont()
00349 {
00350 if (_generalFont)
00351 return *_generalFont;
00352
00353
00354 _generalFont = new QFont("Sans Serif", 10);
00355 _generalFont->setPointSize(10);
00356 _generalFont->setStyleHint(QFont::SansSerif);
00357
00358 KConfigGroup g( KGlobal::config(), "General" );
00359 *_generalFont = g.readFontEntry("font", _generalFont);
00360
00361 return *_generalFont;
00362 }
00363
00364 QFont KGlobalSettings::fixedFont()
00365 {
00366 if (_fixedFont)
00367 return *_fixedFont;
00368
00369
00370 _fixedFont = new QFont("Monospace", 10);
00371 _fixedFont->setPointSize(10);
00372 _fixedFont->setStyleHint(QFont::TypeWriter);
00373
00374 KConfigGroup g( KGlobal::config(), "General" );
00375 *_fixedFont = g.readFontEntry("fixed", _fixedFont);
00376
00377 return *_fixedFont;
00378 }
00379
00380 QFont KGlobalSettings::toolBarFont()
00381 {
00382 if(_toolBarFont)
00383 return *_toolBarFont;
00384
00385
00386 _toolBarFont = new QFont("Sans Serif", 10);
00387 _toolBarFont->setPointSize(10);
00388 _toolBarFont->setStyleHint(QFont::SansSerif);
00389
00390 KConfigGroup g( KGlobal::config(), "General" );
00391 *_toolBarFont = g.readFontEntry("toolBarFont", _toolBarFont);
00392
00393 return *_toolBarFont;
00394 }
00395
00396 QFont KGlobalSettings::menuFont()
00397 {
00398 if(_menuFont)
00399 return *_menuFont;
00400
00401
00402 _menuFont = new QFont("Sans Serif", 10);
00403 _menuFont->setPointSize(10);
00404 _menuFont->setStyleHint(QFont::SansSerif);
00405
00406 KConfigGroup g( KGlobal::config(), "General" );
00407 *_menuFont = g.readFontEntry("menuFont", _menuFont);
00408
00409 return *_menuFont;
00410 }
00411
00412 QFont KGlobalSettings::windowTitleFont()
00413 {
00414 if(_windowTitleFont)
00415 return *_windowTitleFont;
00416
00417
00418 _windowTitleFont = new QFont("Sans Serif", 9, QFont::Bold);
00419 _windowTitleFont->setPointSize(10);
00420 _windowTitleFont->setStyleHint(QFont::SansSerif);
00421
00422 KConfigGroup g( KGlobal::config(), "WM" );
00423 *_windowTitleFont = g.readFontEntry("activeFont", _windowTitleFont);
00424
00425 return *_windowTitleFont;
00426 }
00427
00428 QFont KGlobalSettings::taskbarFont()
00429 {
00430 if(_taskbarFont)
00431 return *_taskbarFont;
00432
00433
00434 _taskbarFont = new QFont("Sans Serif", 10);
00435 _taskbarFont->setPointSize(10);
00436 _taskbarFont->setStyleHint(QFont::SansSerif);
00437
00438 KConfigGroup g( KGlobal::config(), "General" );
00439 *_taskbarFont = g.readFontEntry("taskbarFont", _taskbarFont);
00440
00441 return *_taskbarFont;
00442 }
00443
00444
00445 QFont KGlobalSettings::largeFont(const QString &text)
00446 {
00447 QFontDatabase db;
00448 QStringList fam = db.families();
00449
00450
00451 if (fam.remove("Arial"))
00452 fam.prepend("Arial");
00453 if (fam.remove("Verdana"))
00454 fam.prepend("Verdana");
00455 if (fam.remove("Tahoma"))
00456 fam.prepend("Tahoma");
00457 if (fam.remove("Lucida Sans"))
00458 fam.prepend("Lucida Sans");
00459 if (fam.remove("Lucidux Sans"))
00460 fam.prepend("Lucidux Sans");
00461 if (fam.remove("Nimbus Sans"))
00462 fam.prepend("Nimbus Sans");
00463 if (fam.remove("Gothic I"))
00464 fam.prepend("Gothic I");
00465
00466 if (_largeFont)
00467 fam.prepend(_largeFont->family());
00468
00469 for(QStringList::ConstIterator it = fam.begin();
00470 it != fam.end(); ++it)
00471 {
00472 if (db.isSmoothlyScalable(*it) && !db.isFixedPitch(*it))
00473 {
00474 QFont font(*it);
00475 font.setPixelSize(75);
00476 QFontMetrics metrics(font);
00477 int h = metrics.height();
00478 if ((h < 60) || ( h > 90))
00479 continue;
00480
00481 bool ok = true;
00482 for(unsigned int i = 0; i < text.length(); i++)
00483 {
00484 if (!metrics.inFont(text[i]))
00485 {
00486 ok = false;
00487 break;
00488 }
00489 }
00490 if (!ok)
00491 continue;
00492
00493 font.setPointSize(48);
00494 _largeFont = new QFont(font);
00495 return *_largeFont;
00496 }
00497 }
00498 _largeFont = new QFont(KGlobalSettings::generalFont());
00499 _largeFont->setPointSize(48);
00500 return *_largeFont;
00501 }
00502
00503 void KGlobalSettings::initStatic()
00504 {
00505 if ( s_desktopPath != 0 )
00506 return;
00507
00508 s_desktopPath = new QString();
00509 s_autostartPath = new QString();
00510 s_trashPath = new QString();
00511 s_documentPath = new QString();
00512
00513 KConfigGroup g( KGlobal::config(), "Paths" );
00514
00515
00516 readXdgUserDirs(s_desktopPath, s_documentPath);
00517
00518 *s_desktopPath = QDir::cleanDirPath( *s_desktopPath );
00519 if ( !s_desktopPath->endsWith("/") )
00520 s_desktopPath->append('/');
00521
00522 *s_documentPath = QDir::cleanDirPath( *s_documentPath );
00523 if ( !s_documentPath->endsWith("/"))
00524 s_documentPath->append('/');
00525
00526
00527 *s_trashPath = *s_desktopPath + i18n("Trash") + "/";
00528 *s_trashPath = g.readPathEntry( "Trash" , *s_trashPath);
00529 *s_trashPath = QDir::cleanDirPath( *s_trashPath );
00530 if ( !s_trashPath->endsWith("/") )
00531 s_trashPath->append('/');
00532
00533 if ( !g.hasKey( "Trash" ) )
00534 {
00535 g.writePathEntry( "Trash", *s_trashPath, true, true );
00536 g.sync();
00537 }
00538
00539
00540 *s_autostartPath = KGlobal::dirs()->localkdedir() + "Autostart/";
00541 *s_autostartPath = g.readPathEntry( "Autostart" , *s_autostartPath);
00542 *s_autostartPath = QDir::cleanDirPath( *s_autostartPath );
00543 if ( !s_autostartPath->endsWith("/") )
00544 s_autostartPath->append('/');
00545
00546
00547 if (kapp)
00548 kapp->addKipcEventMask(KIPC::SettingsChanged);
00549 }
00550
00551 void KGlobalSettings::initColors()
00552 {
00553 if (!_kde34Blue) {
00554 if (QPixmap::defaultDepth() > 8)
00555 _kde34Blue = new QColor(103,141,178);
00556 else
00557 _kde34Blue = new QColor(0, 0, 192);
00558 }
00559 if (!alternateColor)
00560 alternateColor = new QColor(237, 244, 249);
00561 }
00562
00563 void KGlobalSettings::rereadFontSettings()
00564 {
00565 delete _generalFont;
00566 _generalFont = 0L;
00567 delete _fixedFont;
00568 _fixedFont = 0L;
00569 delete _menuFont;
00570 _menuFont = 0L;
00571 delete _toolBarFont;
00572 _toolBarFont = 0L;
00573 delete _windowTitleFont;
00574 _windowTitleFont = 0L;
00575 delete _taskbarFont;
00576 _taskbarFont = 0L;
00577 }
00578
00579 void KGlobalSettings::rereadPathSettings()
00580 {
00581 kdDebug() << "KGlobalSettings::rereadPathSettings" << endl;
00582 delete s_autostartPath;
00583 s_autostartPath = 0L;
00584 delete s_trashPath;
00585 s_trashPath = 0L;
00586 delete s_desktopPath;
00587 s_desktopPath = 0L;
00588 delete s_documentPath;
00589 s_documentPath = 0L;
00590 }
00591
00592 KGlobalSettings::KMouseSettings & KGlobalSettings::mouseSettings()
00593 {
00594 if ( ! s_mouseSettings )
00595 {
00596 s_mouseSettings = new KMouseSettings;
00597 KMouseSettings & s = *s_mouseSettings;
00598
00599 #ifndef Q_WS_WIN
00600 KConfigGroup g( KGlobal::config(), "Mouse" );
00601 QString setting = g.readEntry("MouseButtonMapping");
00602 if (setting == "RightHanded")
00603 s.handed = KMouseSettings::RightHanded;
00604 else if (setting == "LeftHanded")
00605 s.handed = KMouseSettings::LeftHanded;
00606 else
00607 {
00608 #ifdef Q_WS_X11
00609
00610
00611
00612 s.handed = KMouseSettings::RightHanded;
00613 unsigned char map[20];
00614 int num_buttons = XGetPointerMapping(kapp->getDisplay(), map, 20);
00615 if( num_buttons == 2 )
00616 {
00617 if ( (int)map[0] == 1 && (int)map[1] == 2 )
00618 s.handed = KMouseSettings::RightHanded;
00619 else if ( (int)map[0] == 2 && (int)map[1] == 1 )
00620 s.handed = KMouseSettings::LeftHanded;
00621 }
00622 else if( num_buttons >= 3 )
00623 {
00624 if ( (int)map[0] == 1 && (int)map[2] == 3 )
00625 s.handed = KMouseSettings::RightHanded;
00626 else if ( (int)map[0] == 3 && (int)map[2] == 1 )
00627 s.handed = KMouseSettings::LeftHanded;
00628 }
00629 #else
00630
00631 #endif
00632 }
00633 #endif //Q_WS_WIN
00634 }
00635 #ifdef Q_WS_WIN
00636
00637 s_mouseSettings->handed = (GetSystemMetrics(SM_SWAPBUTTON) ? KMouseSettings::LeftHanded : KMouseSettings::RightHanded);
00638 #endif
00639 return *s_mouseSettings;
00640 }
00641
00642 void KGlobalSettings::rereadMouseSettings()
00643 {
00644 #ifndef Q_WS_WIN
00645 delete s_mouseSettings;
00646 s_mouseSettings = 0L;
00647 #endif
00648 }
00649
00650 bool KGlobalSettings::isMultiHead()
00651 {
00652 #ifdef Q_WS_WIN
00653 return GetSystemMetrics(SM_CMONITORS) > 1;
00654 #else
00655 QCString multiHead = getenv("KDE_MULTIHEAD");
00656 if (!multiHead.isEmpty()) {
00657 return (multiHead.lower() == "true");
00658 }
00659 return false;
00660 #endif
00661 }
00662
00663 bool KGlobalSettings::wheelMouseZooms()
00664 {
00665 KConfigGroup g( KGlobal::config(), "KDE" );
00666 return g.readBoolEntry( "WheelMouseZooms", KDE_DEFAULT_WHEEL_ZOOM );
00667 }
00668
00669 QRect KGlobalSettings::splashScreenDesktopGeometry()
00670 {
00671 QDesktopWidget *dw = QApplication::desktop();
00672
00673 if (dw->isVirtualDesktop()) {
00674 KConfigGroup group(KGlobal::config(), "Windows");
00675 int scr = group.readNumEntry("Unmanaged", -3);
00676 if (group.readBoolEntry("XineramaEnabled", true) && scr != -2) {
00677 if (scr == -3)
00678 scr = dw->screenNumber(QCursor::pos());
00679 return dw->screenGeometry(scr);
00680 } else {
00681 return dw->geometry();
00682 }
00683 } else {
00684 return dw->geometry();
00685 }
00686 }
00687
00688 QRect KGlobalSettings::desktopGeometry(const QPoint& point)
00689 {
00690 QDesktopWidget *dw = QApplication::desktop();
00691
00692 if (dw->isVirtualDesktop()) {
00693 KConfigGroup group(KGlobal::config(), "Windows");
00694 if (group.readBoolEntry("XineramaEnabled", true) &&
00695 group.readBoolEntry("XineramaPlacementEnabled", true)) {
00696 return dw->screenGeometry(dw->screenNumber(point));
00697 } else {
00698 return dw->geometry();
00699 }
00700 } else {
00701 return dw->geometry();
00702 }
00703 }
00704
00705 QRect KGlobalSettings::desktopGeometry(QWidget* w)
00706 {
00707 QDesktopWidget *dw = QApplication::desktop();
00708
00709 if (dw->isVirtualDesktop()) {
00710 KConfigGroup group(KGlobal::config(), "Windows");
00711 if (group.readBoolEntry("XineramaEnabled", true) &&
00712 group.readBoolEntry("XineramaPlacementEnabled", true)) {
00713 if (w)
00714 return dw->screenGeometry(dw->screenNumber(w));
00715 else return dw->screenGeometry(-1);
00716 } else {
00717 return dw->geometry();
00718 }
00719 } else {
00720 return dw->geometry();
00721 }
00722 }
00723
00724 bool KGlobalSettings::showIconsOnPushButtons()
00725 {
00726 KConfigGroup g( KGlobal::config(), "KDE" );
00727 return g.readBoolEntry("ShowIconsOnPushButtons",
00728 KDE_DEFAULT_ICON_ON_PUSHBUTTON);
00729 }
00730
00731 bool KGlobalSettings::showFilePreview(const KURL &url)
00732 {
00733 KConfigGroup g(KGlobal::config(), "PreviewSettings");
00734 QString protocol = url.protocol();
00735 bool defaultSetting = KProtocolInfo::showFilePreview( protocol );
00736 return g.readBoolEntry(protocol, defaultSetting );
00737 }
00738
00739 bool KGlobalSettings::opaqueResize()
00740 {
00741 KConfigGroup g( KGlobal::config(), "KDE" );
00742 return g.readBoolEntry("OpaqueResize",
00743 KDE_DEFAULT_OPAQUE_RESIZE);
00744 }
00745
00746 int KGlobalSettings::buttonLayout()
00747 {
00748 KConfigGroup g( KGlobal::config(), "KDE" );
00749 return g.readNumEntry("ButtonLayout",
00750 KDE_DEFAULT_BUTTON_LAYOUT);
00751 }