icon support
svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=639602
This commit is contained in:
parent
dcdcafe4df
commit
bfe37da902
@ -37,6 +37,9 @@ class PushButton::Private
|
|||||||
QString labelText;
|
QString labelText;
|
||||||
QString labelIcon;
|
QString labelIcon;
|
||||||
QColor labelTextColor;
|
QColor labelTextColor;
|
||||||
|
QIcon icon;
|
||||||
|
QSize iconSize;
|
||||||
|
bool hasIcon;
|
||||||
int labelTextOpacity;
|
int labelTextOpacity;
|
||||||
int height;
|
int height;
|
||||||
int width;
|
int width;
|
||||||
@ -61,6 +64,8 @@ PushButton::PushButton(QGraphicsItem *parent)
|
|||||||
d->state= PushButton::NONE;
|
d->state= PushButton::NONE;
|
||||||
d->labelText=tr("Plasma");
|
d->labelText=tr("Plasma");
|
||||||
d->labelTextColor= QColor(201,201,255);
|
d->labelTextColor= QColor(201,201,255);
|
||||||
|
d->hasIcon = false;
|
||||||
|
d->iconSize=QSize(32,32);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +86,11 @@ void PushButton::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
|||||||
options.state = option->state;
|
options.state = option->state;
|
||||||
options.rect = boundingRect().toRect();
|
options.rect = boundingRect().toRect();
|
||||||
options.text = text();
|
options.text = text();
|
||||||
|
if (d->hasIcon){
|
||||||
|
options.icon= d->icon;
|
||||||
|
options.iconSize = d->iconSize;
|
||||||
|
}
|
||||||
|
|
||||||
widget->style()->drawPrimitive(QStyle::PE_PanelButtonCommand, &options, painter, widget);
|
widget->style()->drawPrimitive(QStyle::PE_PanelButtonCommand, &options, painter, widget);
|
||||||
widget->style()->drawPrimitive(QStyle::PE_FrameFocusRect, &options, painter, widget);
|
widget->style()->drawPrimitive(QStyle::PE_FrameFocusRect, &options, painter, widget);
|
||||||
widget-> style()->drawControl(QStyle::CE_PushButton, &options, painter, widget);
|
widget-> style()->drawControl(QStyle::CE_PushButton, &options, painter, widget);
|
||||||
@ -136,6 +145,17 @@ void PushButton::setWidth(int w)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PushButton::setIcon(const QString& path)
|
||||||
|
{
|
||||||
|
QPixmap _iconPixmap (path);
|
||||||
|
if (!path.isNull()) {
|
||||||
|
d->icon = QIcon(_iconPixmap);
|
||||||
|
d->iconSize = _iconPixmap.size();
|
||||||
|
d->hasIcon=true;
|
||||||
|
}else {
|
||||||
|
d->hasIcon = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
QSize PushButton::size()
|
QSize PushButton::size()
|
||||||
{
|
{
|
||||||
return QSize(d->width,d->height);
|
return QSize(d->width,d->height);
|
||||||
|
@ -47,12 +47,13 @@ class KDE_EXPORT PushButton : public DataVisualization,public QGraphicsItem
|
|||||||
void setText(const QString&) ;
|
void setText(const QString&) ;
|
||||||
QString text();
|
QString text();
|
||||||
QSize size();
|
QSize size();
|
||||||
|
int height();
|
||||||
|
int width();
|
||||||
|
void setIcon(const QString& path);
|
||||||
void setSize(QSize size);
|
void setSize(QSize size);
|
||||||
void setWidth(int width);
|
void setWidth(int width);
|
||||||
void setHeight(int height);
|
void setHeight(int height);
|
||||||
void setMaximumWidth(int maxwidth);
|
void setMaximumWidth(int maxwidth);
|
||||||
int width();
|
|
||||||
int height();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void data(const DataSource::Data&);
|
void data(const DataSource::Data&);
|
||||||
|
Loading…
Reference in New Issue
Block a user