From 5f3a757bae315e2b4d2a09bc04e16d51657b7cd8 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 27 May 2008 10:57:09 +0000 Subject: [PATCH] new BackgroundHint: TranslucentBackground, now used by folder view. when an applet has TranslucentBackground set, it loads "widgets/tranlucentbackground" as its own background when that svg does not exists in theh them it falls back to "widgets/background" instead of translucentbackground of the default theme svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=813283 --- applet.cpp | 36 +++++++++++++++++++++++++----------- applet.h | 5 +++-- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/applet.cpp b/applet.cpp index 7bf37f6c9..3e6195425 100644 --- a/applet.cpp +++ b/applet.cpp @@ -540,20 +540,31 @@ void Applet::setBackgroundHints(const BackgroundHints hints) d->backgroundHints = hints; //Draw the standard background? - if (hints & StandardBackground) { + if ((hints & StandardBackground) || (hints & TranslucentBackground)) { if (!d->background) { d->background = new Plasma::PanelSvg(); - d->background->setImagePath("widgets/background"); - d->background->setEnabledBorders(Plasma::PanelSvg::AllBorders); - qreal left, top, right, bottom; - d->background->getMargins(left, top, right, bottom); - setContentsMargins(left, right, top, bottom); - QSizeF fitSize(left + right, top + bottom); - if (minimumSize().expandedTo(fitSize) != minimumSize()) { - setMinimumSize(minimumSize().expandedTo(fitSize)); - } - d->background->resizePanel(boundingRect().size()); } + + if (hints & 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"); + } + + d->background->setEnabledBorders(Plasma::PanelSvg::AllBorders); + qreal left, top, right, bottom; + d->background->getMargins(left, top, right, bottom); + setContentsMargins(left, right, top, bottom); + QSizeF fitSize(left + right, top + bottom); + if (minimumSize().expandedTo(fitSize) != minimumSize()) { + setMinimumSize(minimumSize().expandedTo(fitSize)); + } + d->background->resizePanel(boundingRect().size()); } else if (d->background) { qreal left, top, right, bottom; d->background->getMargins(left, top, right, bottom); @@ -1597,6 +1608,9 @@ void Applet::Private::checkImmutability() void Applet::Private::themeChanged() { if (background) { + //do again the translucent background fallback + q->setBackgroundHints(backgroundHints); + qreal left; qreal right; qreal top; diff --git a/applet.h b/applet.h index 53fa62065..ef8c78e6b 100644 --- a/applet.h +++ b/applet.h @@ -82,8 +82,9 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget * Description on how draw a background for the applet */ enum BackgroundHint { NoBackground = 0 /** Not drawing a background under the applet, the applet has its own implementation */, - StandardBackground /** The standard background from the theme is drawn */, - ShadowedBackground /** The applet has a drop shadow */, + StandardBackground = 1 /** The standard background from the theme is drawn */, + TranslucentBackground = 2 /** An alternate version of the background is drawn, usually more translucent */, + ShadowedBackground = 4 /** The applet has a drop shadow */, DefaultBackground = StandardBackground | ShadowedBackground /** Default settings: both standard background and shadow */ }; Q_DECLARE_FLAGS(BackgroundHints, BackgroundHint)