- Override setGeometry so we can give correct rect to layout
- Delete white space from line ends svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=718078
This commit is contained in:
parent
61fa701fc0
commit
79a32822ac
27
applet.cpp
27
applet.cpp
@ -356,7 +356,7 @@ Applet::Applet(QObject* parentObject, const QVariantList& args)
|
||||
args.count() > 1 ? args[1].toInt() : 0))
|
||||
{
|
||||
d->init(this);
|
||||
// the brain damage seen in the initialization list is due to the
|
||||
// the brain damage seen in the initialization list is due to the
|
||||
// inflexibility of KService::createInstance
|
||||
}
|
||||
|
||||
@ -659,10 +659,10 @@ QRectF Applet::boundingRect() const
|
||||
int bottom;
|
||||
|
||||
d->getBorderSize(left,top,right,bottom);
|
||||
|
||||
|
||||
|
||||
|
||||
//qDebug() << "Background , Border size" << d->background << left << top << right << bottom;
|
||||
|
||||
|
||||
return rect.adjusted(-left,-top,right,bottom);
|
||||
}
|
||||
|
||||
@ -1073,6 +1073,24 @@ QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
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!";
|
||||
@ -1093,7 +1111,6 @@ void Applet::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#include "applet.moc"
|
||||
|
32
applet.h
32
applet.h
@ -55,7 +55,7 @@ class Package;
|
||||
*
|
||||
* See techbase.kde.org for tutorial on writing Applets using this class.
|
||||
*/
|
||||
class PLASMA_EXPORT Applet : public Widget
|
||||
class PLASMA_EXPORT Applet : public Widget
|
||||
{
|
||||
Q_OBJECT
|
||||
// Q_PROPERTY( QRectF maxSizeHint READ maxSizeHint )
|
||||
@ -67,6 +67,7 @@ class PLASMA_EXPORT Applet : public Widget
|
||||
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<Applet*> List;
|
||||
@ -218,15 +219,15 @@ class PLASMA_EXPORT Applet : public Widget
|
||||
QSizeF contentSize() const;
|
||||
|
||||
/**
|
||||
* Returns an ideal size for the applet's content.
|
||||
* Returns an ideal size for the applet's content.
|
||||
* Applets can re-implement this to provide a suitable size based
|
||||
* on their contents.
|
||||
*
|
||||
* Unlike sizeHint() , contentSizeHint() does not include the
|
||||
* size of any borders surrounding the content area.
|
||||
* Unlike sizeHint() , contentSizeHint() does not include the
|
||||
* size of any borders surrounding the content area.
|
||||
*
|
||||
* The default implementation returns the sizeHint() of the applet's
|
||||
* layout if it has one, or a null size otherwise.
|
||||
* layout if it has one, or a null size otherwise.
|
||||
*/
|
||||
virtual QSizeF contentSizeHint() const;
|
||||
|
||||
@ -235,11 +236,11 @@ class PLASMA_EXPORT Applet : public Widget
|
||||
*
|
||||
* @param category Only applets matchin this category will be returned.
|
||||
* Useful in conjunction with knownCategories.
|
||||
* If "Misc" is passed in, then applets without a
|
||||
* If "Misc" is passed in, then applets without a
|
||||
* Categories= entry are also returned.
|
||||
* If an empty string is passed in, all applets are
|
||||
* returned.
|
||||
* @param parentApp the application to filter applets on. Uses the
|
||||
* @param parentApp the application to filter applets on. Uses the
|
||||
* X-KDE-ParentApp entry (if any) in the plugin info.
|
||||
* The default value of QString() will result in a
|
||||
* list containing only applets not specifically
|
||||
@ -260,7 +261,7 @@ class PLASMA_EXPORT Applet : public Widget
|
||||
* Returns a list of all the categories used by
|
||||
* installed applets.
|
||||
*
|
||||
* @param parentApp the application to filter applets on. Uses the
|
||||
* @param parentApp the application to filter applets on. Uses the
|
||||
* X-KDE-ParentApp entry (if any) in the plugin info.
|
||||
* The default value of QString() will result in a
|
||||
* list containing only applets not specifically
|
||||
@ -374,7 +375,7 @@ class PLASMA_EXPORT Applet : public Widget
|
||||
**/
|
||||
bool isImmutable() const;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets whether or not this applet is immutable or not.
|
||||
*
|
||||
* @arg immutable true if this applet should not be changeable
|
||||
@ -417,7 +418,7 @@ class PLASMA_EXPORT Applet : public Widget
|
||||
void setFailedToLaunch(bool failed, const QString& reason = QString());
|
||||
|
||||
/**
|
||||
* @return true if the applet currently needs to be configured,
|
||||
* @return true if the applet currently needs to be configured,
|
||||
* otherwise, false
|
||||
*/
|
||||
bool needsConfiguring() const;
|
||||
@ -469,9 +470,18 @@ class PLASMA_EXPORT Applet : public Widget
|
||||
|
||||
// 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.
|
||||
|
Loading…
Reference in New Issue
Block a user