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