Add method to set where we want to put the icon.Usefull for applet

Lock/Logout

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=734943
This commit is contained in:
Alexis Ménard 2007-11-10 15:16:33 +00:00
parent bb79a14a09
commit 1294c4e8a4
3 changed files with 13 additions and 1 deletions

View File

@ -59,6 +59,7 @@ Icon::Private::Private()
iconSize(48, 48), iconSize(48, 48),
state(Private::NoState), state(Private::NoState),
orientation(Qt::Vertical), orientation(Qt::Vertical),
alignment(Qt::AlignHCenter | Qt::AlignTop),
calculateSizeRequested(true) // First time always true calculateSizeRequested(true) // First time always true
{ {
svg.setContentType(Plasma::Svg::ImageSet); svg.setContentType(Plasma::Svg::ImageSet);
@ -546,7 +547,6 @@ QPixmap Icon::Private::decoration(const QStyleOptionGraphicsItem *option) const
QPointF Icon::Private::iconPosition(const QStyleOptionGraphicsItem *option, const QPixmap &pixmap) const QPointF Icon::Private::iconPosition(const QStyleOptionGraphicsItem *option, const QPixmap &pixmap) const
{ {
const QRectF itemRect = subtractMargin(option->rect, Private::ItemMargin); const QRectF itemRect = subtractMargin(option->rect, Private::ItemMargin);
Qt::Alignment alignment = Qt::AlignHCenter | Qt::AlignTop; // NOTE: This assumes always top-center -MB
// Compute the nominal decoration rectangle // Compute the nominal decoration rectangle
const QSizeF size = addMargin(iconSize, Private::IconMargin); const QSizeF size = addMargin(iconSize, Private::IconMargin);
@ -1008,6 +1008,11 @@ Qt::Orientations Icon::expandingDirections() const
return 0; return 0;
} }
void Icon::setAlignment(Qt::Alignment alignment)
{
d->alignment=alignment;
}
/* /*
QSizeF Icon::sizeHint() const QSizeF Icon::sizeHint() const
{ {

View File

@ -147,6 +147,12 @@ public:
*/ */
void addAction(QAction* action); void addAction(QAction* action);
/**
* let set the position in layout area
* @param action the QAction to associate with this icon.
*/
void setAlignment(Qt::Alignment alignment);
// Layout stuff - no need to document // Layout stuff - no need to document
/* /*
Qt::Orientations expandingDirections() const; Qt::Orientations expandingDirections() const;

View File

@ -174,6 +174,7 @@ public:
QIcon icon; QIcon icon;
ButtonState state; ButtonState state;
Qt::Orientation orientation; Qt::Orientation orientation;
Qt::Alignment alignment;
bool calculateSizeRequested; bool calculateSizeRequested;
QList<IconAction*> cornerActions; QList<IconAction*> cornerActions;