• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

Plasma

  • plasma
  • widgets
scrollbar.cpp
Go to the documentation of this file.
1/*
2 * Copyright © 2008 Fredrik Höglund <fredrik@kde.org>
3 * Copyright © 2008 Marco Martin <notmart@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Library General Public License as
7 * published by the Free Software Foundation; either version 2, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#include "scrollbar.h"
22
23#include <QApplication>
24#include <QContextMenuEvent>
25#include <QGraphicsSceneContextMenuEvent>
26
27#include <plasma/private/style_p.h>
28
29namespace Plasma
30{
31
32class ScrollBarPrivate
33{
34public:
35 Plasma::Style::Ptr style;
36};
37
38ScrollBar::ScrollBar(QGraphicsWidget *parent)
39 : QGraphicsProxyWidget(parent),
40 d(new ScrollBarPrivate)
41{
42 QScrollBar *scrollbar = new QScrollBar();
43 scrollbar->setWindowFlags(scrollbar->windowFlags()|Qt::BypassGraphicsProxyWidget);
44 scrollbar->setAttribute(Qt::WA_NoSystemBackground);
45 setWidget(scrollbar);
46 scrollbar->setWindowIcon(QIcon());
47 d->style = Plasma::Style::sharedStyle();
48 scrollbar->setStyle(d->style.data());
49
50 scrollbar->resize(scrollbar->sizeHint());
51 connect(scrollbar, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int)));
52 connect(scrollbar, SIGNAL(sliderMoved(int)), this, SIGNAL(sliderMoved(int)));
53}
54
55ScrollBar::~ScrollBar()
56{
57 delete d;
58 Plasma::Style::doneWithSharedStyle();
59}
60
61void ScrollBar::setRange(int min, int max)
62{
63 static_cast<QScrollBar*>(widget())->setRange(min, max);
64}
65
66void ScrollBar::setSingleStep(int val)
67{
68 static_cast<QScrollBar*>(widget())->setSingleStep(val);
69}
70
71int ScrollBar::singleStep()
72{
73 return static_cast<QScrollBar*>(widget())->singleStep();
74}
75
76void ScrollBar::setPageStep(int val)
77{
78 static_cast<QScrollBar*>(widget())->setPageStep(val);
79}
80
81int ScrollBar::pageStep()
82{
83 return static_cast<QScrollBar*>(widget())->pageStep();
84}
85
86void ScrollBar::setValue(int val)
87{
88 static_cast<QScrollBar*>(widget())->setValue(val);
89}
90
91int ScrollBar::value() const
92{
93 return static_cast<QScrollBar*>(widget())->value();
94}
95
96int ScrollBar::minimum() const
97{
98 return static_cast<QScrollBar*>(widget())->minimum();
99}
100
101int ScrollBar::maximum() const
102{
103 return static_cast<QScrollBar*>(widget())->maximum();
104}
105
106void ScrollBar::setMinimum(const int min) const
107{
108 static_cast<QScrollBar*>(widget())->setMinimum(min);
109}
110
111void ScrollBar::setMaximum(const int max) const
112{
113 static_cast<QScrollBar*>(widget())->setMaximum(max);
114}
115
116void ScrollBar::setStyleSheet(const QString &stylesheet)
117{
118 widget()->setStyleSheet(stylesheet);
119}
120
121QString ScrollBar::styleSheet()
122{
123 return widget()->styleSheet();
124}
125
126QScrollBar *ScrollBar::nativeWidget() const
127{
128 return static_cast<QScrollBar *>(widget());
129}
130
131Qt::Orientation ScrollBar::orientation() const
132{
133 return nativeWidget()->orientation();
134}
135
136void ScrollBar::setOrientation(Qt::Orientation orientation)
137{
138 QScrollBar *native = static_cast<QScrollBar *>(widget());
139 native->setOrientation(orientation);
140 resize(native->sizeHint());
141}
142
143void ScrollBar::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
144{
145 QContextMenuEvent contextMenuEvent(QContextMenuEvent::Reason(event->reason()),
146 event->pos().toPoint(), event->screenPos(), event->modifiers());
147 QApplication::sendEvent(nativeWidget(), &contextMenuEvent);
148}
149
150}
151
152#include <scrollbar.moc>
Plasma::ScrollBar::setSingleStep
void setSingleStep(int val)
Sets the amount of the single step i.e how much the slider will move when the user press an arrow but...
Definition: scrollbar.cpp:66
Plasma::ScrollBar::valueChanged
void valueChanged(int value)
Emitted when the value of the slider changes.
Plasma::ScrollBar::maximum
int maximum() const
Definition: scrollbar.cpp:101
Plasma::ScrollBar::setMinimum
void setMinimum(const int min) const
Definition: scrollbar.cpp:106
Plasma::ScrollBar::setValue
void setValue(int val)
Sets the current value for the ScrollBar.
Definition: scrollbar.cpp:86
Plasma::ScrollBar::singleStep
int singleStep
Definition: scrollbar.h:43
Plasma::ScrollBar::orientation
Qt::Orientation orientation
Definition: scrollbar.h:50
Plasma::ScrollBar::minimum
int minimum() const
Definition: scrollbar.cpp:96
Plasma::ScrollBar::contextMenuEvent
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
Definition: scrollbar.cpp:143
Plasma::ScrollBar::setPageStep
void setPageStep(int val)
Sets the amount the slider will scroll when the user press page up or page down.
Definition: scrollbar.cpp:76
Plasma::ScrollBar::sliderMoved
void sliderMoved(int value)
Emitted when the slider has been moved by the user.
Plasma::ScrollBar::value
int value() const
Definition: scrollbar.cpp:91
Plasma::ScrollBar::nativeWidget
QScrollBar * nativeWidget
Definition: scrollbar.h:49
Plasma::ScrollBar::pageStep
int pageStep
Definition: scrollbar.h:44
Plasma::ScrollBar::setRange
void setRange(int min, int max)
Sets the scrollbar minimum and maximum values.
Definition: scrollbar.cpp:61
Plasma::ScrollBar::setMaximum
void setMaximum(const int max) const
Definition: scrollbar.cpp:111
QGraphicsProxyWidget
QGraphicsWidget
Plasma
Namespace for everything in libplasma.
Definition: abstractdialogmanager.cpp:25
scrollbar.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal