Warning, /games/kreversi/src/qml/Table.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2013 Denis Kuplyakov <dener.kup@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.3 0008 import "globals.js" as Globals 0009 0010 /** 0011 * Table 0012 * 0013 * Represents table with board 0014 */ 0015 0016 Item { 0017 id: tableContainer 0018 0019 /** 0020 * Is board showing labels or not 0021 */ 0022 property bool isBoardShowingLabels: false 0023 /** 0024 * Chips image's ID prefix at SVG theme file to use. 0025 */ 0026 property string chipsImagePrefix: "chip_bw" 0027 /** 0028 * Duration of chip's turning animation 0029 */ 0030 property int chipsAnimationTime: 25 * 12 0031 /** 0032 * Emitted when user clicks (row, column) cell 0033 * @param row row index of cell (starting from 0) 0034 * @param column column index of cell (starting from 0) 0035 */ 0036 signal cellClicked(int row, int column) 0037 /** 0038 * Enables/disables legal marker at (row, column) cell 0039 * @param row row index of cell (starting from 0) 0040 * @param column column index of cell (starting from 0) 0041 * @param value @c true show legal marker 0042 * @c false hide legal marker 0043 */ 0044 function setLegal(row, column, value) { 0045 board.setLegal(row, column, value); 0046 } 0047 /** 0048 * Turn chip to White/Black at (row, column) cell 0049 * @param row row index of cell (starting from 0) 0050 * @param column column index of cell (starting from 0) 0051 * @param value @c "Black" turn chip to black 0052 * @c "White turn chip to white 0053 * @c "" (empty string) hide chip 0054 */ 0055 function setChipState(row, column, value) { 0056 board.setChipState(row, column, value); 0057 } 0058 /** 0059 * Enables/disables hint at (row, column) cell 0060 * @param row row index of cell (starting from 0) 0061 * @param column column index of cell (starting from 0) 0062 * @param value @c true show hint 0063 * @c false hide hint 0064 */ 0065 function setHint(row, col, show) { 0066 board.setHint(row, col, show); 0067 } 0068 /** 0069 * Enables/disables last move marker at (row, column) cell 0070 * @param row row index of cell (starting from 0) 0071 * @param column column index of cell (starting from 0) 0072 * @param value @c true show last move marker 0073 * @c false hide last move marker 0074 */ 0075 function setLastMove(row, column, value) { 0076 board.setLastMove(row, column, value) 0077 } 0078 /** 0079 * Sets time to wait before starting animation 0080 * @param row row index of cell (starting from 0) 0081 * @param column column index of cell (starting from 0) 0082 * @param value time to wait 0083 */ 0084 function setPreAnimationTime(row, column, value) { 0085 board.setPreAnimationTime(row, column, value); 0086 } 0087 /** 0088 * Shows popup with specified text 0089 * @param text Text to show 0090 */ 0091 function showPopup(text) { 0092 popup.show(text, "SHOWING"); 0093 } 0094 0095 CanvasItem { 0096 id: table_background 0097 anchors.fill: parent 0098 spriteKey: "background" 0099 } 0100 0101 CanvasItem { 0102 id: board_image 0103 width: Math.min(parent.width, parent.height) 0104 height: Math.min(parent.width, parent.height) 0105 anchors.horizontalCenter: parent.horizontalCenter 0106 anchors.verticalCenter: parent.verticalCenter 0107 spriteKey: "board" 0108 } 0109 0110 Board { 0111 id: board 0112 width: Math.min(parent.width, parent.height) 0113 height: Math.min(parent.width, parent.height) 0114 anchors.horizontalCenter: parent.horizontalCenter 0115 anchors.verticalCenter: parent.verticalCenter 0116 0117 isShowingLabels: parent.isBoardShowingLabels 0118 chipsImagePrefix: parent.chipsImagePrefix 0119 chipsAnimationTime: parent.chipsAnimationTime 0120 0121 onCellClicked: (row, column) => tableContainer.cellClicked(row, column) 0122 } 0123 0124 Popup { 0125 id: popup 0126 0127 anchors.bottom: undefined 0128 anchors.top: parent.bottom 0129 anchors.left: parent.left 0130 anchors.leftMargin: 5 0131 anchors.bottomMargin: 5 0132 0133 opacity: 0.9 0134 isReplacing: true 0135 0136 states: [ 0137 State { 0138 name: "SHOWING" 0139 0140 AnchorChanges { 0141 target: popup 0142 anchors.bottom: popup.parent.bottom 0143 anchors.top: undefined 0144 } 0145 } 0146 ] 0147 0148 transitions: [ 0149 Transition { 0150 from: "" 0151 to: "SHOWING" 0152 reversible: true 0153 0154 AnchorAnimation { 0155 0156 duration: 300 0157 } 0158 } 0159 ] 0160 } 0161 }