diff --git a/widgets/scrollbar.cpp b/widgets/scrollbar.cpp index b1dd0697d..8d9c4600f 100644 --- a/widgets/scrollbar.cpp +++ b/widgets/scrollbar.cpp @@ -31,17 +31,18 @@ public: Plasma::Style *style; }; -ScrollBar::ScrollBar(Qt::Orientation orientation, QGraphicsWidget *parent) - : QGraphicsProxyWidget(parent), - d(new ScrollBarPrivate) +ScrollBar::ScrollBar(QGraphicsWidget *parent) + : QGraphicsProxyWidget(parent), + d(new ScrollBarPrivate) { - QScrollBar *scrollbar = new QScrollBar(orientation); + QScrollBar *scrollbar = new QScrollBar(); scrollbar->setAttribute(Qt::WA_NoSystemBackground); setWidget(scrollbar); d->style = new Plasma::Style(); scrollbar->setStyle(d->style); scrollbar->resize(scrollbar->sizeHint()); + connect(scrollbar, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int))); } ScrollBar::~ScrollBar() @@ -111,6 +112,11 @@ QScrollBar *ScrollBar::nativeWidget() const return static_cast(widget()); } +void ScrollBar::setOrientation(Qt::Orientation orientation) +{ + static_cast(widget())->setOrientation(orientation); +} + } #include diff --git a/widgets/scrollbar.h b/widgets/scrollbar.h index 2c31b3c8a..b7a3a62d4 100644 --- a/widgets/scrollbar.h +++ b/widgets/scrollbar.h @@ -49,7 +49,11 @@ class PLASMA_EXPORT ScrollBar : public QGraphicsProxyWidget Q_PROPERTY(QScrollBar *nativeWidget READ nativeWidget) public: - explicit ScrollBar(Qt::Orientation orientation, QGraphicsWidget *parent); + /** + * Creates a scrollbar; the default orientation is vertical + */ + explicit ScrollBar(QGraphicsWidget *parent); + ~ScrollBar(); /** @@ -82,12 +86,6 @@ public: */ int pageStep(); - /** - * Sets the current value for the ScrollBar - * @arg value must be minimum() <= value <= maximum() - */ - void setValue(int val); - /** * @return the current scrollbar value */ @@ -120,6 +118,24 @@ public: */ QScrollBar *nativeWidget() const; +public Q_SLOTS: + /** + * Sets the current value for the ScrollBar + * @arg value must be minimum() <= value <= maximum() + */ + void setValue(int val); + + /** + * Sets the orientation of the ScrollBar. + */ + void setOrientation(Qt::Orientation orientation); + +Q_SIGNALS: + /** + * Emitted when the value of the slider changes + */ + void valueChanged(int value); + private: ScrollBarPrivate * const d; };