kdecore Library API Documentation

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., 59 Temple Place - Suite 330,
00016    Boston, MA 02111-1307, 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 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
00031 #include <kipc.h> // schroder
00032 #endif
00033 
00034 #include <kdebug.h>
00035 #include <kglobal.h>
00036 #include <kshortcut.h>
00037 #include <kstandarddirs.h>
00038 #include <kcharsets.h>
00039 #include <kaccel.h>
00040 #include <klocale.h>
00041 #include <qfontinfo.h>
00042 #include <stdlib.h>
00043 #include <kprotocolinfo.h>
00044 
00045 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
00046 //#ifdef Q_WS_X11
00047 //#include <X11/X.h>
00048 #include <X11/Xlib.h> // schroder
00049 //#include <X11/Xutil.h>
00050 #endif
00051 
00052 QString* KGlobalSettings::s_desktopPath = 0;
00053 QString* KGlobalSettings::s_autostartPath = 0;
00054 QString* KGlobalSettings::s_trashPath = 0;
00055 QString* KGlobalSettings::s_documentPath = 0;
00056 QFont *KGlobalSettings::_generalFont = 0;
00057 QFont *KGlobalSettings::_fixedFont = 0;
00058 QFont *KGlobalSettings::_toolBarFont = 0;
00059 QFont *KGlobalSettings::_menuFont = 0;
00060 QFont *KGlobalSettings::_windowTitleFont = 0;
00061 QFont *KGlobalSettings::_taskbarFont = 0;
00062 QFont *KGlobalSettings::_largeFont = 0;
00063 QColor *KGlobalSettings::kde2Blue = 0;
00064 QColor *KGlobalSettings::kde2Gray = 0;
00065 QColor *KGlobalSettings::kde2AlternateColor = 0;
00066 
00067 KGlobalSettings::KMouseSettings *KGlobalSettings::s_mouseSettings = 0;
00068 
00069 int KGlobalSettings::dndEventDelay()
00070 {
00071     KConfig *c = KGlobal::config();
00072     KConfigGroupSaver cgs( c, "General" );
00073     return c->readNumEntry("StartDragDist", QApplication::startDragDistance());
00074 }
00075 
00076 bool KGlobalSettings::singleClick()
00077 {
00078     KConfig *c = KGlobal::config();
00079     KConfigGroupSaver cgs( c, "KDE" );
00080     return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK);
00081 }
00082 
00083 KGlobalSettings::TearOffHandle KGlobalSettings::insertTearOffHandle()
00084 {
00085     int tearoff;
00086     bool effectsenabled;
00087     KConfig *c = KGlobal::config();
00088     KConfigGroupSaver cgs( c, "KDE" );
00089     effectsenabled = c->readBoolEntry( "EffectsEnabled", false);
00090     tearoff =c->readNumEntry("InsertTearOffHandle", KDE_DEFAULT_INSERTTEAROFFHANDLES);
00091     return effectsenabled ? (TearOffHandle) tearoff : Disable;
00092 }
00093 
00094 bool KGlobalSettings::changeCursorOverIcon()
00095 {
00096     KConfig *c = KGlobal::config();
00097     KConfigGroupSaver cgs( c, "KDE" );
00098     return c->readBoolEntry("ChangeCursor", KDE_DEFAULT_CHANGECURSOR);
00099 }
00100 
00101 bool KGlobalSettings::visualActivate()
00102 {
00103     KConfig *c = KGlobal::config();
00104     KConfigGroupSaver cgs( c, "KDE" );
00105     return c->readBoolEntry("VisualActivate", KDE_DEFAULT_VISUAL_ACTIVATE);
00106 }
00107 
00108 unsigned int KGlobalSettings::visualActivateSpeed()
00109 {
00110     KConfig *c = KGlobal::config();
00111     KConfigGroupSaver cgs( c, "KDE" );
00112     return
00113         c->readNumEntry(
00114             "VisualActivateSpeed",
00115             KDE_DEFAULT_VISUAL_ACTIVATE_SPEED
00116         );
00117 }
00118 
00119 
00120 
00121 int KGlobalSettings::autoSelectDelay()
00122 {
00123     KConfig *c = KGlobal::config();
00124     KConfigGroupSaver cgs( c, "KDE" );
00125     return c->readNumEntry("AutoSelectDelay", KDE_DEFAULT_AUTOSELECTDELAY);
00126 }
00127 
00128 KGlobalSettings::Completion KGlobalSettings::completionMode()
00129 {
00130     int completion;
00131     KConfig *c = KGlobal::config();
00132     KConfigGroupSaver cgs( c, "General" );
00133     completion = c->readNumEntry("completionMode", -1);
00134     if ((completion < (int) CompletionNone) ||
00135         (completion > (int) CompletionPopupAuto))
00136       {
00137         completion = (int) CompletionPopup; // Default
00138       }
00139   return (Completion) completion;
00140 }
00141 
00142 bool KGlobalSettings::showContextMenusOnPress ()
00143 {
00144     KConfig *c = KGlobal::config();
00145     KConfigGroupSaver cgs (c, "ContextMenus");
00146 
00147     return cgs.config()->readBoolEntry("ShowOnPress", true);
00148 }
00149 
00150 int KGlobalSettings::contextMenuKey ()
00151 {
00152     KConfig *c = KGlobal::config();
00153     KConfigGroupSaver cgs (c, "Shortcuts");
00154 
00155     KShortcut cut (cgs.config()->readEntry ("PopupMenuContext", "Menu"));
00156     return cut.keyCodeQt();
00157 }
00158 
00159 QColor KGlobalSettings::toolBarHighlightColor()
00160 {
00161     initColors();
00162     KConfig *c = KGlobal::config();
00163     KConfigGroupSaver cgs( c, QString::fromLatin1("Toolbar style") );
00164     return c->readColorEntry("HighlightColor", kde2Blue);
00165 }
00166 
00167 QColor KGlobalSettings::inactiveTitleColor()
00168 {
00169     if (!kde2Gray)
00170         kde2Gray = new QColor(220, 220, 220);
00171     KConfig *c = KGlobal::config();
00172     KConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
00173     return c->readColorEntry( "inactiveBackground", kde2Gray );
00174 }
00175 
00176 QColor KGlobalSettings::inactiveTextColor()
00177 {
00178     KConfig *c = KGlobal::config();
00179     KConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
00180     return c->readColorEntry( "inactiveForeground", &Qt::darkGray );
00181 }
00182 
00183 QColor KGlobalSettings::activeTitleColor()
00184 {
00185     initColors();
00186     KConfig *c = KGlobal::config();
00187     KConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
00188     return c->readColorEntry( "activeBackground", kde2Blue);
00189 }
00190 
00191 QColor KGlobalSettings::activeTextColor()
00192 {
00193     KConfig *c = KGlobal::config();
00194     KConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
00195     return c->readColorEntry( "activeForeground", &Qt::white );
00196 }
00197 
00198 int KGlobalSettings::contrast()
00199 {
00200     KConfig *c = KGlobal::config();
00201     KConfigGroupSaver cgs( c, QString::fromLatin1("KDE") );
00202     return c->readNumEntry( "contrast", 7 );
00203 }
00204 
00205 // IMPORTANT:
00206 //  This function should be get in sync with
00207 //   KApplication::kdisplaySetPalette()
00208 QColor KGlobalSettings::baseColor()
00209 {
00210     KConfig *c = KGlobal::config();
00211     KConfigGroupSaver cgs( c, QString::fromLatin1("General") );
00212     return c->readColorEntry( "windowBackground", &Qt::white );
00213 }
00214 
00215 // IMPORTANT:
00216 //  This function should be get in sync with
00217 //   KApplication::kdisplaySetPalette()
00218 QColor KGlobalSettings::textColor()
00219 {
00220     KConfig *c = KGlobal::config();
00221     KConfigGroupSaver cgs( c, QString::fromLatin1("General") );
00222     return c->readColorEntry( "windowForeground", &Qt::black );
00223 }
00224 
00225 // IMPORTANT:
00226 //  This function should be get in sync with
00227 //   KApplication::kdisplaySetPalette()
00228 QColor KGlobalSettings::highlightedTextColor()
00229 {
00230     KConfig *c = KGlobal::config();
00231     KConfigGroupSaver cgs( c, QString::fromLatin1("General") );
00232     return c->readColorEntry( "selectForeground", &Qt::white );
00233 }
00234 
00235 // IMPORTANT:
00236 //  This function should be get in sync with
00237 //   KApplication::kdisplaySetPalette()
00238 QColor KGlobalSettings::highlightColor()
00239 {
00240     initColors();
00241     KConfig *c = KGlobal::config();
00242     KConfigGroupSaver cgs( c, QString::fromLatin1("General") );
00243     return c->readColorEntry( "selectBackground", kde2Blue );
00244 }
00245 
00246 QColor KGlobalSettings::alternateBackgroundColor()
00247 {
00248     initColors();
00249     KConfig *c = KGlobal::config();
00250     KConfigGroupSaver cgs( c, QString::fromLatin1("General") );
00251     *kde2AlternateColor = calculateAlternateBackgroundColor( baseColor() );
00252     return c->readColorEntry( "alternateBackground", kde2AlternateColor );
00253 }
00254 
00255 QColor KGlobalSettings::calculateAlternateBackgroundColor(const QColor& base)
00256 {
00257     if (base == Qt::white)
00258         return QColor(238,246,255);
00259     else
00260     {
00261         int h, s, v;
00262         base.hsv( &h, &s, &v );
00263         if (v > 128)
00264             return base.dark(106);
00265         else if (base != Qt::black)
00266             return base.light(110);
00267 
00268         return QColor(32,32,32);
00269     }
00270 }
00271 
00272 QColor KGlobalSettings::linkColor()
00273 {
00274     initColors();
00275     KConfig *c = KGlobal::config();
00276     KConfigGroupSaver cgs( c, QString::fromLatin1("General") );
00277     return c->readColorEntry( "linkColor", kde2Blue );
00278 }
00279 
00280 QColor KGlobalSettings::visitedLinkColor()
00281 {
00282     KConfig *c = KGlobal::config();
00283     KConfigGroupSaver cgs( c, QString::fromLatin1("General") );
00284     return c->readColorEntry( "visitedLinkColor", &Qt::magenta );
00285 }
00286 
00287 QFont KGlobalSettings::generalFont()
00288 {
00289     if (_generalFont)
00290         return *_generalFont;
00291 
00292     // Sync default with kdebase/kcontrol/fonts/fonts.cpp
00293     _generalFont = new QFont("helvetica", 12);
00294     _generalFont->setPointSize(12);
00295     _generalFont->setStyleHint(QFont::SansSerif);
00296 
00297     KConfig *c = KGlobal::config();
00298     KConfigGroupSaver cgs( c, QString::fromLatin1("General") );
00299     *_generalFont = c->readFontEntry("font", _generalFont);
00300 
00301     return *_generalFont;
00302 }
00303 
00304 QFont KGlobalSettings::fixedFont()
00305 {
00306     if (_fixedFont)
00307         return *_fixedFont;
00308 
00309     // Sync default with kdebase/kcontrol/fonts/fonts.cpp
00310     _fixedFont = new QFont("courier", 12);
00311     _fixedFont->setPointSize(12);
00312     _fixedFont->setStyleHint(QFont::TypeWriter);
00313 
00314     KConfig *c = KGlobal::config();
00315     KConfigGroupSaver cgs( c, QString::fromLatin1("General") );
00316     *_fixedFont = c->readFontEntry("fixed", _fixedFont);
00317 
00318     return *_fixedFont;
00319 }
00320 
00321 QFont KGlobalSettings::toolBarFont()
00322 {
00323     if(_toolBarFont)
00324         return *_toolBarFont;
00325 
00326     // Sync default with kdebase/kcontrol/fonts/fonts.cpp
00327     _toolBarFont = new QFont("helvetica", 10);
00328     _toolBarFont->setPointSize(10);
00329     _toolBarFont->setStyleHint(QFont::SansSerif);
00330 
00331     KConfig *c = KGlobal::config();
00332     KConfigGroupSaver cgs( c, QString::fromLatin1("General") );
00333     *_toolBarFont = c->readFontEntry("toolBarFont", _toolBarFont);
00334 
00335     return *_toolBarFont;
00336 }
00337 
00338 QFont KGlobalSettings::menuFont()
00339 {
00340     if(_menuFont)
00341         return *_menuFont;
00342 
00343     // Sync default with kdebase/kcontrol/fonts/fonts.cpp
00344     _menuFont = new QFont("helvetica", 12);
00345     _menuFont->setPointSize(12);
00346     _menuFont->setStyleHint(QFont::SansSerif);
00347 
00348     KConfig *c = KGlobal::config();
00349     KConfigGroupSaver cgs( c, QString::fromLatin1("General") );
00350     *_menuFont = c->readFontEntry("menuFont", _menuFont);
00351 
00352     return *_menuFont;
00353 }
00354 
00355 QFont KGlobalSettings::windowTitleFont()
00356 {
00357     if(_windowTitleFont)
00358         return *_windowTitleFont;
00359 
00360     // Sync default with kdebase/kcontrol/fonts/fonts.cpp
00361     _windowTitleFont = new QFont("helvetica", 12, QFont::Bold);
00362     _windowTitleFont->setPointSize(12);
00363     _windowTitleFont->setStyleHint(QFont::SansSerif);
00364 
00365     KConfig *c = KGlobal::config();
00366     KConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
00367     *_windowTitleFont = c->readFontEntry("activeFont", _windowTitleFont); // inconsistency
00368 
00369     return *_windowTitleFont;
00370 }
00371 
00372 QFont KGlobalSettings::taskbarFont()
00373 {
00374     if(_taskbarFont)
00375         return *_taskbarFont;
00376 
00377     // Sync default with kdebase/kcontrol/fonts/fonts.cpp
00378     _taskbarFont = new QFont("helvetica", 11);
00379     _taskbarFont->setPointSize(11);
00380     _taskbarFont->setStyleHint(QFont::SansSerif);
00381 
00382     KConfig *c = KGlobal::config();
00383     KConfigGroupSaver cgs( c, QString::fromLatin1("General") );
00384     *_taskbarFont = c->readFontEntry("taskbarFont", _taskbarFont);
00385 
00386     return *_taskbarFont;
00387 }
00388 
00389 
00390 QFont KGlobalSettings::largeFont(const QString &text)
00391 {
00392     QFontDatabase db;
00393     QStringList fam = db.families();
00394         
00395     // Move a bunch of preferred fonts to the front.
00396     if (fam.remove("Arial"))
00397        fam.prepend("Arial");
00398     if (fam.remove("Verdana"))
00399        fam.prepend("Verdana");
00400     if (fam.remove("Tahoma"))
00401        fam.prepend("Tahoma");
00402     if (fam.remove("Lucida Sans"))
00403        fam.prepend("Lucida Sans");
00404     if (fam.remove("Lucidux Sans"))
00405        fam.prepend("Lucidux Sans");
00406     if (fam.remove("Nimbus Sans"))
00407        fam.prepend("Nimbus Sans");
00408     if (fam.remove("Gothic I"))
00409        fam.prepend("Gothic I");
00410 
00411     if (_largeFont)
00412         fam.prepend(_largeFont->family());
00413 
00414     for(QStringList::ConstIterator it = fam.begin();
00415         it != fam.end(); ++it)
00416     {
00417         if (db.isSmoothlyScalable(*it) && !db.isFixedPitch(*it))
00418         {
00419             QFont font(*it);
00420             font.setPixelSize(75);
00421             QFontMetrics metrics(font);
00422             int h = metrics.height();
00423             if ((h < 60) || ( h > 90))
00424                 continue;
00425 
00426             bool ok = true;
00427             for(unsigned int i = 0; i < text.length(); i++)
00428             {
00429                 if (!metrics.inFont(text[i]))
00430                 {
00431                     ok = false;
00432                     break;
00433                 }
00434             }
00435             if (!ok)
00436                 continue;
00437 
00438             font.setPointSize(48);
00439             _largeFont = new QFont(font);
00440             return *_largeFont;
00441         }
00442     }
00443     _largeFont = new QFont(KGlobalSettings::generalFont());
00444     _largeFont->setPointSize(48);
00445     return *_largeFont;
00446 }
00447 
00448 void KGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here.
00449 {
00450     if ( s_desktopPath != 0 )
00451         return;
00452 
00453     s_desktopPath = new QString();
00454     s_autostartPath = new QString();
00455     s_trashPath = new QString();
00456     s_documentPath = new QString();
00457 
00458     KConfig *config = KGlobal::config();
00459     KConfigGroupSaver cgs( config, "Paths" );
00460 
00461     // Desktop Path
00462     *s_desktopPath = QDir::homeDirPath() + "/Desktop/";
00463     *s_desktopPath = config->readPathEntry( "Desktop", *s_desktopPath);
00464     if ( !s_desktopPath->startsWith("/") )
00465       s_desktopPath->prepend( QDir::homeDirPath() + "/" );
00466     *s_desktopPath = QDir::cleanDirPath( *s_desktopPath );
00467     if ( !s_desktopPath->endsWith("/") )
00468       s_desktopPath->append('/');
00469 
00470     // Trash Path
00471     *s_trashPath = *s_desktopPath + i18n("Trash") + "/";
00472     *s_trashPath = config->readPathEntry( "Trash" , *s_trashPath);
00473     if ( !s_trashPath->startsWith("/") )
00474       s_trashPath->prepend( QDir::homeDirPath() + "/" );
00475     *s_trashPath = QDir::cleanDirPath( *s_trashPath );
00476     if ( !s_trashPath->endsWith("/") )
00477       s_trashPath->append('/');
00478     // We need to save it in any case, in case the language changes later on,
00479     if ( !config->hasKey( "Trash" ) )
00480     {
00481       config->writePathEntry( "Trash", *s_trashPath, true, true );
00482       config->sync();
00483     }
00484 
00485     // Autostart Path
00486     *s_autostartPath = KGlobal::dirs()->localkdedir() + "Autostart/";
00487     *s_autostartPath = config->readPathEntry( "Autostart" , *s_autostartPath);
00488     if ( !s_autostartPath->startsWith("/") )
00489       s_autostartPath->prepend( QDir::homeDirPath() + "/" );
00490     *s_autostartPath = QDir::cleanDirPath( *s_autostartPath );
00491     if ( !s_autostartPath->endsWith("/") )
00492       s_autostartPath->append('/');
00493 
00494     // Document Path
00495     *s_documentPath = config->readPathEntry( "Documents" );
00496     if ( !s_documentPath->startsWith("/") )
00497       s_documentPath->prepend( QDir::homeDirPath() + "/" );
00498     *s_documentPath = QDir::cleanDirPath( *s_documentPath );
00499     if ( !s_documentPath->endsWith("/"))
00500       s_documentPath->append('/');
00501 
00502     // Make sure this app gets the notifications about those paths
00503 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
00504     if (kapp)
00505         kapp->addKipcEventMask(KIPC::SettingsChanged);
00506 #endif
00507 }
00508 
00509 void KGlobalSettings::initColors()
00510 {
00511     if (!kde2Blue) {
00512       if (QPixmap::defaultDepth() > 8)
00513         kde2Blue = new QColor(84, 112, 152);
00514       else
00515         kde2Blue = new QColor(0, 0, 192);
00516     }
00517     if (!kde2AlternateColor)
00518       kde2AlternateColor = new QColor(240, 240, 240);
00519 }
00520 
00521 void KGlobalSettings::rereadFontSettings()
00522 {
00523     delete _generalFont;
00524     _generalFont = 0L;
00525     delete _fixedFont;
00526     _fixedFont = 0L;
00527     delete _menuFont;
00528     _menuFont = 0L;
00529     delete _toolBarFont;
00530     _toolBarFont = 0L;
00531     delete _windowTitleFont;
00532     _windowTitleFont = 0L;
00533     delete _taskbarFont;
00534     _taskbarFont = 0L;
00535 }
00536 
00537 void KGlobalSettings::rereadPathSettings()
00538 {
00539     kdDebug() << "KGlobalSettings::rereadPathSettings" << endl;
00540     delete s_autostartPath;
00541     s_autostartPath = 0L;
00542     delete s_trashPath;
00543     s_trashPath = 0L;
00544     delete s_desktopPath;
00545     s_desktopPath = 0L;
00546     delete s_documentPath;
00547     s_documentPath = 0L;
00548 }
00549 
00550 KGlobalSettings::KMouseSettings & KGlobalSettings::mouseSettings()
00551 {
00552     if ( ! s_mouseSettings )
00553     {
00554         s_mouseSettings = new KMouseSettings;
00555         KMouseSettings & s = *s_mouseSettings; // for convenience
00556 
00557         KConfigGroupSaver cgs( KGlobal::config(), "Mouse" );
00558         QString setting = KGlobal::config()->readEntry("MouseButtonMapping");
00559         if (setting == "RightHanded")
00560             s.handed = KMouseSettings::RightHanded;
00561         else if (setting == "LeftHanded")
00562             s.handed = KMouseSettings::LeftHanded;
00563         else
00564         {
00565 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
00566             // get settings from X server
00567             // This is a simplified version of the code in input/mouse.cpp
00568             // Keep in sync !
00569             s.handed = KMouseSettings::RightHanded;
00570             unsigned char map[5];
00571             switch (XGetPointerMapping(kapp->getDisplay(), map, 5))
00572             {
00573                 case 2:
00574                     if ( (int)map[0] == 1 && (int)map[1] == 2 )
00575                         s.handed = KMouseSettings::RightHanded;
00576                     else if ( (int)map[0] == 2 && (int)map[1] == 1 )
00577                         s.handed = KMouseSettings::LeftHanded;
00578                     break;
00579                 case 3:
00580                 case 5:
00581                     if ( (int)map[0] == 1 && (int)map[2] == 3 )
00582                         s.handed = KMouseSettings::RightHanded;
00583                     else if ( (int)map[0] == 3 && (int)map[2] == 1 )
00584                         s.handed = KMouseSettings::LeftHanded;
00585                     break;
00586                 default:
00587                     break;
00588             }
00589 #else
00590         // FIXME(E): Implement in Qt Embedded
00591 #endif
00592         }
00593     }
00594     return *s_mouseSettings;
00595 }
00596 
00597 void KGlobalSettings::rereadMouseSettings()
00598 {
00599     delete s_mouseSettings;
00600     s_mouseSettings = 0L;
00601 }
00602 
00603 bool KGlobalSettings::isMultiHead()
00604 {
00605     QCString multiHead = getenv("KDE_MULTIHEAD");
00606     if (!multiHead.isEmpty()) {
00607         return (multiHead.lower() == "true");
00608     }
00609     return false;
00610 }
00611 
00612 bool KGlobalSettings::wheelMouseZooms()
00613 {
00614     KConfig *c = KGlobal::config();
00615     KConfigGroupSaver cgs( c, "KDE" );
00616     return c->readBoolEntry( "WheelMouseZooms", KDE_DEFAULT_WHEEL_ZOOM );
00617 }
00618 
00619 QRect KGlobalSettings::splashScreenDesktopGeometry()
00620 {
00621     QDesktopWidget *dw = QApplication::desktop();
00622 
00623     if (dw->isVirtualDesktop()) {
00624         KConfigGroup group(KGlobal::config(), "Windows");
00625         int scr = group.readNumEntry("Unmanaged", -3);
00626         if (group.readBoolEntry("XineramaEnabled", true) && scr != -2) {
00627             if (scr == -3)
00628                 scr = dw->screenNumber(QCursor::pos());
00629             return dw->screenGeometry(scr);
00630         } else {
00631             return dw->geometry();
00632         }
00633     } else {
00634         return dw->geometry();
00635     }
00636 }
00637 
00638 QRect KGlobalSettings::desktopGeometry(const QPoint& point)
00639 {
00640     QDesktopWidget *dw = QApplication::desktop();
00641 
00642     if (dw->isVirtualDesktop()) {
00643         KConfigGroup group(KGlobal::config(), "Windows");
00644         if (group.readBoolEntry("XineramaEnabled", true) &&
00645             group.readBoolEntry("XineramaPlacementEnabled", true)) {
00646             return dw->screenGeometry(dw->screenNumber(point));
00647         } else {
00648             return dw->geometry();
00649         }
00650     } else {
00651         return dw->geometry();
00652     }
00653 }
00654 
00655 QRect KGlobalSettings::desktopGeometry(QWidget* w)
00656 {
00657     QDesktopWidget *dw = QApplication::desktop();
00658 
00659     if (dw->isVirtualDesktop()) {
00660         KConfigGroup group(KGlobal::config(), "Windows");
00661         if (group.readBoolEntry("XineramaEnabled", true) &&
00662             group.readBoolEntry("XineramaPlacementEnabled", true)) {
00663             if (w)
00664                 return dw->screenGeometry(dw->screenNumber(w));
00665             else return dw->screenGeometry(-1);
00666         } else {
00667             return dw->geometry();
00668         }
00669     } else {
00670         return dw->geometry();
00671     }
00672 }
00673 
00674 bool KGlobalSettings::showIconsOnPushButtons()
00675 {
00676     KConfig *c = KGlobal::config();
00677     KConfigGroupSaver cgs( c, "KDE" );
00678     return c->readBoolEntry("ShowIconsOnPushButtons",
00679         KDE_DEFAULT_ICON_ON_PUSHBUTTON);
00680 }
00681 
00682 bool KGlobalSettings::showFilePreview(const KURL &url)
00683 {
00684     KConfigGroup g(KGlobal::config(), "PreviewSettings");
00685     QString protocol = url.protocol();
00686     bool defaultSetting = KProtocolInfo::showFilePreview( protocol );
00687     return g.readBoolEntry(protocol, defaultSetting );
00688 }
00689 
00690 bool KGlobalSettings::opaqueResize()
00691 {
00692     KConfig *c = KGlobal::config();
00693     KConfigGroupSaver cgs( c, "KDE" );
00694     return c->readBoolEntry("OpaqueResize",
00695         KDE_DEFAULT_OPAQUE_RESIZE);
00696 }
KDE Logo
This file is part of the documentation for kdecore Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed May 5 07:19:39 2004 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003