Warning, /education/gcompris/src/activities/share/WidgetOption.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - WidgetOption.qml 0002 * 0003 * SPDX-FileCopyrightText: 2016 Stefan Toncu <stefan.toncu29@gmail.com> 0004 * 0005 * SPDX-License-Identifier: GPL-3.0-or-later 0006 */ 0007 0008 import QtQuick 2.12 0009 import GCompris 1.0 0010 0011 import "../../core" 0012 0013 Rectangle { 0014 id: widget 0015 0016 width: element.opacity > 0 ? items.cellSize * 1.5 : 0 0017 height: width 0018 color: "transparent" 0019 0020 //initial position of the element 0021 //(these vars are assigned to element after release of click mouse) 0022 property int lastX 0023 property int lastY 0024 property string src 0025 property int current: 0 0026 property int total: 0 0027 property string name 0028 property bool canDrag: true 0029 property alias element: element 0030 0031 property string availableItems 0032 0033 // callback defined in each widget called when we release the element in background 0034 property var releaseElement: null 0035 0036 Image { 0037 id: element 0038 fillMode: Image.PreserveAspectFit 0039 width: items.cellSize 0040 sourceSize.width: width 0041 source: widget.src 0042 mipmap: true 0043 } 0044 //number of available items 0045 GCText { 0046 id: elementText 0047 anchors.left: element.right 0048 anchors.bottom: element.bottom 0049 text: availableItems 0050 color: "#f2f2f2" 0051 } 0052 0053 property alias dragAreaElement: dragAreaElement 0054 0055 MouseArea { 0056 id: dragAreaElement 0057 anchors.fill: parent 0058 drag.target: (widget.canDrag) ? element : null 0059 enabled: element.opacity > 0 && !items.buttonsBlocked 0060 onPressed: { 0061 instruction.hide() 0062 if (widget.name !== "candy") 0063 background.resetCandy() 0064 //set the initial position 0065 widget.lastX = element.x 0066 widget.lastY = element.y 0067 } 0068 0069 onReleased: { 0070 widget.releaseElement() 0071 //set the widget to its initial coordinates 0072 element.x = widget.lastX 0073 element.y = widget.lastY 0074 } 0075 } 0076 }