kdeui: do not apply style and palette from KGlobalSettings

palette and style shall be applied by the platform plugin, the font is
independant of the full Katana session (look for
KGlobalSettings::generalFont() for example, font from config is used here
and there because the config and thus KGlobalSettings offer fine grained
font selection for different purposes)

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-21 17:42:31 +03:00
parent c1015be8c8
commit 3dbd7b1da9
5 changed files with 20 additions and 83 deletions

View file

@ -269,6 +269,7 @@ KCmdLineArgsStatic::KCmdLineArgsStatic () {
qt_options.add("title <title>", ki18n("sets the application title (caption)"));
qt_options.add("reverse", ki18n("mirrors the whole layout of widgets"));
qt_options.add("stylesheet <file.qss>", ki18n("applies the Katie stylesheet to the application widgets"));
qt_options.add("style <style>", ki18n("sets the application GUI style"));
// KDE options
kde_options.add("caption <caption>", ki18n("Use 'caption' as name in the titlebar"));
kde_options.add("icon <icon>", ki18n("Use 'icon' as the application icon"));
@ -277,7 +278,6 @@ KCmdLineArgsStatic::KCmdLineArgsStatic () {
#ifdef Q_WS_X11
kde_options.add("waitforwm", ki18n("Waits for a WM_NET compatible windowmanager"));
#endif
kde_options.add("style <style>", ki18n("sets the application GUI style"));
kde_options.add("geometry <geometry>", ki18n("sets the client geometry of the main widget - see man X for the argument format (usually WidthxHeight+XPos+YPos)"));
kde_options.add("smkey <sessionKey>"); // this option is obsolete and exists only to allow smooth upgrades from sessions
}

View file

@ -31,7 +31,23 @@
#include "klocale.h"
#include "kconfiggroup.h"
#include "kstandarddirs.h"
#include <QtCore/qdebug.h>
static int kInitAddLibraryAndPluginPaths()
{
foreach (const QString &it, KGlobal::dirs()->resourceDirs("lib")) {
QCoreApplication::addLibraryPath(it);
}
foreach (const QString &it, KGlobal::dirs()->resourceDirs("module")) {
QCoreApplication::addLibraryPath(it);
}
foreach (const QString &it, KGlobal::dirs()->resourceDirs("qtplugins")) {
QCoreApplication::addPluginPath(it);
}
return 0;
}
Q_CONSTRUCTOR_FUNCTION(kInitAddLibraryAndPluginPaths);
KComponentData::KComponentData()
: d(0)
@ -67,8 +83,7 @@ bool KComponentData::operator==(const KComponentData &rhs) const
enum KdeLibraryPathsAdded {
NeedLazyInit,
LazyInitDone,
KdeLibraryPathsAddedDone
LazyInitDone
};
static KdeLibraryPathsAdded kdeLibraryPathsAdded = NeedLazyInit;
@ -147,21 +162,6 @@ void KComponentDataPrivate::lazyInit(const KComponentData &component)
sharedConfig = KSharedConfig::openConfig(component);
}
}
// the first KComponentData adds the KDE plugin paths
if (kdeLibraryPathsAdded != KdeLibraryPathsAddedDone) {
kdeLibraryPathsAdded = KdeLibraryPathsAddedDone;
foreach (const QString &it, dirs->resourceDirs("lib")) {
QCoreApplication::addLibraryPath(it);
}
foreach (const QString &it, dirs->resourceDirs("module")) {
QCoreApplication::addLibraryPath(it);
}
foreach (const QString &it, dirs->resourceDirs("qtplugins")) {
QCoreApplication::addPluginPath(it);
}
}
}
KStandardDirs *KComponentData::dirs() const

View file

