24 #include <QStyleOptionSpinBox> 25 #include <QGraphicsView> 27 #include <kmimetype.h> 28 #include <knuminput.h> 32 #include "private/focusindicator_p.h" 33 #include "private/style_p.h" 34 #include "private/themedwidgetinterface_p.h" 40 class SpinBoxPrivate :
public ThemedWidgetInterface<SpinBox>
43 SpinBoxPrivate(SpinBox *spinBox)
44 : ThemedWidgetInterface<SpinBox>(spinBox),
47 buttonColorForText =
true;
54 Plasma::Style::Ptr style;
56 FocusIndicator *focusIndicator;
61 d(new SpinBoxPrivate(this))
63 KIntSpinBox *native =
new KIntSpinBox;
68 d->focusIndicator =
new FocusIndicator(
this,
"widgets/lineedit");
71 native->setWindowIcon(QIcon());
72 native->setAttribute(Qt::WA_NoSystemBackground);
73 native->setAutoFillBackground(
false);
76 d->background->setImagePath(
"widgets/lineedit");
77 d->background->setCacheAllRenderedFrames(
true);
79 if (d->background->hasElement(
"hint-focus-over-base")) {
80 d->focusIndicator->setFlag(QGraphicsItem::ItemStacksBehindParent,
false);
83 d->style = Plasma::Style::sharedStyle();
84 native->setStyle(d->style.data());
87 QStyleOptionSpinBox spinOpt;
89 QRect controlrect =
nativeWidget()->style()->subControlRect(QStyle::CC_SpinBox, &spinOpt, QStyle::SC_SpinBoxFrame,
nativeWidget());
90 d->focusIndicator->setCustomGeometry(controlrect);
96 Plasma::Style::doneWithSharedStyle();
101 static_cast<KIntSpinBox*
>(widget())->
setMaximum(max);
106 return static_cast<KIntSpinBox*
>(widget())->
maximum();
111 static_cast<KIntSpinBox*
>(widget())->
setMinimum(min);
116 return static_cast<KIntSpinBox*
>(widget())->
minimum();
121 static_cast<KIntSpinBox*
>(widget())->
setRange(min, max);
126 static_cast<KIntSpinBox*
>(widget())->
setValue(value);
131 return static_cast<KIntSpinBox*
>(widget())->
value();
136 widget()->setStyleSheet(stylesheet);
141 return widget()->styleSheet();
146 return static_cast<KIntSpinBox*
>(widget());
151 d->changeEvent(event);
152 QGraphicsProxyWidget::changeEvent(event);
169 QGraphicsProxyWidget::resizeEvent(event);
170 QStyleOptionSpinBox spinOpt;
172 QRect controlrect =
nativeWidget()->style()->subControlRect(QStyle::CC_SpinBox, &spinOpt, QStyle::SC_SpinBoxFrame,
nativeWidget());
174 if (d->focusIndicator) {
175 d->focusIndicator->setCustomGeometry(controlrect);
184 QGraphicsProxyWidget::paint(painter, option, widget);
192 while (!applet && widget) {
193 widget = widget->parentWidget();
200 QGraphicsProxyWidget::mousePressEvent(event);
208 while (!applet && widget) {
209 widget = widget->parentWidget();
217 QEvent closeEvent(QEvent::CloseSoftwareInputPanel);
219 if (
QGraphicsView *view = qobject_cast<QGraphicsView*>(qApp->focusWidget())) {
220 if (view->scene() && view->scene() == scene()) {
221 QApplication::sendEvent(view, &closeEvent);
226 QGraphicsProxyWidget::focusOutEvent(event);
231 #include <spinbox.moc> void resizeEvent(QGraphicsSceneResizeEvent *event)
void setStyleSheet(const QString &stylesheet)
Sets the stylesheet used to control the visual display of this SpinBox.
void changeEvent(QEvent *event)
void focusOutEvent(QFocusEvent *event)
Provides an SVG with borders.
Namespace for everything in libplasma.
void setMaximum(int maximum)
Sets the maximum value the slider can take.
QGraphicsWidget parentWidget
void setRange(int minimum, int maximum)
Sets the minimum and maximum values the slider can take.
void editingFinished()
This signal is emitted when editing is finished.
void setStatus(const ItemStatus stat)
sets the status for this applet
void setValue(int value)
Sets the value of the slider.
void mousePressEvent(QGraphicsSceneMouseEvent *event)
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
KIntSpinBox * nativeWidget() const
void setMinimum(int minimum)
Sets the minimum value the slider can take.
SpinBox(QGraphicsWidget *parent=0)
void valueChanged(int value)
This signal is emitted when the slider value has changed, with the new slider value as argument...
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
The Item is accepting input.