since it leads to confusion for users, breaks occassionally in svn due to its complexity, incurs overhead on every applet paint but especially when dragging, doesn't look nice at all without composite ... just kill the top level view thing and when you drag something it just "pops" into the right containment.
BUG:176298 svn path=/trunk/KDE/kdelibs/; revision=890331
This commit is contained in:
parent
766dc8ab60
commit
4a7699ce82
73
applet.cpp
73
applet.cpp
@ -986,43 +986,30 @@ void Applet::addAction(QString name, QAction *action)
|
|||||||
void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
if (!d->started) {
|
if (!d->started) {
|
||||||
|
kDebug() << "not started";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainter *p = painter;
|
|
||||||
QPixmap *pixmap = 0;
|
|
||||||
|
|
||||||
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.
|
|
||||||
kDebug() << "Painting ghosted...";
|
|
||||||
pixmap = new QPixmap(boundingRect().size().toSize());
|
|
||||||
pixmap->fill(Qt::transparent);
|
|
||||||
|
|
||||||
p = new QPainter();
|
|
||||||
p->begin(pixmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
p->save();
|
|
||||||
|
|
||||||
if (transform().isRotating()) {
|
if (transform().isRotating()) {
|
||||||
p->setRenderHint(QPainter::SmoothPixmapTransform);
|
painter->setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
p->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->background &&
|
if (d->background &&
|
||||||
formFactor() != Plasma::Vertical &&
|
formFactor() != Plasma::Vertical &&
|
||||||
formFactor() != Plasma::Horizontal) {
|
formFactor() != Plasma::Horizontal) {
|
||||||
//kDebug() << "option rect is" << option->rect;
|
//kDebug() << "option rect is" << option->rect;
|
||||||
d->background->paintFrame(p);
|
d->background->paintFrame(painter);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d->failed) {
|
||||||
|
kDebug() << "failed!";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!d->failed) {
|
|
||||||
qreal left, top, right, bottom;
|
qreal left, top, right, bottom;
|
||||||
getContentsMargins(&left, &top, &right, &bottom);
|
getContentsMargins(&left, &top, &right, &bottom);
|
||||||
QRect contentsRect =
|
QRect contentsRect = QRectF(QPointF(0, 0),
|
||||||
QRectF(QPointF(0, 0),
|
|
||||||
boundingRect().size()).adjusted(left, top, -right, -bottom).toRect();
|
boundingRect().size()).adjusted(left, top, -right, -bottom).toRect();
|
||||||
|
|
||||||
if (widget && isContainment()) {
|
if (widget && isContainment()) {
|
||||||
@ -1036,6 +1023,8 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!v || v->isWallpaperEnabled()) {
|
if (!v || v->isWallpaperEnabled()) {
|
||||||
|
|
||||||
|
// paint the wallpaper
|
||||||
if (c && c->drawWallpaper() && c->wallpaper()) {
|
if (c && c->drawWallpaper() && c->wallpaper()) {
|
||||||
Wallpaper *w = c->wallpaper();
|
Wallpaper *w = c->wallpaper();
|
||||||
if (!w->isInitialized()) {
|
if (!w->isInitialized()) {
|
||||||
@ -1046,39 +1035,25 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
|
|||||||
w->restore(wallpaperConfig);
|
w->restore(wallpaperConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
p->save();
|
painter->save();
|
||||||
c->wallpaper()->paint(p, option->exposedRect);
|
c->wallpaper()->paint(painter, option->exposedRect);
|
||||||
p->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// .. and now paint the actual containment interface, but with
|
||||||
|
// a Containment style option based on the one we get
|
||||||
Containment::StyleOption coption(*option);
|
Containment::StyleOption coption(*option);
|
||||||
coption.view = v;
|
coption.view = v;
|
||||||
paintInterface(p, &coption, contentsRect);
|
paintInterface(painter, &coption, contentsRect);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
p->restore();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//kDebug() << "paint interface of" << (QObject*) this;
|
//kDebug() << "paint interface of" << (QObject*) this;
|
||||||
paintInterface(p, option, contentsRect);
|
// paint the applet's interface
|
||||||
}
|
paintInterface(painter, option, contentsRect);
|
||||||
p->restore();
|
|
||||||
|
|
||||||
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)));
|
|
||||||
p->end();
|
|
||||||
delete p;
|
|
||||||
|
|
||||||
painter->drawPixmap(0, 0, *pixmap);
|
|
||||||
delete pixmap;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Applet::paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void Applet::paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect)
|
||||||
const QRect &contentsRect)
|
|
||||||
{
|
{
|
||||||
if (d->script) {
|
if (d->script) {
|
||||||
d->script->paintInterface(painter, option, contentsRect);
|
d->script->paintInterface(painter, option, contentsRect);
|
||||||
@ -1791,7 +1766,6 @@ AppletPrivate::AppletPrivate(KService::Ptr service, int uniqueID, Applet *applet
|
|||||||
failed(false),
|
failed(false),
|
||||||
isContainment(false),
|
isContainment(false),
|
||||||
transient(false),
|
transient(false),
|
||||||
ghost(false),
|
|
||||||
needsConfig(false),
|
needsConfig(false),
|
||||||
started(false)
|
started(false)
|
||||||
{
|
{
|
||||||
@ -2059,7 +2033,6 @@ void AppletOverlayWidget::paint(QPainter *painter,
|
|||||||
{
|
{
|
||||||
Q_UNUSED(option)
|
Q_UNUSED(option)
|
||||||
Q_UNUSED(widget)
|
Q_UNUSED(widget)
|
||||||
painter->save();
|
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
QColor wash = Plasma::Theme::defaultTheme()->color(Theme::BackgroundColor);
|
QColor wash = Plasma::Theme::defaultTheme()->color(Theme::BackgroundColor);
|
||||||
wash.setAlphaF(.6);
|
wash.setAlphaF(.6);
|
||||||
@ -2071,8 +2044,6 @@ void AppletOverlayWidget::paint(QPainter *painter,
|
|||||||
} else {
|
} else {
|
||||||
painter->fillPath(parentItem()->shape(), wash);
|
painter->fillPath(parentItem()->shape(), wash);
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
@ -113,7 +113,6 @@ public:
|
|||||||
bool isContainment : 1;
|
bool isContainment : 1;
|
||||||
bool square : 1;
|
bool square : 1;
|
||||||
bool transient : 1;
|
bool transient : 1;
|
||||||
bool ghost : 1;
|
|
||||||
bool needsConfig : 1;
|
bool needsConfig : 1;
|
||||||
bool started : 1;
|
bool started : 1;
|
||||||
};
|
};
|
||||||
|
@ -63,7 +63,6 @@ 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_topview(0),
|
|
||||||
m_backgroundBuffer(0),
|
m_backgroundBuffer(0),
|
||||||
m_currentView(applet->view()),
|
m_currentView(applet->view()),
|
||||||
m_entryPos(hoverPos),
|
m_entryPos(hoverPos),
|
||||||
@ -136,9 +135,6 @@ AppletHandle::~AppletHandle()
|
|||||||
{
|
{
|
||||||
detachApplet();
|
detachApplet();
|
||||||
delete m_backgroundBuffer;
|
delete m_backgroundBuffer;
|
||||||
if (m_topview) {
|
|
||||||
delete m_topview;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Applet *AppletHandle::applet() const
|
Applet *AppletHandle::applet() const
|
||||||
@ -229,15 +225,15 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
|||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
|
//kDebug() << m_opacity << m_anim << FadeOut;
|
||||||
if (qFuzzyCompare(m_opacity + 1.0, 1.0)) {
|
if (qFuzzyCompare(m_opacity + 1.0, 1.0)) {
|
||||||
if (m_anim == FadeOut) {
|
if (m_anim == FadeOut) {
|
||||||
|
//kDebug() << "WOOOOOOOOO";
|
||||||
QTimer::singleShot(0, this, SLOT(emitDisappear()));
|
QTimer::singleShot(0, this, SLOT(emitDisappear()));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->save();
|
|
||||||
|
|
||||||
qreal translation;
|
qreal translation;
|
||||||
|
|
||||||
if (m_buttonsOnRight) {
|
if (m_buttonsOnRight) {
|
||||||
@ -393,8 +389,6 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
|||||||
basePoint = m_rect.bottomLeft() + QPointF(HANDLE_MARGIN, 0) - step;
|
basePoint = m_rect.bottomLeft() + QPointF(HANDLE_MARGIN, 0) - step;
|
||||||
sourceIconRect.translate(0, m_iconSize);
|
sourceIconRect.translate(0, m_iconSize);
|
||||||
painter->drawPixmap(QRectF(basePoint + shiftD, iconSize), *m_backgroundBuffer, sourceIconRect);
|
painter->drawPixmap(QRectF(basePoint + shiftD, iconSize), *m_backgroundBuffer, sourceIconRect);
|
||||||
|
|
||||||
painter->restore();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletHandle::emitDisappear()
|
void AppletHandle::emitDisappear()
|
||||||
@ -500,10 +494,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 &&
|
if (v && v != m_currentView && v->containment() != m_containment) {
|
||||||
v != m_currentView &&
|
|
||||||
v != m_topview &&
|
|
||||||
v->containment() != m_containment) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -550,27 +541,6 @@ void AppletHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
break;
|
break;
|
||||||
case MoveButton:
|
case MoveButton:
|
||||||
{
|
{
|
||||||
if (m_topview) {
|
|
||||||
m_topview->hide();
|
|
||||||
delete m_topview;
|
|
||||||
m_topview = 0;
|
|
||||||
m_applet->d->ghost = false;
|
|
||||||
m_applet->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
//find out if we were dropped on a panel or something
|
|
||||||
if (leaveCurrentView(event->screenPos())) {
|
|
||||||
startFading(FadeOut, m_entryPos);
|
|
||||||
Plasma::View *v = Plasma::View::topLevelViewAt(event->screenPos());
|
|
||||||
if (v && v != m_currentView) {
|
|
||||||
Containment *c = v->containment();
|
|
||||||
QPoint pos = v->mapFromGlobal(event->screenPos());
|
|
||||||
//we actually have been dropped on another containment, so
|
|
||||||
//move there: we have a screenpos, we need a scenepos
|
|
||||||
//FIXME how reliable is this transform?
|
|
||||||
switchContainment(c, v->mapToScene(pos));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// test for containment change
|
// test for containment change
|
||||||
//kDebug() << "testing for containment change, sceneBoundingRect = "
|
//kDebug() << "testing for containment change, sceneBoundingRect = "
|
||||||
// << m_containment->sceneBoundingRect();
|
// << m_containment->sceneBoundingRect();
|
||||||
@ -599,7 +569,6 @@ void AppletHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -641,75 +610,22 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
|
|
||||||
if (m_pressedButton == MoveButton) {
|
if (m_pressedButton == MoveButton) {
|
||||||
m_pos += deltaScene;
|
m_pos += deltaScene;
|
||||||
|
if (leaveCurrentView(event->screenPos())) {
|
||||||
//Are we moving out of the current view?
|
Plasma::View *v = Plasma::View::topLevelViewAt(event->screenPos());
|
||||||
bool toTopLevel = leaveCurrentView(event->screenPos());
|
if (v && v != m_currentView) {
|
||||||
|
Containment *c = v->containment();
|
||||||
if (!toTopLevel) {
|
QPoint pos = v->mapFromGlobal(event->screenPos());
|
||||||
|
//we actually have been dropped on another containment, so
|
||||||
|
//move there: we have a screenpos, we need a scenepos
|
||||||
|
//FIXME how reliable is this transform?
|
||||||
|
m_pressedButton = NoButton;
|
||||||
|
switchContainment(c, v->mapToScene(pos));
|
||||||
|
} else {
|
||||||
setPos(m_pos);
|
setPos(m_pos);
|
||||||
if (m_topview) {
|
|
||||||
//We were on a toplevel view, but are moving back on the scene
|
|
||||||
//again. destroy the toplevel view:
|
|
||||||
m_topview->hide();
|
|
||||||
delete m_topview;
|
|
||||||
m_topview = 0;
|
|
||||||
m_applet->d->ghost = false;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//set the screenRect correctly. the screenRect contains the bounding
|
setPos(m_pos);
|
||||||
//rect of the applet in screen coordinates. m_mousePos contains the
|
|
||||||
//position of the mouse relative to the applet, in screen coords.
|
|
||||||
QRect screenRect = QRect(event->screenPos() - m_mousePos, m_applet->size().toSize());
|
|
||||||
|
|
||||||
//kDebug() << "screenRect = " << screenRect;
|
|
||||||
|
|
||||||
if (!m_topview) { //create a new toplevel view
|
|
||||||
m_topview = new View(m_containment, -1, 0);
|
|
||||||
|
|
||||||
m_topview->setTrackContainmentChanges(false);
|
|
||||||
m_topview->setWindowFlags(
|
|
||||||
Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
|
||||||
m_topview->setWallpaperEnabled(false);
|
|
||||||
m_topview->resize(screenRect.size());
|
|
||||||
m_topview->setSceneRect(m_applet->sceneBoundingRect());
|
|
||||||
m_topview->centerOn(m_applet);
|
|
||||||
|
|
||||||
//We might have to scale the view, because we might be zoomed out.
|
|
||||||
qreal scale = screenRect.width() / m_applet->boundingRect().width();
|
|
||||||
m_topview->scale(scale, scale);
|
|
||||||
|
|
||||||
//Paint a mask based on the applets shape.
|
|
||||||
//TODO: I think it's nicer to have this functionality in Applet.
|
|
||||||
//TODO: When the corona tiled background is disabled, disable the
|
|
||||||
//mask when compositing is enabled.
|
|
||||||
//FIXME: the mask doesn't function correctly when zoomed out.
|
|
||||||
QBitmap bitmap(screenRect.size());
|
|
||||||
{
|
|
||||||
QPainter shapePainter;
|
|
||||||
shapePainter.begin(&bitmap);
|
|
||||||
shapePainter.fillRect(0, 0, screenRect.width(),
|
|
||||||
screenRect.height(),
|
|
||||||
Qt::white);
|
|
||||||
shapePainter.setBrush(Qt::black);
|
|
||||||
shapePainter.drawPath(m_applet->shape());
|
|
||||||
shapePainter.end();
|
|
||||||
}
|
}
|
||||||
m_topview->setMask(bitmap);
|
|
||||||
|
|
||||||
m_topview->show();
|
|
||||||
|
|
||||||
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
|
|
||||||
//looks absolutely terrible when masked, while the minor rounded corners of most
|
|
||||||
//themes should look quite ok. I said should, since shape() doesn't really
|
|
||||||
//function correctly right now for applets drawing standard backgrounds.
|
|
||||||
}
|
|
||||||
|
|
||||||
m_topview->setGeometry(screenRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (m_pressedButton == RotateButton ||
|
} else if (m_pressedButton == RotateButton ||
|
||||||
m_pressedButton == ResizeButton) {
|
m_pressedButton == ResizeButton) {
|
||||||
if (_k_distanceForPoint(deltaScene) <= 1.0) {
|
if (_k_distanceForPoint(deltaScene) <= 1.0) {
|
||||||
@ -874,7 +790,7 @@ void AppletHandle::switchContainment(Containment *containment, const QPointF &po
|
|||||||
{
|
{
|
||||||
if (containment->containmentType() != Containment::PanelContainment) {
|
if (containment->containmentType() != Containment::PanelContainment) {
|
||||||
//FIXME assuming everything else behaves like desktop?
|
//FIXME assuming everything else behaves like desktop?
|
||||||
kDebug() << "desktop";
|
//kDebug() << "desktop";
|
||||||
m_containment = containment;
|
m_containment = containment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -930,15 +846,6 @@ void AppletHandle::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
//wait a moment to hide the handle in order to recheck the mouse position
|
//wait a moment to hide the handle in order to recheck the mouse position
|
||||||
m_leaveTimer->start();
|
m_leaveTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_topview) {
|
|
||||||
//We were on a toplevel view, but are moving back on the scene
|
|
||||||
//again. destroy the toplevel view:
|
|
||||||
m_topview->hide();
|
|
||||||
delete m_topview;
|
|
||||||
m_topview = 0;
|
|
||||||
m_applet->d->ghost = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppletHandle::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
bool AppletHandle::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||||
@ -958,7 +865,8 @@ void AppletHandle::fadeAnimation(qreal progress)
|
|||||||
} else {
|
} else {
|
||||||
m_opacity = 1 - progress;
|
m_opacity = 1 - progress;
|
||||||
}
|
}
|
||||||
//kDebug() << "progress" << progress << "m_opacity" << m_opacity;// << endOpacity;
|
|
||||||
|
//kDebug() << "progress" << progress << "m_opacity" << m_opacity << m_anim << "(" << FadeIn << ")";
|
||||||
if (qFuzzyCompare(progress, qreal(1.0))) {
|
if (qFuzzyCompare(progress, qreal(1.0))) {
|
||||||
m_animId = 0;
|
m_animId = 0;
|
||||||
delete m_backgroundBuffer;
|
delete m_backgroundBuffer;
|
||||||
@ -1009,6 +917,7 @@ void AppletHandle::startFading(FadeType anim, const QPointF &hoverPos)
|
|||||||
|
|
||||||
if (!m_applet || (anim == FadeOut && m_hoverTimer->isActive())) {
|
if (!m_applet || (anim == FadeOut && m_hoverTimer->isActive())) {
|
||||||
// fading out before we've started fading in
|
// fading out before we've started fading in
|
||||||
|
m_anim = FadeOut;
|
||||||
fadeAnimation(1.0);
|
fadeAnimation(1.0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1055,8 +964,8 @@ void AppletHandle::startFading(FadeType anim, const QPointF &hoverPos)
|
|||||||
|
|
||||||
m_anim = anim;
|
m_anim = anim;
|
||||||
//kDebug() << "animating for " << time << "ms";
|
//kDebug() << "animating for " << time << "ms";
|
||||||
m_animId = Animator::self()->customAnimation(
|
m_animId = Animator::self()->customAnimation(80 * (time / 1000.0), (int)time,
|
||||||
80 * (time / 1000.0), (int)time, Animator::EaseInCurve, this, "fadeAnimation");
|
Animator::EaseInCurve, this, "fadeAnimation");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletHandle::forceDisappear()
|
void AppletHandle::forceDisappear()
|
||||||
|
@ -120,7 +120,6 @@ class AppletHandle : public QObject, public QGraphicsItem
|
|||||||
QColor m_gradientColor;
|
QColor m_gradientColor;
|
||||||
QTimer *m_hoverTimer;
|
QTimer *m_hoverTimer;
|
||||||
QTimer *m_leaveTimer;
|
QTimer *m_leaveTimer;
|
||||||
View *m_topview;
|
|
||||||
QPixmap *m_backgroundBuffer;
|
QPixmap *m_backgroundBuffer;
|
||||||
QGraphicsView *m_currentView;
|
QGraphicsView *m_currentView;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user