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