kglobalsettings.cpp
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2000 David Faure <faure@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 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 #ifdef Q_WS_X11 00054 #include <X11/Xlib.h> 00055 #endif 00056 00057 QString* KGlobalSettings::s_desktopPath = 0; 00058 QString* KGlobalSettings::s_autostartPath = 0; 00059 QString* KGlobalSettings::s_trashPath = 0; 00060 QString* KGlobalSettings::s_documentPath = 0; 00061 QFont *KGlobalSettings::_generalFont = 0; 00062 QFont *KGlobalSettings::_fixedFont = 0; 00063 QFont *KGlobalSettings::_toolBarFont = 0; 00064 QFont *KGlobalSettings::_menuFont = 0; 00065 QFont *KGlobalSettings::_windowTitleFont = 0; 00066 QFont *KGlobalSettings::_taskbarFont = 0; 00067 QFont *KGlobalSettings::_largeFont = 0; 00068 QColor *KGlobalSettings::_kde34Blue = 0; 00069 QColor *KGlobalSettings::_inactiveBackground = 0; 00070 QColor *KGlobalSettings::_inactiveForeground = 0; 00071 QColor *KGlobalSettings::_activeBackground = 0; 00072 QColor *KGlobalSettings::_buttonBackground = 0; 00073 QColor *KGlobalSettings::_selectBackground = 0; 00074 QColor *KGlobalSettings::_linkColor = 0; 00075 QColor *KGlobalSettings::_visitedLinkColor = 0; 00076 QColor *KGlobalSettings::alternateColor = 0; 00077 00078 KGlobalSettings::KMouseSettings *KGlobalSettings::s_mouseSettings = 0; 00079 00080 int KGlobalSettings::dndEventDelay() 00081 { 00082 KConfigGroup g( KGlobal::config(), "General" ); 00083 return g.readNumEntry("StartDragDist", QApplication::startDragDistance()); 00084 } 00085 00086 bool KGlobalSettings::singleClick() 00087 { 00088 KConfigGroup g( KGlobal::config(), "KDE" ); 00089 return g.readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK); 00090 } 00091 00092 KGlobalSettings::TearOffHandle KGlobalSettings::insertTearOffHandle() 00093 { 00094 int tearoff; 00095 bool effectsenabled; 00096 KConfigGroup g( KGlobal::config(), "KDE" ); 00097 effectsenabled = g.readBoolEntry( "EffectsEnabled", false); 00098 tearoff = g.readNumEntry("InsertTearOffHandle", KDE_DEFAULT_INSERTTEAROFFHANDLES); 00099 return effectsenabled ? (TearOffHandle) tearoff : Disable; 00100 } 00101 00102 bool KGlobalSettings::changeCursorOverIcon() 00103 { 00104 KConfigGroup g( KGlobal::config(), "KDE" ); 00105 return g.readBoolEntry("ChangeCursor", KDE_DEFAULT_CHANGECURSOR); 00106 } 00107 00108 bool KGlobalSettings::visualActivate() 00109 { 00110 KConfigGroup g( KGlobal::config(), "KDE" ); 00111 return g.readBoolEntry("VisualActivate", KDE_DEFAULT_VISUAL_ACTIVATE); 00112 } 00113 00114 unsigned int KGlobalSettings::visualActivateSpeed() 00115 { 00116 KConfigGroup g( KGlobal::config(), "KDE" ); 00117 return 00118 g.readNumEntry( 00119 "VisualActivateSpeed", 00120 KDE_DEFAULT_VISUAL_ACTIVATE_SPEED 00121 ); 00122 } 00123 00124 00125 00126 int KGlobalSettings::autoSelectDelay() 00127 { 00128 KConfigGroup g( KGlobal::config(), "KDE" ); 00129 return g.readNumEntry("AutoSelectDelay", KDE_DEFAULT_AUTOSELECTDELAY); 00130 } 00131 00132 KGlobalSettings::Completion KGlobalSettings::completionMode() 00133 { 00134 int completion; 00135 KConfigGroup g( KGlobal::config(), "General" ); 00136 completion = g.readNumEntry("completionMode", -1); 00137 if ((completion < (int) CompletionNone) || 00138 (completion > (int) CompletionPopupAuto)) 00139 { 00140 completion = (int) CompletionPopup; // Default 00141 } 00142 return (Completion) completion; 00143 } 00144 00145 bool KGlobalSettings::showContextMenusOnPress () 00146 { 00147 KConfigGroup g(KGlobal::config(), "ContextMenus"); 00148 return g.readBoolEntry("ShowOnPress", true); 00149 } 00150 00151 int KGlobalSettings::contextMenuKey () 00152 { 00153 KConfigGroup g(KGlobal::config(), "Shortcuts"); 00154 KShortcut cut (g.readEntry ("PopupMenuContext", "Menu")); 00155 return cut.keyCodeQt(); 00156 } 00157 00158 QColor KGlobalSettings::toolBarHighlightColor() 00159 { 00160 initColors(); 00161 KConfigGroup g( KGlobal::config(), "Toolbar style" ); 00162 return g.readColorEntry("HighlightColor", _kde34Blue); 00163 } 00164 00165 QColor KGlobalSettings::inactiveTitleColor() 00166 { 00167 #ifdef Q_WS_WIN 00168 return qt_colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTION)); 00169 #else 00170 if (!_inactiveBackground) 00171 _inactiveBackground = new QColor(157, 170, 186); 00172 KConfigGroup g( KGlobal::config(), "WM" ); 00173 return g.readColorEntry( "inactiveBackground", _inactiveBackground ); 00174 #endif 00175 } 00176 00177 QColor KGlobalSettings::inactiveTextColor() 00178 { 00179 #ifdef Q_WS_WIN 00180 return qt_colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTIONTEXT)); 00181 #else 00182 if (!_inactiveForeground) 00183 _inactiveForeground = new QColor(221,221,221); 00184 KConfigGroup g( KGlobal::config(), "WM" ); 00185 return g.readColorEntry( "inactiveForeground", _inactiveForeground ); 00186 #endif 00187 } 00188 00189 QColor KGlobalSettings::activeTitleColor() 00190 { 00191 #ifdef Q_WS_WIN 00192 return qt_colorref2qrgb(GetSysColor(COLOR_ACTIVECAPTION)); 00193 #else 00194 initColors(); 00195 if (!_activeBackground) 00196 _activeBackground = new QColor(65,142,220); 00197 KConfigGroup g( KGlobal::config(), "WM" ); 00198 return g.readColorEntry( "activeBackground", _activeBackground); 00199 #endif 00200 } 00201 00202 QColor KGlobalSettings::activeTextColor() 00203 { 00204 #ifdef Q_WS_WIN 00205 return qt_colorref2qrgb(GetSysColor(COLOR_CAPTIONTEXT)); 00206 #else 00207 KConfigGroup g( KGlobal::config(), "WM" ); 00208 return g.readColorEntry( "activeForeground", &Qt::white ); 00209 #endif 00210 } 00211 00212 int KGlobalSettings::contrast() 00213 { 00214 KConfigGroup g( KGlobal::config(), "KDE" ); 00215 return g.readNumEntry( "contrast", 7 ); 00216 } 00217 00218 QColor KGlobalSettings::buttonBackground() 00219 { 00220 if (!_buttonBackground) 00221 _buttonBackground = new QColor(221,223,228); 00222 KConfigGroup g( KGlobal::config(), "General" ); 00223 return g.readColorEntry( "buttonBackground", _buttonBackground ); 00224 } 00225 00226 QColor KGlobalSettings::buttonTextColor() 00227 { 00228 KConfigGroup g( KGlobal::config(), "General" ); 00229 return g.readColorEntry( "buttonForeground", &Qt::black ); 00230 } 00231 00232 // IMPORTANT: 00233 // This function should be get in sync with 00234 // KApplication::kdisplaySetPalette() 00235 QColor KGlobalSettings::baseColor() 00236 { 00237 KConfigGroup g( KGlobal::config(), "General" ); 00238 return g.readColorEntry( "windowBackground", &Qt::white ); 00239 } 00240 00241 // IMPORTANT: 00242 // This function should be get in sync with 00243 // KApplication::kdisplaySetPalette() 00244 QColor KGlobalSettings::textColor() 00245 { 00246 KConfigGroup g( KGlobal::config(), "General" ); 00247 return g.readColorEntry( "windowForeground", &Qt::black ); 00248 } 00249 00250 // IMPORTANT: 00251 // This function should be get in sync with 00252 // KApplication::kdisplaySetPalette() 00253 QColor KGlobalSettings::highlightedTextColor() 00254 { 00255 KConfigGroup g( KGlobal::config(), "General" ); 00256 return g.readColorEntry( "selectForeground", &Qt::white ); 00257 } 00258 00259 // IMPORTANT: 00260 // This function should be get in sync with 00261 // KApplication::kdisplaySetPalette() 00262 QColor KGlobalSettings::highlightColor() 00263 { 00264 initColors(); 00265 if (!_selectBackground) 00266 _selectBackground = new QColor(103,141,178); 00267 KConfigGroup g( KGlobal::config(), "General" ); 00268 return g.readColorEntry( "selectBackground", _selectBackground ); 00269 } 00270 00271 QColor KGlobalSettings::alternateBackgroundColor() 00272 { 00273 initColors(); 00274 KConfigGroup g( KGlobal::config(), "General" ); 00275 *alternateColor = calculateAlternateBackgroundColor( baseColor() ); 00276 return g.readColorEntry( "alternateBackground", alternateColor ); 00277 } 00278 00279 QColor KGlobalSettings::calculateAlternateBackgroundColor(const QColor& base) 00280 { 00281 if (base == Qt::white) 00282 return QColor(238,246,255); 00283 else 00284 { 00285 int h, s, v; 00286 base.hsv( &h, &s, &v ); 00287 if (v > 128) 00288 return base.dark(106); 00289 else if (base != Qt::black) 00290 return base.light(110); 00291 00292 return QColor(32,32,32); 00293 } 00294 } 00295 00296 bool KGlobalSettings::shadeSortColumn() 00297 { 00298 KConfigGroup g( KGlobal::config(), "General" ); 00299 return g.readBoolEntry( "shadeSortColumn", KDE_DEFAULT_SHADE_SORT_COLUMN ); 00300 } 00301 00302 QColor KGlobalSettings::linkColor() 00303 { 00304 initColors(); 00305 if (!_linkColor) 00306 _linkColor = new QColor(0,0,238); 00307 KConfigGroup g( KGlobal::config(), "General" ); 00308 return g.readColorEntry( "linkColor", _linkColor ); 00309 } 00310 00311 QColor KGlobalSettings::visitedLinkColor() 00312 { 00313 if (!_visitedLinkColor) 00314 _visitedLinkColor = new QColor(82,24,139); 00315 KConfigGroup g( KGlobal::config(), "General" ); 00316 return g.readColorEntry( "visitedLinkColor", _visitedLinkColor ); 00317 } 00318 00319 QFont KGlobalSettings::generalFont() 00320 { 00321 if (_generalFont) 00322 return *_generalFont; 00323 00324 // Sync default with kdebase/kcontrol/fonts/fonts.cpp 00325 _generalFont = new QFont("Sans Serif", 10); 00326 _generalFont->setPointSize(10); 00327 _generalFont->setStyleHint(QFont::SansSerif); 00328 00329 KConfigGroup g( KGlobal::config(), "General" ); 00330 *_generalFont = g.readFontEntry("font", _generalFont); 00331 00332 return *_generalFont; 00333 } 00334 00335 QFont KGlobalSettings::fixedFont() 00336 { 00337 if (_fixedFont) 00338 return *_fixedFont; 00339 00340 // Sync default with kdebase/kcontrol/fonts/fonts.cpp 00341 _fixedFont = new QFont("Monospace", 10); 00342 _fixedFont->setPointSize(10); 00343 _fixedFont->setStyleHint(QFont::TypeWriter); 00344 00345 KConfigGroup g( KGlobal::config(), "General" ); 00346 *_fixedFont = g.readFontEntry("fixed", _fixedFont); 00347 00348 return *_fixedFont; 00349 } 00350 00351 QFont KGlobalSettings::toolBarFont() 00352 { 00353 if(_toolBarFont) 00354 return *_toolBarFont; 00355 00356 // Sync default with kdebase/kcontrol/fonts/fonts.cpp 00357 _toolBarFont = new QFont("Sans Serif", 10); 00358 _toolBarFont->setPointSize(10); 00359 _toolBarFont->setStyleHint(QFont::SansSerif); 00360 00361 KConfigGroup g( KGlobal::config(), "General" ); 00362 *_toolBarFont = g.readFontEntry("toolBarFont", _toolBarFont); 00363 00364 return *_toolBarFont; 00365 } 00366 00367 QFont KGlobalSettings::menuFont() 00368 { 00369 if(_menuFont) 00370 return *_menuFont; 00371 00372 // Sync default with kdebase/kcontrol/fonts/fonts.cpp 00373 _menuFont = new QFont("Sans Serif", 10); 00374 _menuFont->setPointSize(10); 00375 _menuFont->setStyleHint(QFont::SansSerif); 00376 00377 KConfigGroup g( KGlobal::config(), "General" ); 00378 *_menuFont = g.readFontEntry("menuFont", _menuFont); 00379 00380 return *_menuFont; 00381 } 00382 00383 QFont KGlobalSettings::windowTitleFont() 00384 { 00385 if(_windowTitleFont) 00386 return *_windowTitleFont; 00387 00388 // Sync default with kdebase/kcontrol/fonts/fonts.cpp 00389 _windowTitleFont = new QFont("Sans Serif", 9, QFont::Bold); 00390 _windowTitleFont->setPointSize(10); 00391 _windowTitleFont->setStyleHint(QFont::SansSerif); 00392 00393 KConfigGroup g( KGlobal::config(), "WM" ); 00394 *_windowTitleFont = g.readFontEntry("activeFont", _windowTitleFont); // inconsistency 00395 00396 return *_windowTitleFont; 00397 } 00398 00399 QFont KGlobalSettings::taskbarFont() 00400 { 00401 if(_taskbarFont) 00402 return *_taskbarFont; 00403 00404 // Sync default with kdebase/kcontrol/fonts/fonts.cpp 00405 _taskbarFont = new QFont("Sans Serif", 10); 00406 _taskbarFont->setPointSize(10); 00407 _taskbarFont->setStyleHint(QFont::SansSerif); 00408 00409 KConfigGroup g( KGlobal::config(), "General" ); 00410 *_taskbarFont = g.readFontEntry("taskbarFont", _taskbarFont); 00411 00412 return *_taskbarFont; 00413 } 00414 00415 00416 QFont KGlobalSettings::largeFont(const QString &text) 00417 { 00418 QFontDatabase db; 00419 QStringList fam = db.families(); 00420 00421 // Move a bunch of preferred fonts to the front. 00422 if (fam.remove("Arial")) 00423 fam.prepend("Arial"); 00424 if (fam.remove("Verdana")) 00425 fam.prepend("Verdana"); 00426 if (fam.remove("Tahoma")) 00427 fam.prepend("Tahoma"); 00428 if (fam.remove("Lucida Sans")) 00429 fam.prepend("Lucida Sans"); 00430 if (fam.remove("Lucidux Sans")) 00431 fam.prepend("Lucidux Sans"); 00432 if (fam.remove("Nimbus Sans")) 00433 fam.prepend("Nimbus Sans"); 00434 if (fam.remove("Gothic I")) 00435 fam.prepend("Gothic I"); 00436 00437 if (_largeFont) 00438 fam.prepend(_largeFont->family()); 00439 00440 for(QStringList::ConstIterator it = fam.begin(); 00441 it != fam.end(); ++it) 00442 { 00443 if (db.isSmoothlyScalable(*it) && !db.isFixedPitch(*it)) 00444 { 00445 QFont font(*it); 00446 font.setPixelSize(75); 00447 QFontMetrics metrics(font); 00448 int h = metrics.height(); 00449 if ((h < 60) || ( h > 90)) 00450 continue; 00451 00452 bool ok = true; 00453 for(unsigned int i = 0; i < text.length(); i++) 00454 { 00455 if (!metrics.inFont(text[i])) 00456 { 00457 ok = false; 00458 break; 00459 } 00460 } 00461 if (!ok) 00462 continue; 00463 00464 font.setPointSize(48); 00465 _largeFont = new QFont(font); 00466 return *_largeFont; 00467 } 00468 } 00469 _largeFont = new QFont(KGlobalSettings::generalFont()); 00470 _largeFont->setPointSize(48); 00471 return *_largeFont; 00472 } 00473 00474 void KGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here. 00475 { 00476 if ( s_desktopPath != 0 ) 00477 return; 00478 00479 s_desktopPath = new QString(); 00480 s_autostartPath = new QString(); 00481 s_trashPath = new QString(); 00482 s_documentPath = new QString(); 00483 00484 KConfigGroup g( KGlobal::config(), "Paths" ); 00485 00486 // Desktop Path 00487 *s_desktopPath = QDir::homeDirPath() + "/Desktop/"; 00488 *s_desktopPath = g.readPathEntry( "Desktop", *s_desktopPath); 00489 *s_desktopPath = QDir::cleanDirPath( *s_desktopPath ); 00490 if ( !s_desktopPath->endsWith("/") ) 00491 s_desktopPath->append('/'); 00492 00493 // Trash Path - TODO remove in KDE4 (kio_trash can't use it for interoperability reasons) 00494 *s_trashPath = *s_desktopPath + i18n("Trash") + "/"; 00495 *s_trashPath = g.readPathEntry( "Trash" , *s_trashPath); 00496 *s_trashPath = QDir::cleanDirPath( *s_trashPath ); 00497 if ( !s_trashPath->endsWith("/") ) 00498 s_trashPath->append('/'); 00499 // We need to save it in any case, in case the language changes later on, 00500 if ( !g.hasKey( "Trash" ) ) 00501 { 00502 g.writePathEntry( "Trash", *s_trashPath, true, true ); 00503 g.sync(); 00504 } 00505 00506 // Autostart Path 00507 *s_autostartPath = KGlobal::dirs()->localkdedir() + "Autostart/"; 00508 *s_autostartPath = g.readPathEntry( "Autostart" , *s_autostartPath); 00509 *s_autostartPath = QDir::cleanDirPath( *s_autostartPath ); 00510 if ( !s_autostartPath->endsWith("/") ) 00511 s_autostartPath->append('/'); 00512 00513 // Document Path 00514 *s_documentPath = g.readPathEntry( "Documents", 00515 #ifdef Q_WS_WIN 00516 getWin32ShellFoldersPath("Personal") 00517 #else 00518 QDir::homeDirPath() 00519 #endif 00520 ); 00521 *s_documentPath = QDir::cleanDirPath( *s_documentPath ); 00522 if ( !s_documentPath->endsWith("/")) 00523 s_documentPath->append('/'); 00524 00525 // Make sure this app gets the notifications about those paths 00526 if (kapp) 00527 kapp->addKipcEventMask(KIPC::SettingsChanged); 00528 } 00529 00530 void KGlobalSettings::initColors() 00531 { 00532 if (!_kde34Blue) { 00533 if (QPixmap::defaultDepth() > 8) 00534 _kde34Blue = new QColor(103,141,178); 00535 else 00536 _kde34Blue = new QColor(0, 0, 192); 00537 } 00538 if (!alternateColor) 00539 alternateColor = new QColor(237, 244, 249); 00540 } 00541 00542 void KGlobalSettings::rereadFontSettings() 00543 { 00544 delete _generalFont; 00545 _generalFont = 0L; 00546 delete _fixedFont; 00547 _fixedFont = 0L; 00548 delete _menuFont; 00549 _menuFont = 0L; 00550 delete _toolBarFont; 00551 _toolBarFont = 0L; 00552 delete _windowTitleFont; 00553 _windowTitleFont = 0L; 00554 delete _taskbarFont; 00555 _taskbarFont = 0L; 00556 } 00557 00558 void KGlobalSettings::rereadPathSettings() 00559 { 00560 kdDebug() << "KGlobalSettings::rereadPathSettings" << endl; 00561 delete s_autostartPath; 00562 s_autostartPath = 0L; 00563 delete s_trashPath; 00564 s_trashPath = 0L; 00565 delete s_desktopPath; 00566 s_desktopPath = 0L; 00567 delete s_documentPath; 00568 s_documentPath = 0L; 00569 } 00570 00571 KGlobalSettings::KMouseSettings & KGlobalSettings::mouseSettings() 00572 { 00573 if ( ! s_mouseSettings ) 00574 { 00575 s_mouseSettings = new KMouseSettings; 00576 KMouseSettings & s = *s_mouseSettings; // for convenience 00577 00578 #ifndef Q_WS_WIN 00579 KConfigGroup g( KGlobal::config(), "Mouse" ); 00580 QString setting = g.readEntry("MouseButtonMapping"); 00581 if (setting == "RightHanded") 00582 s.handed = KMouseSettings::RightHanded; 00583 else if (setting == "LeftHanded") 00584 s.handed = KMouseSettings::LeftHanded; 00585 else 00586 { 00587 #ifdef Q_WS_X11 00588 // get settings from X server 00589 // This is a simplified version of the code in input/mouse.cpp 00590 // Keep in sync ! 00591 s.handed = KMouseSettings::RightHanded; 00592 unsigned char map[20]; 00593 int num_buttons = XGetPointerMapping(kapp->getDisplay(), map, 20); 00594 if( num_buttons == 2 ) 00595 { 00596 if ( (int)map[0] == 1 && (int)map[1] == 2 ) 00597 s.handed = KMouseSettings::RightHanded; 00598 else if ( (int)map[0] == 2 && (int)map[1] == 1 ) 00599 s.handed = KMouseSettings::LeftHanded; 00600 } 00601 else if( num_buttons >= 3 ) 00602 { 00603 if ( (int)map[0] == 1 && (int)map[2] == 3 ) 00604 s.handed = KMouseSettings::RightHanded; 00605 else if ( (int)map[0] == 3 && (int)map[2] == 1 ) 00606 s.handed = KMouseSettings::LeftHanded; 00607 } 00608 #else 00609 // FIXME(E): Implement in Qt Embedded 00610 #endif 00611 } 00612 #endif //Q_WS_WIN 00613 } 00614 #ifdef Q_WS_WIN 00615 //not cached 00616 s_mouseSettings->handed = (GetSystemMetrics(SM_SWAPBUTTON) ? KMouseSettings::LeftHanded : KMouseSettings::RightHanded); 00617 #endif 00618 return *s_mouseSettings; 00619 } 00620 00621 void KGlobalSettings::rereadMouseSettings() 00622 { 00623 #ifndef Q_WS_WIN 00624 delete s_mouseSettings; 00625 s_mouseSettings = 0L; 00626 #endif 00627 } 00628 00629 bool KGlobalSettings::isMultiHead() 00630 { 00631 #ifdef Q_WS_WIN 00632 return GetSystemMetrics(SM_CMONITORS) > 1; 00633 #else 00634 QCString multiHead = getenv("KDE_MULTIHEAD"); 00635 if (!multiHead.isEmpty()) { 00636 return (multiHead.lower() == "true"); 00637 } 00638 return false; 00639 #endif 00640 } 00641 00642 bool KGlobalSettings::wheelMouseZooms() 00643 { 00644 KConfigGroup g( KGlobal::config(), "KDE" ); 00645 return g.readBoolEntry( "WheelMouseZooms", KDE_DEFAULT_WHEEL_ZOOM ); 00646 } 00647 00648 QRect KGlobalSettings::splashScreenDesktopGeometry() 00649 { 00650 QDesktopWidget *dw = QApplication::desktop(); 00651 00652 if (dw->isVirtualDesktop()) { 00653 KConfigGroup group(KGlobal::config(), "Windows"); 00654 int scr = group.readNumEntry("Unmanaged", -3); 00655 if (group.readBoolEntry("XineramaEnabled", true) && scr != -2) { 00656 if (scr == -3) 00657 scr = dw->screenNumber(QCursor::pos()); 00658 return dw->screenGeometry(scr); 00659 } else { 00660 return dw->geometry(); 00661 } 00662 } else { 00663 return dw->geometry(); 00664 } 00665 } 00666 00667 QRect KGlobalSettings::desktopGeometry(const QPoint& point) 00668 { 00669 QDesktopWidget *dw = QApplication::desktop(); 00670 00671 if (dw->isVirtualDesktop()) { 00672 KConfigGroup group(KGlobal::config(), "Windows"); 00673 if (group.readBoolEntry("XineramaEnabled", true) && 00674 group.readBoolEntry("XineramaPlacementEnabled", true)) { 00675 return dw->screenGeometry(dw->screenNumber(point)); 00676 } else { 00677 return dw->geometry(); 00678 } 00679 } else { 00680 return dw->geometry(); 00681 } 00682 } 00683 00684 QRect KGlobalSettings::desktopGeometry(QWidget* w) 00685 { 00686 QDesktopWidget *dw = QApplication::desktop(); 00687 00688 if (dw->isVirtualDesktop()) { 00689 KConfigGroup group(KGlobal::config(), "Windows"); 00690 if (group.readBoolEntry("XineramaEnabled", true) && 00691 group.readBoolEntry("XineramaPlacementEnabled", true)) { 00692 if (w) 00693 return dw->screenGeometry(dw->screenNumber(w)); 00694 else return dw->screenGeometry(-1); 00695 } else { 00696 return dw->geometry(); 00697 } 00698 } else { 00699 return dw->geometry(); 00700 } 00701 } 00702 00703 bool KGlobalSettings::showIconsOnPushButtons() 00704 { 00705 KConfigGroup g( KGlobal::config(), "KDE" ); 00706 return g.readBoolEntry("ShowIconsOnPushButtons", 00707 KDE_DEFAULT_ICON_ON_PUSHBUTTON); 00708 } 00709 00710 bool KGlobalSettings::showFilePreview(const KURL &url) 00711 { 00712 KConfigGroup g(KGlobal::config(), "PreviewSettings"); 00713 QString protocol = url.protocol(); 00714 bool defaultSetting = KProtocolInfo::showFilePreview( protocol ); 00715 return g.readBoolEntry(protocol, defaultSetting ); 00716 } 00717 00718 bool KGlobalSettings::opaqueResize() 00719 { 00720 KConfigGroup g( KGlobal::config(), "KDE" ); 00721 return g.readBoolEntry("OpaqueResize", 00722 KDE_DEFAULT_OPAQUE_RESIZE); 00723 } 00724 00725 int KGlobalSettings::buttonLayout() 00726 { 00727 KConfigGroup g( KGlobal::config(), "KDE" ); 00728 return g.readNumEntry("ButtonLayout", 00729 KDE_DEFAULT_BUTTON_LAYOUT); 00730 }