add Theme::currentThemeHasImage() that checks if the current theme has a

certain svg or if it would fallback to the default theme if loaded.
this makes possible an alternative fallback mechanism between images of
the same theme, used now for the TransparentBackground background hint

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=816734
This commit is contained in:
Marco Martin 2008-06-04 17:44:37 +00:00
parent e729dcd481
commit 5ddceb467b
3 changed files with 15 additions and 6 deletions

View File

@ -574,13 +574,8 @@ void Applet::setBackgroundHints(const BackgroundHints hints)
d->background = new Plasma::PanelSvg();
}
if (hints & TranslucentBackground) {
if ((hints & TranslucentBackground) && Plasma::Theme::defaultTheme()->currentThemeHasImage("widgets/translucentbackground")) {
d->background->setImagePath("widgets/translucentbackground");
//FIXME: this fallback is an hack, an api like Plasma::Theme::hasImage() would be needed to make this clean
if (!Plasma::Theme::defaultTheme()->imagePath("widgets/translucentbackground").contains(Plasma::Theme::defaultTheme()->themeName())) {
d->background->setImagePath("widgets/background");
}
} else {
d->background->setImagePath("widgets/background");
}

View File

@ -259,6 +259,11 @@ QString Theme::imagePath(const QString& name) const
return path;
}
bool Theme::currentThemeHasImage(const QString& name) const
{
return (!d->findInTheme(name, d->themeName).isEmpty());
}
KSharedConfigPtr Theme::colorScheme() const
{
return d->colors;

View File

@ -100,6 +100,15 @@ class PLASMA_EXPORT Theme : public QObject
*/
Q_INVOKABLE QString imagePath( const QString& name ) const;
/**
* Checks if this theme has an image named in a certain way
*
* @arg name the name of the file in the theme directory (without the
* ".svg" part or a leading slash)
* @return true if the image exists for this theme
*/
Q_INVOKABLE bool currentThemeHasImage(const QString& name) const;
/**
* Returns the color scheme configurationthat goes along this theme.
* This can be used with KStatefulBrush and KColorScheme to determine