Added signals appletTransformedByUsed and appletTransformedItself to

Plasma::Applet. This makes it easier for layouts to know when applets 
are transformed (moved/resized/rotated), and know whether the change
was by the user or the applet itself.

svn path=/trunk/KDE/kdelibs/; revision=923848
This commit is contained in:
Ambroz Bizjak 2009-02-09 15:09:28 +00:00
parent b4267d0689
commit 476fd1a6a3
4 changed files with 20 additions and 0 deletions

View File

@ -607,6 +607,16 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
*/
void geometryChanged();
/**
* Emitted when the user completes a transformation of the applet.
*/
void appletTransformedByUser();
/**
* Emitted when the applet changes its own geometry or transform.
*/
void appletTransformedItself();
/**
* Emitted by Applet subclasses when they change a sizeHint and wants to announce the change
*/

View File

@ -246,6 +246,7 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints)
//size not saved/invalid size saved
if (oldSize.width() < q->minimumSize().width() || oldSize.height() < q->minimumSize().height()) {
q->resize(prefSize);
emit q->appletTransformedItself();
}
//FIXME: this will be automatically propagated by the qgraphicslayout in the future

View File

@ -72,6 +72,9 @@ AppletHandle::AppletHandle(Containment *parent, Applet *applet, const QPointF &h
Theme::defaultTheme()->colorScheme());
m_gradientColor = colorScheme.background(KColorScheme::NormalBackground).color();
m_originalGeom = m_applet->geometry();
m_originalTransform = m_applet->transform();
QTransform originalMatrix = m_applet->transform();
m_applet->resetTransform();
@ -167,6 +170,10 @@ void AppletHandle::detachApplet ()
m_applet->setZValue(m_zValue);
if (m_applet->geometry() != m_originalGeom || m_applet->transform() != m_originalTransform) {
emit m_applet->appletTransformedByUser();
}
m_applet->update(); // re-render the background, now we've transformed the applet
m_applet = 0;

View File

@ -127,6 +127,8 @@ class AppletHandle : public QObject, public QGraphicsItem
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.
QRectF m_originalGeom;
QTransform m_originalTransform;
// used for both resize and rotate
QPointF m_origAppletCenter;