Warning, /education/gcompris/src/activities/sudoku/SudokuListWidget.qml is written in an unsupported language. File is not indexed.
0001 /* gcompris - SudokuListWidget.qml 0002 0003 SPDX-FileCopyrightText: 2014 Johnny Jazeix <jazeix@gmail.com> 0004 0005 2003, 2014: Bruno Coudoin: initial version 0006 2014: Johnny Jazeix: Qt port 0007 0008 SPDX-License-Identifier: GPL-3.0-or-later 0009 */ 0010 0011 import QtQuick 2.12 0012 import GCompris 1.0 0013 import "sudoku.js" as Activity 0014 import "../../core" 0015 0016 Item { 0017 id: listWidget 0018 width: view.width 0019 height: view.height 0020 anchors { 0021 left: parent.left 0022 leftMargin: background.baseMargins 0023 top: parent.top 0024 topMargin: background.baseMargins 0025 } 0026 0027 property alias model: mymodel; 0028 property alias view: view; 0029 property GCSfx audioEffects 0030 property bool inputBlocked: false 0031 0032 ListModel { 0033 id: mymodel 0034 } 0035 0036 ListView { 0037 id: view 0038 interactive: false 0039 spacing: 5 * ApplicationInfo.ratio 0040 model: mymodel 0041 delegate: listItemComponent 0042 0043 property int iconSize 0044 0045 states: [ 0046 State { 0047 name: "horizontalLayout" 0048 when: background.isHorizontalLayout 0049 PropertyChanges { 0050 target: view 0051 width: iconSize 0052 height: background.height - 2 * bar.height 0053 orientation: ListView.Vertical 0054 iconSize: Math.min((height - (mymodel.count - 1) * spacing) / mymodel.count, 0055 100 * ApplicationInfo.ratio) 0056 } 0057 }, 0058 State { 0059 name: "verticalLayout" 0060 when: !background.isHorizontalLayout 0061 PropertyChanges { 0062 target: view 0063 width: background.width - background.baseMargins * 2 0064 height: iconSize 0065 orientation: ListView.Horizontal 0066 iconSize: Math.min((width - (model.count - 1) * spacing) / mymodel.count, 0067 100 * ApplicationInfo.ratio) 0068 } 0069 } 0070 ] 0071 0072 Component { 0073 id: listItemComponent 0074 0075 Rectangle { 0076 id: iconBg 0077 width: view.iconSize 0078 height: view.iconSize 0079 color: "#AAFFFFFF" 0080 radius: height * 0.1 0081 0082 Image { 0083 id: icon 0084 anchors.centerIn: parent 0085 sourceSize.height: view.iconSize 0086 source: model.imgName === undefined ? "" : 0087 Activity.url + model.imgName 0088 z: iAmSelected ? 10 : 1 0089 0090 property bool iAmSelected: view.currentIndex == index 0091 0092 states: [ 0093 State { 0094 name: "notclicked" 0095 when: !icon.iAmSelected && !mouseArea.containsMouse 0096 PropertyChanges { 0097 target: icon 0098 scale: 0.8 0099 } 0100 }, 0101 State { 0102 name: "clicked" 0103 when: mouseArea.pressed 0104 PropertyChanges { 0105 target: icon 0106 scale: 0.7 0107 } 0108 }, 0109 State { 0110 name: "hover" 0111 when: mouseArea.containsMouse && !icon.iAmSelected 0112 PropertyChanges { 0113 target: icon 0114 scale: 1 0115 } 0116 }, 0117 State { 0118 name: "selected" 0119 when: icon.iAmSelected 0120 PropertyChanges { 0121 target: icon 0122 scale: 0.9 0123 } 0124 } 0125 ] 0126 0127 SequentialAnimation { 0128 id: anim 0129 running: icon.iAmSelected 0130 loops: Animation.Infinite 0131 alwaysRunToEnd: true 0132 NumberAnimation { 0133 target: iconBg 0134 property: "rotation" 0135 from: 0; to: 5 0136 duration: 200 0137 easing.type: Easing.OutQuad 0138 } 0139 NumberAnimation { 0140 target: iconBg 0141 property: "rotation" 0142 from: 5; to: -5 0143 duration: 400 0144 easing.type: Easing.InOutQuad 0145 } 0146 NumberAnimation { 0147 target: iconBg 0148 property: "rotation" 0149 from: -5; to: 0 0150 duration: 200 0151 easing.type: Easing.InQuad 0152 } 0153 } 0154 0155 Behavior on scale { NumberAnimation { duration: 70 } } 0156 0157 MouseArea { 0158 id: mouseArea 0159 anchors.fill: icon 0160 hoverEnabled: true 0161 enabled: !listWidget.inputBlocked 0162 onClicked: { 0163 listWidget.audioEffects.play('qrc:/gcompris/src/core/resource/sounds/scroll.wav') 0164 view.currentIndex = index 0165 } 0166 } 0167 } 0168 } 0169 } 0170 } 0171 } 0172