* 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:
parent
d404d951f2
commit
81ff908a3e
11
applet.cpp
11
applet.cpp
@ -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.
|
//FIXME: we should probably set the pixmap to screenSize(), but that breaks stuff atm.
|
||||||
QPixmap *pixmap = 0;
|
QPixmap *pixmap = 0;
|
||||||
|
|
||||||
QGraphicsView* qgv = qobject_cast<QGraphicsView*>(widget ? widget->parent() : 0);
|
if (d->ghost) {
|
||||||
bool ghost = (qgv && (qgv == d->ghostView));
|
|
||||||
|
|
||||||
if (ghost) {
|
|
||||||
// The applet has to be displayed semi transparent. Create a pixmap and a painter on
|
// 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
|
// that pixmap where the applet can draw on so we can draw the result transparently
|
||||||
// at the end.
|
// at the end.
|
||||||
@ -921,7 +918,7 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
|
|||||||
}
|
}
|
||||||
p->restore();
|
p->restore();
|
||||||
|
|
||||||
if (ghost) {
|
if (d->ghost) {
|
||||||
// Lets display the pixmap that we've just drawn... transparently.
|
// Lets display the pixmap that we've just drawn... transparently.
|
||||||
p->setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
p->setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||||
p->fillRect(pixmap->rect(), QColor(0, 0, 0, (0.3 * 255)));
|
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),
|
mainConfig(0),
|
||||||
pendingConstraints(NoConstraint),
|
pendingConstraints(NoConstraint),
|
||||||
aspectRatioMode(Plasma::KeepAspectRatio),
|
aspectRatioMode(Plasma::KeepAspectRatio),
|
||||||
ghostView(0),
|
|
||||||
immutability(Mutable),
|
immutability(Mutable),
|
||||||
actions(applet),
|
actions(applet),
|
||||||
activationAction(0),
|
activationAction(0),
|
||||||
@ -1542,7 +1538,8 @@ AppletPrivate::AppletPrivate(KService::Ptr service, int uniqueID, Applet *applet
|
|||||||
hasConfigurationInterface(false),
|
hasConfigurationInterface(false),
|
||||||
failed(false),
|
failed(false),
|
||||||
isContainment(false),
|
isContainment(false),
|
||||||
transient(false)
|
transient(false),
|
||||||
|
ghost(false)
|
||||||
{
|
{
|
||||||
if (appletId == 0) {
|
if (appletId == 0) {
|
||||||
appletId = ++s_maxAppletId;
|
appletId = ++s_maxAppletId;
|
||||||
|
@ -92,7 +92,6 @@ public:
|
|||||||
KConfigGroup *mainConfig;
|
KConfigGroup *mainConfig;
|
||||||
Plasma::Constraints pendingConstraints;
|
Plasma::Constraints pendingConstraints;
|
||||||
Plasma::AspectRatioMode aspectRatioMode;
|
Plasma::AspectRatioMode aspectRatioMode;
|
||||||
QGraphicsView* ghostView;
|
|
||||||
ImmutabilityType immutability;
|
ImmutabilityType immutability;
|
||||||
KActionCollection actions;
|
KActionCollection actions;
|
||||||
KAction *activationAction;
|
KAction *activationAction;
|
||||||
@ -102,6 +101,7 @@ public:
|
|||||||
bool isContainment : 1;
|
bool isContainment : 1;
|
||||||
bool square : 1;
|
bool square : 1;
|
||||||
bool transient : 1;
|
bool transient : 1;
|
||||||
|
bool ghost : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
@ -62,10 +62,11 @@ AppletHandle::AppletHandle(Containment *parent, Applet *applet, const QPointF &h
|
|||||||
m_tempAngle(0.0),
|
m_tempAngle(0.0),
|
||||||
m_scaleWidth(1.0),
|
m_scaleWidth(1.0),
|
||||||
m_scaleHeight(1.0),
|
m_scaleHeight(1.0),
|
||||||
m_buttonsOnRight(false),
|
|
||||||
m_pendingFade(false),
|
|
||||||
m_topview(0),
|
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());
|
KColorScheme colorScheme(QPalette::Active, KColorScheme::View, Theme::defaultTheme()->colorScheme());
|
||||||
m_gradientColor = colorScheme.background(KColorScheme::NormalBackground).color();
|
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,
|
//is this widget a plasma view, a different view then our current one,
|
||||||
//AND not a dashboardview?
|
//AND not a dashboardview?
|
||||||
Plasma::View *v = qobject_cast<Plasma::View *>(widget);
|
Plasma::View *v = qobject_cast<Plasma::View *>(widget);
|
||||||
if (v && v != m_applet->containment()->view()
|
if (v && v != m_currentView
|
||||||
&& v != m_topview
|
&& v != m_topview
|
||||||
&& v->containment() != m_containment) {
|
&& v->containment() != m_containment) {
|
||||||
return true;
|
return true;
|
||||||
@ -442,7 +443,7 @@ void AppletHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
m_topview->hide();
|
m_topview->hide();
|
||||||
delete m_topview;
|
delete m_topview;
|
||||||
m_topview = 0;
|
m_topview = 0;
|
||||||
m_applet->d->ghostView = 0;
|
m_applet->d->ghost = false;
|
||||||
m_applet->update();
|
m_applet->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,7 +451,7 @@ void AppletHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
if (leaveCurrentView(event->screenPos())) {
|
if (leaveCurrentView(event->screenPos())) {
|
||||||
startFading(FadeOut, m_entryPos);
|
startFading(FadeOut, m_entryPos);
|
||||||
Plasma::View *v = Plasma::View::topLevelViewAt(event->screenPos());
|
Plasma::View *v = Plasma::View::topLevelViewAt(event->screenPos());
|
||||||
if (v && v != m_containment->view()) {
|
if (v && v != m_currentView) {
|
||||||
Containment *c = v->containment();
|
Containment *c = v->containment();
|
||||||
QPoint pos = v->mapFromGlobal(event->screenPos());
|
QPoint pos = v->mapFromGlobal(event->screenPos());
|
||||||
//we actually have been dropped on another containment, so
|
//we actually have been dropped on another containment, so
|
||||||
@ -539,7 +540,7 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
m_topview->hide();
|
m_topview->hide();
|
||||||
delete m_topview;
|
delete m_topview;
|
||||||
m_topview = 0;
|
m_topview = 0;
|
||||||
m_applet->d->ghostView = 0;
|
m_applet->d->ghost = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//set the screenRect correctly. the screenRect contains the bounding
|
//set the screenRect correctly. the screenRect contains the bounding
|
||||||
@ -585,7 +586,7 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
|
|
||||||
m_topview->show();
|
m_topview->show();
|
||||||
|
|
||||||
m_applet->d->ghostView = m_containment->view();
|
m_applet->d->ghost = true;
|
||||||
|
|
||||||
//TODO: non compositing users are screwed: masking looks terrible.
|
//TODO: non compositing users are screwed: masking looks terrible.
|
||||||
//Consider always enabling the applet background. Stuff like the analog clock
|
//Consider always enabling the applet background. Stuff like the analog clock
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
#include "animator.h"
|
#include "animator.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
|
|
||||||
|
class QGraphicsView;
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
class Applet;
|
class Applet;
|
||||||
@ -104,14 +106,16 @@ class AppletHandle : public QObject, public QGraphicsItem
|
|||||||
QColor m_gradientColor;
|
QColor m_gradientColor;
|
||||||
QTimer *m_hoverTimer;
|
QTimer *m_hoverTimer;
|
||||||
QTimer *m_leaveTimer;
|
QTimer *m_leaveTimer;
|
||||||
bool m_buttonsOnRight;
|
|
||||||
bool m_pendingFade;
|
|
||||||
View *m_topview;
|
View *m_topview;
|
||||||
|
QGraphicsView *m_currentView;
|
||||||
|
|
||||||
QPoint m_mousePos; //mousepos relative to applet
|
QPoint m_mousePos; //mousepos relative to applet
|
||||||
QPointF m_entryPos; //where the hover in event occurred
|
QPointF m_entryPos; //where the hover in event occurred
|
||||||
QPointF m_pos; //current position of applet in sceneCoords
|
QPointF m_pos; //current position of applet in sceneCoords
|
||||||
qreal m_zValue; //current zValue of the applet, so it can be restored after drag.
|
qreal m_zValue; //current zValue of the applet, so it can be restored after drag.
|
||||||
|
|
||||||
|
bool m_buttonsOnRight : 1;
|
||||||
|
bool m_pendingFade : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user