aboutsummaryrefslogtreecommitdiff
path: root/qt/NissyMain.qml
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-04-17 16:27:38 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-04-17 16:27:38 +0200
commitf91e5c4c83a071ab720417d490fd44a8f4678bc1 (patch)
tree9d38fad279c015bea0bf256184b6936171310aa7 /qt/NissyMain.qml
parentc182f3f16e56e9533060ffa06b25391e239a28ee (diff)
downloadnissy-core-f91e5c4c83a071ab720417d490fd44a8f4678bc1.tar.gz
nissy-core-f91e5c4c83a071ab720417d490fd44a8f4678bc1.zip
Improvements to QT UI
Diffstat (limited to 'qt/NissyMain.qml')
-rw-r--r--qt/NissyMain.qml261
1 files changed, 0 insertions, 261 deletions
diff --git a/qt/NissyMain.qml b/qt/NissyMain.qml
deleted file mode 100644
index 24aff43..0000000
--- a/qt/NissyMain.qml
+++ /dev/null
@@ -1,261 +0,0 @@
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5Window {
6 id: mainWindow
7
8 width: 800
9 height: 600
10 visible: true
11 title: "Nissy 3.0 - Preview"
12
13 SplitView {
14 id: splitView
15 anchors.fill: parent
16 orientation: Qt.Vertical
17
18 handle: Rectangle {
19 implicitHeight: 3
20 color: SplitHandle.hovered ? "black" : "#AAAAAA"
21 }
22
23 component MyScrollBar: ScrollBar {
24 orientation: Qt.Vertical
25 size: parent.height
26 policy: ScrollBar.AlwaysOn
27 anchors.right: parent.right
28 anchors.top: parent.top
29 anchors.bottom: parent.bottom
30 contentItem: Rectangle {
31 implicitWidth: 4
32 radius: implicitWidth/2
33 color: "black"
34 }
35 background: Rectangle {
36 implicitWidth: 4
37 radius: implicitWidth/2
38 color: "#AAAAAA"
39 }
40 }
41
42 ColumnLayout {
43 id: mainArea
44
45 property alias scramble: scrambleRow.scramble
46 property alias minmoves: solverCfg.minmoves
47 property alias maxmoves: solverCfg.maxmoves
48 property alias maxsolutions: solverCfg.maxsolutions
49 property alias sols: sols.text
50 property alias solsHeader: solsHeader.text
51
52 property bool solutionsLoading: false
53
54 anchors.top: parent.top
55 anchors.left: parent.left
56 anchors.right: parent.right
57 anchors.bottom: logView.top
58 anchors.margins: 6
59 spacing: 10
60
61 SplitView.minimumHeight: 180
62 SplitView.preferredHeight: 300
63
64 component Separator: Rectangle {
65 height: 1
66 Layout.fillWidth: true
67 color: "black"
68 }
69
70 ColumnLayout {
71 id: scrambleRow
72
73 property alias scramble: scrambleRowLayout.scramble
74
75 RowLayout {
76 id: scrambleRowLayout
77
78 property alias scramble: scrambleEditor.text
79
80 spacing: 6
81
82 TextField {
83 id: scrambleEditor
84
85 placeholderText: "Enter scramble here"
86 Layout.fillWidth: true
87 padding: 4
88
89 readonly property bool empty: text.trim().length == 0
90 readonly property bool valid: NissyAdapter.isValidScramble(text)
91
92 onAccepted: if (!empty && valid) submitScramble()
93 }
94
95 Button {
96 id: solveButton
97
98 enabled: !scrambleEditor.empty && scrambleEditor.valid &&
99 !mainArea.solutionsLoading
100 text: "Solve!"
101
102 onPressed: submitScramble()
103 }
104 }
105
106 Label {
107 id: invalidScrambleWarning
108 text: scrambleEditor.empty || scrambleEditor.valid ?
109 "" : "Invalid Scramble"
110 }
111 }
112
113 Separator {}
114
115 ColumnLayout {
116 id: solverCfg
117 property alias minmoves: minMaxRow.min
118 property alias maxmoves: minMaxRow.max
119 property alias maxsolutions: maxOptimal.maxsolutions
120
121 RowLayout {
122 id: minMaxRow
123
124 property alias min: slider.min
125 property alias max: slider.max
126
127 Rectangle {
128 width: 100
129 height: 20
130 Label { text: "Min moves: " + slider.min }
131 }
132 RangeSlider {
133 id: slider
134 from: 0
135 to: 20
136 first.value: from
137 second.value: to
138 stepSize: 1
139 snapMode: RangeSlider.SnapAlways
140
141 readonly property int min: Math.round(first.value)
142 readonly property int max: Math.round(second.value)
143 }
144 Rectangle {
145 width: 100
146 height: 20
147 Label { text: "Max moves: " + slider.max }
148 }
149 }
150
151 RowLayout {
152 id: maxOptimal
153
154 property alias maxsolutions: maxSolsRect.maxsolutions
155
156 Rectangle {
157 width: 220
158 height: 20
159 Label { text: "Maximum number of solutions:" }
160 }
161 Rectangle {
162 id: maxSolsRect
163
164 property int maxsolutions: parseInt(textField.text)
165
166 width: 35
167 height: 20
168
169 TextField {
170 id: textField
171
172 width: parent.width
173 text: "1"
174 validator: IntValidator{ bottom: 1; top: 999; }
175
176 onAccepted: submitScramble()
177 }
178 }
179 }
180 }
181
182 Separator {}
183
184 Label { id: solsHeader }
185
186 ScrollView {
187 Layout.fillHeight: true
188 Layout.fillWidth: true
189 Layout.bottomMargin: 10
190 ScrollBar.vertical: MyScrollBar {}
191
192 TextEdit {
193 id: sols
194 readOnly: true
195 font.family: "Monospace"
196 }
197 }
198 }
199
200 ScrollView {
201 id: logView
202
203 property alias text: logText.text
204
205 anchors.left: parent.left
206 anchors.right: parent.right
207 anchors.bottom: parent.bottom
208 anchors.margins: 6
209
210 SplitView.preferredHeight: 300
211
212 background: Rectangle {
213 color: "#404040"
214 radius: 4
215 }
216
217 ScrollBar.vertical: MyScrollBar {
218 id: scrollBar
219 position: 1.0 - size
220 }
221 Label {
222 id: logText
223
224 font.family: "Monospace"
225 color: "white"
226 }
227 }
228 }
229
230 function submitScramble() {
231 mainArea.solutionsLoading = true;
232 mainArea.solsHeader = "Loading solutions..."
233 mainArea.sols = ""
234 logView.text = ""
235 NissyAdapter.requestSolve(
236 mainArea.scramble,
237 "h48h3k2",
238 mainArea.minmoves,
239 mainArea.maxmoves,
240 mainArea.maxsolutions,
241 -1
242 )
243 }
244
245 Connections {
246 target: NissyAdapter
247 function onSolutionsReady(header, sols) {
248 mainArea.solutionsLoading = false
249 mainArea.solsHeader = header
250 mainArea.sols = sols
251 }
252 function onSolverError(msg) {
253 mainArea.solutionsLoading = false
254 mainArea.solusHeader = msg
255 mainArea.sols = ""
256 }
257 function onAppendLog(msg) {
258 logView.text += msg
259 }
260 }
261}

Generated with cgit - Back to sebastiano.tronto.net