Warning, /games/kolorfill/src/qml/main.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright (c) 2018 Sune Vuorela <sune@vuorela.dk> 0003 * 0004 * Permission is hereby granted, free of charge, to any person 0005 * obtaining a copy of this software and associated documentation 0006 * files (the "Software"), to deal in the Software without 0007 * restriction, including without limitation the rights to use, 0008 * copy, modify, merge, publish, distribute, sublicense, and/or sell 0009 * copies of the Software, and to permit persons to whom the 0010 * Software is furnished to do so, subject to the following 0011 * conditions: 0012 * 0013 * The above copyright notice and this permission notice shall be 0014 * included in all copies or substantial portions of the Software. 0015 * 0016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 0017 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 0018 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 0019 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 0020 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 0021 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 0022 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 0023 * OTHER DEALINGS IN THE SOFTWARE. 0024 */ 0025 0026 import QtQuick 2.0 0027 import QtQuick.Controls 2.0 0028 import QtQuick.Layouts 1.2 0029 import org.kde.kirigami 2.4 as Kirigami 0030 import KolorFill 1.0 0031 0032 Kirigami.ApplicationWindow 0033 { 0034 visible: true 0035 width: 480 0036 height: 640 0037 title: "KolorFill" 0038 header: Kirigami.Heading { 0039 text: qsTr("Fills: %1").arg(gamearea.fillCounter) 0040 } 0041 0042 HighScore { 0043 id: highscorehandler 0044 size: gamearea.boardsize; 0045 } 0046 0047 globalDrawer: Kirigami.GlobalDrawer { 0048 title: "KolorFill" 0049 titleIcon: "color-fill" 0050 actions: [ 0051 Kirigami.Action { 0052 text: qsTr("Restart") 0053 iconName: "view-refresh" 0054 onTriggered:gamearea.restart() 0055 }, 0056 Kirigami.Action { 0057 text: qsTr("Highscore") 0058 iconName: "games-highscores" 0059 onTriggered: highscore.sheetOpen = true 0060 }, 0061 Kirigami.Action { 0062 text: qsTr("Help") 0063 iconName: "help-contents" 0064 onTriggered: help.sheetOpen = true 0065 } 0066 ] 0067 } 0068 0069 Kirigami.OverlaySheet { 0070 id: help 0071 header: Kirigami.Heading { text: qsTr("Help") } 0072 Help { 0073 } 0074 } 0075 0076 Kirigami.OverlaySheet { 0077 id: highscore 0078 header: Kirigami.Heading { 0079 text: qsTr("High score") 0080 } 0081 HighScoreView { 0082 allHighscores: highscorehandler.allHighscores 0083 0084 } 0085 0086 } 0087 Kirigami.OverlaySheet { 0088 id: winner 0089 header: Kirigami.Heading { 0090 text: qsTr("Winner!") 0091 } 0092 property alias highscorebeaten: winBanner.highscoreBeaten; 0093 Winner { 0094 id: winBanner 0095 fillCounter: gamearea.fillCounter 0096 onRestartClicked: { 0097 gamearea.restart() 0098 winner.sheetOpen = false 0099 } 0100 } 0101 } 0102 0103 GameArea { 0104 id: gamearea 0105 anchors.bottomMargin: 40 0106 anchors.fill: parent 0107 boardsize: 15 0108 colorList: [ "red", "darkGreen", "blue", "yellow", "darkMagenta", "orange" ] 0109 Component.onCompleted: { 0110 gamearea.restart() 0111 } 0112 onFilledChanged: { 0113 if (filled) { 0114 winner.highscorebeaten = (highscorehandler.highscore > gamearea.fillCounter) || (highscorehandler.highscore === -1) 0115 if (winner.highscorebeaten) { 0116 highscorehandler.highscore = gamearea.fillCounter; 0117 } 0118 } 0119 winner.sheetOpen = filled 0120 } 0121 } 0122 }