Index: applet.h =================================================================== --- applet.h (revision 717592) +++ applet.h (working copy) @@ -67,6 +67,7 @@ Q_PROPERTY( bool failedToLaunch READ failedToLaunch WRITE setFailedToLaunch ) Q_PROPERTY( bool needsConfiguring READ needsConfiguring WRITE setNeedsConfiguring ) Q_PROPERTY( QRectF boundingRect READ boundingRect ) + Q_PROPERTY( QRectF geometry READ geometry WRITE setGeometry ) public: typedef QList List; @@ -469,9 +470,18 @@ // reimplemented from LayoutItem // value is the same as contentSizeHint() if drawStandardBackground() is false - // or contentSizeHint() plus the size of the border otherwise. + // or contentSizeHint() plus the size of the border otherwise. virtual QSizeF sizeHint() const; + /** + * Sets the geometry of this Applet. + */ + /** + * Sets the geometry of this Plasma::Applet + * @param geometry the geometry to apply to this Plasma::Applet. + */ + void setGeometry(const QRectF &geometry); + Q_SIGNALS: /** * Emitted when the applet needs to take (or lose) keyboard focus. Index: widgets/widget.h =================================================================== --- widgets/widget.h (revision 717592) +++ widgets/widget.h (working copy) @@ -256,6 +256,7 @@ */ virtual void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); void contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent); + void setSize(const QSizeF& size); private: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); Index: widgets/widget.cpp =================================================================== --- widgets/widget.cpp (revision 717592) +++ widgets/widget.cpp (working copy) @@ -222,6 +222,11 @@ update(); } +void Widget::setSize(const QSizeF& size) +{ + d->size = size; +} + void Widget::updateGeometry() { if ( managingLayout() ) { Index: widgets/boxlayout.cpp =================================================================== --- widgets/boxlayout.cpp (revision 717592) +++ widgets/boxlayout.cpp (working copy) @@ -77,27 +77,27 @@ Q_ASSERT(false); return Qt::Horizontal; } - } + } // returns the position from which layouting should // begin depending on the direction of this layout - qreal startPos(const QRectF& geometry) const + qreal startPos(const QRectF& geometry) const { switch ( direction ) { case LeftToRight: case TopToBottom: - return 0; + return q->margin(); case RightToLeft: - return geometry.width(); + return geometry.width() - q->margin(); case BottomToTop: - return geometry.height(); + return geometry.height() - q->margin(); default: Q_ASSERT(false); return 0; } } - // lays out an item + // lays out an item // // 'geometry' the geometry of the layout // 'item' the item whoose geometry should be altered Index: applet.cpp =================================================================== --- applet.cpp (revision 717592) +++ applet.cpp (working copy) @@ -1073,6 +1073,24 @@ return QGraphicsItem::itemChange(change, value); } +void Applet::setGeometry(const QRectF& geometry) +{ + if (size() != geometry.size()) { + prepareGeometryChange(); + qreal width = qBound(minimumSize().width(), geometry.size().width(), maximumSize().width()); + qreal height = qBound(minimumSize().height(), geometry.size().height(), maximumSize().height()); + + setSize(QSizeF(width, height)); + + if (layout()) { + layout()->setGeometry(QRectF(QPoint(0, 0), contentSize())); + } + } + + setPos(geometry.topLeft()); + update(); +} + void Applet::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { //kDebug() << "context menu event!";