Warning, /games/knetwalk/src/qml/Cell.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2013 Ashwin Rajeev <ashwin_rajeev@hotmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 import QtQuick 2.3
0008 
0009 Item{
0010     property string sprite
0011     property string type
0012     property int index
0013     property int angle
0014     property bool locked: false
0015 
0016     width: grid.width / grid.columns;
0017     height: width;
0018 
0019     Rectangle {
0020         anchors.fill: parent
0021         color: "black"
0022         opacity: (locked && main.state === "running")? 0.5 : 0
0023     }
0024 
0025     MouseArea {
0026         anchors.fill: parent
0027         enabled: main.state === "running"
0028         acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
0029         hoverEnabled: true
0030         onClicked: mouse => {
0031             main.selected = index
0032             switch (mouse.button) {
0033                 case Qt.LeftButton:
0034                     if (main.reverseButtons) {
0035                         main.rotateClockwise();
0036                     }
0037                     else {
0038                         main.rotateCounterclockwise();
0039                     }
0040                     break;
0041                 case Qt.RightButton:
0042                     if (main.reverseButtons) {
0043                         main.rotateCounterclockwise();
0044                     }
0045                     else {
0046                         main.rotateClockwise();
0047                     }
0048                     break;
0049                 case Qt.MiddleButton:
0050                     locked = !locked;
0051                     break;
0052             }
0053         }
0054         onEntered: main.selected = index
0055         onPositionChanged: main.selected = index
0056     }
0057 }