Warning, /maui/mauikit/src/controls.5/GalleryRollTemplate.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 2.14 0002 import QtQuick.Controls 2.14 0003 0004 import org.mauikit.controls 1.2 as Maui 0005 import QtGraphicalEffects 1.0 0006 0007 Maui.ShadowedRectangle 0008 { 0009 id: control 0010 color: "#333" 0011 0012 property alias interactive : _featuredRoll.interactive 0013 0014 property alias orientation : _featuredRoll.orientation 0015 0016 /** 0017 * cached 0018 */ 0019 property bool cache : true 0020 0021 0022 /** 0023 * cb : function 0024 */ 0025 property var cb 0026 0027 /** 0028 * images : 0029 */ 0030 property var images : [] 0031 property int radius : 0 0032 0033 property int fillMode: Image.PreserveAspectCrop 0034 property alias running: _featuredTimer.running 0035 0036 property int imageWidth : -1 0037 property int imageHeight : -1 0038 0039 corners 0040 { 0041 topLeftRadius: control.radius 0042 topRightRadius: control.radius 0043 bottomLeftRadius: control.radius 0044 bottomRightRadius: control.radius 0045 } 0046 0047 0048 ListView 0049 { 0050 id: _featuredRoll 0051 anchors.fill: parent 0052 0053 interactive: false 0054 orientation: Qt.Horizontal 0055 snapMode: ListView.SnapOneItem 0056 clip: true 0057 0058 boundsBehavior: Flickable.StopAtBounds 0059 boundsMovement: Flickable.StopAtBounds 0060 0061 0062 model: control.images 0063 0064 Component.onCompleted: _featuredTimer.start() 0065 0066 Timer 0067 { 0068 id: _featuredTimer 0069 interval: randomInteger(6000, 8000) 0070 repeat: true 0071 onTriggered: _featuredRoll.cycleSlideForward() 0072 } 0073 0074 function cycleSlideForward() 0075 { 0076 if(_featuredRoll.dragging) 0077 { 0078 return 0079 } 0080 0081 if (_featuredRoll.currentIndex === _featuredRoll.count - 1) 0082 { 0083 _featuredRoll.currentIndex = 0 0084 } else 0085 { 0086 _featuredRoll.incrementCurrentIndex() 0087 } 0088 _featuredTimer.restart() 0089 } 0090 0091 function cycleSlideBackward() 0092 { 0093 if(_featuredRoll.dragging) 0094 { 0095 return 0096 } 0097 0098 if (_featuredRoll.currentIndex === 0) 0099 { 0100 _featuredRoll.currentIndex = _featuredRoll.count - 1; 0101 } else 0102 { 0103 _featuredRoll.decrementCurrentIndex(); 0104 } 0105 0106 _featuredTimer.restart() 0107 } 0108 0109 delegate: Item 0110 { 0111 width: ListView.view.width 0112 height: ListView.view.height 0113 0114 Image 0115 { 0116 anchors.fill: parent 0117 sourceSize.width: (control.imageWidth > -1 ? control.imageWidth : control.width) * 1.5 0118 sourceSize.height: (control.imageHeight > -1 ? control.imageHeight : control.height) * 1.5 0119 asynchronous: true 0120 smooth: true 0121 cache: control.cache 0122 source: control.cb ? control.cb(modelData) : modelData 0123 fillMode: control.fillMode 0124 } 0125 0126 Behavior on height 0127 { 0128 NumberAnimation 0129 { 0130 duration: Maui.Style.units.shortDuration 0131 easing.type: Easing.InOutQuad 0132 } 0133 } 0134 } 0135 0136 layer.enabled: control.radius 0137 layer.effect: OpacityMask 0138 { 0139 maskSource: Maui.ShadowedRectangle 0140 { 0141 width: control.width 0142 height: control.height 0143 0144 corners 0145 { 0146 topLeftRadius: control.corners.topLeftRadius 0147 topRightRadius: control.corners.topRightRadius 0148 bottomLeftRadius: control.corners.bottomLeftRadius 0149 bottomRightRadius: control.corners.bottomRightRadius 0150 } 0151 } 0152 } 0153 } 0154 0155 0156 function randomInteger(min, max) 0157 { 0158 return Math.floor(Math.random() * (max - min + 1)) + min; 0159 } 0160 }