inksim 0.3.2__tar.gz → 0.3.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {inksim-0.3.2 → inksim-0.3.10}/PKG-INFO +32 -19
- {inksim-0.3.2 → inksim-0.3.10}/README.md +30 -17
- {inksim-0.3.2 → inksim-0.3.10}/pyproject.toml +2 -2
- {inksim-0.3.2 → inksim-0.3.10}/pyproject.toml.orig +2 -2
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/cli.py +32 -6
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/config.py +5 -1
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/constants.py +1 -1
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/gui/about.py +8 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/gui/export_dialog.py +10 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/gui/frame.py +125 -3
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/gui/gl_viewer.py +3 -2
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/gui/help.py +2 -1
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/gui/shortcuts.py +2 -2
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/gui/status.py +1 -1
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/interconnect.py +7 -2
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/render/export.py +28 -10
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/render/grid.py +14 -2
- inksim-0.3.10/src/inksim/update_check.py +128 -0
- {inksim-0.3.2 → inksim-0.3.10}/LICENSE +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/__init__.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/__main__.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/InkSim_colorful_small.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/app_icons/inksim.svg +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/bold_4strand_cap_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/bold_4strand_manifest.json +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/bold_4strand_normal_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/classic_3strand_cap_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/classic_3strand_manifest.json +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/classic_3strand_normal_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/fuzzy_3strand_cap_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/fuzzy_3strand_manifest.json +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/fuzzy_3strand_normal_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/gap_2strand_cap_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/gap_2strand_manifest.json +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/gap_2strand_normal_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/loose_twist_cap_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/loose_twist_manifest.json +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/loose_twist_normal_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/soft_2strand_cap_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/soft_2strand_manifest.json +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/soft_2strand_normal_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/thick_6strand_cap_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/thick_6strand_manifest.json +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/thick_6strand_normal_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/thin_2strand_cap_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/thin_2strand_manifest.json +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/thin_2strand_normal_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/tight_twist_cap_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/tight_twist_manifest.json +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/tight_twist_normal_mask.png +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/debug.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/formats.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/gui/__init__.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/gui/config_editor.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/gui/dialogs.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/gui/renderer_picker.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/gui/settings.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/gui/splash.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/gui/timeline.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/gui/viewer.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/render/__init__.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/render/density.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/render/fabric.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/render/previews.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/render/registry.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/render/stitches.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/render/stitches_gl.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/render/stitches_numba.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/render/stitches_qt.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/render/viewport.py +0 -0
- {inksim-0.3.2 → inksim-0.3.10}/src/inksim/runtime.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: inksim
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.10
|
|
4
4
|
Summary: Interactive embroidery simulator
|
|
5
5
|
Author: InkSim contributors
|
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
|
@@ -28,7 +28,7 @@ Requires-Dist: pyside6-essentials
|
|
|
28
28
|
Requires-Dist: pyopengl
|
|
29
29
|
Requires-Dist: tomli-w
|
|
30
30
|
Requires-Dist: filelock
|
|
31
|
-
Requires-Python: >=3.
|
|
31
|
+
Requires-Python: >=3.11
|
|
32
32
|
Project-URL: Homepage, https://github.com/oorteo/inksim
|
|
33
33
|
Project-URL: Repository, https://github.com/oorteo/inksim.git
|
|
34
34
|
Project-URL: Issues, https://github.com/oorteo/inksim/issues
|
|
@@ -40,6 +40,10 @@ InkSim is a standalone interactive embroidery simulator and preview renderer.
|
|
|
40
40
|
It opens embroidery files, displays their stitch sequence, and lets the user
|
|
41
41
|
inspect or replay the design before production.
|
|
42
42
|
|
|
43
|
+
<p align="center">
|
|
44
|
+
<img src="https://raw.githubusercontent.com/oorteo/inksim/kgn/fix/win/docs/assets/images/InkSim_colorful_small.png" alt="InkSim preview" width="250">
|
|
45
|
+
</p>
|
|
46
|
+
|
|
43
47
|
The viewer now includes an **OpenGL textured renderer** that draws stitches as
|
|
44
48
|
realistic ribbon quads with normal-mapped thread and Blinn-Phong lighting. Press
|
|
45
49
|
`Z` in the viewer to toggle between the CPU and GPU renderers. The GPU renderer
|
|
@@ -47,30 +51,37 @@ requires **OpenGL 3.3**; older systems and virtual machines fall back to the
|
|
|
47
51
|
CPU raster renderer automatically.
|
|
48
52
|
|
|
49
53
|
<p align="center">
|
|
50
|
-
<img src="https://raw.githubusercontent.com/oorteo/inksim/
|
|
54
|
+
<img src="https://raw.githubusercontent.com/oorteo/inksim/kgn/fix/win/docs/assets/images/thread_texture.webp" alt="Thread texture detail" width="450">
|
|
55
|
+
<br>
|
|
56
|
+
<em>Detail of the normal-mapped thread texture used by the OpenGL renderer.</em>
|
|
51
57
|
</p>
|
|
52
58
|
|
|
53
59
|
InkSim is experimental software provided for development and testing.
|
|
54
60
|
|
|
55
|
-
##
|
|
61
|
+
## Running
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
Run InkSim from your terminal or command prompt:
|
|
58
64
|
|
|
59
65
|
```bash
|
|
60
|
-
|
|
66
|
+
inksim design.pes
|
|
61
67
|
```
|
|
62
68
|
|
|
63
|
-
|
|
69
|
+
On Windows you can also use `inksim-gui design.pes` to launch without a console
|
|
70
|
+
window. Both command names work the same on Windows, macOS, and Linux.
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
inksim
|
|
67
|
-
|
|
72
|
+
<p align="center">
|
|
73
|
+
<img src="https://raw.githubusercontent.com/oorteo/inksim/kgn/fix/win/docs/assets/basic_usage/010_basic_windows.webp" alt="InkSim main window" width="600">
|
|
74
|
+
<br>
|
|
75
|
+
<em>The InkSim window after opening a design.</em>
|
|
76
|
+
</p>
|
|
68
77
|
|
|
69
|
-
|
|
70
|
-
names behave consistently on Windows, macOS, and Linux.
|
|
78
|
+
## Installation
|
|
71
79
|
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
InkSim requires Python 3.11 or newer. Install it with your preferred Python
|
|
81
|
+
package manager (`uv`, `pip`, `pipx`, or another). See the
|
|
82
|
+
[installation guide](https://github.com/oorteo/inksim/blob/kgn/fix/win/docs/installation.md) for step-by-step instructions for
|
|
83
|
+
the most common tools, including how to add InkSim to your `PATH` and how to
|
|
84
|
+
install a development copy from source.
|
|
74
85
|
|
|
75
86
|
## Quick start
|
|
76
87
|
|
|
@@ -82,10 +93,12 @@ inksim design.pes --play
|
|
|
82
93
|
|
|
83
94
|
## Documentation
|
|
84
95
|
|
|
85
|
-
- [Installation and running](https://github.com/oorteo/inksim/blob/
|
|
86
|
-
- [User guide](https://github.com/oorteo/inksim/blob/
|
|
87
|
-
- [
|
|
88
|
-
- [
|
|
96
|
+
- [Installation and running](https://github.com/oorteo/inksim/blob/kgn/fix/win/docs/installation.md)
|
|
97
|
+
- [User guide](https://github.com/oorteo/inksim/blob/kgn/fix/win/docs/user-guide.md)
|
|
98
|
+
- [Rendering modes and overlays](https://github.com/oorteo/inksim/blob/kgn/fix/win/docs/rendering.md)
|
|
99
|
+
- [Inkscape / Ink/Stitch workflow](https://github.com/oorteo/inksim/blob/kgn/fix/win/docs/inkscape-workflow.md)
|
|
100
|
+
- [Application interconnect](https://github.com/oorteo/inksim/blob/kgn/fix/win/docs/interconnect.md)
|
|
101
|
+
- [Contributing](https://github.com/oorteo/inksim/blob/kgn/fix/win/CONTRIBUTING.md)
|
|
89
102
|
|
|
90
103
|
## Background
|
|
91
104
|
|
|
@@ -108,4 +121,4 @@ embroidery alive and inspiring.
|
|
|
108
121
|
|
|
109
122
|
## License
|
|
110
123
|
|
|
111
|
-
InkSim is released under the [GNU General Public License v3 or later](https://github.com/oorteo/inksim/blob/
|
|
124
|
+
InkSim is released under the [GNU General Public License v3 or later](https://github.com/oorteo/inksim/blob/kgn/fix/win/LICENSE).
|
|
@@ -4,6 +4,10 @@ InkSim is a standalone interactive embroidery simulator and preview renderer.
|
|
|
4
4
|
It opens embroidery files, displays their stitch sequence, and lets the user
|
|
5
5
|
inspect or replay the design before production.
|
|
6
6
|
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src="https://raw.githubusercontent.com/oorteo/inksim/kgn/fix/win/docs/assets/images/InkSim_colorful_small.png" alt="InkSim preview" width="250">
|
|
9
|
+
</p>
|
|
10
|
+
|
|
7
11
|
The viewer now includes an **OpenGL textured renderer** that draws stitches as
|
|
8
12
|
realistic ribbon quads with normal-mapped thread and Blinn-Phong lighting. Press
|
|
9
13
|
`Z` in the viewer to toggle between the CPU and GPU renderers. The GPU renderer
|
|
@@ -11,30 +15,37 @@ requires **OpenGL 3.3**; older systems and virtual machines fall back to the
|
|
|
11
15
|
CPU raster renderer automatically.
|
|
12
16
|
|
|
13
17
|
<p align="center">
|
|
14
|
-
<img src="https://raw.githubusercontent.com/oorteo/inksim/
|
|
18
|
+
<img src="https://raw.githubusercontent.com/oorteo/inksim/kgn/fix/win/docs/assets/images/thread_texture.webp" alt="Thread texture detail" width="450">
|
|
19
|
+
<br>
|
|
20
|
+
<em>Detail of the normal-mapped thread texture used by the OpenGL renderer.</em>
|
|
15
21
|
</p>
|
|
16
22
|
|
|
17
23
|
InkSim is experimental software provided for development and testing.
|
|
18
24
|
|
|
19
|
-
##
|
|
25
|
+
## Running
|
|
20
26
|
|
|
21
|
-
|
|
27
|
+
Run InkSim from your terminal or command prompt:
|
|
22
28
|
|
|
23
29
|
```bash
|
|
24
|
-
|
|
30
|
+
inksim design.pes
|
|
25
31
|
```
|
|
26
32
|
|
|
27
|
-
|
|
33
|
+
On Windows you can also use `inksim-gui design.pes` to launch without a console
|
|
34
|
+
window. Both command names work the same on Windows, macOS, and Linux.
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
inksim
|
|
31
|
-
|
|
36
|
+
<p align="center">
|
|
37
|
+
<img src="https://raw.githubusercontent.com/oorteo/inksim/kgn/fix/win/docs/assets/basic_usage/010_basic_windows.webp" alt="InkSim main window" width="600">
|
|
38
|
+
<br>
|
|
39
|
+
<em>The InkSim window after opening a design.</em>
|
|
40
|
+
</p>
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
names behave consistently on Windows, macOS, and Linux.
|
|
42
|
+
## Installation
|
|
35
43
|
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
InkSim requires Python 3.11 or newer. Install it with your preferred Python
|
|
45
|
+
package manager (`uv`, `pip`, `pipx`, or another). See the
|
|
46
|
+
[installation guide](https://github.com/oorteo/inksim/blob/kgn/fix/win/docs/installation.md) for step-by-step instructions for
|
|
47
|
+
the most common tools, including how to add InkSim to your `PATH` and how to
|
|
48
|
+
install a development copy from source.
|
|
38
49
|
|
|
39
50
|
## Quick start
|
|
40
51
|
|
|
@@ -46,10 +57,12 @@ inksim design.pes --play
|
|
|
46
57
|
|
|
47
58
|
## Documentation
|
|
48
59
|
|
|
49
|
-
- [Installation and running](https://github.com/oorteo/inksim/blob/
|
|
50
|
-
- [User guide](https://github.com/oorteo/inksim/blob/
|
|
51
|
-
- [
|
|
52
|
-
- [
|
|
60
|
+
- [Installation and running](https://github.com/oorteo/inksim/blob/kgn/fix/win/docs/installation.md)
|
|
61
|
+
- [User guide](https://github.com/oorteo/inksim/blob/kgn/fix/win/docs/user-guide.md)
|
|
62
|
+
- [Rendering modes and overlays](https://github.com/oorteo/inksim/blob/kgn/fix/win/docs/rendering.md)
|
|
63
|
+
- [Inkscape / Ink/Stitch workflow](https://github.com/oorteo/inksim/blob/kgn/fix/win/docs/inkscape-workflow.md)
|
|
64
|
+
- [Application interconnect](https://github.com/oorteo/inksim/blob/kgn/fix/win/docs/interconnect.md)
|
|
65
|
+
- [Contributing](https://github.com/oorteo/inksim/blob/kgn/fix/win/CONTRIBUTING.md)
|
|
53
66
|
|
|
54
67
|
## Background
|
|
55
68
|
|
|
@@ -72,4 +85,4 @@ embroidery alive and inspiring.
|
|
|
72
85
|
|
|
73
86
|
## License
|
|
74
87
|
|
|
75
|
-
InkSim is released under the [GNU General Public License v3 or later](https://github.com/oorteo/inksim/blob/
|
|
88
|
+
InkSim is released under the [GNU General Public License v3 or later](https://github.com/oorteo/inksim/blob/kgn/fix/win/LICENSE).
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "inksim"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.10"
|
|
4
4
|
description = "Interactive embroidery simulator"
|
|
5
5
|
authors = [{ name = "InkSim contributors" }]
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
license = { file = "LICENSE" }
|
|
8
|
-
requires-python = ">=3.
|
|
8
|
+
requires-python = ">=3.11"
|
|
9
9
|
dependencies = [
|
|
10
10
|
"numba",
|
|
11
11
|
"numpy",
|
|
@@ -36,8 +36,21 @@ def _parse_pair(value, name, separator):
|
|
|
36
36
|
return first, second
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
def
|
|
40
|
-
"""
|
|
39
|
+
def _write_response_file(output_path, response):
|
|
40
|
+
"""Write a JSON response to ``output_path`` for a GUI-subsystem caller."""
|
|
41
|
+
try:
|
|
42
|
+
output_path.write_text(json.dumps(response), encoding="utf-8")
|
|
43
|
+
except OSError as ex:
|
|
44
|
+
raise SystemExit(f"cannot write response to {output_path}: {ex}")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _send_command_and_exit(json_text, output_path=None):
|
|
48
|
+
"""Send a JSON command to a running server and print the response.
|
|
49
|
+
|
|
50
|
+
When ``output_path`` is given the JSON response is written to that file
|
|
51
|
+
instead of stdout. This lets a GUI-subsystem launcher (``inksim-gui`` on
|
|
52
|
+
Windows) report its result without needing an attached console.
|
|
53
|
+
"""
|
|
41
54
|
try:
|
|
42
55
|
command = json.loads(json_text)
|
|
43
56
|
except json.JSONDecodeError as ex:
|
|
@@ -52,9 +65,15 @@ def _send_command_and_exit(json_text):
|
|
|
52
65
|
try:
|
|
53
66
|
response = send_command(command)
|
|
54
67
|
except RuntimeError as ex:
|
|
55
|
-
|
|
68
|
+
if output_path is not None:
|
|
69
|
+
_write_response_file(output_path, {"ok": False, "error": str(ex)})
|
|
70
|
+
else:
|
|
71
|
+
print(str(ex), file=sys.stderr)
|
|
56
72
|
raise SystemExit(1)
|
|
57
|
-
|
|
73
|
+
if output_path is not None:
|
|
74
|
+
_write_response_file(output_path, response)
|
|
75
|
+
else:
|
|
76
|
+
print(json.dumps(response))
|
|
58
77
|
raise SystemExit(0 if response.get("ok") else 1)
|
|
59
78
|
|
|
60
79
|
|
|
@@ -111,6 +130,10 @@ def build_argument_parser():
|
|
|
111
130
|
metavar="JSON",
|
|
112
131
|
help="Send one JSON command to a running InkSim server and exit",
|
|
113
132
|
)
|
|
133
|
+
parser.add_argument(
|
|
134
|
+
"--output", type=Path, metavar="FILE",
|
|
135
|
+
help="Write the --send-command JSON response to FILE instead of stdout",
|
|
136
|
+
)
|
|
114
137
|
parser.add_argument(
|
|
115
138
|
"--debug", "--dbg", action="store_true",
|
|
116
139
|
help="Enable debug logging",
|
|
@@ -193,6 +216,8 @@ def main():
|
|
|
193
216
|
if args.version:
|
|
194
217
|
print("\n".join(runtime_info_lines()))
|
|
195
218
|
return
|
|
219
|
+
if args.output is not None and not args.send_command:
|
|
220
|
+
parser.error("--output is only meaningful with --send-command")
|
|
196
221
|
if args.send_command:
|
|
197
222
|
debug_enabled = args.debug or args.log is not None or bool(
|
|
198
223
|
os.environ.get("INKSIM_DEBUG") or os.environ.get("INKSIM_LOG")
|
|
@@ -208,7 +233,7 @@ def main():
|
|
|
208
233
|
configure_logging(True, log_path)
|
|
209
234
|
except OSError as ex:
|
|
210
235
|
parser.error(f"cannot create debug log {log_path}: {ex}")
|
|
211
|
-
_send_command_and_exit(args.send_command)
|
|
236
|
+
_send_command_and_exit(args.send_command, args.output)
|
|
212
237
|
|
|
213
238
|
export_values = [
|
|
214
239
|
value for value in (
|
|
@@ -301,7 +326,6 @@ def main():
|
|
|
301
326
|
snap_layout_key = args.snap
|
|
302
327
|
app = QApplication.instance() or QApplication([])
|
|
303
328
|
app.setApplicationName(APP_TITLE)
|
|
304
|
-
app.setApplicationDisplayName(APP_TITLE)
|
|
305
329
|
app.setOrganizationName(APP_TITLE)
|
|
306
330
|
app.setWindowIcon(QIcon(str(
|
|
307
331
|
Path(__file__).parent / "assets" / "app_icons" / "inksim.svg")))
|
|
@@ -336,6 +360,8 @@ def main():
|
|
|
336
360
|
command["snap"] = snap_layout_key
|
|
337
361
|
if document_path is not None and command["command"] == open_command:
|
|
338
362
|
command["document_path"] = str(document_path)
|
|
363
|
+
if args.play and command["command"] == open_command:
|
|
364
|
+
command["autoplay"] = True
|
|
339
365
|
response = send_command(command)
|
|
340
366
|
frame.close()
|
|
341
367
|
if not response.get("ok"):
|
|
@@ -145,6 +145,9 @@ class Config:
|
|
|
145
145
|
def load_text(self, text: str) -> None:
|
|
146
146
|
"""Replace the in-memory data with *text* and persist it.
|
|
147
147
|
|
|
148
|
+
This is a full replacement: keys removed from *text* are deleted from
|
|
149
|
+
the file, unlike :meth:`save` which merges with the on-disk content.
|
|
150
|
+
|
|
148
151
|
Raises:
|
|
149
152
|
ValueError: If *text* is not valid TOML.
|
|
150
153
|
"""
|
|
@@ -154,7 +157,8 @@ class Config:
|
|
|
154
157
|
self._data = tomllib.loads(text)
|
|
155
158
|
except Exception as exc:
|
|
156
159
|
raise ValueError(f"Invalid TOML: {exc}") from exc
|
|
157
|
-
self.
|
|
160
|
+
with self._lock.acquire(timeout=5.0):
|
|
161
|
+
self._save_locked()
|
|
158
162
|
|
|
159
163
|
def merge_data(self, data: dict[str, Any]) -> None:
|
|
160
164
|
"""Merge *data* into the current in-memory dictionary and persist.
|
|
@@ -29,7 +29,7 @@ IPC_PROTOCOL_VERSION = 1
|
|
|
29
29
|
TOKEN_FILENAME = "inksim-server.token"
|
|
30
30
|
DEFAULT_STATUS_TEXT = (
|
|
31
31
|
"Space=play/pause | C=center | F=fit | F11=fullscreen | "
|
|
32
|
-
"Ctrl+Arrows=color | G=grid H=help"
|
|
32
|
+
"Ctrl+Up/Dn=speed | Ctrl+Arrows=color | G=grid H=help"
|
|
33
33
|
)
|
|
34
34
|
DENSITY_RADIUS_MM = 2.5
|
|
35
35
|
DENSITY_WARNING_PER_MM2 = 3.0
|
|
@@ -17,6 +17,7 @@ from PySide6.QtWidgets import (
|
|
|
17
17
|
|
|
18
18
|
from ..constants import APP_TITLE
|
|
19
19
|
from ..runtime import runtime_info_lines
|
|
20
|
+
from ..update_check import last_check_text
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
def show_about(parent):
|
|
@@ -70,6 +71,13 @@ def show_about(parent):
|
|
|
70
71
|
runtime.setMaximumHeight(210)
|
|
71
72
|
layout.addWidget(runtime)
|
|
72
73
|
|
|
74
|
+
last_check = QLabel(
|
|
75
|
+
f"Last update check: {last_check_text(parent.config)}", dialog
|
|
76
|
+
)
|
|
77
|
+
last_check.setObjectName("body")
|
|
78
|
+
last_check.setAlignment(Qt.AlignCenter)
|
|
79
|
+
layout.addWidget(last_check)
|
|
80
|
+
|
|
73
81
|
buttons = QDialogButtonBox(QDialogButtonBox.Close, parent=dialog)
|
|
74
82
|
buttons.rejected.connect(dialog.reject)
|
|
75
83
|
buttons.accepted.connect(dialog.accept)
|
|
@@ -230,7 +230,17 @@ class ExportPreviewDialog(QDialog):
|
|
|
230
230
|
if self._current_format() == "WebP":
|
|
231
231
|
self._regenerate_preview()
|
|
232
232
|
|
|
233
|
+
def _reset_action_buttons(self):
|
|
234
|
+
"""Re-enable Copy/Save after the preview changes."""
|
|
235
|
+
if self._copy_button.text() != "Copy to clipboard":
|
|
236
|
+
self._copy_button.setText("Copy to clipboard")
|
|
237
|
+
self._copy_button.setEnabled(True)
|
|
238
|
+
if self._save_button.text() != "Save...":
|
|
239
|
+
self._save_button.setText("Save...")
|
|
240
|
+
self._save_button.setEnabled(True)
|
|
241
|
+
|
|
233
242
|
def _regenerate_preview(self):
|
|
243
|
+
self._reset_action_buttons()
|
|
234
244
|
if self._render_callback is None:
|
|
235
245
|
self._info_label.setText(self._format_info(self._current_scale()))
|
|
236
246
|
return
|
|
@@ -34,6 +34,15 @@ from ..formats import (
|
|
|
34
34
|
)
|
|
35
35
|
from ..render import render_export_image
|
|
36
36
|
from ..runtime import _sanitize_path, _unsanitize_path
|
|
37
|
+
from ..update_check import (
|
|
38
|
+
UpdateCheckThread,
|
|
39
|
+
current_version,
|
|
40
|
+
is_newer,
|
|
41
|
+
last_result,
|
|
42
|
+
record_check,
|
|
43
|
+
record_result,
|
|
44
|
+
should_check,
|
|
45
|
+
)
|
|
37
46
|
from .dialogs import EmbroideryOpenDialog
|
|
38
47
|
from .about import show_about
|
|
39
48
|
from .config_editor import show_config_editor
|
|
@@ -94,6 +103,9 @@ class MainWindow(QMainWindow):
|
|
|
94
103
|
self._snapped_geometry = None
|
|
95
104
|
self._last_geometry = self.geometry()
|
|
96
105
|
self._base_title = APP_TITLE
|
|
106
|
+
self._update_thread = None
|
|
107
|
+
self._update_suffix = self._resolve_update_suffix(last_result(self.config))
|
|
108
|
+
self._update_window_title()
|
|
97
109
|
|
|
98
110
|
main_panel = QWidget(self)
|
|
99
111
|
layout = QVBoxLayout(main_panel)
|
|
@@ -328,6 +340,7 @@ class MainWindow(QMainWindow):
|
|
|
328
340
|
else:
|
|
329
341
|
self.show()
|
|
330
342
|
QTimer.singleShot(0, lambda: self._finish_initial_display(autoplay))
|
|
343
|
+
QTimer.singleShot(1500, self._maybe_auto_check_updates)
|
|
331
344
|
if initial_directory:
|
|
332
345
|
directory_path = Path(initial_directory)
|
|
333
346
|
if directory_path.is_dir():
|
|
@@ -482,6 +495,8 @@ class MainWindow(QMainWindow):
|
|
|
482
495
|
checkable=True,
|
|
483
496
|
)
|
|
484
497
|
self._action(help_menu, f"About {APP_TITLE}", lambda: show_about(self))
|
|
498
|
+
help_menu.addSeparator()
|
|
499
|
+
self._action(help_menu, "Check for updates", self._check_for_updates)
|
|
485
500
|
|
|
486
501
|
def _finish_initial_display(self, autoplay):
|
|
487
502
|
self.viewer.fit_to_screen()
|
|
@@ -499,6 +514,82 @@ class MainWindow(QMainWindow):
|
|
|
499
514
|
self.viewer.update()
|
|
500
515
|
self.progress.update()
|
|
501
516
|
|
|
517
|
+
def _maybe_auto_check_updates(self):
|
|
518
|
+
"""Run an update check once per configured interval, if enabled."""
|
|
519
|
+
if not should_check(self.config):
|
|
520
|
+
return
|
|
521
|
+
self._check_for_updates(automatic=True)
|
|
522
|
+
|
|
523
|
+
def _check_for_updates(self, automatic=False):
|
|
524
|
+
"""Query PyPI for a newer version and notify the user."""
|
|
525
|
+
if self._update_thread is not None and self._update_thread.isRunning():
|
|
526
|
+
return
|
|
527
|
+
self.statusBar().showMessage("Checking for updates...", 3000)
|
|
528
|
+
thread = UpdateCheckThread(self)
|
|
529
|
+
thread.result_ready.connect(
|
|
530
|
+
lambda latest: self._on_update_result(latest, automatic)
|
|
531
|
+
)
|
|
532
|
+
thread.finished.connect(thread.deleteLater)
|
|
533
|
+
thread.finished.connect(lambda: self._clear_update_thread(thread))
|
|
534
|
+
self._update_thread = thread
|
|
535
|
+
thread.start()
|
|
536
|
+
|
|
537
|
+
def _clear_update_thread(self, thread):
|
|
538
|
+
if self._update_thread is thread:
|
|
539
|
+
self._update_thread = None
|
|
540
|
+
|
|
541
|
+
def _on_update_result(self, latest, automatic=False):
|
|
542
|
+
record_check(self.config)
|
|
543
|
+
if not latest:
|
|
544
|
+
if automatic:
|
|
545
|
+
return
|
|
546
|
+
QMessageBox.information(
|
|
547
|
+
self,
|
|
548
|
+
"Check for updates",
|
|
549
|
+
"Could not reach PyPI to check for updates.\n"
|
|
550
|
+
"Check your internet connection and try again.",
|
|
551
|
+
)
|
|
552
|
+
return
|
|
553
|
+
installed = current_version()
|
|
554
|
+
if is_newer(latest, installed):
|
|
555
|
+
title = "Update available"
|
|
556
|
+
suffix = f" [available version {latest}]"
|
|
557
|
+
stored = latest
|
|
558
|
+
message = (
|
|
559
|
+
f"A newer InkSim version is available.\n\n"
|
|
560
|
+
f"Installed: {installed}\n"
|
|
561
|
+
f"Latest: {latest}\n\n"
|
|
562
|
+
f"Run `pip install --upgrade inksim` to update."
|
|
563
|
+
)
|
|
564
|
+
elif is_newer(installed, latest):
|
|
565
|
+
title = "Development version"
|
|
566
|
+
suffix = f" [development version {installed}]"
|
|
567
|
+
stored = installed
|
|
568
|
+
message = (
|
|
569
|
+
f"Your local InkSim is newer than the published release.\n\n"
|
|
570
|
+
f"Installed: {installed}\n"
|
|
571
|
+
f"Published: {latest}\n\n"
|
|
572
|
+
f"This is expected while developing locally."
|
|
573
|
+
)
|
|
574
|
+
else:
|
|
575
|
+
title = "Up to date"
|
|
576
|
+
suffix = ""
|
|
577
|
+
stored = ""
|
|
578
|
+
message = (
|
|
579
|
+
f"InkSim is up to date.\n\n"
|
|
580
|
+
f"Installed: {installed}\n"
|
|
581
|
+
f"Latest: {latest}"
|
|
582
|
+
)
|
|
583
|
+
if automatic:
|
|
584
|
+
# Automatic checks surface the result permanently in the window
|
|
585
|
+
# title instead of popping up another dialog. Store only the raw
|
|
586
|
+
# version so we can suppress stale suffixes on the next start.
|
|
587
|
+
self._update_suffix = suffix
|
|
588
|
+
record_result(self.config, stored)
|
|
589
|
+
self._update_window_title()
|
|
590
|
+
return
|
|
591
|
+
QMessageBox.information(self, title, message)
|
|
592
|
+
|
|
502
593
|
def _build_command_dock(self):
|
|
503
594
|
self.command_table = QTableWidget(0, 4, self)
|
|
504
595
|
command_font = self.command_table.font()
|
|
@@ -714,9 +805,33 @@ class MainWindow(QMainWindow):
|
|
|
714
805
|
self._last_geometry = current
|
|
715
806
|
|
|
716
807
|
def _update_window_title(self):
|
|
717
|
-
"""Show layout state in the window title."""
|
|
808
|
+
"""Show layout state and update status in the window title."""
|
|
718
809
|
snap_prefix = "[snap] " if self._layout_state == "snapped" else ""
|
|
719
|
-
self.
|
|
810
|
+
base = self._base_title
|
|
811
|
+
suffix = self._update_suffix
|
|
812
|
+
# The suffix must never repeat the application name.
|
|
813
|
+
if suffix and APP_TITLE in suffix:
|
|
814
|
+
suffix = ""
|
|
815
|
+
self.setWindowTitle(f"{snap_prefix}{base}{suffix}")
|
|
816
|
+
|
|
817
|
+
def _resolve_update_suffix(self, stored: str) -> str:
|
|
818
|
+
"""Return a clean title suffix from the stored version, if any."""
|
|
819
|
+
if not stored or not isinstance(stored, str):
|
|
820
|
+
return ""
|
|
821
|
+
stored = stored.strip()
|
|
822
|
+
installed = current_version()
|
|
823
|
+
# A stored plain version equal to the installed one means we are up to
|
|
824
|
+
# date, so suppress the suffix.
|
|
825
|
+
if stored == installed:
|
|
826
|
+
return ""
|
|
827
|
+
# Legacy verbose values are dropped.
|
|
828
|
+
if "InkSim" in stored or "update:" in stored or "dev:" in stored or " — " in stored:
|
|
829
|
+
return ""
|
|
830
|
+
if is_newer(stored, installed):
|
|
831
|
+
return f" [available version {stored}]"
|
|
832
|
+
if is_newer(installed, stored):
|
|
833
|
+
return f" [development version {installed}]"
|
|
834
|
+
return ""
|
|
720
835
|
|
|
721
836
|
def _update_snap_menu_state(self):
|
|
722
837
|
"""Enable snap save/clear only when the snap layout is active."""
|
|
@@ -742,8 +857,15 @@ class MainWindow(QMainWindow):
|
|
|
742
857
|
import subprocess
|
|
743
858
|
try:
|
|
744
859
|
if os.name == "nt":
|
|
860
|
+
# Suppress the console window that ``tasklist`` would
|
|
861
|
+
# otherwise flash on Windows.
|
|
862
|
+
creationflags = getattr(subprocess, "CREATE_NO_WINDOW", 0)
|
|
745
863
|
result = subprocess.run(
|
|
746
|
-
["tasklist"],
|
|
864
|
+
["tasklist"],
|
|
865
|
+
capture_output=True,
|
|
866
|
+
text=True,
|
|
867
|
+
check=False,
|
|
868
|
+
creationflags=creationflags,
|
|
747
869
|
)
|
|
748
870
|
lowered = result.stdout.lower()
|
|
749
871
|
return ("inkscape.exe" in lowered
|
|
@@ -201,9 +201,10 @@ void main() {
|
|
|
201
201
|
float fine = max(gridLine(v_world.x, 1.0), gridLine(v_world.y, 1.0));
|
|
202
202
|
float fineFade = smoothstep(1.5, 3.0, u_zoom_ratio);
|
|
203
203
|
|
|
204
|
-
// 0.1 mm micro grid for fine thread-width tuning at high zoom.
|
|
204
|
+
// 0.1 mm micro grid for fine thread-width tuning at high zoom. At least
|
|
205
|
+
// 3 px per division is required to avoid aliasing with the pixel grid.
|
|
205
206
|
float micro = max(gridLine(v_world.x, 0.1), gridLine(v_world.y, 0.1));
|
|
206
|
-
float microFade = smoothstep(
|
|
207
|
+
float microFade = smoothstep(30.0, 50.0, u_zoom);
|
|
207
208
|
|
|
208
209
|
float minor = max(gridLine(v_world.x, 10.0), gridLine(v_world.y, 10.0));
|
|
209
210
|
float major = max(gridLine(v_world.x, 50.0), gridLine(v_world.y, 50.0));
|
|
@@ -32,6 +32,7 @@ HELP_SECTIONS = (
|
|
|
32
32
|
| Shift + Right / Left | Next or previous command |
|
|
33
33
|
| Ctrl + Right / Left | Next or previous color |
|
|
34
34
|
| Up / Down | Adjust playback speed while playing |
|
|
35
|
+
| Ctrl + Up / Down | Adjust playback speed anytime |
|
|
35
36
|
| Home / End | First or last stitch |
|
|
36
37
|
| Space | Play or pause |
|
|
37
38
|
| Esc | Finish playback directionally (forward → full design, backward → hide all) |
|
|
@@ -52,7 +53,7 @@ HELP_SECTIONS = (
|
|
|
52
53
|
| J | Cycle jumps: off, all, risky only |
|
|
53
54
|
| X | Toggle density map |
|
|
54
55
|
| B | Cycle background: configured → black → white → configured |
|
|
55
|
-
| E |
|
|
56
|
+
| E | Bottom view (draw later stitches under earlier ones) |
|
|
56
57
|
| Z | Toggle realistic rendering |
|
|
57
58
|
| R | Choose stitch renderer |
|
|
58
59
|
| H | Toggle help |
|
|
@@ -151,9 +151,9 @@ class ViewerShortcutFilter(QObject):
|
|
|
151
151
|
):
|
|
152
152
|
viewer.set_playback_direction(key == Qt.Key_Right)
|
|
153
153
|
handled = True
|
|
154
|
-
elif viewer.is_playing and not is_alt and not is_ctrl and key in (
|
|
154
|
+
elif (viewer.is_playing and not is_alt and not is_ctrl and key in (
|
|
155
155
|
Qt.Key_Up, Qt.Key_Down
|
|
156
|
-
):
|
|
156
|
+
)) or (is_ctrl and not is_alt and key in (Qt.Key_Up, Qt.Key_Down)):
|
|
157
157
|
viewer.adjust_playback_speed(1 if key == Qt.Key_Up else -1)
|
|
158
158
|
handled = True
|
|
159
159
|
elif is_ctrl and key in (Qt.Key_Right, Qt.Key_Left):
|
|
@@ -242,7 +242,7 @@ class ModeBar(QWidget):
|
|
|
242
242
|
tooltips = {
|
|
243
243
|
"Z": "Toggle GPU textured rendering",
|
|
244
244
|
"X": "Toggle stitch density overlay",
|
|
245
|
-
"E": "
|
|
245
|
+
"E": "Bottom view (draw later stitches under earlier ones)",
|
|
246
246
|
"J": "Cycle jump display: off, all, risky only",
|
|
247
247
|
"V": "Toggle stitch visibility",
|
|
248
248
|
"B": "Cycle background: black, white, configured",
|
|
@@ -234,8 +234,13 @@ class InterconnectServer(QObject):
|
|
|
234
234
|
raise ValueError(f"unknown command: {command!r}")
|
|
235
235
|
|
|
236
236
|
|
|
237
|
-
def send_command(command, server_name=IPC_SERVER_NAME, timeout=
|
|
238
|
-
"""Send one command to a running InkSim server and return its response.
|
|
237
|
+
def send_command(command, server_name=IPC_SERVER_NAME, timeout=10000):
|
|
238
|
+
"""Send one command to a running InkSim server and return its response.
|
|
239
|
+
|
|
240
|
+
The timeout is generous because ``open``/``open_and_delete`` load the
|
|
241
|
+
design synchronously on the server before replying, which can take a few
|
|
242
|
+
seconds on Windows.
|
|
243
|
+
"""
|
|
239
244
|
logger.debug("IPC client sending command to %s: %s", server_name, command.get("command"))
|
|
240
245
|
token = read_auth_token()
|
|
241
246
|
if token is None:
|
|
@@ -22,7 +22,14 @@ def render_export_image(
|
|
|
22
22
|
light_factor=0.45,
|
|
23
23
|
scale_factor=1.0,
|
|
24
24
|
):
|
|
25
|
-
"""Render a PNG/WebP/JPEG using the same renderer as the viewer.
|
|
25
|
+
"""Render a PNG/WebP/JPEG using the same renderer as the viewer.
|
|
26
|
+
|
|
27
|
+
A small margin is left around the design bounding box so stitches that
|
|
28
|
+
extend past the strict bounds (thread thickness, shading, etc.) are not
|
|
29
|
+
clipped. The embedded physical-resolution tags are computed from the
|
|
30
|
+
rendering zoom so the design itself imports at the correct real-world size
|
|
31
|
+
in Inkscape; the margin makes the total canvas slightly larger.
|
|
32
|
+
"""
|
|
26
33
|
if renderer_key not in RENDERERS_BY_KEY:
|
|
27
34
|
raise ValueError(f"unknown renderer: {renderer_key}")
|
|
28
35
|
|
|
@@ -94,13 +101,24 @@ def render_export_image(
|
|
|
94
101
|
True,
|
|
95
102
|
)
|
|
96
103
|
painter.end()
|
|
97
|
-
|
|
98
|
-
image
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
# Always set the standard physical-resolution tags (PNG pHYs / JPEG EXIF
|
|
105
|
+
# resolution) so every image viewer/editor can recover the real-world size
|
|
106
|
+
# from pixels-per-meter. `zoom` is the exact pixel-to-mm scale used for the
|
|
107
|
+
# design, so even with a margin the design itself imports at the correct
|
|
108
|
+
# physical size in Inkscape.
|
|
109
|
+
if dpi is None or dpi <= 0:
|
|
110
|
+
dpi = max(1.0, zoom * 25.4)
|
|
111
|
+
dots_per_meter = round(dpi / 0.0254)
|
|
112
|
+
image.setDotsPerMeterX(dots_per_meter)
|
|
113
|
+
image.setDotsPerMeterY(dots_per_meter)
|
|
114
|
+
|
|
115
|
+
# One human-readable comment with the key facts. InkSim-specific tags are
|
|
116
|
+
# secondary to the standard resolution tags above.
|
|
117
|
+
image.setText("InkSim", (
|
|
118
|
+
f"created_by=InkSim; "
|
|
119
|
+
f"design_size_mm={design_width:.3f}x{design_height:.3f}; "
|
|
120
|
+
f"dpi={dpi:.2f}; "
|
|
121
|
+
f"renderer={renderer_key}; "
|
|
122
|
+
f"background={background}"
|
|
123
|
+
))
|
|
106
124
|
return image
|
|
@@ -97,9 +97,15 @@ def render_grid_numba(buf, zoom, pan_x, pan_y):
|
|
|
97
97
|
elif is_major:
|
|
98
98
|
r, g, b = line, line, line
|
|
99
99
|
strength = 30
|
|
100
|
-
|
|
100
|
+
elif solid_centimeter_grid:
|
|
101
101
|
r, g, b = line, line, line
|
|
102
102
|
strength = 18
|
|
103
|
+
else:
|
|
104
|
+
# At low zoom the lines are only a few pixels apart; drawing them
|
|
105
|
+
# as dotted (every 3rd pixel) creates moiré patterns with the
|
|
106
|
+
# screen pixel grid. Draw a continuous but fainter line instead.
|
|
107
|
+
r, g, b = line, line, line
|
|
108
|
+
strength = 9
|
|
103
109
|
|
|
104
110
|
# Keep crowded grids subtle, but make centimeter lines continuous
|
|
105
111
|
# once there is enough room between them.
|
|
@@ -123,9 +129,15 @@ def render_grid_numba(buf, zoom, pan_x, pan_y):
|
|
|
123
129
|
elif is_major:
|
|
124
130
|
r, g, b = line, line, line
|
|
125
131
|
strength = 30
|
|
126
|
-
|
|
132
|
+
elif solid_centimeter_grid:
|
|
127
133
|
r, g, b = line, line, line
|
|
128
134
|
strength = 18
|
|
135
|
+
else:
|
|
136
|
+
# At low zoom the lines are only a few pixels apart; drawing them
|
|
137
|
+
# as dotted (every 3rd pixel) creates moiré patterns with the
|
|
138
|
+
# screen pixel grid. Draw a continuous but fainter line instead.
|
|
139
|
+
r, g, b = line, line, line
|
|
140
|
+
strength = 9
|
|
129
141
|
|
|
130
142
|
for x in range(w):
|
|
131
143
|
if not (is_axis or solid_centimeter_grid) and x % 3 != 0:
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Authors (see git history)
|
|
2
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
3
|
+
|
|
4
|
+
"""Check PyPI for a newer InkSim release.
|
|
5
|
+
|
|
6
|
+
The check is intentionally lightweight and non-blocking: the caller runs it
|
|
7
|
+
on a background thread and only surfaces a result when a newer version is
|
|
8
|
+
available. Network failures are treated as "no update" so a machine without
|
|
9
|
+
internet access never shows an error.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import importlib.metadata
|
|
15
|
+
import json
|
|
16
|
+
import time
|
|
17
|
+
import urllib.request
|
|
18
|
+
|
|
19
|
+
from PySide6.QtCore import QThread, Signal
|
|
20
|
+
|
|
21
|
+
PYPI_JSON_URL = "https://pypi.org/pypi/inksim/json"
|
|
22
|
+
REQUEST_TIMEOUT_S = 5.0
|
|
23
|
+
|
|
24
|
+
# Config keys.
|
|
25
|
+
CONFIG_ENABLED = "update_check_enabled"
|
|
26
|
+
CONFIG_INTERVAL_DAYS = "update_check_interval_days"
|
|
27
|
+
CONFIG_LAST_CHECK = "last_update_check"
|
|
28
|
+
CONFIG_LAST_RESULT = "last_update_result"
|
|
29
|
+
|
|
30
|
+
DEFAULT_INTERVAL_DAYS = 1
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def current_version() -> str:
|
|
34
|
+
"""Return the installed InkSim version, or "0" when unknown."""
|
|
35
|
+
try:
|
|
36
|
+
return importlib.metadata.version("inksim")
|
|
37
|
+
except importlib.metadata.PackageNotFoundError:
|
|
38
|
+
return "0"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _parse_version(version: str) -> tuple:
|
|
42
|
+
"""Split a version string into a comparable tuple of ints."""
|
|
43
|
+
parts = []
|
|
44
|
+
for chunk in version.replace("-", ".").split("."):
|
|
45
|
+
digits = "".join(ch for ch in chunk if ch.isdigit())
|
|
46
|
+
parts.append(int(digits) if digits else 0)
|
|
47
|
+
return tuple(parts)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def is_newer(latest: str, current: str) -> bool:
|
|
51
|
+
"""Return True when *latest* is a newer release than *current*."""
|
|
52
|
+
return _parse_version(latest) > _parse_version(current)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def fetch_latest_version(timeout: float = REQUEST_TIMEOUT_S) -> str | None:
|
|
56
|
+
"""Return the latest published version from PyPI, or None on failure."""
|
|
57
|
+
request = urllib.request.Request(
|
|
58
|
+
PYPI_JSON_URL,
|
|
59
|
+
headers={"User-Agent": "inksim-update-check"},
|
|
60
|
+
)
|
|
61
|
+
try:
|
|
62
|
+
with urllib.request.urlopen(request, timeout=timeout) as response:
|
|
63
|
+
data = json.load(response)
|
|
64
|
+
except (OSError, ValueError):
|
|
65
|
+
return None
|
|
66
|
+
version = data.get("info", {}).get("version")
|
|
67
|
+
return version or None
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def should_check(config, now: float | None = None) -> bool:
|
|
71
|
+
"""Return True when an automatic check is due.
|
|
72
|
+
|
|
73
|
+
The check is skipped when disabled, or when the last check happened more
|
|
74
|
+
recently than the configured interval.
|
|
75
|
+
"""
|
|
76
|
+
if not config.get(CONFIG_ENABLED, True):
|
|
77
|
+
return False
|
|
78
|
+
now = time.time() if now is None else now
|
|
79
|
+
interval_days = config.get(CONFIG_INTERVAL_DAYS, DEFAULT_INTERVAL_DAYS)
|
|
80
|
+
try:
|
|
81
|
+
interval_days = float(interval_days)
|
|
82
|
+
except (TypeError, ValueError):
|
|
83
|
+
interval_days = DEFAULT_INTERVAL_DAYS
|
|
84
|
+
last = config.get(CONFIG_LAST_CHECK)
|
|
85
|
+
if last is None:
|
|
86
|
+
return True
|
|
87
|
+
try:
|
|
88
|
+
last = float(last)
|
|
89
|
+
except (TypeError, ValueError):
|
|
90
|
+
return True
|
|
91
|
+
return (now - last) >= interval_days * 86400.0
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def record_check(config, now: float | None = None) -> None:
|
|
95
|
+
"""Persist the timestamp of the most recent check."""
|
|
96
|
+
config.set(CONFIG_LAST_CHECK, time.time() if now is None else now)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def record_result(config, result: str) -> None:
|
|
100
|
+
"""Persist the human-readable result of the most recent check."""
|
|
101
|
+
config.set(CONFIG_LAST_RESULT, result)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def last_result(config) -> str:
|
|
105
|
+
"""Return the stored result of the most recent check, or ""."""
|
|
106
|
+
return config.get(CONFIG_LAST_RESULT, "") or ""
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def last_check_text(config) -> str:
|
|
110
|
+
"""Return a human-readable description of the last check, if any."""
|
|
111
|
+
last = config.get(CONFIG_LAST_CHECK)
|
|
112
|
+
if last is None:
|
|
113
|
+
return "never"
|
|
114
|
+
try:
|
|
115
|
+
last = float(last)
|
|
116
|
+
except (TypeError, ValueError):
|
|
117
|
+
return "unknown"
|
|
118
|
+
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(last))
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
class UpdateCheckThread(QThread):
|
|
122
|
+
"""Fetch the latest version off the GUI thread and report the result."""
|
|
123
|
+
|
|
124
|
+
result_ready = Signal(str) # latest version, or "" when none/error
|
|
125
|
+
|
|
126
|
+
def run(self):
|
|
127
|
+
latest = fetch_latest_version()
|
|
128
|
+
self.result_ready.emit(latest or "")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/bold_4strand_normal_mask.png
RENAMED
|
File without changes
|
{inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/classic_3strand_cap_mask.png
RENAMED
|
File without changes
|
{inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/classic_3strand_manifest.json
RENAMED
|
File without changes
|
{inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/classic_3strand_normal_mask.png
RENAMED
|
File without changes
|
|
File without changes
|
{inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/fuzzy_3strand_manifest.json
RENAMED
|
File without changes
|
{inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/fuzzy_3strand_normal_mask.png
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/gap_2strand_normal_mask.png
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/loose_twist_normal_mask.png
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/soft_2strand_normal_mask.png
RENAMED
|
File without changes
|
|
File without changes
|
{inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/thick_6strand_manifest.json
RENAMED
|
File without changes
|
{inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/thick_6strand_normal_mask.png
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/thin_2strand_normal_mask.png
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{inksim-0.3.2 → inksim-0.3.10}/src/inksim/assets/thread_textures/tight_twist_normal_mask.png
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|