- 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))
|
args.count() > 1 ? args[1].toInt() : 0))
|
||||||
{
|
{
|
||||||
d->init(this);
|
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
|
// inflexibility of KService::createInstance
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -659,10 +659,10 @@ QRectF Applet::boundingRect() const
|
|||||||
int bottom;
|
int bottom;
|
||||||
|
|
||||||
d->getBorderSize(left,top,right,bottom);
|
d->getBorderSize(left,top,right,bottom);
|
||||||
|
|
||||||
|
|
||||||
//qDebug() << "Background , Border size" << d->background << left << top << right << bottom;
|
//qDebug() << "Background , Border size" << d->background << left << top << right << bottom;
|
||||||
|
|
||||||
return rect.adjusted(-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);
|
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)
|
void Applet::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
//kDebug() << "context menu event!";
|
//kDebug() << "context menu event!";
|
||||||
@ -1093,7 +1111,6 @@ void Applet::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
|
||||||
#include "applet.moc"
|
#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.
|
* 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_OBJECT
|
||||||
// Q_PROPERTY( QRectF maxSizeHint READ maxSizeHint )
|
// 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 failedToLaunch READ failedToLaunch WRITE setFailedToLaunch )
|
||||||
Q_PROPERTY( bool needsConfiguring READ needsConfiguring WRITE setNeedsConfiguring )
|
Q_PROPERTY( bool needsConfiguring READ needsConfiguring WRITE setNeedsConfiguring )
|
||||||
Q_PROPERTY( QRectF boundingRect READ boundingRect )
|
Q_PROPERTY( QRectF boundingRect READ boundingRect )
|
||||||
|
Q_PROPERTY( QRectF geometry READ geometry WRITE setGeometry )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef QList<Applet*> List;
|
typedef QList<Applet*> List;
|
||||||
@ -218,15 +219,15 @@ class PLASMA_EXPORT Applet : public Widget
|
|||||||
QSizeF contentSize() const;
|
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
|
* Applets can re-implement this to provide a suitable size based
|
||||||
* on their contents.
|
* on their contents.
|
||||||
*
|
*
|
||||||
* Unlike sizeHint() , contentSizeHint() does not include the
|
* Unlike sizeHint() , contentSizeHint() does not include the
|
||||||
* size of any borders surrounding the content area.
|
* size of any borders surrounding the content area.
|
||||||
*
|
*
|
||||||
* The default implementation returns the sizeHint() of the applet's
|
* 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;
|
virtual QSizeF contentSizeHint() const;
|
||||||
|
|
||||||
@ -235,11 +236,11 @@ class PLASMA_EXPORT Applet : public Widget
|
|||||||
*
|
*
|
||||||
* @param category Only applets matchin this category will be returned.
|
* @param category Only applets matchin this category will be returned.
|
||||||
* Useful in conjunction with knownCategories.
|
* 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.
|
* Categories= entry are also returned.
|
||||||
* If an empty string is passed in, all applets are
|
* If an empty string is passed in, all applets are
|
||||||
* returned.
|
* 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.
|
* X-KDE-ParentApp entry (if any) in the plugin info.
|
||||||
* The default value of QString() will result in a
|
* The default value of QString() will result in a
|
||||||
* list containing only applets not specifically
|
* 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
|
* Returns a list of all the categories used by
|
||||||
* installed applets.
|
* 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.
|
* X-KDE-ParentApp entry (if any) in the plugin info.
|
||||||
* The default value of QString() will result in a
|
* The default value of QString() will result in a
|
||||||
* list containing only applets not specifically
|
* list containing only applets not specifically
|
||||||
@ -374,7 +375,7 @@ class PLASMA_EXPORT Applet : public Widget
|
|||||||
**/
|
**/
|
||||||
bool isImmutable() const;
|
bool isImmutable() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether or not this applet is immutable or not.
|
* Sets whether or not this applet is immutable or not.
|
||||||
*
|
*
|
||||||
* @arg immutable true if this applet should not be changeable
|
* @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());
|
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
|
* otherwise, false
|
||||||
*/
|
*/
|
||||||
bool needsConfiguring() const;
|
bool needsConfiguring() const;
|
||||||
@ -469,9 +470,18 @@ class PLASMA_EXPORT Applet : public Widget
|
|||||||
|
|
||||||
// reimplemented from LayoutItem
|
// reimplemented from LayoutItem
|
||||||
// value is the same as contentSizeHint() if drawStandardBackground() is false
|
// 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;
|
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:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
* Emitted when the applet needs to take (or lose) keyboard focus.
|
* Emitted when the applet needs to take (or lose) keyboard focus.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user