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
This commit is contained in:
Marco Martin 2008-05-27 10:57:09 +00:00
parent 83a5c1ee6f
commit 5f3a757bae
2 changed files with 28 additions and 13 deletions

View File

@ -540,10 +540,22 @@ 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();
}
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);
@ -553,7 +565,6 @@ void Applet::setBackgroundHints(const BackgroundHints hints)
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;

View File

@ -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)