KStyle::defaultStyle() related

Ralf Habacker ralf.habacker at freenet.de
Tue Nov 25 10:02:21 GMT 2008


Hi,

in kdelibs/kdeui/kernel/kglobalsettings.cpp there is the following code 
snippet

void KGlobalSettings::Private::applyGUIStyle()
{
    const QLatin1String 
currentStyleName(qApp->style()->metaObject()->className());

    if (kde_overrideStyle.isEmpty()) {
#ifdef Q_WS_X11
        const QString &defaultStyle = KStyle::defaultStyle();
#else
        const QString defaultStyle; // Mac, Windows: no change for style 
by default
#endif
        const KConfigGroup pConfig(KGlobal::config(), "General");
        const QString &styleStr = pConfig.readEntry("widgetStyle", 
defaultStyle);
...

This code seems to me a special hack for non x11 platforms to be able to 
use a "native" default style, which is not supported by the recent 
implementation of KStyle:defaultStyle(), which is hardcoded to "oxygen". 
Would it not make the code clearer to extend KStyle::defaultStyle() with 
the platform related native style like shown below ?

 QString KStyle::defaultStyle()
 {
#ifndef Q_WS_X11
     return QString(""); // native
#else
     return QString("oxygen");
#endif
 }

Then the first code snippet above could be eased to 


void KGlobalSettings::Private::applyGUIStyle()
{
    const QLatin1String currentStyleName(qApp->style()->metaObject()->className());

    if (kde_overrideStyle.isEmpty()) {
        const QString &defaultStyle = KStyle::defaultStyle();
        const KConfigGroup pConfig(KGlobal::config(), "General");
        const QString &styleStr = pConfig.readEntry("widgetStyle", defaultStyle);
... 

I would apply the required changes to trunk and other branches if 
required if there are no objections

Regards
 Ralf






More information about the kde-core-devel mailing list