@ -151,12 +151,6 @@ public:
{
}
~KApplicationPrivate()
{
}
KConfig *config() { return KGlobal::config().data(); }
void _k_x11FilterDestroyed();
void _k_checkAppStartedSlot();
void _k_disableAutorestartSlot();
@ -360,9 +354,6 @@ void KApplicationPrivate::init()
// make sure the clipboard is created before setting the window icon (bug 209263)
(void) QApplication::clipboard();
// initialize qt plugin path (see KComponentDataPrivate::lazyInit)
(void) KGlobal::config();
#if defined Q_WS_X11
KStartupInfoId id = KStartupInfo::currentStartupIdEnv();
KStartupInfo::resetStartupEnv();
@ -623,16 +614,6 @@ void KApplicationPrivate::parseCommandLine( )
{
KCmdLineArgs *args = KCmdLineArgs::parsedArgs("kde");
if (args && args->isSet("style"))
{
extern QString kde_overrideStyle; // see KGlobalSettings. Should we have a static setter?
QString reqStyle(args->getOption("style").toLower());
if (QStyleFactory::keys().contains(reqStyle, Qt::CaseInsensitive))
kde_overrideStyle = reqStyle;
else
qWarning() << i18n("The style '%1' was not found", reqStyle);
}
if (args && args->isSet("config"))
{
QString config = args->getOption("config");

View file

@ -65,10 +65,6 @@ class KGlobalSettings::Private
Private(KGlobalSettings *q)
: q(q), activated(false), paletteCreated(false)
{
kdeFullSession = !qgetenv("KDE_FULL_SESSION").isEmpty();
if (!kdeFullSession) {
kdeFullSession = (QProcess::execute("kcheckrunning") == 0);
}
}
QPalette createApplicationPalette(const KSharedConfigPtr &config);
@ -79,12 +75,10 @@ class KGlobalSettings::Private
void kdisplaySetPalette();
void kdisplaySetStyle();
void kdisplaySetFont();
void applyGUIStyle();
KGlobalSettings *q;
bool activated;
bool paletteCreated;
bool kdeFullSession;
QPalette applicationPalette;
};
@ -507,28 +501,6 @@ void KGlobalSettings::Private::_k_slotNotifyChange(int changeType, int arg)
}
}
// Set by KApplication
QString kde_overrideStyle;
void KGlobalSettings::Private::applyGUIStyle()
{
if (!kdeFullSession) {
return;
}
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);
}
}
emit q->kdisplayStyleChanged();
}
QPalette KGlobalSettings::createApplicationPalette(const KSharedConfigPtr &config)
{
return self()->d->createApplicationPalette(config);
@ -601,23 +573,12 @@ QPalette KGlobalSettings::Private::createNewApplicationPalette(const KSharedConf
void KGlobalSettings::Private::kdisplaySetPalette()
{
if (!kdeFullSession) {
return;
}
if (qApp->type() == KAPPLICATION_GUI_TYPE) {
QApplication::setPalette(q->createApplicationPalette());
}
emit q->kdisplayPaletteChanged();
emit q->appearanceChanged();
}
void KGlobalSettings::Private::kdisplaySetFont()
{
if (!kdeFullSession) {
return;
}
if (qApp->type() == KAPPLICATION_GUI_TYPE) {
QApplication::setFont(KGlobalSettings::generalFont());
const QFont menuFont = KGlobalSettings::menuFont();
@ -632,7 +593,7 @@ void KGlobalSettings::Private::kdisplaySetFont()
void KGlobalSettings::Private::kdisplaySetStyle()
{
if (qApp->type() == KAPPLICATION_GUI_TYPE) {
applyGUIStyle();
emit q->kdisplayStyleChanged();
// Reread palette from config file.
kdisplaySetPalette();

View file

@ -40,11 +40,6 @@ QTEST_KDEMAIN( KGlobalSettingsTest, GUI )
void KGlobalSettingsTest::initTestCase()
{
// Some signals are only emitted when we are running a full KDE session. If
// we are not then KDE applications follow the platform palette and font
// settings.
qputenv("KDE_FULL_SESSION", "1");
QDBusConnectionInterface *bus = 0;
if (!QDBusConnection::sessionBus().isConnected() || !(bus = QDBusConnection::sessionBus().interface())) {
QFAIL("Session bus not found");