forked from sandsmark/recrossable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
152 lines (129 loc) · 3.46 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import QtQuick 2.6
import QtQuick.Window 2.2
import com.iskrembilen 1.0
TabletWindow {
visible: true
width: 1404
height: 1872
title: "reCrossable"
flags: Qt.Dialog
Rectangle {
anchors.fill: parent
}
Text {
id: currentHint
anchors {
bottom: parent.bottom
bottomMargin: 20
horizontalCenter: parent.horizontalCenter
}
font.pointSize: 20
width: parent.width / 3
}
Rectangle {
anchors.fill: mainGrid
anchors.margins: -(border.width + 2)
color: "transparent"
border.width: 5
border.color: "black"
}
Grid {
id: mainGrid
anchors {
right: parent.right
margins: 20
bottom: parent.bottom
left: downHints.right
top: acrossHints.bottom
}
spacing: 1
rows: Crossword.rows
columns: Crossword.columns
property int cellSize: Math.max(Math.floor(Math.min(width / Crossword.columns, height / Crossword.rows)), 80);
Repeater {
model: Crossword.rows * Crossword.columns
delegate: DrawableCell {
width: mainGrid.cellSize
// width: 1404 - downHints.width
height: mainGrid.cellSize
onWidthChanged: console.log("cell widtH:" + width)
enabled: Crossword.isOpen(index) && !correctText.visible
Rectangle {
anchors.fill: parent
border.width: 1
color: parent.enabled ? "transparent" : "black"
}
Text {
x: 5
y: 5
text: Crossword.hintAt(index)
color: parent.enabled ? "gray" : "white"
font.pixelSize: 15
}
Text {
id: correctText
anchors.centerIn: parent
visible: parent.recognized === text
text: Crossword.correctAt(index)
color: "white"
}
}
}
}
Rectangle {
anchors.fill: downHints
anchors.margins: -(border.width + 2)
color: "transparent"
border.width: 5
border.color: "black"
}
Column {
id: downHints
anchors {
top: acrossHints.bottom
topMargin: 20
left: parent.left
leftMargin: 10
}
Text {
text: "Down"
font.bold: true
}
Repeater {
model: Crossword.hintsDown()
delegate: Text {
text: modelData
font.pixelSize: 20
width: 200
wrapMode: Text.WordWrap
}
}
}
Rectangle {
anchors.fill: acrossHints
anchors.margins: -(border.width + 2)
color: "transparent"
border.width: 5
border.color: "black"
}
Grid {
id: acrossHints
anchors {
right: parent.right
left: parent.left
top: parent.top
margins: 10
}
Text {
text: "Across"
font.bold: true
}
Repeater {
model: Crossword.hintsAcross()
delegate: Text {
text: modelData
font.pixelSize: 20
}
}
}
}