KStyle::defaultStyle() related

Olivier Goffart ogoffart at kde.org
Wed Nov 26 00:20:25 GMT 2008


Le mardi 25 novembre 2008, Ralf Habacker a écrit :
> 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


Hi,

This is plain wrong!

Not this particular paticular patch, but the whole applyGUIStyle() function.

And i've been trying to find a solution for that for some times now, without 
finding a good solution.

This function override any attempt of Qt to be smart.
And that for any Qt Application that loads a KDE plugin.

For instance, Greenhouse^W QtCreator uses his own proxy QStyle,  but once you 
load any KDE designer plugin, you the style get replaced by a plain oxygen 
style making everything ugly.

If you run designer (which load kde designer plugins) or a Qt application 
using phonon,  inside gnome,  you will get the KDE style instead of the 
default one in gnome (cleanlooks/gtk)

That applyGUIStyle() cannot really be removed because we cannot rely on Qt 
default all the time

Qt 4.4 will default to Plastique on KDE.  (not good)
Qt 4.5 will try to read the kde config file, and default to oxygen if he can't 
find them.  (almost good, but the parsing of the kde config file inside Qt is 
only 99% reliable[1], and if we want to change our default style in a next 
version of kde, Qt need to be modified)

What we could do at least is check if we are really an instance of 
KApplication in that function. 

Anyway, this patch is wrong anyway because we will not get oxygen by default 
anymore. (or how?)


[1] Qt doesn't handle Kiosk, doesn't know what is the KDE_DEFAULT_HOME passed 
to cmake,  the detection of the running session might fail if you don't use a 
standard xdm, ...

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20081126/8a64bbd1/attachment.sig>


More information about the kde-core-devel mailing list