2014-11-13 01:04:59 +02:00
|
|
|
/* This file is part of the KDE libraries
|
|
|
|
Copyright (C) 2000, 2006 David Faure <faure@kde.org>
|
|
|
|
Copyright 2008 Friedrich W. H. Kossebau <kossebau@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 "kglobalsettings.h"
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <kconfig.h>
|
2023-01-01 20:48:04 +02:00
|
|
|
#include <kconfiggroup.h>
|
2014-11-13 01:04:59 +02:00
|
|
|
#include <kglobal.h>
|
|
|
|
#include <klocale.h>
|
|
|
|
#include <kstandarddirs.h>
|
|
|
|
#include <kprotocolinfo.h>
|
|
|
|
#include <kcolorscheme.h>
|
|
|
|
#include <kstyle.h>
|
2019-05-04 23:52:26 +00:00
|
|
|
#include <kapplication.h>
|
2023-01-01 20:48:04 +02:00
|
|
|
#include <kdebug.h>
|
2014-11-13 01:04:59 +02:00
|
|
|
|
2022-05-26 08:49:51 +03:00
|
|
|
#include <QtCore/QDir>
|
|
|
|
#include <QtCore/QStandardPaths>
|
2022-05-26 09:04:59 +03:00
|
|
|
#include <QtCore/QProcess>
|
2014-11-13 01:04:59 +02:00
|
|
|
#include <QtGui/QColor>
|
|
|
|
#include <QtGui/QCursor>
|
|
|
|
#include <QtGui/QDesktopWidget>
|
|
|
|
#include <QtGui/QFont>
|
|
|
|
#include <QtGui/QPixmap>
|
|
|
|
#include <QtGui/QPixmapCache>
|
|
|
|
#include <QtGui/QToolTip>
|
|
|
|
#include <QtGui/QWhatsThis>
|
2022-05-26 08:49:51 +03:00
|
|
|
#include <QtGui/QApplication>
|
|
|
|
#include <QtGui/QStyleFactory>
|
|
|
|
#include <QtGui/QGuiPlatformPlugin>
|
|
|
|
#include <QtDBus/QtDBus>
|
|
|
|
#include "qplatformdefs.h"
|
2014-11-13 01:04:59 +02:00
|
|
|
|
|
|
|
#ifdef Q_WS_X11
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#ifdef HAVE_XCURSOR
|
|
|
|
#include <X11/Xcursor/Xcursor.h>
|
|
|
|
#endif
|
|
|
|
#include "fixx11h.h"
|
2015-08-11 05:56:07 +03:00
|
|
|
#include <QtGui/qx11info_x11.h>
|
2014-11-13 01:04:59 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
class KGlobalSettings::Private
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Private(KGlobalSettings *q)
|
|
|
|
: q(q), activated(false), paletteCreated(false)
|
|
|
|
{
|
|
|
|
kdeFullSession = !qgetenv("KDE_FULL_SESSION").isEmpty();
|
2022-05-26 09:04:59 +03:00
|
|
|
if (!kdeFullSession) {
|
|
|
|
kdeFullSession = (QProcess::execute("kcheckrunning") == 0);
|
|
|
|
}
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QPalette createApplicationPalette(const KSharedConfigPtr &config);
|
|
|
|
QPalette createNewApplicationPalette(const KSharedConfigPtr &config);
|
|
|
|
void _k_slotNotifyChange(int, int);
|
|
|
|
|
|
|
|
void propagateQtSettings();
|
|
|
|
void kdisplaySetPalette();
|
|
|
|
void kdisplaySetStyle();
|
|
|
|
void kdisplaySetFont();
|
2022-11-03 01:55:59 +02:00
|
|
|
void kdisplaySetCursor();
|
2014-11-13 01:04:59 +02:00
|
|
|
void applyGUIStyle();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*
|
|
|
|
* Ensures that cursors are loaded from the theme KDE is configured
|
|
|
|
* to use. Note that calling this function doesn't cause existing
|
|
|
|
* cursors to be reloaded. Reloading already created cursors is
|
|
|
|
* handled by the KCM when a cursor theme is applied.
|
|
|
|
*
|
|
|
|
* It is not necessary to call this function when KGlobalSettings
|
|
|
|
* is initialized.
|
|
|
|
*/
|
|
|
|
void applyCursorTheme();
|
|
|
|
|
|
|
|
KGlobalSettings *q;
|
|
|
|
bool activated;
|
|
|
|
bool paletteCreated;
|
|
|
|
bool kdeFullSession;
|
|
|
|
QPalette applicationPalette;
|
|
|
|
};
|
|
|
|
|
|
|
|
KGlobalSettings* KGlobalSettings::self()
|
|
|
|
{
|
|
|
|
K_GLOBAL_STATIC(KGlobalSettings, s_self)
|
|
|
|
return s_self;
|
|
|
|
}
|
|
|
|
|
|
|
|
KGlobalSettings::KGlobalSettings()
|
2023-01-01 20:48:04 +02:00
|
|
|
: QObject(0),
|
|
|
|
d(new Private(this))
|
2014-11-13 01:04:59 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
KGlobalSettings::~KGlobalSettings()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KGlobalSettings::activate()
|
|
|
|
{
|
|
|
|
activate(ApplySettings | ListenForChanges);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KGlobalSettings::activate(ActivateOptions options)
|
|
|
|
{
|
|
|
|
if (!d->activated) {
|
|
|
|
d->activated = true;
|
|
|
|
|
|
|
|
if (options & ListenForChanges) {
|
2023-01-01 20:02:17 +02:00
|
|
|
QDBusConnection::sessionBus().connect(QString(), "/KGlobalSettings", "org.kde.KGlobalSettings",
|
|
|
|
"notifyChange", this, SLOT(_k_slotNotifyChange(int,int)));
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (options & ApplySettings) {
|
|
|
|
d->kdisplaySetStyle(); // implies palette setup
|
|
|
|
d->kdisplaySetFont();
|
2022-11-03 01:55:59 +02:00
|
|
|
d->kdisplaySetCursor();
|
2014-11-13 01:04:59 +02:00
|
|
|
d->propagateQtSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int KGlobalSettings::dndEventDelay()
|
|
|
|
{
|
2023-01-01 20:02:17 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "General");
|
2014-11-13 01:04:59 +02:00
|
|
|
return g.readEntry("StartDragDist", QApplication::startDragDistance());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool KGlobalSettings::singleClick()
|
|
|
|
{
|
2023-01-01 20:02:17 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "KDE");
|
2023-01-01 20:48:04 +02:00
|
|
|
return g.readEntry("SingleClick", KDE_DEFAULT_SINGLECLICK);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool KGlobalSettings::smoothScroll()
|
|
|
|
{
|
2023-01-02 00:26:14 +02:00
|
|
|
KConfigGroup g( KGlobal::config(), "KDE");
|
2023-01-01 20:48:04 +02:00
|
|
|
return g.readEntry("SmoothScroll", KDE_DEFAULT_SMOOTHSCROLL);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
KGlobalSettings::TearOffHandle KGlobalSettings::insertTearOffHandle()
|
|
|
|
{
|
2022-11-21 23:39:15 +02:00
|
|
|
bool effectsenabled = (KGlobalSettings::graphicEffectsLevel() > KGlobalSettings::NoEffects);
|
2023-01-01 20:48:04 +02:00
|
|
|
KConfigGroup g( KGlobal::config(), "KDE");
|
2022-11-21 23:39:15 +02:00
|
|
|
int tearoff = g.readEntry("InsertTearOffHandle", KDE_DEFAULT_INSERTTEAROFFHANDLES);
|
2014-11-13 01:04:59 +02:00
|
|
|
return effectsenabled ? (TearOffHandle) tearoff : Disable;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool KGlobalSettings::changeCursorOverIcon()
|
|
|
|
{
|
2023-01-01 20:02:17 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "KDE");
|
2014-11-13 01:04:59 +02:00
|
|
|
return g.readEntry("ChangeCursor", KDE_DEFAULT_CHANGECURSOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
int KGlobalSettings::autoSelectDelay()
|
|
|
|
{
|
2023-01-01 20:02:17 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "KDE");
|
2014-11-13 01:04:59 +02:00
|
|
|
return g.readEntry("AutoSelectDelay", KDE_DEFAULT_AUTOSELECTDELAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
KGlobalSettings::Completion KGlobalSettings::completionMode()
|
|
|
|
{
|
2023-01-01 20:02:17 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "General");
|
2023-01-01 20:48:04 +02:00
|
|
|
int completion = g.readEntry("completionMode", -1);
|
|
|
|
if ((completion < (int) CompletionNone) || (completion > (int) CompletionPopupAuto)) {
|
2014-11-13 01:04:59 +02:00
|
|
|
completion = (int) CompletionPopup; // Default
|
2023-01-01 20:48:04 +02:00
|
|
|
}
|
|
|
|
return (Completion) completion;
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
2023-01-01 20:48:04 +02:00
|
|
|
bool KGlobalSettings::showContextMenusOnPress()
|
2014-11-13 01:04:59 +02:00
|
|
|
{
|
|
|
|
KConfigGroup g(KGlobal::config(), "ContextMenus");
|
|
|
|
return g.readEntry("ShowOnPress", true);
|
|
|
|
}
|
|
|
|
|
2023-01-01 20:48:04 +02:00
|
|
|
// NOTE: keep this in sync with kde-workspace/kcontrol/colors/colorscm.cpp
|
2014-11-13 01:04:59 +02:00
|
|
|
QColor KGlobalSettings::inactiveTitleColor()
|
|
|
|
{
|
2023-01-01 20:02:17 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "WM");
|
|
|
|
return g.readEntry("inactiveBackground", QColor(224,223,222));
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QColor KGlobalSettings::inactiveTextColor()
|
|
|
|
{
|
2023-01-01 20:02:17 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "WM");
|
|
|
|
return g.readEntry("inactiveForeground", QColor(75,71,67));
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QColor KGlobalSettings::activeTitleColor()
|
|
|
|
{
|
2023-01-01 20:02:17 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "WM");
|
|
|
|
return g.readEntry("activeBackground", QColor(48,174,232));
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QColor KGlobalSettings::activeTextColor()
|
|
|
|
{
|
2023-01-01 20:48:04 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "WM");
|
2023-01-01 20:02:17 +02:00
|
|
|
return g.readEntry("activeForeground", QColor(255,255,255));
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int KGlobalSettings::contrast()
|
|
|
|
{
|
2023-01-01 20:02:17 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "KDE");
|
|
|
|
return g.readEntry("contrast", 7);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
qreal KGlobalSettings::contrastF(const KSharedConfigPtr &config)
|
|
|
|
{
|
|
|
|
if (config) {
|
2023-01-01 20:02:17 +02:00
|
|
|
KConfigGroup g(config, "KDE");
|
|
|
|
return 0.1 * g.readEntry("contrast", 7);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
return 0.1 * (qreal)contrast();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool KGlobalSettings::shadeSortColumn()
|
|
|
|
{
|
2023-01-01 20:02:17 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "General");
|
|
|
|
return g.readEntry("shadeSortColumn", KDE_DEFAULT_SHADE_SORT_COLUMN);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
2023-01-01 20:48:04 +02:00
|
|
|
// NOTE: keep in sync with kde-workspace/kcontrol/fonts/fonts.cpp
|
2014-11-13 01:04:59 +02:00
|
|
|
QFont KGlobalSettings::generalFont()
|
|
|
|
{
|
2023-01-01 20:48:04 +02:00
|
|
|
static const QFont defaultFont(KDE_DEFAULT_FONT, 9);
|
|
|
|
KConfigGroup g(KGlobal::config(), "General");
|
|
|
|
return g.readEntry("font", defaultFont);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
2023-01-01 20:48:04 +02:00
|
|
|
|
2014-11-13 01:04:59 +02:00
|
|
|
QFont KGlobalSettings::fixedFont()
|
|
|
|
{
|
2023-01-01 20:48:04 +02:00
|
|
|
static const QFont defaultFont(KDE_DEFAULT_FIXED_FONT, 9);
|
|
|
|
KConfigGroup g(KGlobal::config(), "General");
|
|
|
|
return g.readEntry("fixed", defaultFont);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
2023-01-01 20:48:04 +02:00
|
|
|
|
2014-11-13 01:04:59 +02:00
|
|
|
QFont KGlobalSettings::toolBarFont()
|
|
|
|
{
|
2023-01-01 20:48:04 +02:00
|
|
|
static const QFont defaultFont(KDE_DEFAULT_FIXED_FONT, 8);
|
|
|
|
KConfigGroup g(KGlobal::config(), "General");
|
|
|
|
return g.readEntry("toolBarFont", defaultFont);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
2023-01-01 20:48:04 +02:00
|
|
|
|
2014-11-13 01:04:59 +02:00
|
|
|
QFont KGlobalSettings::menuFont()
|
|
|
|
{
|
2023-01-01 20:48:04 +02:00
|
|
|
static const QFont defaultFont(KDE_DEFAULT_FONT, 9);
|
|
|
|
KConfigGroup g(KGlobal::config(), "General");
|
|
|
|
return g.readEntry("menuFont", defaultFont);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
2023-01-01 20:48:04 +02:00
|
|
|
|
2014-11-13 01:04:59 +02:00
|
|
|
QFont KGlobalSettings::windowTitleFont()
|
|
|
|
{
|
2023-01-01 20:48:04 +02:00
|
|
|
static const QFont defaultFont(KDE_DEFAULT_FONT, 8);
|
|
|
|
KConfigGroup g(KGlobal::config(), "WM");
|
|
|
|
return g.readEntry("activeFont", defaultFont);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
2023-01-01 20:48:04 +02:00
|
|
|
|
2014-11-13 01:04:59 +02:00
|
|
|
QFont KGlobalSettings::taskbarFont()
|
|
|
|
{
|
2023-01-01 20:48:04 +02:00
|
|
|
static const QFont defaultFont(KDE_DEFAULT_FONT, 9);
|
|
|
|
KConfigGroup g(KGlobal::config(), "General");
|
|
|
|
return g.readEntry("taskbarFont", defaultFont);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
2023-01-01 20:48:04 +02:00
|
|
|
QFont KGlobalSettings::smallestReadableFont()
|
2014-11-13 01:04:59 +02:00
|
|
|
{
|
2023-01-01 20:48:04 +02:00
|
|
|
static const QFont defaultFont(KDE_DEFAULT_FONT, 8);
|
|
|
|
KConfigGroup g(KGlobal::config(), "General");
|
|
|
|
return g.readEntry("smallestReadableFont", defaultFont);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
2023-01-01 20:48:04 +02:00
|
|
|
QFont KGlobalSettings::largeFont()
|
2014-11-13 01:04:59 +02:00
|
|
|
{
|
2023-01-01 20:48:04 +02:00
|
|
|
QFont largeFont = generalFont();
|
|
|
|
largeFont.setPointSize(48);
|
|
|
|
return largeFont;
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
2023-01-01 19:44:26 +02:00
|
|
|
KGlobalSettings::Mouse KGlobalSettings::mouseButtonMapping()
|
2014-11-13 01:04:59 +02:00
|
|
|
{
|
2023-01-01 19:44:26 +02:00
|
|
|
KGlobalSettings::Mouse handed = KGlobalSettings::RightHanded;
|
|
|
|
|
|
|
|
KConfig config("kcminputrc");
|
|
|
|
KConfigGroup g = config.group("Mouse");
|
|
|
|
QString setting = g.readEntry("MouseButtonMapping");
|
|
|
|
if (setting == "RightHanded") {
|
|
|
|
handed = KGlobalSettings::RightHanded;
|
|
|
|
} else if (setting == "LeftHanded") {
|
|
|
|
handed = KGlobalSettings::LeftHanded;
|
|
|
|
} else {
|
|
|
|
// get settings from X server
|
|
|
|
// This is a simplified version of the code in input/mouse.cpp
|
|
|
|
// Keep in sync !
|
|
|
|
handed = KGlobalSettings::RightHanded;
|
|
|
|
unsigned char map[20];
|
|
|
|
::memset(map, 0, sizeof(map) * sizeof(unsigned char));
|
|
|
|
int num_buttons = XGetPointerMapping(QX11Info::display(), map, 20);
|
|
|
|
if (num_buttons == 2) {
|
|
|
|
if ((int)map[0] == 1 && (int)map[1] == 2) {
|
|
|
|
handed = KGlobalSettings::RightHanded;
|
|
|
|
} else if ((int)map[0] == 2 && (int)map[1] == 1) {
|
|
|
|
handed = KGlobalSettings::LeftHanded;
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
2023-01-01 19:44:26 +02:00
|
|
|
} else if (num_buttons >= 3) {
|
|
|
|
if ((int)map[0] == 1 && (int)map[2] == 3) {
|
|
|
|
handed = KGlobalSettings::RightHanded;
|
|
|
|
} else if ((int)map[0] == 3 && (int)map[2] == 1) {
|
|
|
|
handed = KGlobalSettings::LeftHanded;
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-01 19:44:26 +02:00
|
|
|
return handed;
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString KGlobalSettings::desktopPath()
|
|
|
|
{
|
2023-01-02 00:26:14 +02:00
|
|
|
QString path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
|
|
|
return (path.isEmpty() ? QDir::homePath() : path);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString KGlobalSettings::documentPath()
|
|
|
|
{
|
2023-01-02 00:26:14 +02:00
|
|
|
QString path = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
|
|
|
return (path.isEmpty() ? QDir::homePath() : path);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString KGlobalSettings::downloadPath()
|
|
|
|
{
|
2023-01-02 00:26:14 +02:00
|
|
|
QString path = QStandardPaths::writableLocation(QStandardPaths::DownloadsLocation);
|
|
|
|
return (path.isEmpty() ? QDir::homePath() + "/Downloads" : path);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString KGlobalSettings::videosPath()
|
|
|
|
{
|
2023-01-02 00:26:14 +02:00
|
|
|
QString path = QStandardPaths::writableLocation(QStandardPaths::VideosLocation);
|
|
|
|
return (path.isEmpty() ? QDir::homePath() : path);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString KGlobalSettings::picturesPath()
|
|
|
|
{
|
2023-01-02 00:26:14 +02:00
|
|
|
QString path = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
|
|
|
|
return (path.isEmpty() ? QDir::homePath() : path);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString KGlobalSettings::musicPath()
|
|
|
|
{
|
2023-01-02 00:26:14 +02:00
|
|
|
QString path = QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
|
|
|
|
return (path.isEmpty() ? QDir::homePath() : path);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool KGlobalSettings::isMultiHead()
|
|
|
|
{
|
|
|
|
QByteArray multiHead = qgetenv("KDE_MULTIHEAD");
|
|
|
|
if (!multiHead.isEmpty()) {
|
|
|
|
return (multiHead.toLower() == "true");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool KGlobalSettings::wheelMouseZooms()
|
|
|
|
{
|
2023-01-02 00:26:14 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "KDE");
|
|
|
|
return g.readEntry("WheelMouseZooms", KDE_DEFAULT_WHEEL_ZOOM);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QRect KGlobalSettings::splashScreenDesktopGeometry()
|
|
|
|
{
|
|
|
|
QDesktopWidget *dw = QApplication::desktop();
|
|
|
|
|
|
|
|
if (dw->isVirtualDesktop()) {
|
|
|
|
KConfigGroup group(KGlobal::config(), "Windows");
|
|
|
|
int scr = group.readEntry("Unmanaged", -3);
|
|
|
|
if (group.readEntry("XineramaEnabled", true) && scr != -2) {
|
2023-01-02 00:26:14 +02:00
|
|
|
if (scr == -3) {
|
2014-11-13 01:04:59 +02:00
|
|
|
scr = dw->screenNumber(QCursor::pos());
|
2023-01-02 00:26:14 +02:00
|
|
|
}
|
2014-11-13 01:04:59 +02:00
|
|
|
return dw->screenGeometry(scr);
|
|
|
|
}
|
|
|
|
}
|
2023-01-02 00:26:14 +02:00
|
|
|
return dw->geometry();
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QRect KGlobalSettings::desktopGeometry(const QPoint& point)
|
|
|
|
{
|
|
|
|
QDesktopWidget *dw = QApplication::desktop();
|
|
|
|
|
|
|
|
if (dw->isVirtualDesktop()) {
|
|
|
|
KConfigGroup group(KGlobal::config(), "Windows");
|
|
|
|
if (group.readEntry("XineramaEnabled", true) &&
|
|
|
|
group.readEntry("XineramaPlacementEnabled", true)) {
|
|
|
|
return dw->screenGeometry(dw->screenNumber(point));
|
|
|
|
}
|
|
|
|
}
|
2023-01-02 00:26:14 +02:00
|
|
|
return dw->geometry();
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QRect KGlobalSettings::desktopGeometry(const QWidget* w)
|
|
|
|
{
|
|
|
|
QDesktopWidget *dw = QApplication::desktop();
|
|
|
|
|
|
|
|
if (dw->isVirtualDesktop()) {
|
|
|
|
KConfigGroup group(KGlobal::config(), "Windows");
|
|
|
|
if (group.readEntry("XineramaEnabled", true) &&
|
|
|
|
group.readEntry("XineramaPlacementEnabled", true)) {
|
2023-01-02 00:26:14 +02:00
|
|
|
if (w) {
|
2014-11-13 01:04:59 +02:00
|
|
|
return dw->screenGeometry(dw->screenNumber(w));
|
2023-01-02 00:26:14 +02:00
|
|
|
}
|
|
|
|
return dw->screenGeometry(-1);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
}
|
2023-01-02 00:26:14 +02:00
|
|
|
return dw->geometry();
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool KGlobalSettings::showIconsOnPushButtons()
|
|
|
|
{
|
2023-01-02 00:26:14 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "KDE");
|
2022-11-22 04:44:24 +02:00
|
|
|
return g.readEntry("ShowIconsOnPushButtons", KDE_DEFAULT_ICON_ON_PUSHBUTTON);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool KGlobalSettings::naturalSorting()
|
|
|
|
{
|
2023-01-02 00:26:14 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "KDE");
|
2022-11-22 04:44:24 +02:00
|
|
|
return g.readEntry("NaturalSorting", KDE_DEFAULT_NATURAL_SORTING);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
KGlobalSettings::GraphicEffects KGlobalSettings::graphicEffectsLevel()
|
|
|
|
{
|
2023-01-02 00:26:14 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "KDE-Global GUI Settings");
|
2022-11-22 04:44:24 +02:00
|
|
|
int graphicEffects = g.readEntry("GraphicEffectsLevel", int(KGlobalSettings::graphicEffectsLevelDefault()));
|
|
|
|
return GraphicEffects(graphicEffects);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
KGlobalSettings::GraphicEffects KGlobalSettings::graphicEffectsLevelDefault()
|
|
|
|
{
|
2022-12-03 03:22:28 +02:00
|
|
|
KGlobalSettings::GraphicEffects result = KGlobalSettings::SimpleAnimationEffects;
|
|
|
|
// NOTE: Katie's fade effect requires compositor and it is enabled if complex effects are
|
|
|
|
if (QX11Info::isCompositingManagerRunning()) {
|
|
|
|
result |= KGlobalSettings::ComplexAnimationEffects;
|
|
|
|
}
|
|
|
|
return result;
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool KGlobalSettings::showFilePreview(const KUrl &url)
|
|
|
|
{
|
|
|
|
KConfigGroup g(KGlobal::config(), "PreviewSettings");
|
|
|
|
QString protocol = url.protocol();
|
2023-01-02 00:26:14 +02:00
|
|
|
bool defaultSetting = KProtocolInfo::showFilePreview(protocol);
|
|
|
|
return g.readEntry(protocol, defaultSetting);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool KGlobalSettings::opaqueResize()
|
|
|
|
{
|
2023-01-02 00:26:14 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "KDE");
|
2014-11-13 01:04:59 +02:00
|
|
|
return g.readEntry("OpaqueResize", KDE_DEFAULT_OPAQUE_RESIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int KGlobalSettings::buttonLayout()
|
|
|
|
{
|
2023-01-02 00:26:14 +02:00
|
|
|
KConfigGroup g(KGlobal::config(), "KDE");
|
2014-11-13 01:04:59 +02:00
|
|
|
return g.readEntry("ButtonLayout", KDE_DEFAULT_BUTTON_LAYOUT);
|
|
|
|
}
|
|
|
|
|
2017-08-04 09:17:49 +00:00
|
|
|
#ifdef Q_WS_X11
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
extern void qt_x11_apply_settings_in_all_apps();
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
#endif
|
|
|
|
|
2014-11-13 01:04:59 +02:00
|
|
|
void KGlobalSettings::emitChange(ChangeType changeType, int arg)
|
|
|
|
{
|
2023-01-02 00:26:14 +02:00
|
|
|
QDBusMessage message = QDBusMessage::createSignal("/KGlobalSettings", "org.kde.KGlobalSettings", "notifyChange");
|
2014-11-13 01:04:59 +02:00
|
|
|
QList<QVariant> args;
|
|
|
|
args.append(static_cast<int>(changeType));
|
|
|
|
args.append(arg);
|
|
|
|
message.setArguments(args);
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
|
|
|
#ifdef Q_WS_X11
|
|
|
|
if (qApp && qApp->type() != QApplication::Tty) {
|
|
|
|
//notify non-kde qt applications of the change
|
|
|
|
qt_x11_apply_settings_in_all_apps();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void KGlobalSettings::Private::_k_slotNotifyChange(int changeType, int arg)
|
|
|
|
{
|
|
|
|
switch(changeType) {
|
2023-01-02 00:26:14 +02:00
|
|
|
case StyleChanged: {
|
|
|
|
if (activated) {
|
|
|
|
KGlobal::config()->reparseConfiguration();
|
|
|
|
kdisplaySetStyle();
|
|
|
|
}
|
|
|
|
break;
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
2023-01-02 00:26:14 +02:00
|
|
|
case ToolbarStyleChanged: {
|
2014-11-13 01:04:59 +02:00
|
|
|
KGlobal::config()->reparseConfiguration();
|
2023-01-02 00:26:14 +02:00
|
|
|
emit q->toolbarAppearanceChanged(arg);
|
|
|
|
break;
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
2023-01-02 00:26:14 +02:00
|
|
|
case PaletteChanged: {
|
|
|
|
if (activated) {
|
|
|
|
KGlobal::config()->reparseConfiguration();
|
|
|
|
paletteCreated = false;
|
|
|
|
kdisplaySetPalette();
|
|
|
|
}
|
|
|
|
break;
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
2023-01-02 00:26:14 +02:00
|
|
|
case FontChanged: {
|
|
|
|
KGlobal::config()->reparseConfiguration();
|
2014-11-13 01:04:59 +02:00
|
|
|
if (activated) {
|
2023-01-02 00:26:14 +02:00
|
|
|
kdisplaySetFont();
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
2023-01-02 00:26:14 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SettingsChanged: {
|
|
|
|
KGlobal::config()->reparseConfiguration();
|
|
|
|
SettingsCategory category = static_cast<SettingsCategory>(arg);
|
|
|
|
if (category == SETTINGS_QT) {
|
|
|
|
if (activated) {
|
|
|
|
propagateQtSettings();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (category) {
|
|
|
|
case SETTINGS_LOCALE:
|
|
|
|
KGlobal::locale()->reparseConfiguration();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
emit q->settingsChanged(category);
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
2023-01-02 00:26:14 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IconChanged: {
|
|
|
|
QPixmapCache::clear();
|
|
|
|
KGlobal::config()->reparseConfiguration();
|
|
|
|
emit q->iconChanged(arg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CursorChanged: {
|
|
|
|
applyCursorTheme();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BlockShortcuts: {
|
|
|
|
// NOTE: KGlobalAccel connects to this signal
|
|
|
|
emit q->blockShortcuts(arg); // see kwin
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NaturalSortingChanged: {
|
|
|
|
emit q->naturalSortingChanged();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
kWarning(240) << "Unknown type of change in KGlobalSettings::slotNotifyChange: " << changeType;
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set by KApplication
|
|
|
|
QString kde_overrideStyle;
|
|
|
|
|
|
|
|
void KGlobalSettings::Private::applyGUIStyle()
|
|
|
|
{
|
2022-05-26 08:49:51 +03:00
|
|
|
if (!kdeFullSession) {
|
|
|
|
return;
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
2022-06-01 01:06:57 +03:00
|
|
|
if (qApp->type() == KAPPLICATION_GUI_TYPE) {
|
|
|
|
if (kde_overrideStyle.isEmpty()) {
|
|
|
|
const KConfigGroup pConfig(KGlobal::config(), "General");
|
|
|
|
kde_overrideStyle = pConfig.readEntry("widgetStyle", KStyle::defaultStyle());
|
|
|
|
}
|
|
|
|
if (!kde_overrideStyle.isEmpty()) {
|
|
|
|
qApp->setStyle(kde_overrideStyle);
|
|
|
|
}
|
2022-05-26 08:49:51 +03:00
|
|
|
}
|
|
|
|
|
2014-11-13 01:04:59 +02:00
|
|
|
emit q->kdisplayStyleChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPalette KGlobalSettings::createApplicationPalette(const KSharedConfigPtr &config)
|
|
|
|
{
|
|
|
|
return self()->d->createApplicationPalette(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
QPalette KGlobalSettings::createNewApplicationPalette(const KSharedConfigPtr &config)
|
|
|
|
{
|
|
|
|
return self()->d->createNewApplicationPalette(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
QPalette KGlobalSettings::Private::createApplicationPalette(const KSharedConfigPtr &config)
|
|
|
|
{
|
|
|
|
// This method is typically called once by KQGuiPlatformPlugin::palette and once again
|
|
|
|
// by kdisplaySetPalette(), so we cache the palette to save time.
|
|
|
|
if (config == KGlobal::config() && paletteCreated) {
|
|
|
|
return applicationPalette;
|
|
|
|
}
|
|
|
|
return createNewApplicationPalette(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
QPalette KGlobalSettings::Private::createNewApplicationPalette(const KSharedConfigPtr &config)
|
|
|
|
{
|
|
|
|
QPalette palette;
|
|
|
|
|
2023-01-02 00:26:14 +02:00
|
|
|
QPalette::ColorGroup states[3] = {
|
|
|
|
QPalette::Active,
|
|
|
|
QPalette::Inactive,
|
|
|
|
QPalette::Disabled
|
|
|
|
};
|
2014-11-13 01:04:59 +02:00
|
|
|
|
|
|
|
// TT thinks tooltips shouldn't use active, so we use our active colors for all states
|
|
|
|
KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
|
|
|
|
|
2023-01-02 00:26:14 +02:00
|
|
|
for (int i = 0; i < 3; i++) {
|
2014-11-13 01:04:59 +02:00
|
|
|
QPalette::ColorGroup state = states[i];
|
|
|
|
KColorScheme schemeView(state, KColorScheme::View, config);
|
|
|
|
KColorScheme schemeWindow(state, KColorScheme::Window, config);
|
|
|
|
KColorScheme schemeButton(state, KColorScheme::Button, config);
|
|
|
|
KColorScheme schemeSelection(state, KColorScheme::Selection, config);
|
|
|
|
|
2023-01-02 00:26:14 +02:00
|
|
|
palette.setBrush(state, QPalette::WindowText, schemeWindow.foreground());
|
|
|
|
palette.setBrush(state, QPalette::Window, schemeWindow.background());
|
|
|
|
palette.setBrush(state, QPalette::Base, schemeView.background());
|
|
|
|
palette.setBrush(state, QPalette::Text, schemeView.foreground());
|
|
|
|
palette.setBrush(state, QPalette::Button, schemeButton.background());
|
|
|
|
palette.setBrush(state, QPalette::ButtonText, schemeButton.foreground());
|
|
|
|
palette.setBrush(state, QPalette::Highlight, schemeSelection.background());
|
|
|
|
palette.setBrush(state, QPalette::HighlightedText, schemeSelection.foreground());
|
|
|
|
palette.setBrush(state, QPalette::ToolTipBase, schemeTooltip.background());
|
|
|
|
palette.setBrush(state, QPalette::ToolTipText, schemeTooltip.foreground());
|
|
|
|
|
|
|
|
palette.setColor(state, QPalette::Light, schemeWindow.shade(KColorScheme::LightShade));
|
|
|
|
palette.setColor(state, QPalette::Midlight, schemeWindow.shade(KColorScheme::MidlightShade));
|
|
|
|
palette.setColor(state, QPalette::Mid, schemeWindow.shade(KColorScheme::MidShade));
|
|
|
|
palette.setColor(state, QPalette::Dark, schemeWindow.shade(KColorScheme::DarkShade));
|
|
|
|
palette.setColor(state, QPalette::Shadow, schemeWindow.shade(KColorScheme::ShadowShade));
|
|
|
|
|
|
|
|
palette.setBrush(state, QPalette::AlternateBase, schemeView.background(KColorScheme::AlternateBackground));
|
|
|
|
palette.setBrush(state, QPalette::Link, schemeView.foreground(KColorScheme::LinkText));
|
|
|
|
palette.setBrush(state, QPalette::LinkVisited, schemeView.foreground(KColorScheme::VisitedText));
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (config == KGlobal::config()) {
|
|
|
|
paletteCreated = true;
|
|
|
|
applicationPalette = palette;
|
|
|
|
}
|
|
|
|
|
|
|
|
return palette;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KGlobalSettings::Private::kdisplaySetPalette()
|
|
|
|
{
|
|
|
|
if (!kdeFullSession) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-04 23:52:26 +00:00
|
|
|
if (qApp->type() == KAPPLICATION_GUI_TYPE) {
|
2023-01-02 00:26:14 +02:00
|
|
|
QApplication::setPalette(q->createApplicationPalette());
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
emit q->kdisplayPaletteChanged();
|
|
|
|
emit q->appearanceChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KGlobalSettings::Private::kdisplaySetFont()
|
|
|
|
{
|
|
|
|
if (!kdeFullSession) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-04 23:52:26 +00:00
|
|
|
if (qApp->type() == KAPPLICATION_GUI_TYPE) {
|
2023-01-01 20:48:04 +02:00
|
|
|
QApplication::setFont(KGlobalSettings::generalFont());
|
|
|
|
const QFont menuFont = KGlobalSettings::menuFont();
|
|
|
|
QApplication::setFont(menuFont, "QMenuBar");
|
|
|
|
QApplication::setFont(menuFont, "QMenu");
|
|
|
|
QApplication::setFont(KGlobalSettings::toolBarFont(), "QToolBar");
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
emit q->kdisplayFontChanged();
|
|
|
|
emit q->appearanceChanged();
|
|
|
|
}
|
|
|
|
|
2022-11-03 01:55:59 +02:00
|
|
|
void KGlobalSettings::Private::kdisplaySetCursor()
|
|
|
|
{
|
|
|
|
if (!kdeFullSession) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
applyCursorTheme();
|
|
|
|
}
|
2014-11-13 01:04:59 +02:00
|
|
|
|
|
|
|
void KGlobalSettings::Private::kdisplaySetStyle()
|
|
|
|
{
|
2019-05-04 23:52:26 +00:00
|
|
|
if (qApp->type() == KAPPLICATION_GUI_TYPE) {
|
2014-11-13 01:04:59 +02:00
|
|
|
applyGUIStyle();
|
|
|
|
|
|
|
|
// Reread palette from config file.
|
|
|
|
kdisplaySetPalette();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KGlobalSettings::Private::applyCursorTheme()
|
|
|
|
{
|
|
|
|
#if defined(Q_WS_X11) && defined(HAVE_XCURSOR)
|
|
|
|
KConfig config("kcminputrc");
|
2023-01-01 20:02:17 +02:00
|
|
|
KConfigGroup g = config.group("Mouse");
|
2014-11-13 01:04:59 +02:00
|
|
|
|
2022-11-03 10:37:03 +02:00
|
|
|
QByteArray theme = g.readEntry("cursorTheme", QByteArray("Oxygen_White"));
|
2022-11-03 01:52:02 +02:00
|
|
|
int size = g.readEntry("cursorSize", -1);
|
2014-11-13 01:04:59 +02:00
|
|
|
|
|
|
|
// Default cursor size is 16 points
|
2022-11-03 01:52:02 +02:00
|
|
|
if (size == -1) {
|
2023-01-02 00:26:14 +02:00
|
|
|
size = qApp->desktop()->screen(0)->logicalDpiY() * 16 / 72;
|
2014-11-13 01:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Note that in X11R7.1 and earlier, calling XcursorSetTheme()
|
|
|
|
// with a NULL theme would cause Xcursor to use "default", but
|
|
|
|
// in 7.2 and later it will cause it to revert to the theme that
|
|
|
|
// was configured when the application was started.
|
2022-11-03 01:52:02 +02:00
|
|
|
XcursorSetTheme(QX11Info::display(), theme.constData());
|
2014-11-13 01:04:59 +02:00
|
|
|
XcursorSetDefaultSize(QX11Info::display(), size);
|
|
|
|
|
|
|
|
emit q->cursorChanged();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KGlobalSettings::Private::propagateQtSettings()
|
|
|
|
{
|
|
|
|
KConfigGroup cg( KGlobal::config(), "KDE" );
|
|
|
|
int num = cg.readEntry("CursorBlinkRate", QApplication::cursorFlashTime());
|
|
|
|
if ((num != 0) && (num < 200))
|
|
|
|
num = 200;
|
|
|
|
if (num > 2000)
|
|
|
|
num = 2000;
|
|
|
|
QApplication::setCursorFlashTime(num);
|
|
|
|
num = cg.readEntry("DoubleClickInterval", QApplication::doubleClickInterval());
|
|
|
|
QApplication::setDoubleClickInterval(num);
|
|
|
|
num = cg.readEntry("StartDragTime", QApplication::startDragTime());
|
|
|
|
QApplication::setStartDragTime(num);
|
|
|
|
num = cg.readEntry("StartDragDist", QApplication::startDragDistance());
|
|
|
|
QApplication::setStartDragDistance(num);
|
|
|
|
num = cg.readEntry("WheelScrollLines", QApplication::wheelScrollLines());
|
|
|
|
QApplication::setWheelScrollLines(num);
|
|
|
|
bool showIcons = cg.readEntry("ShowIconsInMenuItems", !QApplication::testAttribute(Qt::AA_DontShowIconsInMenus));
|
|
|
|
QApplication::setAttribute(Qt::AA_DontShowIconsInMenus, !showIcons);
|
|
|
|
|
|
|
|
// KDE5: this seems fairly pointless
|
|
|
|
emit q->settingsChanged(SETTINGS_QT);
|
|
|
|
}
|
|
|
|
|
2015-02-27 07:40:26 +00:00
|
|
|
#include "moc_kglobalsettings.cpp"
|