Plasma
Go to the documentation of this file.
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);
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();
194 applet = qobject_cast<Plasma::Applet *>(widget);
200 QGraphicsProxyWidget::mousePressEvent(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>
Namespace for everything in libplasma.
void setRange(int minimum, int maximum)
Sets the minimum and maximum values the slider can take.
SpinBox(QGraphicsWidget *parent=0)
void setMaximum(int maximum)
Sets the maximum value the slider can take.
void focusOutEvent(QFocusEvent *event)
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
void setValue(int value)
Sets the value of the slider.
void setStyleSheet(const QString &stylesheet)
Sets the stylesheet used to control the visual display of this SpinBox.
void changeEvent(QEvent *event)
void setMinimum(int minimum)
Sets the minimum value 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.
void editingFinished()
This signal is emitted when editing is finished.
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void resizeEvent(QGraphicsSceneResizeEvent *event)
void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
QGraphicsWidget * parentWidget
void setStatus(const ItemStatus stat)
sets the status for this applet
@ UnknownStatus
The status is unknown.
void mousePressEvent(QGraphicsSceneMouseEvent *event)
@ AcceptingInputStatus
The Item is accepting input.
KIntSpinBox * nativeWidget
Provides an SVG with borders.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Aug 27 2020 00:00:00 by
doxygen 1.8.20 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.