Warning, /education/kstars/kstars/data/qml/whatisinteresting/ScrollBar.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-License-Identifier: GPL-2.0-or-later 0003 */ 0004 0005 /** This qml code implements a vertical scrollbar which shall be displayed in listview of sky-objects. 0006 * This piece of code is based on this example code: 0007 * https://projects.forum.nokia.com/qmluiexamples/browser/qml/qmluiexamples/Scrollable/ScrollBar.qml 0008 */ 0009 0010 import QtQuick 1.0 0011 0012 Rectangle { 0013 // The flickable to which the scrollbar is attached to, must be set 0014 property variant flickable 0015 0016 // If set to false, scrollbar is visible even when not scrolling 0017 property bool hideScrollBarsWhenStopped: true 0018 0019 // Thickness of the scrollbar, in pixels 0020 property int scrollbarWidth: 10 0021 0022 color: "gray" 0023 radius: width/2 0024 0025 function sbOpacity() 0026 { 0027 if (!hideScrollBarsWhenStopped || height < parent.height) 0028 { 0029 return 0.5; 0030 } 0031 0032 return (flickable.flicking || flickable.moving) ? (height >= parent.height ? 0 : 0.5) : 0; 0033 } 0034 0035 // Scrollbar appears automatically when content is bigger than the Flickable 0036 opacity: sbOpacity() 0037 0038 width: scrollbarWidth 0039 height: flickable.visibleArea.heightRatio * parent.height 0040 x: parent.width - width 0041 y: flickable.visibleArea.yPosition * parent.height 0042 0043 // Animate scrollbar appearing/disappearing 0044 Behavior on opacity { NumberAnimation { duration: 200 }} 0045 }