From a70c17bc59dd017b28953dcedfd55c08622fa5c9 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 8 Nov 2011 12:57:46 +0100 Subject: [PATCH] fix drawing of focusindicator of spinbox and combobox use the proper prefix for drawing the combobox focusindicator --- private/focusindicator.cpp | 12 ++++++++++++ private/focusindicator_p.h | 3 +++ widgets/combobox.cpp | 10 +++++++++- widgets/spinbox.cpp | 3 +++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/private/focusindicator.cpp b/private/focusindicator.cpp index f24217e05..1d0744fdd 100644 --- a/private/focusindicator.cpp +++ b/private/focusindicator.cpp @@ -304,6 +304,18 @@ void FocusIndicator::syncGeometry() } } +void FocusIndicator::setFrameSvg(FrameSvg *frameSvg) +{ + if (m_background != frameSvg) { + m_background = frameSvg; + } +} + +FrameSvg *FocusIndicator::frameSvg() const +{ + return m_background; +} + } #include diff --git a/private/focusindicator_p.h b/private/focusindicator_p.h index 9ac9e12aa..12a81d088 100644 --- a/private/focusindicator_p.h +++ b/private/focusindicator_p.h @@ -43,6 +43,9 @@ public: void animateVisibility(const bool visible); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + void setFrameSvg(FrameSvg *svg); + FrameSvg *frameSvg() const; + protected: bool eventFilter(QObject *watched, QEvent *event); void resizeEvent(QGraphicsSceneResizeEvent *event); diff --git a/widgets/combobox.cpp b/widgets/combobox.cpp index 0de46d03e..48a492346 100644 --- a/widgets/combobox.cpp +++ b/widgets/combobox.cpp @@ -56,6 +56,7 @@ public: FrameSvg *background; FrameSvg *lineEditBackground; + FocusIndicator *focusIndicator; int animId; qreal opacity; QRectF activeRect; @@ -99,6 +100,13 @@ void ComboBoxPrivate::syncBorders() q->setFont(Theme::defaultTheme()->font(Theme::DefaultFont)); customFont = false; } + + if (q->nativeWidget()->isEditable()) { + focusIndicator->setFrameSvg(lineEditBackground); + } else { + focusIndicator->setFrameSvg(background); + } + focusIndicator->setFlag(QGraphicsItem::ItemStacksBehindParent, !q->nativeWidget()->isEditable() || !lineEditBackground->hasElement("hint-focus-over-base")); } @@ -119,7 +127,7 @@ ComboBox::ComboBox(QGraphicsWidget *parent) d->style = Style::sharedStyle(); - new FocusIndicator(this, d->background); + d->focusIndicator = new FocusIndicator(this, d->background); setNativeWidget(new KComboBox); connect(d->background, SIGNAL(repaintNeeded()), SLOT(syncBorders())); d->initTheming(); diff --git a/widgets/spinbox.cpp b/widgets/spinbox.cpp index d76f7c459..bacdabdca 100644 --- a/widgets/spinbox.cpp +++ b/widgets/spinbox.cpp @@ -76,6 +76,9 @@ SpinBox::SpinBox(QGraphicsWidget *parent) d->background->setImagePath("widgets/lineedit"); d->background->setCacheAllRenderedFrames(true); + if (d->background->hasElement("hint-focus-over-base")) { + d->focusIndicator->setFlag(QGraphicsItem::ItemStacksBehindParent, false); + } d->style = Plasma::Style::sharedStyle(); native->setStyle(d->style.data());