Added Alignment and Pen options and getters/setters.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=692757
This commit is contained in:
parent
28b20a150a
commit
ff936c2a57
@ -11,12 +11,16 @@ class Label::Private
|
|||||||
Private() {}
|
Private() {}
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
|
Qt::Alignment alignment;
|
||||||
|
QPen textPen;
|
||||||
};
|
};
|
||||||
|
|
||||||
Label::Label(Widget *parent)
|
Label::Label(Widget *parent)
|
||||||
: Widget(parent),
|
: Widget(parent),
|
||||||
d(new Private)
|
d(new Private)
|
||||||
{
|
{
|
||||||
|
setAlignment(Qt::AlignHCenter);
|
||||||
|
setPen(QPen(Qt::black, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
Label::~Label()
|
Label::~Label()
|
||||||
@ -55,14 +59,33 @@ QString Label::text() const
|
|||||||
return d->text;
|
return d->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Label::setAlignment(Qt::Alignment align)
|
||||||
|
{
|
||||||
|
d->alignment = align;
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::Alignment Label::alignment() const
|
||||||
|
{
|
||||||
|
return d->alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::setPen(const QPen& pen)
|
||||||
|
{
|
||||||
|
d->textPen = pen;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPen Label::pen() const
|
||||||
|
{
|
||||||
|
return d->textPen;
|
||||||
|
}
|
||||||
|
|
||||||
void Label::paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void Label::paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
/* TODO: Add config parameters, like text color, text alignment, and brush. */
|
p->setPen(d->textPen);
|
||||||
p->setPen(QPen(Qt::black, 1));
|
p->drawText(localGeometry(), d->alignment | Qt::TextWordWrap, d->text);
|
||||||
p->drawText(localGeometry(), Qt::AlignCenter | Qt::TextWordWrap, d->text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,26 @@ class PLASMA_EXPORT Label : public Plasma::Widget
|
|||||||
*/
|
*/
|
||||||
QString text() const;
|
QString text() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the alignment of the displayed text.
|
||||||
|
*/
|
||||||
|
void setAlignment(Qt::Alignment align);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the alignment of the displayed text.
|
||||||
|
*/
|
||||||
|
Qt::Alignment alignment() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the pen used to paint the text.
|
||||||
|
*/
|
||||||
|
void setPen(const QPen& pen);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the pen used to paint the text.
|
||||||
|
*/
|
||||||
|
QPen pen() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paint function.
|
* Paint function.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user