24#include <QStyleOptionSpinBox>
25#include <QGraphicsView>
32#include "private/focusindicator_p.h"
33#include "private/style_p.h"
34#include "private/themedwidgetinterface_p.h"
40class 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();
99void SpinBox::setMaximum(
int max)
101 static_cast<KIntSpinBox*
>(widget())->
setMaximum(max);
104int SpinBox::maximum()
const
106 return static_cast<KIntSpinBox*
>(widget())->
maximum();
109void SpinBox::setMinimum(
int min)
111 static_cast<KIntSpinBox*
>(widget())->
setMinimum(min);
114int SpinBox::minimum()
const
116 return static_cast<KIntSpinBox*
>(widget())->
minimum();
119void SpinBox::setRange(
int min,
int max)
121 static_cast<KIntSpinBox*
>(widget())->
setRange(min, max);
124void SpinBox::setValue(
int value)
129int SpinBox::value()
const
131 return static_cast<KIntSpinBox*
>(widget())->
value();
134void SpinBox::setStyleSheet(
const QString &stylesheet)
136 widget()->setStyleSheet(stylesheet);
139QString SpinBox::styleSheet()
141 return widget()->styleSheet();
144KIntSpinBox *SpinBox::nativeWidget()
const
146 return static_cast<KIntSpinBox*
>(widget());
149void SpinBox::changeEvent(QEvent *event)
151 d->changeEvent(event);
152 QGraphicsProxyWidget::changeEvent(event);
155void SpinBox::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
161void SpinBox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
167void SpinBox::resizeEvent(QGraphicsSceneResizeEvent *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);
187void SpinBox::mousePressEvent(QGraphicsSceneMouseEvent *event)
192 while (!applet && widget) {
193 widget = widget->parentWidget();
194 applet = qobject_cast<Plasma::Applet *>(widget);
200 QGraphicsProxyWidget::mousePressEvent(event);
203void SpinBox::focusOutEvent(QFocusEvent *event)
208 while (!applet && widget) {
209 widget = widget->parentWidget();
210 applet = qobject_cast<Plasma::Applet *>(widget);
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 setStatus(const ItemStatus stat)
sets the status for this applet
Provides an SVG with borders.
void setMinimum(int minimum)
Sets the minimum value the slider can take.
KIntSpinBox * nativeWidget
void setMaximum(int maximum)
Sets the maximum value the slider can take.
void setValue(int value)
Sets the value of the slider.
void setRange(int minimum, int maximum)
Sets the minimum and maximum values the slider can take.
void valueChanged(int value)
This signal is emitted when the slider value has changed, with the new slider value as argument.
QGraphicsWidget * parentWidget
void editingFinished()
This signal is emitted when editing is finished.
Namespace for everything in libplasma.
@ AcceptingInputStatus
The Item is accepting input.
@ UnknownStatus
The status is unknown.