-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPathofTrading.qml
More file actions
499 lines (442 loc) · 23.6 KB
/
Copy pathPathofTrading.qml
File metadata and controls
499 lines (442 loc) · 23.6 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
/*
* Path of Trading - PoE2 Price Checker UI
* Copyright (C) 2026 brendancohan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Quickshell
import Quickshell.Wayland
import Quickshell.Io
PanelWindow {
id: window
color: "transparent"
anchors.top: true
anchors.bottom: true
anchors.left: true
anchors.right: true
exclusiveZone: 0
focusable: true
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
function s(val) { return val; } // Standard 1:1 scaling for standalone
readonly property color base: "#1e1e2e"
readonly property color text: "#cdd6f4"
readonly property color blue: "#89b4fa"
readonly property color yellow: "#f9e2af"
readonly property color surface2: "#585b70"
readonly property color subtext0: "#a6adc8"
property real introMain: 0
SequentialAnimation {
running: true
PauseAnimation { duration: 20 }
NumberAnimation { target: window; property: "introMain"; from: 0; to: 1.0; duration: 800; easing.type: Easing.OutQuart }
}
Shortcut {
sequence: "Escape"
onActivated: Qt.quit()
}
property var priceData: ({ "status": "loading", "item": "Loading...", "listings": [], "parsed_stats": [], "leagues": [], "selected_league": "" })
Process {
id: dataReader
command: ["cat", Quickshell.env("HOME") + "/.cache/pathoftrading-v1.0/price_data.json"]
stdout: StdioCollector {
onStreamFinished: {
try {
window.priceData = JSON.parse(this.text);
} catch (e) {
console.log("Error parsing price JSON: " + e);
}
}
}
}
Timer {
interval: 300
running: window.visible && window.priceData.status === "loading"
repeat: true
triggeredOnStart: true
onTriggered: {
dataReader.running = false;
dataReader.running = true;
}
}
// Process to trigger the backend requery
Process {
id: requeryProcess
onExited: {
dataReader.running = false;
dataReader.running = true;
}
}
Item {
anchors.fill: parent
scale: 0.95 + (0.05 * introMain)
opacity: introMain
// Root MouseArea to close on click-outside
MouseArea {
anchors.fill: parent
onClicked: Qt.quit()
}
Rectangle {
id: innerBg
width: window.s(950)
height: window.s(500)
// Stable centering logic
x: (parent.width - width) / 2
y: (parent.height - height) / 2
radius: window.s(20)
color: window.base
border.color: window.surface2
border.width: 1
clip: true
// Drag Logic
property point lastMousePos
MouseArea {
anchors.fill: parent
onPressed: (mouse) => innerBg.lastMousePos = Qt.point(mouse.x, mouse.y)
onPositionChanged: (mouse) => {
if (pressed) {
innerBg.x += mouse.x - innerBg.lastMousePos.x
innerBg.y += mouse.y - innerBg.lastMousePos.y
}
}
}
ColumnLayout {
anchors.fill: parent
anchors.margins: window.s(25)
spacing: window.s(15)
RowLayout {
Layout.fillWidth: true
spacing: window.s(10)
Flow {
Layout.fillWidth: true
spacing: window.s(8)
visible: window.priceData && window.priceData.base_properties && window.priceData.base_properties.length > 0
Repeater {
model: (window.priceData && window.priceData.base_properties) ? window.priceData.base_properties : []
delegate: Rectangle {
color: modelData.active ? window.blue : "transparent"
border.color: window.blue
border.width: 1
radius: window.s(15)
height: window.s(26)
width: propText.implicitWidth + window.s(20)
Text {
id: propText
anchors.centerIn: parent
text: modelData.text !== undefined ? modelData.text : ""
color: modelData.active ? window.base : window.text
font.family: "JetBrains Mono"
font.pixelSize: window.s(12)
font.bold: true
}
MouseArea {
anchors.fill: parent
onClicked: {
var newData = JSON.parse(JSON.stringify(window.priceData));
newData.base_properties[index].active = !newData.base_properties[index].active;
window.priceData = newData;
}
}
}
}
}
// --- Game & League Dropdowns ---
RowLayout {
spacing: window.s(10)
Layout.alignment: Qt.AlignRight | Qt.AlignTop
ComboBox {
id: gameBox
Layout.preferredWidth: window.s(100)
model: ["PoE 2", "PoE 1"]
currentIndex: 0
delegate: ItemDelegate {
width: gameBox.width
text: modelData
highlighted: gameBox.highlightedIndex === index
enabled: index === 0 // PoE 1 disabled
contentItem: Text {
text: gameBox.textRole ? (Array.isArray(gameBox.model) ? modelData[gameBox.textRole] : model[gameBox.textRole]) : modelData
color: index === 0 ? window.text : window.subtext0
font.family: "JetBrains Mono"
font.pixelSize: window.s(11)
verticalAlignment: Text.AlignVCenter
}
}
background: Rectangle {
color: window.surface2
radius: window.s(5)
}
contentItem: Text {
text: gameBox.displayText
color: window.text
font.family: "JetBrains Mono"
font.pixelSize: window.s(11)
verticalAlignment: Text.AlignVCenter
leftPadding: window.s(10)
}
}
ComboBox {
id: leagueBox
Layout.preferredWidth: window.s(160)
model: (window.priceData && window.priceData.leagues) ? window.priceData.leagues : []
currentIndex: {
if (!window.priceData || !window.priceData.leagues || !window.priceData.selected_league) return 0;
return window.priceData.leagues.indexOf(window.priceData.selected_league);
}
onActivated: (index) => {
var newData = JSON.parse(JSON.stringify(window.priceData));
newData.selected_league = leagueBox.model[index];
window.priceData = newData;
}
background: Rectangle {
color: window.surface2
radius: window.s(5)
}
contentItem: Text {
text: leagueBox.displayText
color: window.text
font.family: "JetBrains Mono"
font.pixelSize: window.s(11)
verticalAlignment: Text.AlignVCenter
leftPadding: window.s(10)
}
}
}
}
Text {
text: (window.priceData && window.priceData.item) ? window.priceData.item.toUpperCase() : "UNKNOWN ITEM"
color: window.text
font.family: "JetBrains Mono"
font.weight: Font.Black
font.pixelSize: window.s(20)
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
visible: !window.priceData || !window.priceData.base_properties || window.priceData.base_properties.length === 0
}
Rectangle {
Layout.fillWidth: true
height: window.s(2)
color: Qt.alpha(window.surface2, 0.4)
}
RowLayout {
Layout.fillWidth: true
Layout.fillHeight: true
spacing: window.s(20)
// LEFT COLUMN: Listings
Rectangle {
Layout.fillHeight: true
Layout.preferredWidth: window.s(300)
color: "transparent"
Text {
id: statusText
text: {
if (window.priceData && (window.priceData.status === "loading" || window.priceData.status === "requerying")) {
return "Searching market...";
}
if (window.priceData && window.priceData.listings && window.priceData.listings.length > 0) {
return "Top Listings";
}
return window.priceData.price || "No matching listings";
}
color: window.yellow
font.family: "JetBrains Mono"
font.pixelSize: window.s(14)
font.bold: true
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignHCenter
width: parent.width
wrapMode: Text.Wrap
}
ScrollView {
anchors.top: statusText.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: window.s(10)
clip: true
ColumnLayout {
width: parent.width
spacing: window.s(8)
Repeater {
model: (window.priceData && window.priceData.listings) ? window.priceData.listings : []
delegate: Rectangle {
Layout.fillWidth: true
height: window.s(35)
color: Qt.alpha(window.surface2, 0.2)
radius: window.s(8)
border.color: Qt.alpha(window.surface2, 0.4)
border.width: 1
Text {
anchors.centerIn: parent
text: {
var txt = modelData.display !== undefined ? modelData.display : "?";
if (modelData.age) {
txt += " • " + modelData.age;
}
return txt;
}
color: window.yellow
font.family: "JetBrains Mono"
font.weight: Font.Bold
font.pixelSize: window.s(13)
}
}
}
}
}
}
// Divider
Rectangle {
Layout.fillHeight: true
width: window.s(2)
color: Qt.alpha(window.surface2, 0.4)
visible: !(window.priceData && window.priceData.raw_item && window.priceData.raw_item.isBulk)
}
// RIGHT COLUMN: Stat Modifiers
ColumnLayout {
Layout.fillHeight: true
Layout.fillWidth: true
spacing: window.s(10)
visible: !(window.priceData && window.priceData.raw_item && window.priceData.raw_item.isBulk)
Text {
text: "Stat Filters"
color: window.yellow
font.family: "JetBrains Mono"
font.pixelSize: window.s(14)
font.bold: true
Layout.alignment: Qt.AlignHCenter
}
ScrollView {
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
ColumnLayout {
width: parent.width
spacing: window.s(10)
Repeater {
model: (window.priceData && window.priceData.parsed_stats) ? window.priceData.parsed_stats : []
delegate: Rectangle {
Layout.fillWidth: true
height: window.s(50)
color: Qt.alpha(window.surface2, 0.1)
radius: window.s(8)
RowLayout {
anchors.fill: parent
anchors.margins: window.s(5)
spacing: window.s(10)
CheckBox {
checked: modelData.active !== undefined ? modelData.active : true
onCheckedChanged: {
window.priceData.parsed_stats[index].active = checked;
}
}
RowLayout {
Layout.fillWidth: true
spacing: window.s(8)
MouseArea {
anchors.fill: parent
onClicked: {
// Toggle the active state
var newData = JSON.parse(JSON.stringify(window.priceData));
newData.parsed_stats[index].active = !newData.parsed_stats[index].active;
window.priceData = newData;
}
}
Rectangle {
visible: modelData.tier !== undefined && modelData.tier !== null
Layout.preferredWidth: window.s(30)
Layout.preferredHeight: window.s(20)
radius: window.s(4)
color: modelData.tier === 1 ? "#FFD700" : (modelData.tier === 2 ? window.blue : window.surface2)
Text {
anchors.centerIn: parent
text: "T" + modelData.tier
color: modelData.tier === 1 ? "black" : (modelData.tier === 2 ? window.base : window.text)
font.family: "JetBrains Mono"
font.pixelSize: modelData.tier === 1 ? window.s(12) : window.s(10)
font.bold: modelData.tier <= 2
}
}
Text {
textFormat: Text.RichText
text: {
if (modelData.text === undefined) return "";
return modelData.text.replace(/([+-]?\d+(?:\.\d+)?)(?:\([^)]+\))?/g, function(match, p1) {
var remainder = match.substring(p1.length);
return "<span style=\"color: " + window.blue + "; font-size: " + window.s(13) + "px;\"><b>" + p1 + "</b></span>" + remainder;
});
}
color: window.text
font.family: "JetBrains Mono"
font.pixelSize: window.s(12)
Layout.fillWidth: true
elide: Text.ElideRight
wrapMode: Text.Wrap
}
}
TextField {
Layout.preferredWidth: window.s(55)
placeholderText: "Min"
text: modelData.min !== undefined ? modelData.min : ""
font.family: "JetBrains Mono"
font.pixelSize: window.s(12)
selectByMouse: true
onActiveFocusChanged: if (activeFocus) selectAll()
onTextChanged: { window.priceData.parsed_stats[index].min = text; }
onAccepted: requeryButton.clicked()
}
TextField {
Layout.preferredWidth: window.s(55)
placeholderText: "Max"
text: modelData.max !== undefined ? modelData.max : ""
font.family: "JetBrains Mono"
font.pixelSize: window.s(12)
selectByMouse: true
onActiveFocusChanged: if (activeFocus) selectAll()
onTextChanged: { window.priceData.parsed_stats[index].max = text; }
onAccepted: requeryButton.clicked()
}
}
}
}
}
}
Button {
id: requeryButton
Layout.fillWidth: true
Layout.preferredHeight: window.s(40)
text: "REQUERY TRADES"
font.family: "JetBrains Mono"
font.bold: true
onClicked: {
var payload = JSON.stringify(window.priceData);
// Completely reassign the object to force the UI to recognize the state change
var newData = JSON.parse(payload);
newData.status = "requerying";
window.priceData = newData;
requeryProcess.command = ["python3", Quickshell.env("HOME") + "/.local/share/pathoftrading-v1.0/backend.py", "--requery-data", payload];
requeryProcess.running = false;
requeryProcess.running = true;
}
}
}
}
}
}
}
}