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:
parent
83a5c1ee6f
commit
5f3a757bae
36
applet.cpp
36
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;
|
||||
|
5
applet.h
5
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user