aboutsummaryrefslogtreecommitdiff
path: root/qt/Main.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/Main.qml
parentc182f3f16e56e9533060ffa06b25391e239a28ee (diff)
downloadnissy-core-f91e5c4c83a071ab720417d490fd44a8f4678bc1.tar.gz
nissy-core-f91e5c4c83a071ab720417d490fd44a8f4678bc1.zip
Improvements to QT UI
Diffstat (limited to '')
-rw-r--r--qt/Main.qml (renamed from qt/NissyMain.qml)135
1 files changed, 103 insertions, 32 deletions
diff --git a/qt/NissyMain.qml b/qt/Main.qml
index 24aff43..a6e034a 100644
--- a/qt/NissyMain.qml
+++ b/qt/Main.qml
@@ -43,9 +43,11 @@ Window {
43 id: mainArea 43 id: mainArea
44 44
45 property alias scramble: scrambleRow.scramble 45 property alias scramble: scrambleRow.scramble
46 property alias solver: solverCfg.solver
46 property alias minmoves: solverCfg.minmoves 47 property alias minmoves: solverCfg.minmoves
47 property alias maxmoves: solverCfg.maxmoves 48 property alias maxmoves: solverCfg.maxmoves
48 property alias maxsolutions: solverCfg.maxsolutions 49 property alias maxsolutions: solverCfg.maxsolutions
50 property alias optimal: solverCfg.optimal
49 property alias sols: sols.text 51 property alias sols: sols.text
50 property alias solsHeader: solsHeader.text 52 property alias solsHeader: solsHeader.text
51 53
@@ -59,7 +61,7 @@ Window {
59 spacing: 10 61 spacing: 10
60 62
61 SplitView.minimumHeight: 180 63 SplitView.minimumHeight: 180
62 SplitView.preferredHeight: 300 64 SplitView.preferredHeight: 500
63 65
64 component Separator: Rectangle { 66 component Separator: Rectangle {
65 height: 1 67 height: 1
@@ -67,6 +69,50 @@ Window {
67 color: "black" 69 color: "black"
68 } 70 }
69 71
72 component OptionalValue: RowLayout {
73 property alias currentValue: valueRect.value
74 property alias from: spinBox.from
75 property alias to: spinBox.to
76 property alias defaultValue: spinBox.value
77 property alias defaultEnabled: sw.checked
78 property alias label: sw.text
79 property int defaultSavedValue: 1
80 property int savedValue: defaultSavedValue
81
82 Switch {
83 id: sw
84
85 checked: true
86
87 onToggled: () => {
88 if (checked) {
89 currentValue = savedValue
90 } else {
91 savedValue = currentValue
92 currentValue = spinBox.to
93 }
94 }
95 }
96
97 Rectangle {
98 id: valueRect
99
100 property alias enabled: sw.checked
101 property alias value: spinBox.value
102
103 width: 65
104 height: 20
105
106 SpinBox {
107 id: spinBox
108
109 width: parent.width
110 editable: true
111 enabled: parent.enabled
112 }
113 }
114 }
115
70 ColumnLayout { 116 ColumnLayout {
71 id: scrambleRow 117 id: scrambleRow
72 118
@@ -114,9 +160,36 @@ Window {
114 160
115 ColumnLayout { 161 ColumnLayout {
116 id: solverCfg 162 id: solverCfg
163
117 property alias minmoves: minMaxRow.min 164 property alias minmoves: minMaxRow.min
118 property alias maxmoves: minMaxRow.max 165 property alias maxmoves: minMaxRow.max
119 property alias maxsolutions: maxOptimal.maxsolutions 166 property alias maxsolutions: maxSols.currentValue
167 property alias optimal: optimal.currentValue
168 property alias solver: solverRow.solver
169
170 RowLayout {
171 id: solverRow
172
173 property alias solver: comboBox.currentValue
174
175 Label { text: "Solver" }
176 ComboBox {
177 id: comboBox
178
179 currentIndex: 3
180 textRole: "text"
181 valueRole: "name"
182 implicitContentWidthPolicy: ComboBox.WidestTextWhenCompleted
183
184 model: ListModel {
185 ListElement { text: "h48 h=0, k=4 (59 Mb)"; name: "h48h0k4" }
186 ListElement { text: "h48 h=1, k=2 (115 Mb)"; name: "h48h1k2" }
187 ListElement { text: "h48 h=2, k=2 (171 Mb)"; name: "h48h2k2" }
188 ListElement { text: "h48 h=3, k=2 (283 Mb)"; name: "h48h3k2" }
189 ListElement { text: "h48 h=7, k=2 (3.6 Gb)"; name: "h48h7k2" }
190 }
191 }
192 }
120 193
121 RowLayout { 194 RowLayout {
122 id: minMaxRow 195 id: minMaxRow
@@ -148,40 +221,38 @@ Window {
148 } 221 }
149 } 222 }
150 223
151 RowLayout { 224 OptionalValue {
152 id: maxOptimal 225 id: optimal
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 226
169 TextField { 227 label: "Above optimal by at most"
170 id: textField 228 from: 0
229 to: 20
230 defaultValue: 20
231 defaultEnabled: false
232 defaultSavedValue: 0
233 }
171 234
172 width: parent.width 235 OptionalValue {
173 text: "1" 236 id: maxSols
174 validator: IntValidator{ bottom: 1; top: 999; }
175 237
176 onAccepted: submitScramble() 238 label: "Limit number of solutions to"
177 } 239 from: 1
178 } 240 to: 999
241 defaultValue: 1
242 defaultEnabled: true
243 defaultSavedValue: 1
179 } 244 }
180 } 245 }
181 246
182 Separator {} 247 Separator {}
183 248
184 Label { id: solsHeader } 249 StackLayout {
250 Layout.maximumHeight: 30
251 currentIndex: mainArea.solutionsLoading ? 0 : 1
252
253 BusyIndicator { running: mainArea.solutionsLoading }
254 Label { id: solsHeader }
255 }
185 256
186 ScrollView { 257 ScrollView {
187 Layout.fillHeight: true 258 Layout.fillHeight: true
@@ -229,16 +300,16 @@ Window {
229 300
230 function submitScramble() { 301 function submitScramble() {
231 mainArea.solutionsLoading = true; 302 mainArea.solutionsLoading = true;
232 mainArea.solsHeader = "Loading solutions..." 303 mainArea.solsHeader = ""
233 mainArea.sols = "" 304 mainArea.sols = ""
234 logView.text = "" 305 logView.text = ""
235 NissyAdapter.requestSolve( 306 NissyAdapter.requestSolve(
236 mainArea.scramble, 307 mainArea.scramble,
237 "h48h3k2", 308 mainArea.solver,
238 mainArea.minmoves, 309 mainArea.minmoves,
239 mainArea.maxmoves, 310 mainArea.maxmoves,
240 mainArea.maxsolutions, 311 mainArea.maxsolutions,
241 -1 312 mainArea.optimal
242 ) 313 )
243 } 314 }
244 315
@@ -251,7 +322,7 @@ Window {
251 } 322 }
252 function onSolverError(msg) { 323 function onSolverError(msg) {
253 mainArea.solutionsLoading = false 324 mainArea.solutionsLoading = false
254 mainArea.solusHeader = msg 325 mainArea.solsHeader = msg
255 mainArea.sols = "" 326 mainArea.sols = ""
256 } 327 }
257 function onAppendLog(msg) { 328 function onAppendLog(msg) {

Generated with cgit - Back to sebastiano.tronto.net