kdecore Library: kglobalsettings.cpp Source File (kdecore Library)

| # kdecore Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

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

This file is part of the documentation for kdecore Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:18:04 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003