use different focus and hover for horizontal and vertical sliders

svn path=/trunk/KDE/kdelibs/; revision=1055167
This commit is contained in:
Marco Martin 2009-11-27 13:42:00 +00:00
parent 3c84247ae6
commit 6d38a2a3b6
4 changed files with 15 additions and 2 deletions

View File

@ -64,6 +64,11 @@ void FocusIndicator::setCustomGeometry(const QRectF &geometry)
syncGeometry();
}
void FocusIndicator::setCustomPrefix(const QString &prefix)
{
m_customPrefix = prefix;
}
bool FocusIndicator::eventFilter(QObject *watched, QEvent *event)
{
if (static_cast<QGraphicsWidget *>(watched) != m_parent) {
@ -72,7 +77,7 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event)
if (!m_parent->hasFocus() && event->type() == QEvent::GraphicsSceneHoverEnter) {
m_background->setElementPrefix("hover");
m_prefix = "hover";
m_prefix = m_customPrefix + "hover";
m_fade->setProperty("startOpacity", 0.0);
m_fade->setProperty("targetOpacity", 1.0);
m_fade->start();
@ -84,7 +89,7 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event)
syncGeometry();
} else if (event->type() == QEvent::FocusIn) {
m_background->setElementPrefix("focus");
m_prefix = "focus";
m_prefix = m_customPrefix + "focus";
m_fade->setProperty("startOpacity", 0.0);
m_fade->setProperty("targetOpacity", 1.0);
m_fade->start();

View File

@ -37,6 +37,7 @@ public:
~FocusIndicator();
void setCustomGeometry(const QRectF &geometry);
void setCustomPrefix(const QString &prefix);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
@ -53,6 +54,7 @@ private:
AbstractAnimation *m_fade;
QRectF m_customGeometry;
QString m_prefix;
QString m_customPrefix;
};
}
#endif

View File

@ -1066,6 +1066,7 @@ void IconWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
Plasma::PaintUtils::drawHalo(painter, rect);
}
}
d->drawTextItems(painter, option, labelLayout, infoLayout);
}

View File

@ -157,6 +157,11 @@ void Slider::paint(QPainter *painter,
QRect elementRect = d->background->elementRect(handle).toRect();
elementRect.moveCenter(handleRect.center());
if (orientation() == Qt::Vertical) {
d->focusIndicator->setCustomPrefix("vertical-slider");
} else {
d->focusIndicator->setCustomPrefix("horizontal-slider");
}
d->focusIndicator->setCustomGeometry(elementRect);
d->background->paint(painter, elementRect, handle);