use the plasma font...
unless someone called QGraphicsWidget::setFont() svn path=/trunk/KDE/kdelibs/; revision=1022790
This commit is contained in:
parent
6e412aedd9
commit
a827d621f8
@ -49,7 +49,8 @@ public:
|
|||||||
background(0),
|
background(0),
|
||||||
animId(-1),
|
animId(-1),
|
||||||
fadeIn(false),
|
fadeIn(false),
|
||||||
svg(0)
|
svg(0),
|
||||||
|
customFont(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,6 +111,7 @@ public:
|
|||||||
QString absImagePath;
|
QString absImagePath;
|
||||||
Svg *svg;
|
Svg *svg;
|
||||||
QString svgElement;
|
QString svgElement;
|
||||||
|
bool customFont;
|
||||||
};
|
};
|
||||||
|
|
||||||
void PushButtonPrivate::syncActiveRect()
|
void PushButtonPrivate::syncActiveRect()
|
||||||
@ -382,8 +384,15 @@ void PushButton::paint(QPainter *painter,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QFont widgetFont;
|
||||||
|
if (d->customFont) {
|
||||||
|
widgetFont = Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont);
|
||||||
|
} else {
|
||||||
|
widgetFont = font();
|
||||||
|
}
|
||||||
|
|
||||||
//if there is not enough room for the text make it to fade out
|
//if there is not enough room for the text make it to fade out
|
||||||
QFontMetricsF fm(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
|
QFontMetricsF fm(widgetFont);
|
||||||
if (rect.width() < fm.width(nativeWidget()->text())) {
|
if (rect.width() < fm.width(nativeWidget()->text())) {
|
||||||
if (bufferPixmap.isNull()) {
|
if (bufferPixmap.isNull()) {
|
||||||
bufferPixmap = QPixmap(rect.size().toSize());
|
bufferPixmap = QPixmap(rect.size().toSize());
|
||||||
@ -392,7 +401,7 @@ void PushButton::paint(QPainter *painter,
|
|||||||
|
|
||||||
QPainter p(&bufferPixmap);
|
QPainter p(&bufferPixmap);
|
||||||
p.setPen(painter->pen());
|
p.setPen(painter->pen());
|
||||||
p.setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
|
p.setFont(widgetFont);
|
||||||
|
|
||||||
// Create the alpha gradient for the fade out effect
|
// Create the alpha gradient for the fade out effect
|
||||||
QLinearGradient alphaGradient(0, 0, 1, 0);
|
QLinearGradient alphaGradient(0, 0, 1, 0);
|
||||||
@ -414,7 +423,7 @@ void PushButton::paint(QPainter *painter,
|
|||||||
|
|
||||||
painter->drawPixmap(rect.topLeft(), bufferPixmap);
|
painter->drawPixmap(rect.topLeft(), bufferPixmap);
|
||||||
} else {
|
} else {
|
||||||
painter->setFont(Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont));
|
painter->setFont(widgetFont);
|
||||||
painter->drawText(rect, Qt::AlignCenter, nativeWidget()->text());
|
painter->drawText(rect, Qt::AlignCenter, nativeWidget()->text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -439,6 +448,13 @@ void PushButton::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
QGraphicsProxyWidget::hoverEnterEvent(event);
|
QGraphicsProxyWidget::hoverEnterEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PushButton::changeEvent(QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::FontChange) {
|
||||||
|
d->customFont = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PushButton::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
void PushButton::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
if (nativeWidget()->isDown()) {
|
if (nativeWidget()->isDown()) {
|
||||||
|
@ -167,6 +167,7 @@ protected:
|
|||||||
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
void changeEvent(QEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PushButtonPrivate *const d;
|
PushButtonPrivate *const d;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user