You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
775 lines
22 KiB
775 lines
22 KiB
15 years ago
|
/* This file is part of the KDE libraries
|
||
|
Copyright (C) 2000 David Faure <faure@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License version 2 as published by the Free Software Foundation.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
#include "config.h"
|
||
12 years ago
|
#include "tdeglobalsettings.h"
|
||
15 years ago
|
|
||
14 years ago
|
#include <tqdir.h>
|
||
|
#include <tqpixmap.h>
|
||
|
#include <tqfontdatabase.h>
|
||
|
#include <tqcursor.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdeconfig.h>
|
||
15 years ago
|
#include <ksimpleconfig.h>
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
15 years ago
|
|
||
|
#include <kipc.h>
|
||
|
|
||
|
#ifdef Q_WS_WIN
|
||
|
#include <windows.h>
|
||
|
#include "qt_windows.h"
|
||
|
#include <win32_utils.h>
|
||
|
static QRgb qt_colorref2qrgb(COLORREF col)
|
||
|
{
|
||
14 years ago
|
return tqRgb(GetRValue(col),GetGValue(col),GetBValue(col));
|
||
15 years ago
|
}
|
||
|
#endif
|
||
|
|
||
|
#include <kdebug.h>
|
||
12 years ago
|
#include <tdeglobal.h>
|
||
12 years ago
|
#include <tdeshortcut.h>
|
||
15 years ago
|
#include <kstandarddirs.h>
|
||
|
#include <kcharsets.h>
|
||
12 years ago
|
#include <tdeaccel.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
14 years ago
|
#include <tqfontinfo.h>
|
||
15 years ago
|
#include <stdlib.h>
|
||
|
#include <kprotocolinfo.h>
|
||
|
|
||
13 years ago
|
#include <tqtextcodec.h>
|
||
|
#include <tqtextstream.h>
|
||
14 years ago
|
#include <tqfile.h>
|
||
15 years ago
|
|
||
15 years ago
|
#ifdef Q_WS_X11
|
||
|
#include <X11/Xlib.h>
|
||
|
#endif
|
||
|
|
||
12 years ago
|
TQString* TDEGlobalSettings::s_desktopPath = 0;
|
||
|
TQString* TDEGlobalSettings::s_autostartPath = 0;
|
||
|
TQString* TDEGlobalSettings::s_trashPath = 0;
|
||
|
TQString* TDEGlobalSettings::s_documentPath = 0;
|
||
|
TQFont *TDEGlobalSettings::_generalFont = 0;
|
||
|
TQFont *TDEGlobalSettings::_fixedFont = 0;
|
||
|
TQFont *TDEGlobalSettings::_toolBarFont = 0;
|
||
|
TQFont *TDEGlobalSettings::_menuFont = 0;
|
||
|
TQFont *TDEGlobalSettings::_windowTitleFont = 0;
|
||
|
TQFont *TDEGlobalSettings::_taskbarFont = 0;
|
||
|
TQFont *TDEGlobalSettings::_largeFont = 0;
|
||
|
TQColor *TDEGlobalSettings::_trinity4Blue = 0;
|
||
|
TQColor *TDEGlobalSettings::_inactiveBackground = 0;
|
||
|
TQColor *TDEGlobalSettings::_inactiveForeground = 0;
|
||
|
TQColor *TDEGlobalSettings::_activeBackground = 0;
|
||
|
TQColor *TDEGlobalSettings::_buttonBackground = 0;
|
||
|
TQColor *TDEGlobalSettings::_selectBackground = 0;
|
||
|
TQColor *TDEGlobalSettings::_linkColor = 0;
|
||
|
TQColor *TDEGlobalSettings::_visitedLinkColor = 0;
|
||
|
TQColor *TDEGlobalSettings::alternateColor = 0;
|
||
|
|
||
|
TDEGlobalSettings::KMouseSettings *TDEGlobalSettings::s_mouseSettings = 0;
|
||
15 years ago
|
|
||
15 years ago
|
// helper function for reading xdg user dirs: it is required in order to take
|
||
|
// care of locale stuff
|
||
14 years ago
|
void readXdgUserDirs(TQString *desktop, TQString *documents)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQFile f( TQDir::homeDirPath() + "/.config/user-dirs.dirs" );
|
||
15 years ago
|
|
||
|
if (!f.open(IO_ReadOnly))
|
||
|
return;
|
||
|
|
||
|
// set the codec for the current locale
|
||
14 years ago
|
TQTextStream s(&f);
|
||
|
s.setCodec( TQTextCodec::codecForLocale() );
|
||
15 years ago
|
|
||
14 years ago
|
TQString line = s.readLine();
|
||
15 years ago
|
while (!line.isNull())
|
||
|
{
|
||
|
if (line.startsWith("XDG_DESKTOP_DIR="))
|
||
14 years ago
|
*desktop = line.remove("XDG_DESKTOP_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
|
||
15 years ago
|
else if (line.startsWith("XDG_DOCUMENTS_DIR="))
|
||
14 years ago
|
*documents = line.remove("XDG_DOCUMENTS_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath());
|
||
15 years ago
|
|
||
|
line = s.readLine();
|
||
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
int TDEGlobalSettings::dndEventDelay()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
14 years ago
|
return g.readNumEntry("StartDragDist", TQApplication::startDragDistance());
|
||
15 years ago
|
}
|
||
|
|
||
12 years ago
|
bool TDEGlobalSettings::singleClick()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "KDE" );
|
||
15 years ago
|
return g.readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK);
|
||
|
}
|
||
|
|
||
12 years ago
|
bool TDEGlobalSettings::iconUseRoundedRect()
|
||
14 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "KDE" );
|
||
14 years ago
|
return g.readBoolEntry("IconUseRoundedRect", KDE_DEFAULT_ICONTEXTROUNDED);
|
||
14 years ago
|
}
|
||
|
|
||
12 years ago
|
TDEGlobalSettings::TearOffHandle TDEGlobalSettings::insertTearOffHandle()
|
||
15 years ago
|
{
|
||
|
int tearoff;
|
||
|
bool effectsenabled;
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "KDE" );
|
||
15 years ago
|
effectsenabled = g.readBoolEntry( "EffectsEnabled", false);
|
||
|
tearoff = g.readNumEntry("InsertTearOffHandle", KDE_DEFAULT_INSERTTEAROFFHANDLES);
|
||
|
return effectsenabled ? (TearOffHandle) tearoff : Disable;
|
||
|
}
|
||
|
|
||
12 years ago
|
bool TDEGlobalSettings::changeCursorOverIcon()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "KDE" );
|
||
15 years ago
|
return g.readBoolEntry("ChangeCursor", KDE_DEFAULT_CHANGECURSOR);
|
||
|
}
|
||
|
|
||
12 years ago
|
bool TDEGlobalSettings::visualActivate()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "KDE" );
|
||
15 years ago
|
return g.readBoolEntry("VisualActivate", KDE_DEFAULT_VISUAL_ACTIVATE);
|
||
|
}
|
||
|
|
||
12 years ago
|
unsigned int TDEGlobalSettings::visualActivateSpeed()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "KDE" );
|
||
15 years ago
|
return
|
||
|
g.readNumEntry(
|
||
|
"VisualActivateSpeed",
|
||
|
KDE_DEFAULT_VISUAL_ACTIVATE_SPEED
|
||
|
);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
12 years ago
|
int TDEGlobalSettings::autoSelectDelay()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "KDE" );
|
||
15 years ago
|
return g.readNumEntry("AutoSelectDelay", KDE_DEFAULT_AUTOSELECTDELAY);
|
||
|
}
|
||
|
|
||
12 years ago
|
TDEGlobalSettings::Completion TDEGlobalSettings::completionMode()
|
||
15 years ago
|
{
|
||
|
int completion;
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
15 years ago
|
completion = g.readNumEntry("completionMode", -1);
|
||
|
if ((completion < (int) CompletionNone) ||
|
||
|
(completion > (int) CompletionPopupAuto))
|
||
|
{
|
||
|
completion = (int) CompletionPopup; // Default
|
||
|
}
|
||
|
return (Completion) completion;
|
||
|
}
|
||
|
|
||
12 years ago
|
bool TDEGlobalSettings::showContextMenusOnPress ()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g(TDEGlobal::config(), "ContextMenus");
|
||
15 years ago
|
return g.readBoolEntry("ShowOnPress", true);
|
||
|
}
|
||
|
|
||
12 years ago
|
int TDEGlobalSettings::contextMenuKey ()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g(TDEGlobal::config(), "Shortcuts");
|
||
12 years ago
|
TDEShortcut cut (g.readEntry ("PopupMenuContext", "Menu"));
|
||
15 years ago
|
return cut.keyCodeQt();
|
||
|
}
|
||
|
|
||
12 years ago
|
TQColor TDEGlobalSettings::toolBarHighlightColor()
|
||
15 years ago
|
{
|
||
|
initColors();
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "Toolbar style" );
|
||
13 years ago
|
return g.readColorEntry("HighlightColor", _trinity4Blue);
|
||
15 years ago
|
}
|
||
|
|
||
12 years ago
|
TQColor TDEGlobalSettings::inactiveTitleColor()
|
||
15 years ago
|
{
|
||
|
#ifdef Q_WS_WIN
|
||
|
return qt_colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTION));
|
||
|
#else
|
||
|
if (!_inactiveBackground)
|
||
14 years ago
|
_inactiveBackground = new TQColor(157, 170, 186);
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "WM" );
|
||
15 years ago
|
return g.readColorEntry( "inactiveBackground", _inactiveBackground );
|
||
|
#endif
|
||
|
}
|
||
|
|
||
12 years ago
|
TQColor TDEGlobalSettings::inactiveTextColor()
|
||
15 years ago
|
{
|
||
|
#ifdef Q_WS_WIN
|
||
|
return qt_colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTIONTEXT));
|
||
|
#else
|
||
|
if (!_inactiveForeground)
|
||
14 years ago
|
_inactiveForeground = new TQColor(221,221,221);
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "WM" );
|
||
15 years ago
|
return g.readColorEntry( "inactiveForeground", _inactiveForeground );
|
||
|
#endif
|
||
|
}
|
||
|
|
||
12 years ago
|
TQColor TDEGlobalSettings::activeTitleColor()
|
||
15 years ago
|
{
|
||
|
#ifdef Q_WS_WIN
|
||
|
return qt_colorref2qrgb(GetSysColor(COLOR_ACTIVECAPTION));
|
||
|
#else
|
||
|
initColors();
|
||
|
if (!_activeBackground)
|
||
14 years ago
|
_activeBackground = new TQColor(65,142,220);
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "WM" );
|
||
15 years ago
|
return g.readColorEntry( "activeBackground", _activeBackground);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
12 years ago
|
TQColor TDEGlobalSettings::activeTextColor()
|
||
15 years ago
|
{
|
||
|
#ifdef Q_WS_WIN
|
||
|
return qt_colorref2qrgb(GetSysColor(COLOR_CAPTIONTEXT));
|
||
|
#else
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "WM" );
|
||
14 years ago
|
return g.readColorEntry( "activeForeground", tqwhiteptr );
|
||
15 years ago
|
#endif
|
||
|
}
|
||
|
|
||
12 years ago
|
int TDEGlobalSettings::contrast()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "KDE" );
|
||
15 years ago
|
return g.readNumEntry( "contrast", 7 );
|
||
|
}
|
||
|
|
||
12 years ago
|
TQColor TDEGlobalSettings::buttonBackground()
|
||
15 years ago
|
{
|
||
|
if (!_buttonBackground)
|
||
14 years ago
|
_buttonBackground = new TQColor(221,223,228);
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
15 years ago
|
return g.readColorEntry( "buttonBackground", _buttonBackground );
|
||
|
}
|
||
|
|
||
12 years ago
|
TQColor TDEGlobalSettings::buttonTextColor()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
14 years ago
|
return g.readColorEntry( "buttonForeground", tqblackptr );
|
||
15 years ago
|
}
|
||
|
|
||
|
// IMPORTANT:
|
||
14 years ago
|
// This function should be kept in sync with
|
||
12 years ago
|
// TDEApplication::tdedisplaySetPalette()
|
||
12 years ago
|
TQColor TDEGlobalSettings::baseColor()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
14 years ago
|
return g.readColorEntry( "windowBackground", tqwhiteptr );
|
||
15 years ago
|
}
|
||
|
|
||
|
// IMPORTANT:
|
||
14 years ago
|
// This function should be kept in sync with
|
||
12 years ago
|
// TDEApplication::tdedisplaySetPalette()
|
||
12 years ago
|
TQColor TDEGlobalSettings::textColor()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
14 years ago
|
return g.readColorEntry( "windowForeground", tqblackptr );
|
||
15 years ago
|
}
|
||
|
|
||
|
// IMPORTANT:
|
||
14 years ago
|
// This function should be kept in sync with
|
||
12 years ago
|
// TDEApplication::tdedisplaySetPalette()
|
||
12 years ago
|
TQColor TDEGlobalSettings::highlightedTextColor()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
14 years ago
|
return g.readColorEntry( "selectForeground", tqwhiteptr );
|
||
15 years ago
|
}
|
||
|
|
||
|
// IMPORTANT:
|
||
14 years ago
|
// This function should be kept in sync with
|
||
12 years ago
|
// TDEApplication::tdedisplaySetPalette()
|
||
12 years ago
|
TQColor TDEGlobalSettings::highlightColor()
|
||
15 years ago
|
{
|
||
|
initColors();
|
||
|
if (!_selectBackground)
|
||
14 years ago
|
_selectBackground = new TQColor(103,141,178);
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
15 years ago
|
return g.readColorEntry( "selectBackground", _selectBackground );
|
||
|
}
|
||
|
|
||
12 years ago
|
TQColor TDEGlobalSettings::alternateBackgroundColor()
|
||
15 years ago
|
{
|
||
|
initColors();
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
15 years ago
|
*alternateColor = calculateAlternateBackgroundColor( baseColor() );
|
||
|
return g.readColorEntry( "alternateBackground", alternateColor );
|
||
|
}
|
||
|
|
||
12 years ago
|
TQColor TDEGlobalSettings::calculateAlternateBackgroundColor(const TQColor& base)
|
||
15 years ago
|
{
|
||
|
if (base == Qt::white)
|
||
14 years ago
|
return TQColor(238,246,255);
|
||
15 years ago
|
else
|
||
|
{
|
||
|
int h, s, v;
|
||
|
base.hsv( &h, &s, &v );
|
||
|
if (v > 128)
|
||
|
return base.dark(106);
|
||
|
else if (base != Qt::black)
|
||
|
return base.light(110);
|
||
|
|
||
14 years ago
|
return TQColor(32,32,32);
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
bool TDEGlobalSettings::shadeSortColumn()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
15 years ago
|
return g.readBoolEntry( "shadeSortColumn", KDE_DEFAULT_SHADE_SORT_COLUMN );
|
||
|
}
|
||
|
|
||
12 years ago
|
TQColor TDEGlobalSettings::linkColor()
|
||
15 years ago
|
{
|
||
|
initColors();
|
||
|
if (!_linkColor)
|
||
14 years ago
|
_linkColor = new TQColor(0,0,238);
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
15 years ago
|
return g.readColorEntry( "linkColor", _linkColor );
|
||
|
}
|
||
|
|
||
12 years ago
|
TQColor TDEGlobalSettings::visitedLinkColor()
|
||
15 years ago
|
{
|
||
|
if (!_visitedLinkColor)
|
||
14 years ago
|
_visitedLinkColor = new TQColor(82,24,139);
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
15 years ago
|
return g.readColorEntry( "visitedLinkColor", _visitedLinkColor );
|
||
|
}
|
||
|
|
||
12 years ago
|
TQFont TDEGlobalSettings::generalFont()
|
||
15 years ago
|
{
|
||
|
if (_generalFont)
|
||
|
return *_generalFont;
|
||
|
|
||
13 years ago
|
// Sync default with tdebase/kcontrol/fonts/fonts.cpp
|
||
14 years ago
|
_generalFont = new TQFont("Sans Serif", 10);
|
||
15 years ago
|
_generalFont->setPointSize(10);
|
||
14 years ago
|
_generalFont->setStyleHint(TQFont::SansSerif);
|
||
15 years ago
|
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
15 years ago
|
*_generalFont = g.readFontEntry("font", _generalFont);
|
||
|
|
||
|
return *_generalFont;
|
||
|
}
|
||
|
|
||
12 years ago
|
TQFont TDEGlobalSettings::fixedFont()
|
||
15 years ago
|
{
|
||
|
if (_fixedFont)
|
||
|
return *_fixedFont;
|
||
|
|
||
13 years ago
|
// Sync default with tdebase/kcontrol/fonts/fonts.cpp
|
||
14 years ago
|
_fixedFont = new TQFont("Monospace", 10);
|
||
15 years ago
|
_fixedFont->setPointSize(10);
|
||
14 years ago
|
_fixedFont->setStyleHint(TQFont::TypeWriter);
|
||
15 years ago
|
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
15 years ago
|
*_fixedFont = g.readFontEntry("fixed", _fixedFont);
|
||
|
|
||
|
return *_fixedFont;
|
||
|
}
|
||
|
|
||
12 years ago
|
TQFont TDEGlobalSettings::toolBarFont()
|
||
15 years ago
|
{
|
||
|
if(_toolBarFont)
|
||
|
return *_toolBarFont;
|
||
|
|
||
13 years ago
|
// Sync default with tdebase/kcontrol/fonts/fonts.cpp
|
||
14 years ago
|
_toolBarFont = new TQFont("Sans Serif", 10);
|
||
15 years ago
|
_toolBarFont->setPointSize(10);
|
||
14 years ago
|
_toolBarFont->setStyleHint(TQFont::SansSerif);
|
||
15 years ago
|
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
15 years ago
|
*_toolBarFont = g.readFontEntry("toolBarFont", _toolBarFont);
|
||
|
|
||
|
return *_toolBarFont;
|
||
|
}
|
||
|
|
||
12 years ago
|
TQFont TDEGlobalSettings::menuFont()
|
||
15 years ago
|
{
|
||
|
if(_menuFont)
|
||
|
return *_menuFont;
|
||
|
|
||
13 years ago
|
// Sync default with tdebase/kcontrol/fonts/fonts.cpp
|
||
14 years ago
|
_menuFont = new TQFont("Sans Serif", 10);
|
||
15 years ago
|
_menuFont->setPointSize(10);
|
||
14 years ago
|
_menuFont->setStyleHint(TQFont::SansSerif);
|
||
15 years ago
|
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
15 years ago
|
*_menuFont = g.readFontEntry("menuFont", _menuFont);
|
||
|
|
||
|
return *_menuFont;
|
||
|
}
|
||
|
|
||
12 years ago
|
TQFont TDEGlobalSettings::windowTitleFont()
|
||
15 years ago
|
{
|
||
|
if(_windowTitleFont)
|
||
|
return *_windowTitleFont;
|
||
|
|
||
13 years ago
|
// Sync default with tdebase/kcontrol/fonts/fonts.cpp
|
||
14 years ago
|
_windowTitleFont = new TQFont("Sans Serif", 9, TQFont::Bold);
|
||
15 years ago
|
_windowTitleFont->setPointSize(10);
|
||
14 years ago
|
_windowTitleFont->setStyleHint(TQFont::SansSerif);
|
||
15 years ago
|
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "WM" );
|
||
15 years ago
|
*_windowTitleFont = g.readFontEntry("activeFont", _windowTitleFont); // inconsistency
|
||
|
|
||
|
return *_windowTitleFont;
|
||
|
}
|
||
|
|
||
12 years ago
|
TQFont TDEGlobalSettings::taskbarFont()
|
||
15 years ago
|
{
|
||
|
if(_taskbarFont)
|
||
|
return *_taskbarFont;
|
||
|
|
||
13 years ago
|
// Sync default with tdebase/kcontrol/fonts/fonts.cpp
|
||
14 years ago
|
_taskbarFont = new TQFont("Sans Serif", 10);
|
||
15 years ago
|
_taskbarFont->setPointSize(10);
|
||
14 years ago
|
_taskbarFont->setStyleHint(TQFont::SansSerif);
|
||
15 years ago
|
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "General" );
|
||
15 years ago
|
*_taskbarFont = g.readFontEntry("taskbarFont", _taskbarFont);
|
||
|
|
||
|
return *_taskbarFont;
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
TQFont TDEGlobalSettings::largeFont(const TQString &text)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQFontDatabase db;
|
||
13 years ago
|
TQStringList fam = db.families();
|
||
15 years ago
|
|
||
|
// Move a bunch of preferred fonts to the front.
|
||
|
if (fam.remove("Arial"))
|
||
|
fam.prepend("Arial");
|
||
|
if (fam.remove("Verdana"))
|
||
|
fam.prepend("Verdana");
|
||
|
if (fam.remove("Tahoma"))
|
||
|
fam.prepend("Tahoma");
|
||
|
if (fam.remove("Lucida Sans"))
|
||
|
fam.prepend("Lucida Sans");
|
||
|
if (fam.remove("Lucidux Sans"))
|
||
|
fam.prepend("Lucidux Sans");
|
||
|
if (fam.remove("Nimbus Sans"))
|
||
|
fam.prepend("Nimbus Sans");
|
||
|
if (fam.remove("Gothic I"))
|
||
|
fam.prepend("Gothic I");
|
||
|
|
||
|
if (_largeFont)
|
||
|
fam.prepend(_largeFont->family());
|
||
|
|
||
14 years ago
|
for(TQStringList::ConstIterator it = fam.begin();
|
||
15 years ago
|
it != fam.end(); ++it)
|
||
|
{
|
||
|
if (db.isSmoothlyScalable(*it) && !db.isFixedPitch(*it))
|
||
|
{
|
||
14 years ago
|
TQFont font(*it);
|
||
15 years ago
|
font.setPixelSize(75);
|
||
14 years ago
|
TQFontMetrics metrics(font);
|
||
15 years ago
|
int h = metrics.height();
|
||
|
if ((h < 60) || ( h > 90))
|
||
|
continue;
|
||
|
|
||
|
bool ok = true;
|
||
|
for(unsigned int i = 0; i < text.length(); i++)
|
||
|
{
|
||
|
if (!metrics.inFont(text[i]))
|
||
|
{
|
||
|
ok = false;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (!ok)
|
||
|
continue;
|
||
|
|
||
|
font.setPointSize(48);
|
||
14 years ago
|
_largeFont = new TQFont(font);
|
||
15 years ago
|
return *_largeFont;
|
||
|
}
|
||
|
}
|
||
12 years ago
|
_largeFont = new TQFont(TDEGlobalSettings::generalFont());
|
||
15 years ago
|
_largeFont->setPointSize(48);
|
||
|
return *_largeFont;
|
||
|
}
|
||
|
|
||
12 years ago
|
void TDEGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here.
|
||
15 years ago
|
{
|
||
|
if ( s_desktopPath != 0 )
|
||
|
return;
|
||
|
|
||
14 years ago
|
s_desktopPath = new TQString();
|
||
|
s_autostartPath = new TQString();
|
||
|
s_trashPath = new TQString();
|
||
|
s_documentPath = new TQString();
|
||
15 years ago
|
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "Paths" );
|
||
15 years ago
|
|
||
15 years ago
|
// Read desktop and documents path using XDG_USER_DIRS
|
||
|
readXdgUserDirs(s_desktopPath, s_documentPath);
|
||
|
|
||
14 years ago
|
if (s_desktopPath->isEmpty() == true) {
|
||
14 years ago
|
*s_desktopPath = TQDir::homeDirPath() + "/Desktop/";
|
||
14 years ago
|
}
|
||
14 years ago
|
*s_desktopPath = TQDir::cleanDirPath( *s_desktopPath );
|
||
15 years ago
|
if ( !s_desktopPath->endsWith("/") )
|
||
|
s_desktopPath->append('/');
|
||
|
|
||
14 years ago
|
if (s_documentPath->isEmpty() == true) {
|
||
|
#ifdef Q_WS_WIN
|
||
|
*s_documentPath = getWin32ShellFoldersPath("Personal");
|
||
|
#else
|
||
14 years ago
|
*s_documentPath = TQDir::homeDirPath() + "/Documents/";
|
||
14 years ago
|
#endif
|
||
|
}
|
||
14 years ago
|
*s_documentPath = TQDir::cleanDirPath( *s_documentPath );
|
||
15 years ago
|
if ( !s_documentPath->endsWith("/"))
|
||
|
s_documentPath->append('/');
|
||
|
|
||
12 years ago
|
// Trash Path - TODO remove in KDE4 (tdeio_trash can't use it for interoperability reasons)
|
||
15 years ago
|
*s_trashPath = *s_desktopPath + i18n("Trash") + "/";
|
||
|
*s_trashPath = g.readPathEntry( "Trash" , *s_trashPath);
|
||
14 years ago
|
*s_trashPath = TQDir::cleanDirPath( *s_trashPath );
|
||
15 years ago
|
if ( !s_trashPath->endsWith("/") )
|
||
|
s_trashPath->append('/');
|
||
|
// We need to save it in any case, in case the language changes later on,
|
||
|
if ( !g.hasKey( "Trash" ) )
|
||
|
{
|
||
|
g.writePathEntry( "Trash", *s_trashPath, true, true );
|
||
|
g.sync();
|
||
|
}
|
||
|
|
||
|
// Autostart Path
|
||
12 years ago
|
*s_autostartPath = TDEGlobal::dirs()->localtdedir() + "Autostart/";
|
||
15 years ago
|
*s_autostartPath = g.readPathEntry( "Autostart" , *s_autostartPath);
|
||
14 years ago
|
*s_autostartPath = TQDir::cleanDirPath( *s_autostartPath );
|
||
15 years ago
|
if ( !s_autostartPath->endsWith("/") )
|
||
|
s_autostartPath->append('/');
|
||
|
|
||
|
// Make sure this app gets the notifications about those paths
|
||
|
if (kapp)
|
||
|
kapp->addKipcEventMask(KIPC::SettingsChanged);
|
||
|
}
|
||
|
|
||
12 years ago
|
void TDEGlobalSettings::initColors()
|
||
15 years ago
|
{
|
||
13 years ago
|
if (!_trinity4Blue) {
|
||
14 years ago
|
if (TQPixmap::defaultDepth() > 8)
|
||
13 years ago
|
_trinity4Blue = new TQColor(103,141,178);
|
||
15 years ago
|
else
|
||
13 years ago
|
_trinity4Blue = new TQColor(0, 0, 192);
|
||
15 years ago
|
}
|
||
|
if (!alternateColor)
|
||
14 years ago
|
alternateColor = new TQColor(237, 244, 249);
|
||
15 years ago
|
}
|
||
|
|
||
12 years ago
|
void TDEGlobalSettings::rereadFontSettings()
|
||
15 years ago
|
{
|
||
|
delete _generalFont;
|
||
|
_generalFont = 0L;
|
||
|
delete _fixedFont;
|
||
|
_fixedFont = 0L;
|
||
|
delete _menuFont;
|
||
|
_menuFont = 0L;
|
||
|
delete _toolBarFont;
|
||
|
_toolBarFont = 0L;
|
||
|
delete _windowTitleFont;
|
||
|
_windowTitleFont = 0L;
|
||
|
delete _taskbarFont;
|
||
|
_taskbarFont = 0L;
|
||
|
}
|
||
|
|
||
12 years ago
|
void TDEGlobalSettings::rereadPathSettings()
|
||
15 years ago
|
{
|
||
12 years ago
|
kdDebug() << "TDEGlobalSettings::rereadPathSettings" << endl;
|
||
15 years ago
|
delete s_autostartPath;
|
||
|
s_autostartPath = 0L;
|
||
|
delete s_trashPath;
|
||
|
s_trashPath = 0L;
|
||
|
delete s_desktopPath;
|
||
|
s_desktopPath = 0L;
|
||
|
delete s_documentPath;
|
||
|
s_documentPath = 0L;
|
||
|
}
|
||
|
|
||
12 years ago
|
TDEGlobalSettings::KMouseSettings & TDEGlobalSettings::mouseSettings()
|
||
15 years ago
|
{
|
||
|
if ( ! s_mouseSettings )
|
||
|
{
|
||
|
s_mouseSettings = new KMouseSettings;
|
||
|
KMouseSettings & s = *s_mouseSettings; // for convenience
|
||
|
|
||
|
#ifndef Q_WS_WIN
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "Mouse" );
|
||
14 years ago
|
TQString setting = g.readEntry("MouseButtonMapping");
|
||
15 years ago
|
if (setting == "RightHanded")
|
||
|
s.handed = KMouseSettings::RightHanded;
|
||
|
else if (setting == "LeftHanded")
|
||
|
s.handed = KMouseSettings::LeftHanded;
|
||
|
else
|
||
|
{
|
||
|
#ifdef Q_WS_X11
|
||
|
// get settings from X server
|
||
|
// This is a simplified version of the code in input/mouse.cpp
|
||
|
// Keep in sync !
|
||
|
s.handed = KMouseSettings::RightHanded;
|
||
|
unsigned char map[20];
|
||
|
int num_buttons = XGetPointerMapping(kapp->getDisplay(), map, 20);
|
||
|
if( num_buttons == 2 )
|
||
|
{
|
||
|
if ( (int)map[0] == 1 && (int)map[1] == 2 )
|
||
|
s.handed = KMouseSettings::RightHanded;
|
||
|
else if ( (int)map[0] == 2 && (int)map[1] == 1 )
|
||
|
s.handed = KMouseSettings::LeftHanded;
|
||
|
}
|
||
|
else if( num_buttons >= 3 )
|
||
|
{
|
||
|
if ( (int)map[0] == 1 && (int)map[2] == 3 )
|
||
|
s.handed = KMouseSettings::RightHanded;
|
||
|
else if ( (int)map[0] == 3 && (int)map[2] == 1 )
|
||
|
s.handed = KMouseSettings::LeftHanded;
|
||
|
}
|
||
|
#else
|
||
|
// FIXME(E): Implement in Qt Embedded
|
||
|
#endif
|
||
|
}
|
||
|
#endif //Q_WS_WIN
|
||
|
}
|
||
|
#ifdef Q_WS_WIN
|
||
|
//not cached
|
||
|
s_mouseSettings->handed = (GetSystemMetrics(SM_SWAPBUTTON) ? KMouseSettings::LeftHanded : KMouseSettings::RightHanded);
|
||
|
#endif
|
||
|
return *s_mouseSettings;
|
||
|
}
|
||
|
|
||
12 years ago
|
void TDEGlobalSettings::rereadMouseSettings()
|
||
15 years ago
|
{
|
||
|
#ifndef Q_WS_WIN
|
||
|
delete s_mouseSettings;
|
||
|
s_mouseSettings = 0L;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
12 years ago
|
bool TDEGlobalSettings::isMultiHead()
|
||
15 years ago
|
{
|
||
|
#ifdef Q_WS_WIN
|
||
|
return GetSystemMetrics(SM_CMONITORS) > 1;
|
||
|
#else
|
||
13 years ago
|
TQCString multiHead = getenv("TDE_MULTIHEAD");
|
||
15 years ago
|
if (!multiHead.isEmpty()) {
|
||
|
return (multiHead.lower() == "true");
|
||
|
}
|
||
|
return false;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
12 years ago
|
bool TDEGlobalSettings::wheelMouseZooms()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "KDE" );
|
||
15 years ago
|
return g.readBoolEntry( "WheelMouseZooms", KDE_DEFAULT_WHEEL_ZOOM );
|
||
|
}
|
||
|
|
||
12 years ago
|
TQRect TDEGlobalSettings::splashScreenDesktopGeometry()
|
||
15 years ago
|
{
|
||
14 years ago
|
TQDesktopWidget *dw = TQApplication::desktop();
|
||
15 years ago
|
|
||
|
if (dw->isVirtualDesktop()) {
|
||
12 years ago
|
TDEConfigGroup group(TDEGlobal::config(), "Windows");
|
||
15 years ago
|
int scr = group.readNumEntry("Unmanaged", -3);
|
||
|
if (group.readBoolEntry("XineramaEnabled", true) && scr != -2) {
|
||
|
if (scr == -3)
|
||
14 years ago
|
scr = dw->screenNumber(TQCursor::pos());
|
||
15 years ago
|
return dw->screenGeometry(scr);
|
||
|
} else {
|
||
14 years ago
|
return dw->geometry();
|
||
15 years ago
|
}
|
||
|
} else {
|
||
14 years ago
|
return dw->geometry();
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
TQRect TDEGlobalSettings::desktopGeometry(const TQPoint& point)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQDesktopWidget *dw = TQApplication::desktop();
|
||
15 years ago
|
|
||
|
if (dw->isVirtualDesktop()) {
|
||
12 years ago
|
TDEConfigGroup group(TDEGlobal::config(), "Windows");
|
||
15 years ago
|
if (group.readBoolEntry("XineramaEnabled", true) &&
|
||
|
group.readBoolEntry("XineramaPlacementEnabled", true)) {
|
||
|
return dw->screenGeometry(dw->screenNumber(point));
|
||
|
} else {
|
||
14 years ago
|
return dw->geometry();
|
||
15 years ago
|
}
|
||
|
} else {
|
||
14 years ago
|
return dw->geometry();
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
TQRect TDEGlobalSettings::desktopGeometry(TQWidget* w)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQDesktopWidget *dw = TQApplication::desktop();
|
||
15 years ago
|
|
||
|
if (dw->isVirtualDesktop()) {
|
||
12 years ago
|
TDEConfigGroup group(TDEGlobal::config(), "Windows");
|
||
15 years ago
|
if (group.readBoolEntry("XineramaEnabled", true) &&
|
||
|
group.readBoolEntry("XineramaPlacementEnabled", true)) {
|
||
|
if (w)
|
||
|
return dw->screenGeometry(dw->screenNumber(w));
|
||
|
else return dw->screenGeometry(-1);
|
||
|
} else {
|
||
14 years ago
|
return dw->geometry();
|
||
15 years ago
|
}
|
||
|
} else {
|
||
14 years ago
|
return dw->geometry();
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
bool TDEGlobalSettings::showIconsOnPushButtons()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "KDE" );
|
||
15 years ago
|
return g.readBoolEntry("ShowIconsOnPushButtons",
|
||
|
KDE_DEFAULT_ICON_ON_PUSHBUTTON);
|
||
|
}
|
||
|
|
||
12 years ago
|
bool TDEGlobalSettings::showFilePreview(const KURL &url)
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g(TDEGlobal::config(), "PreviewSettings");
|
||
14 years ago
|
TQString protocol = url.protocol();
|
||
15 years ago
|
bool defaultSetting = KProtocolInfo::showFilePreview( protocol );
|
||
|
return g.readBoolEntry(protocol, defaultSetting );
|
||
|
}
|
||
|
|
||
12 years ago
|
bool TDEGlobalSettings::showKonqIconActivationEffect()
|
||
14 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "KDE" );
|
||
14 years ago
|
return g.readBoolEntry("ShowKonqIconActivationEffect",
|
||
|
KDE_DEFAULT_KONQ_ACTIVATION_EFFECT);
|
||
|
}
|
||
|
|
||
12 years ago
|
bool TDEGlobalSettings::opaqueResize()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "KDE" );
|
||
15 years ago
|
return g.readBoolEntry("OpaqueResize",
|
||
|
KDE_DEFAULT_OPAQUE_RESIZE);
|
||
|
}
|
||
|
|
||
12 years ago
|
int TDEGlobalSettings::buttonLayout()
|
||
15 years ago
|
{
|
||
12 years ago
|
TDEConfigGroup g( TDEGlobal::config(), "KDE" );
|
||
15 years ago
|
return g.readNumEntry("ButtonLayout",
|
||
|
KDE_DEFAULT_BUTTON_LAYOUT);
|
||
|
}
|