File indexing completed on 2024-04-28 12:30:04
0001 /*************************************************************************** 0002 * Copyright (C) 2017-2018 by Emmanuel Lepage Vallee * 0003 * Author : Emmanuel Lepage Vallee <emmanuel.lepage@kde.org> * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 3 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0017 **************************************************************************/ 0018 #ifndef KQUICKITEMVIEWS_FLICKABLESCROLLBAR_H 0019 #define KQUICKITEMVIEWS_FLICKABLESCROLLBAR_H 0020 0021 // Qt 0022 #include <QQuickItem> 0023 0024 // KQuickItemViews 0025 class FlickableScrollBarPrivate; 0026 0027 /** 0028 * A scrollbar widget designed for the Simpleflickable based views. 0029 * 0030 * In theory it works with the QtQuick2.FlickableView based ones too, but it's 0031 * unsupported. 0032 * 0033 * The idea is to have both a desktop and mobile mode and good support for 0034 * categorized views. The shell is C++, but the widget implementation is 0035 * pure QML. 0036 * 0037 * The idea is that with the categories and everything being known internally 0038 * by the Simpleflickable views, having everything reverse engineered by QML 0039 * widget doesn't scale. It always requires to be fixed to match the internal 0040 * changes. 0041 */ 0042 class Q_DECL_EXPORT FlickableScrollBar : public QQuickItem 0043 { 0044 Q_OBJECT 0045 public: 0046 Q_PROPERTY(QObject* view READ view WRITE setView) 0047 Q_PROPERTY(qreal position READ position WRITE setPosition NOTIFY positionChanged) 0048 Q_PROPERTY(qreal handleHeight READ handleHeight NOTIFY handleHeightChanged) 0049 Q_PROPERTY(bool handleVisible READ isHandleVisible NOTIFY handleHeightChanged) 0050 0051 explicit FlickableScrollBar(QQuickItem* parent = nullptr); 0052 virtual ~FlickableScrollBar(); 0053 0054 QObject* view() const; 0055 void setView(QObject* v); 0056 0057 qreal handleHeight() const; 0058 bool isHandleVisible() const; 0059 0060 qreal position() const; 0061 void setPosition(qreal p); 0062 0063 Q_SIGNALS: 0064 void handleHeightChanged(); 0065 void positionChanged(); 0066 0067 private: 0068 FlickableScrollBarPrivate* d_ptr; 0069 Q_DECLARE_PRIVATE(FlickableScrollBar) 0070 }; 0071 0072 #endif