Warning, /graphics/kphotoalbum/AndroidRemoteControl/qml/ScrollBar.qml is written in an unsupported language. File is not indexed.
0001 /* SPDX-FileCopyrightText: 2014 Jesper K. Pedersen <blackie@kde.org> 0002 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 // Code based on http://stackoverflow.com/questions/17833103/how-to-create-scrollbar-in-qtquick-2-0 0007 import QtQuick 2.0; 0008 0009 Item { 0010 id: scrollbar; 0011 width: (handleSize + 2 * (backScrollbar.border.width +1)); 0012 visible: (flickable.visibleArea.heightRatio < 1.0); 0013 anchors { 0014 top: flickable.top; 0015 right: flickable.right; 0016 bottom: flickable.bottom; 0017 margins: 1; 0018 } 0019 0020 property Flickable flickable : null; 0021 property int handleSize : 20; 0022 0023 function scrollDown () { 0024 flickable.contentY = Math.min (flickable.contentY + (flickable.height / 4), flickable.contentHeight - flickable.height); 0025 } 0026 function scrollUp () { 0027 flickable.contentY = Math.max (flickable.contentY - (flickable.height / 4), 0); 0028 } 0029 0030 Binding { 0031 target: handle; 0032 property: "y"; 0033 value: (flickable.contentY * clicker.drag.maximumY / (flickable.contentHeight - flickable.height)); 0034 when: (!clicker.drag.active); 0035 } 0036 Binding { 0037 target: flickable; 0038 property: "contentY"; 0039 value: (handle.y * (flickable.contentHeight - flickable.height) / clicker.drag.maximumY); 0040 when: (clicker.drag.active || clicker.pressed); 0041 } 0042 Rectangle { 0043 id: backScrollbar; 0044 radius: 2; 0045 antialiasing: true; 0046 color: Qt.rgba(0.5, 0.5, 0.5, 0.85); 0047 border { 0048 width: 1; 0049 color: "darkgray"; 0050 } 0051 anchors { fill: parent; } 0052 0053 MouseArea { 0054 anchors.fill: parent; 0055 onClicked: { } 0056 } 0057 } 0058 MouseArea { 0059 id: btnUp; 0060 height: width; 0061 anchors { 0062 top: parent.top; 0063 left: parent.left; 0064 right: parent.right; 0065 margins: (backScrollbar.border.width +1); 0066 } 0067 onClicked: { scrollUp (); } 0068 0069 Text { 0070 text: "V"; 0071 color: (btnUp.pressed ? "blue" : "black"); 0072 rotation: -180; 0073 anchors.centerIn: parent; 0074 } 0075 } 0076 MouseArea { 0077 id: btnDown; 0078 height: width; 0079 anchors { 0080 left: parent.left; 0081 right: parent.right; 0082 bottom: parent.bottom; 0083 margins: (backScrollbar.border.width +1); 0084 } 0085 onClicked: { scrollDown (); } 0086 0087 Text { 0088 text: "V"; 0089 color: (btnDown.pressed ? "blue" : "black"); 0090 anchors.centerIn: parent; 0091 } 0092 } 0093 Item { 0094 id: groove; 0095 clip: true; 0096 anchors { 0097 fill: parent; 0098 topMargin: (backScrollbar.border.width +1 + btnUp.height +1); 0099 leftMargin: (backScrollbar.border.width +1); 0100 rightMargin: (backScrollbar.border.width +1); 0101 bottomMargin: (backScrollbar.border.width +1 + btnDown.height +1); 0102 } 0103 0104 MouseArea { 0105 id: clicker; 0106 drag { 0107 target: handle; 0108 minimumY: 0; 0109 maximumY: (groove.height - handle.height); 0110 axis: Drag.YAxis; 0111 } 0112 anchors { fill: parent; } 0113 onClicked: { flickable.contentY = (mouse.y / groove.height * (flickable.contentHeight - flickable.height)); } 0114 } 0115 Item { 0116 id: handle; 0117 height: Math.max (20, (flickable.visibleArea.heightRatio * groove.height)); 0118 anchors { 0119 left: parent.left; 0120 right: parent.right; 0121 } 0122 0123 Rectangle { 0124 id: backHandle; 0125 color: (clicker.pressed ? "blue" : "black"); 0126 opacity: (flickable.moving ? 0.65 : 0.35); 0127 anchors { fill: parent; } 0128 0129 Behavior on opacity { NumberAnimation { duration: 150; } } 0130 } 0131 } 0132 } 0133 }