use the lineedit element
have a glow on mouseover and a stronger one for focus svn path=/trunk/KDE/kdelibs/; revision=1027174
This commit is contained in:
parent
73e61fa25f
commit
e17155505a
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
|
#include "framesvg.h"
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
@ -63,6 +64,7 @@ public:
|
|||||||
|
|
||||||
LineEdit *q;
|
LineEdit *q;
|
||||||
Plasma::Style::Ptr style;
|
Plasma::Style::Ptr style;
|
||||||
|
Plasma::FrameSvg *background;
|
||||||
bool customFont;
|
bool customFont;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -72,6 +74,9 @@ LineEdit::LineEdit(QGraphicsWidget *parent)
|
|||||||
{
|
{
|
||||||
KLineEdit *native = new KLineEdit;
|
KLineEdit *native = new KLineEdit;
|
||||||
d->style = Plasma::Style::sharedStyle();
|
d->style = Plasma::Style::sharedStyle();
|
||||||
|
d->background = new Plasma::FrameSvg(this);
|
||||||
|
d->background->setImagePath("widgets/lineedit");
|
||||||
|
|
||||||
native->setStyle(d->style.data());
|
native->setStyle(d->style.data());
|
||||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||||
setWidget(native);
|
setWidget(native);
|
||||||
@ -126,6 +131,38 @@ KLineEdit *LineEdit::nativeWidget() const
|
|||||||
return static_cast<KLineEdit*>(widget());
|
return static_cast<KLineEdit*>(widget());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LineEdit::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineEdit::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineEdit::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option)
|
||||||
|
Q_UNUSED(widget)
|
||||||
|
|
||||||
|
if (hasFocus() || isUnderMouse()) {
|
||||||
|
if (hasFocus()) {
|
||||||
|
d->background->setElementPrefix("focus");
|
||||||
|
} else {
|
||||||
|
d->background->setElementPrefix("hover");
|
||||||
|
}
|
||||||
|
qreal left, top, right, bottom;
|
||||||
|
d->background->getMargins(left, top, right, bottom);
|
||||||
|
d->background->resizeFrame(size()+QSizeF(left+right, top+bottom));
|
||||||
|
d->background->paintFrame(painter, QPoint(-left, -top));
|
||||||
|
}
|
||||||
|
|
||||||
|
nativeWidget()->render(painter, QPoint(0, 0), QRegion(), QWidget::DrawChildren|QWidget::IgnoreMask);
|
||||||
|
}
|
||||||
|
|
||||||
void LineEdit::changeEvent(QEvent *event)
|
void LineEdit::changeEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::FontChange) {
|
if (event->type() == QEvent::FontChange) {
|
||||||
|
@ -92,7 +92,10 @@ public:
|
|||||||
KLineEdit *nativeWidget() const;
|
KLineEdit *nativeWidget() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void changeEvent(QEvent *event);
|
void changeEvent(QEvent *event);
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void editingFinished();
|
void editingFinished();
|
||||||
|
Loading…
Reference in New Issue
Block a user