get rid of the background, we need only hints

This commit is contained in:
Marco Martin 2012-09-25 12:52:18 +02:00
parent ae4d0787d3
commit 3a8db22059
3 changed files with 1 additions and 100 deletions

View File

@ -678,43 +678,6 @@ void Applet::setBackgroundHints(const Plasma::BackgroundHints hints)
}
d->backgroundHints = hints;
d->preferredBackgroundHints = hints;
//Draw the standard background?
if ((hints & StandardBackground) || (hints & TranslucentBackground)) {
if (!d->background) {
d->background = new Plasma::FrameSvg(this);
}
if ((hints & TranslucentBackground) &&
Plasma::Theme::defaultTheme()->currentThemeHasImage("widgets/translucentbackground")) {
d->background->setImagePath("widgets/translucentbackground");
} else {
d->background->setImagePath("widgets/background");
}
d->background->setEnabledBorders(Plasma::FrameSvg::AllBorders);
qreal left, top, right, bottom;
d->background->getMargins(left, top, right, bottom);
QSizeF fitSize(left + right, top + bottom);
d->background->resizeFrame(boundingRect().size());
//if the background has an "overlay" element decide a random position for it and then save it so it's consistent across plasma starts
if (d->background->hasElement("overlay")) {
QSize overlaySize = d->background->elementSize("overlay");
//position is in the boundaries overlaySize.width()*2, overlaySize.height()
qsrand(id());
d->background->d->overlayPos.rx() = - (overlaySize.width() /2) + (overlaySize.width() /4) * (qrand() % (4 + 1));
d->background->d->overlayPos.ry() = (- (overlaySize.height() /2) + (overlaySize.height() /4) * (qrand() % (4 + 1)))/2;
}
} else if (d->background) {
qreal left, top, right, bottom;
d->background->getMargins(left, top, right, bottom);
delete d->background;
d->background = 0;
}
}
bool Applet::hasFailedToLaunch() const
@ -837,13 +800,6 @@ void Applet::flushPendingConstraintsEvents()
if (c & Plasma::FormFactorConstraint) {
FormFactor f = formFactor();
if (!d->isContainment && f != Vertical && f != Horizontal) {
setBackgroundHints(d->preferredBackgroundHints);
} else {
BackgroundHints hints = d->preferredBackgroundHints;
setBackgroundHints(NoBackground);
d->preferredBackgroundHints = hints;
}
// avoid putting rotated applets in panels
if (f == Vertical || f == Horizontal) {
@ -929,57 +885,6 @@ void Applet::addAction(QString name, QAction *action)
d->actions->addAction(name, action);
}
void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
if (!d->started) {
//kDebug() << "not started";
return;
}
if (transform().isRotating()) {
painter->setRenderHint(QPainter::SmoothPixmapTransform);
painter->setRenderHint(QPainter::Antialiasing);
}
if (d->background &&
formFactor() != Plasma::Vertical &&
formFactor() != Plasma::Horizontal) {
//kDebug() << "option rect is" << option->rect;
d->background->paintFrame(painter);
}
if (d->failed) {
//kDebug() << "failed!";
return;
}
if (widget && d->isContainment) {
// note that the widget we get is actually the viewport of the view, not the view itself
// View* v = qobject_cast<Plasma::View*>(widget->parent());
Containment* c = qobject_cast<Plasma::Containment*>(this);
//FIXME: new View?
if (1/*!v || v->isWallpaperEnabled()*/) {
// paint the wallpaper
if (c && c->drawWallpaper() && c->wallpaper()) {
Wallpaper *w = c->wallpaper();
if (!w->isInitialized()) {
// delayed paper initialization
KConfigGroup wallpaperConfig = c->config();
wallpaperConfig = KConfigGroup(&wallpaperConfig, "Wallpaper");
wallpaperConfig = KConfigGroup(&wallpaperConfig, w->pluginName());
w->restore(wallpaperConfig);
}
painter->save();
c->wallpaper()->paint(painter, option->exposedRect);
painter->restore();
}
}
}
}
FormFactor Applet::formFactor() const
{
Containment *c = containment();

View File

@ -56,12 +56,10 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int
: appletId(uniqueID),
q(applet),
remotingService(0),
preferredBackgroundHints(StandardBackground),
backgroundHints(NoBackground),
backgroundHints(StandardBackground),
aspectRatioMode(Plasma::KeepAspectRatio),
immutability(Mutable),
appletDescription(info ? *info : KPluginInfo(service)),
background(0),
mainConfig(0),
pendingConstraints(NoConstraint),
script(0),

View File

@ -138,7 +138,6 @@ public:
// applet attributes
Service *remotingService;
BackgroundHints preferredBackgroundHints;
BackgroundHints backgroundHints;
AspectRatioMode aspectRatioMode;
ImmutabilityType immutability;
@ -148,7 +147,6 @@ public:
QVariantList args;
// bookkeeping
Plasma::FrameSvg *background;
KConfigGroup *mainConfig;
Plasma::Constraints pendingConstraints;