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>
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>
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     *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     *s_trashPath = QDir::cleanDirPath( *s_trashPath );
00472     if ( !s_trashPath->endsWith("/") )
00473       s_trashPath->append('/');
00474     // We need to save it in any case, in case the language changes later on,
00475     if ( !config->hasKey( "Trash" ) )
00476     {
00477       config->writePathEntry( "Trash", *s_trashPath, true, true );
00478       config->sync();
00479     }
00480 
00481     // Autostart Path
00482     *s_autostartPath = KGlobal::dirs()->localkdedir() + "Autostart/";
00483     *s_autostartPath = config->readPathEntry( "Autostart" , *s_autostartPath);
00484     *s_autostartPath = QDir::cleanDirPath( *s_autostartPath );
00485     if ( !s_autostartPath->endsWith("/") )
00486       s_autostartPath->append('/');
00487 
00488     // Document Path
00489     *s_documentPath = config->readPathEntry( "Documents", QDir::homeDirPath() );
00490     *s_documentPath = QDir::cleanDirPath( *s_documentPath );
00491     if ( !s_documentPath->endsWith("/"))
00492       s_documentPath->append('/');
00493 
00494     // Make sure this app gets the notifications about those paths
00495 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
00496     if (kapp)
00497         kapp->addKipcEventMask(KIPC::SettingsChanged);
00498 #endif
00499 }
00500 
00501 void KGlobalSettings::initColors()
00502 {
00503     if (!kde2Blue) {
00504       if (QPixmap::defaultDepth() > 8)
00505         kde2Blue = new QColor(84, 112, 152);
00506       else
00507         kde2Blue = new QColor(0, 0, 192);
00508     }
00509     if (!kde2AlternateColor)
00510       kde2AlternateColor = new QColor(240, 240, 240);
00511 }
00512 
00513 void KGlobalSettings::rereadFontSettings()
00514 {
00515     delete _generalFont;
00516     _generalFont = 0L;
00517     delete _fixedFont;
00518     _fixedFont = 0L;
00519     delete _menuFont;
00520     _menuFont = 0L;
00521     delete _toolBarFont;
00522     _toolBarFont = 0L;
00523     delete _windowTitleFont;
00524     _windowTitleFont = 0L;
00525     delete _taskbarFont;
00526     _taskbarFont = 0L;
00527 }
00528 
00529 void KGlobalSettings::rereadPathSettings()
00530 {
00531     kdDebug() << "KGlobalSettings::rereadPathSettings" << endl;
00532     delete s_autostartPath;
00533     s_autostartPath = 0L;
00534     delete s_trashPath;
00535     s_trashPath = 0L;
00536     delete s_desktopPath;
00537     s_desktopPath = 0L;
00538     delete s_documentPath;
00539     s_documentPath = 0L;
00540 }
00541 
00542 KGlobalSettings::KMouseSettings & KGlobalSettings::mouseSettings()
00543 {
00544     if ( ! s_mouseSettings )
00545     {
00546         s_mouseSettings = new KMouseSettings;
00547         KMouseSettings & s = *s_mouseSettings; // for convenience
00548 
00549         KConfigGroupSaver cgs( KGlobal::config(), "Mouse" );
00550         QString setting = KGlobal::config()->readEntry("MouseButtonMapping");
00551         if (setting == "RightHanded")
00552             s.handed = KMouseSettings::RightHanded;
00553         else if (setting == "LeftHanded")
00554             s.handed = KMouseSettings::LeftHanded;
00555         else
00556         {
00557 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
00558             // get settings from X server
00559             // This is a simplified version of the code in input/mouse.cpp
00560             // Keep in sync !
00561             s.handed = KMouseSettings::RightHanded;
00562             unsigned char map[5];
00563             switch (XGetPointerMapping(kapp->getDisplay(), map, 5))
00564             {
00565                 case 2:
00566                     if ( (int)map[0] == 1 && (int)map[1] == 2 )
00567                         s.handed = KMouseSettings::RightHanded;
00568                     else if ( (int)map[0] == 2 && (int)map[1] == 1 )
00569                         s.handed = KMouseSettings::LeftHanded;
00570                     break;
00571                 case 3:
00572                 case 5:
00573                     if ( (int)map[0] == 1 && (int)map[2] == 3 )
00574                         s.handed = KMouseSettings::RightHanded;
00575                     else if ( (int)map[0] == 3 && (int)map[2] == 1 )
00576                         s.handed = KMouseSettings::LeftHanded;
00577                     break;
00578                 default:
00579                     break;
00580             }
00581 #else
00582         // FIXME(E): Implement in Qt Embedded
00583 #endif
00584         }
00585     }
00586     return *s_mouseSettings;
00587 }
00588 
00589 void KGlobalSettings::rereadMouseSettings()
00590 {
00591     delete s_mouseSettings;
00592     s_mouseSettings = 0L;
00593 }
00594 
00595 bool KGlobalSettings::isMultiHead()
00596 {
00597     QCString multiHead = getenv("KDE_MULTIHEAD");
00598     if (!multiHead.isEmpty()) {
00599         return (multiHead.lower() == "true");
00600     }
00601     return false;
00602 }
00603 
00604 bool KGlobalSettings::wheelMouseZooms()
00605 {
00606     KConfig *c = KGlobal::config();
00607     KConfigGroupSaver cgs( c, "KDE" );
00608     return c->readBoolEntry( "WheelMouseZooms", KDE_DEFAULT_WHEEL_ZOOM );
00609 }
00610 
00611 QRect KGlobalSettings::splashScreenDesktopGeometry()
00612 {
00613     QDesktopWidget *dw = QApplication::desktop();
00614 
00615     if (dw->isVirtualDesktop()) {
00616         KConfigGroup group(KGlobal::config(), "Windows");
00617         int scr = group.readNumEntry("Unmanaged", -3);
00618         if (group.readBoolEntry("XineramaEnabled", true) && scr != -2) {
00619             if (scr == -3)
00620                 scr = dw->screenNumber(QCursor::pos());
00621             return dw->screenGeometry(scr);
00622         } else {
00623             return dw->geometry();
00624         }
00625     } else {
00626         return dw->geometry();
00627     }
00628 }
00629 
00630 QRect KGlobalSettings::desktopGeometry(const QPoint& point)
00631 {
00632     QDesktopWidget *dw = QApplication::desktop();
00633 
00634     if (dw->isVirtualDesktop()) {
00635         KConfigGroup group(KGlobal::config(), "Windows");
00636         if (group.readBoolEntry("XineramaEnabled", true) &&
00637             group.readBoolEntry("XineramaPlacementEnabled", true)) {
00638             return dw->screenGeometry(dw->screenNumber(point));
00639         } else {
00640             return dw->geometry();
00641         }
00642     } else {
00643         return dw->geometry();
00644     }
00645 }
00646 
00647 QRect KGlobalSettings::desktopGeometry(QWidget* w)
00648 {
00649     QDesktopWidget *dw = QApplication::desktop();
00650 
00651     if (dw->isVirtualDesktop()) {
00652         KConfigGroup group(KGlobal::config(), "Windows");
00653         if (group.readBoolEntry("XineramaEnabled", true) &&
00654             group.readBoolEntry("XineramaPlacementEnabled", true)) {
00655             if (w)
00656                 return dw->screenGeometry(dw->screenNumber(w));
00657             else return dw->screenGeometry(-1);
00658         } else {
00659             return dw->geometry();
00660         }
00661     } else {
00662         return dw->geometry();
00663     }
00664 }
00665 
00666 bool KGlobalSettings::showIconsOnPushButtons()
00667 {
00668     KConfig *c = KGlobal::config();
00669     KConfigGroupSaver cgs( c, "KDE" );
00670     return c->readBoolEntry("ShowIconsOnPushButtons",
00671         KDE_DEFAULT_ICON_ON_PUSHBUTTON);
00672 }
00673 
00674 bool KGlobalSettings::showFilePreview(const KURL &url)
00675 {
00676     KConfigGroup g(KGlobal::config(), "PreviewSettings");
00677     QString protocol = url.protocol();
00678     bool defaultSetting = KProtocolInfo::showFilePreview( protocol );
00679     return g.readBoolEntry(protocol, defaultSetting );
00680 }
00681 
00682 bool KGlobalSettings::opaqueResize()
00683 {
00684     KConfig *c = KGlobal::config();
00685     KConfigGroupSaver cgs( c, "KDE" );
00686     return c->readBoolEntry("OpaqueResize",
00687         KDE_DEFAULT_OPAQUE_RESIZE);
00688 }
00689 
00690 int KGlobalSettings::buttonLayout()
00691 {
00692     KConfig *c = KGlobal::config();
00693     KConfigGroupSaver cgs( c, "KDE" );
00694     return c->readNumEntry("ButtonLayout",
00695         KDE_DEFAULT_BUTTON_LAYOUT);
00696 }
KDE Logo
This file is part of the documentation for kdecore Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jan 22 16:43:41 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003