* for ghost painting, used when dragging, we only need to know true or false .. we don't need to check the view

* cache the current view as this gets called on every mouse move event when dragging something by the handle.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=858901
This commit is contained in:
Aaron J. Seigo 2008-09-09 00:23:02 +00:00
parent d404d951f2
commit 81ff908a3e
4 changed files with 20 additions and 18 deletions

View File

@ -859,10 +859,7 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
//FIXME: we should probably set the pixmap to screenSize(), but that breaks stuff atm.
QPixmap *pixmap = 0;
QGraphicsView* qgv = qobject_cast<QGraphicsView*>(widget ? widget->parent() : 0);
bool ghost = (qgv && (qgv == d->ghostView));
if (ghost) {
if (d->ghost) {
// The applet has to be displayed semi transparent. Create a pixmap and a painter on
// that pixmap where the applet can draw on so we can draw the result transparently
// at the end.
@ -921,7 +918,7 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
}
p->restore();
if (ghost) {
if (d->ghost) {
// Lets display the pixmap that we've just drawn... transparently.
p->setCompositionMode(QPainter::CompositionMode_DestinationIn);
p->fillRect(pixmap->rect(), QColor(0, 0, 0, (0.3 * 255)));
@ -1534,7 +1531,6 @@ AppletPrivate::AppletPrivate(KService::Ptr service, int uniqueID, Applet *applet
mainConfig(0),
pendingConstraints(NoConstraint),
aspectRatioMode(Plasma::KeepAspectRatio),
ghostView(0),
immutability(Mutable),
actions(applet),
activationAction(0),
@ -1542,7 +1538,8 @@ AppletPrivate::AppletPrivate(KService::Ptr service, int uniqueID, Applet *applet
hasConfigurationInterface(false),
failed(false),
isContainment(false),
transient(false)
transient(false),
ghost(false)
{
if (appletId == 0) {
appletId = ++s_maxAppletId;

View File

@ -92,7 +92,6 @@ public:
KConfigGroup *mainConfig;
Plasma::Constraints pendingConstraints;
Plasma::AspectRatioMode aspectRatioMode;
QGraphicsView* ghostView;
ImmutabilityType immutability;
KActionCollection actions;
KAction *activationAction;
@ -102,6 +101,7 @@ public:
bool isContainment : 1;
bool square : 1;
bool transient : 1;
bool ghost : 1;
};
} // Plasma namespace

View File

@ -62,10 +62,11 @@ AppletHandle::AppletHandle(Containment *parent, Applet *applet, const QPointF &h
m_tempAngle(0.0),
m_scaleWidth(1.0),
m_scaleHeight(1.0),
m_buttonsOnRight(false),
m_pendingFade(false),
m_topview(0),
m_entryPos(hoverPos)
m_currentView(applet->view()),
m_entryPos(hoverPos),
m_buttonsOnRight(false),
m_pendingFade(false)
{
KColorScheme colorScheme(QPalette::Active, KColorScheme::View, Theme::defaultTheme()->colorScheme());
m_gradientColor = colorScheme.background(KColorScheme::NormalBackground).color();
@ -374,7 +375,7 @@ bool AppletHandle::leaveCurrentView(const QPoint &pos) const
//is this widget a plasma view, a different view then our current one,
//AND not a dashboardview?
Plasma::View *v = qobject_cast<Plasma::View *>(widget);
if (v && v != m_applet->containment()->view()
if (v && v != m_currentView
&& v != m_topview
&& v->containment() != m_containment) {
return true;
@ -442,7 +443,7 @@ void AppletHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
m_topview->hide();
delete m_topview;
m_topview = 0;
m_applet->d->ghostView = 0;
m_applet->d->ghost = false;
m_applet->update();
}
@ -450,7 +451,7 @@ void AppletHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (leaveCurrentView(event->screenPos())) {
startFading(FadeOut, m_entryPos);
Plasma::View *v = Plasma::View::topLevelViewAt(event->screenPos());
if (v && v != m_containment->view()) {
if (v && v != m_currentView) {
Containment *c = v->containment();
QPoint pos = v->mapFromGlobal(event->screenPos());
//we actually have been dropped on another containment, so
@ -539,7 +540,7 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
m_topview->hide();
delete m_topview;
m_topview = 0;
m_applet->d->ghostView = 0;
m_applet->d->ghost = false;
}
} else {
//set the screenRect correctly. the screenRect contains the bounding
@ -585,7 +586,7 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
m_topview->show();
m_applet->d->ghostView = m_containment->view();
m_applet->d->ghost = true;
//TODO: non compositing users are screwed: masking looks terrible.
//Consider always enabling the applet background. Stuff like the analog clock

View File

@ -27,6 +27,8 @@
#include "animator.h"
#include "svg.h"
class QGraphicsView;
namespace Plasma
{
class Applet;
@ -104,14 +106,16 @@ class AppletHandle : public QObject, public QGraphicsItem
QColor m_gradientColor;
QTimer *m_hoverTimer;
QTimer *m_leaveTimer;
bool m_buttonsOnRight;
bool m_pendingFade;
View *m_topview;
QGraphicsView *m_currentView;
QPoint m_mousePos; //mousepos relative to applet
QPointF m_entryPos; //where the hover in event occurred
QPointF m_pos; //current position of applet in sceneCoords
qreal m_zValue; //current zValue of the applet, so it can be restored after drag.
bool m_buttonsOnRight : 1;
bool m_pendingFade : 1;
};
}