Improved drag&drop: now the toplevel window appears correctly when zoomed out.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=806544
This commit is contained in:
parent
1172ef79e9
commit
df22556806
16
applet.cpp
16
applet.cpp
@ -701,7 +701,8 @@ QList<QAction*> Applet::contextualActions()
|
||||
void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
QPainter *p;
|
||||
QPixmap pixmap(size().toSize());
|
||||
//FIXME: we should probably set the pixmap to screenSize(), but that breaks stuff atm.
|
||||
QPixmap pixmap(boundingRect().size().toSize());
|
||||
|
||||
QGraphicsView* qgv = qobject_cast<QGraphicsView*>(widget->parent());
|
||||
bool ghost = (qgv && (qgv == d->ghostView));
|
||||
@ -771,7 +772,6 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
|
||||
|
||||
delete p;
|
||||
|
||||
kDebug() << "draw the pixmap!";
|
||||
painter->drawPixmap(0, 0, pixmap);
|
||||
}
|
||||
}
|
||||
@ -1221,6 +1221,18 @@ void Applet::setGeometry(const QRectF& geometry)
|
||||
}
|
||||
}
|
||||
|
||||
QRect Applet::screenRect() const
|
||||
{
|
||||
QPointF bottomRight = pos();
|
||||
bottomRight.setX(bottomRight.x() + size().width());
|
||||
bottomRight.setY(bottomRight.y() + size().height());
|
||||
|
||||
QPoint tL = view()->mapToGlobal(view()->mapFromScene(pos()));
|
||||
QPoint bR = view()->mapToGlobal(view()->mapFromScene(bottomRight));
|
||||
|
||||
return QRect(QPoint(0, 0), QSize(bR.x() - tL.x(), bR.y() - tL.y()));
|
||||
}
|
||||
|
||||
void Applet::raise()
|
||||
{
|
||||
setZValue(++Private::s_maxZValue);
|
||||
|
5
applet.h
5
applet.h
@ -432,6 +432,11 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
|
||||
*/
|
||||
void setGeometry(const QRectF &geometry);
|
||||
|
||||
/**
|
||||
* @return a rect of the applet in screen coordinates.
|
||||
*/
|
||||
QRect screenRect() const;
|
||||
|
||||
/**
|
||||
* Reimplemented from QGraphicsItem
|
||||
**/
|
||||
|
@ -421,20 +421,18 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
|
||||
m_topview->setWallpaperEnabled(false);
|
||||
|
||||
m_topview->resize(m_applet->screenRect().size());
|
||||
kDebug() << "resizing topview to: " << m_applet->screenRect().size();
|
||||
|
||||
//TODO: when zoomed out, this doesn't work correctly
|
||||
m_topview->setSceneRect(m_applet->sceneBoundingRect());
|
||||
|
||||
// Calculate the size of the applet in screen coordinates.
|
||||
QPointF bottomRight = m_applet->pos();
|
||||
bottomRight.setX(bottomRight.x() + m_applet->size().width());
|
||||
bottomRight.setY(bottomRight.y() + m_applet->size().height());
|
||||
m_topview->centerOn(m_applet);
|
||||
//We might have to scale the qgv, because we might be zoomed out.
|
||||
qreal scale = m_applet->screenRect().width() / m_applet->boundingRect().width();
|
||||
kDebug() << "scaling topview with: " << scale;
|
||||
m_topview->scale(scale, scale);
|
||||
|
||||
QPoint tL = m_applet->view()->mapToGlobal(m_applet->view()->mapFromScene(
|
||||
m_applet->pos()));
|
||||
QPoint bR = m_applet->view()->mapToGlobal(m_applet->view()->mapFromScene(
|
||||
bottomRight));
|
||||
|
||||
m_topview->resize(bR.x() - tL.x(), bR.y() - tL.y());
|
||||
m_topview->show();
|
||||
|
||||
m_applet->setGhostView(m_applet->containment()->view());
|
||||
|
Loading…
Reference in New Issue
Block a user