prkit 0.3.6__tar.gz → 0.3.7__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.
Files changed (28) hide show
  1. {prkit-0.3.6 → prkit-0.3.7}/PKG-INFO +4 -4
  2. {prkit-0.3.6 → prkit-0.3.7}/README.md +3 -3
  3. {prkit-0.3.6 → prkit-0.3.7}/pyproject.toml +1 -1
  4. {prkit-0.3.6 → prkit-0.3.7}/pyproject.toml.orig +1 -1
  5. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/__init__.py +1 -1
  6. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/app.py +2 -2
  7. prkit-0.3.7/src/prkit/icon.py +142 -0
  8. prkit-0.3.6/src/prkit/icon.py +0 -58
  9. {prkit-0.3.6 → prkit-0.3.7}/LICENSE +0 -0
  10. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/__main__.py +0 -0
  11. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/autostart.py +0 -0
  12. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/capslock.py +0 -0
  13. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/cursor_watchdog.py +0 -0
  14. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/input_source.py +0 -0
  15. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/keyboard.py +0 -0
  16. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/keys.py +0 -0
  17. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/language.py +0 -0
  18. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/mac_capslock.py +0 -0
  19. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/mac_keyboard.py +0 -0
  20. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/message_dialog.py +0 -0
  21. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/overlays.py +0 -0
  22. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/platform.py +0 -0
  23. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/py.typed +0 -0
  24. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/settings.py +0 -0
  25. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/single_instance.py +0 -0
  26. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/spotlight.py +0 -0
  27. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/tray.py +0 -0
  28. {prkit-0.3.6 → prkit-0.3.7}/src/prkit/windows_cursor.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: prkit
3
- Version: 0.3.6
3
+ Version: 0.3.7
4
4
  Summary: A cross-platform system-tray presentation toolkit
5
5
  Author: meebox
6
6
  Author-email: meebox <meebox@gmail.com>
@@ -40,8 +40,8 @@ Description-Content-Type: text/markdown
40
40
 
41
41
  | 平台 | 下載檔案 | 啟動方式 |
42
42
  | --- | --- | --- |
43
- | Windows x64 | `PRKit-0.3.6-windows-x64.zip` | 解壓完整資料夾後執行 `PRKit/PRKit.exe` |
44
- | macOS Apple Silicon | `PRKit-0.3.6-macos-arm64.dmg` | 開啟 DMG,將 `PRKit.app` 拖到「Applications」捷徑後啟動 |
43
+ | Windows x64 | `PRKit-0.3.7-windows-x64.zip` | 解壓完整資料夾後執行 `PRKit/PRKit.exe` |
44
+ | macOS Apple Silicon | `PRKit-0.3.7-macos-arm64.dmg` | 開啟 DMG,將 `PRKit.app` 拖到「Applications」捷徑後啟動 |
45
45
 
46
46
  Windows ZIP 包含完整執行環境與游標復原 watchdog;請保留整個 `PRKit` 資料夾。macOS 目前僅提供 Apple Silicon 版。程式啟動後顯示在系統匣/選單列,不會開啟主視窗。若啟用了開機自動啟動,搬移 Windows 資料夾後請在選單取消勾選再重新勾選,以更新啟動路徑。
47
47
 
@@ -74,7 +74,7 @@ uv tool install git+https://github.com/codemee/prkit.git@latest
74
74
  prkit
75
75
  ```
76
76
 
77
- 若要固定特定版本,將 `latest` 改成版本標籤,例如 `v0.3.6`。
77
+ 若要固定特定版本,將 `latest` 改成版本標籤,例如 `v0.3.7`。
78
78
 
79
79
  ## 授權
80
80
 
@@ -21,8 +21,8 @@
21
21
 
22
22
  | 平台 | 下載檔案 | 啟動方式 |
23
23
  | --- | --- | --- |
24
- | Windows x64 | `PRKit-0.3.6-windows-x64.zip` | 解壓完整資料夾後執行 `PRKit/PRKit.exe` |
25
- | macOS Apple Silicon | `PRKit-0.3.6-macos-arm64.dmg` | 開啟 DMG,將 `PRKit.app` 拖到「Applications」捷徑後啟動 |
24
+ | Windows x64 | `PRKit-0.3.7-windows-x64.zip` | 解壓完整資料夾後執行 `PRKit/PRKit.exe` |
25
+ | macOS Apple Silicon | `PRKit-0.3.7-macos-arm64.dmg` | 開啟 DMG,將 `PRKit.app` 拖到「Applications」捷徑後啟動 |
26
26
 
27
27
  Windows ZIP 包含完整執行環境與游標復原 watchdog;請保留整個 `PRKit` 資料夾。macOS 目前僅提供 Apple Silicon 版。程式啟動後顯示在系統匣/選單列,不會開啟主視窗。若啟用了開機自動啟動,搬移 Windows 資料夾後請在選單取消勾選再重新勾選,以更新啟動路徑。
28
28
 
@@ -55,7 +55,7 @@ uv tool install git+https://github.com/codemee/prkit.git@latest
55
55
  prkit
56
56
  ```
57
57
 
58
- 若要固定特定版本,將 `latest` 改成版本標籤,例如 `v0.3.6`。
58
+ 若要固定特定版本,將 `latest` 改成版本標籤,例如 `v0.3.7`。
59
59
 
60
60
  ## 授權
61
61
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "prkit"
3
- version = "0.3.6"
3
+ version = "0.3.7"
4
4
  description = "A cross-platform system-tray presentation toolkit"
5
5
  readme = "README.md"
6
6
  license = "GPL-3.0-or-later"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "prkit"
3
- version = "0.3.6"
3
+ version = "0.3.7"
4
4
  description = "A cross-platform system-tray presentation toolkit"
5
5
  readme = "README.md"
6
6
  license = "GPL-3.0-or-later"
@@ -1,3 +1,3 @@
1
1
  """Presentation tools for the system tray."""
2
2
 
3
- __version__ = "0.3.6"
3
+ __version__ = "0.3.7"
@@ -10,7 +10,7 @@ from PySide6.QtWidgets import QApplication, QMessageBox
10
10
 
11
11
  from prkit import autostart
12
12
  from prkit.capslock import CapsLockMonitor
13
- from prkit.icon import tray_icon
13
+ from prkit.icon import app_icon
14
14
  from prkit.input_source import InputSourceMonitor
15
15
  from prkit.keyboard import KeyboardMonitor
16
16
  from prkit.language import effective_language, set_qt_language, tr
@@ -347,7 +347,7 @@ def create_application(arguments: Sequence[str] | None = None) -> QApplication:
347
347
  app = QApplication(list(arguments) if arguments is not None else sys.argv)
348
348
  app.setOrganizationName("prkit")
349
349
  app.setApplicationName("簡報瑞士刀")
350
- app.setWindowIcon(tray_icon(template=False))
350
+ app.setWindowIcon(app_icon())
351
351
  app.setQuitOnLastWindowClosed(False)
352
352
  set_qt_language(app, SettingsStore().load().language)
353
353
  return app
@@ -0,0 +1,142 @@
1
+ from __future__ import annotations
2
+
3
+ import math
4
+ import sys
5
+
6
+ from PySide6.QtCore import QByteArray, QPointF, QRectF, Qt
7
+ from PySide6.QtGui import (
8
+ QColor,
9
+ QFont,
10
+ QIcon,
11
+ QImage,
12
+ QLinearGradient,
13
+ QPainter,
14
+ QPainterPath,
15
+ QPen,
16
+ QPixmap,
17
+ )
18
+ from PySide6.QtSvg import QSvgRenderer
19
+
20
+ TRAY_ICON_SVG = b"""<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
21
+ <defs><radialGradient id="g"><stop offset="0" stop-color="#fff"/>
22
+ <stop offset=".18" stop-color="#ffb3b3"/><stop offset=".48" stop-color="#f44336"/>
23
+ <stop offset="1" stop-color="#8b0000" stop-opacity=".25"/></radialGradient></defs>
24
+ <circle cx="32" cy="32" r="27" fill="url(#g)"/><circle cx="32" cy="32" r="8" fill="#fff"/>
25
+ </svg>"""
26
+
27
+ # macOS menu bar icons must be monochrome template images: only the alpha
28
+ # channel matters and the system tints them for light/dark menu bars.
29
+ TEMPLATE_ICON_SVG = b"""<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
30
+ <circle cx="32" cy="32" r="24" fill="none" stroke="#000" stroke-width="6"/>
31
+ <circle cx="32" cy="32" r="9" fill="#000"/>
32
+ </svg>"""
33
+
34
+
35
+ def tray_icon(template: bool | None = None) -> QIcon:
36
+ if template is None:
37
+ template = sys.platform == "darwin"
38
+ renderer = QSvgRenderer(QByteArray(TEMPLATE_ICON_SVG if template else TRAY_ICON_SVG))
39
+ icon = QIcon()
40
+ for size in (16, 20, 24, 32, 48, 64):
41
+ pixmap = QPixmap(size, size)
42
+ pixmap.fill("transparent")
43
+ painter = QPainter(pixmap)
44
+ renderer.render(painter)
45
+ painter.end()
46
+ icon.addPixmap(pixmap)
47
+ icon.setIsMask(template)
48
+ return icon
49
+
50
+
51
+ def _squircle(rect: QRectF, exponent: float = 5.0) -> QPainterPath:
52
+ """Apple-style superellipse used by macOS application icons."""
53
+ path = QPainterPath()
54
+ cx, cy = rect.center().x(), rect.center().y()
55
+ half_w, half_h = rect.width() / 2, rect.height() / 2
56
+ steps = 720
57
+ for index in range(steps):
58
+ angle = 2 * math.pi * index / steps
59
+ cos, sin = math.cos(angle), math.sin(angle)
60
+ x = math.copysign(abs(cos) ** (2 / exponent), cos)
61
+ y = math.copysign(abs(sin) ** (2 / exponent), sin)
62
+ point = QPointF(cx + x * half_w, cy + y * half_h)
63
+ if index == 0:
64
+ path.moveTo(point)
65
+ else:
66
+ path.lineTo(point)
67
+ path.closeSubpath()
68
+ return path
69
+
70
+
71
+ def macos_app_icon_image(size: int = 1024) -> QImage:
72
+ """App icon on its own macOS-template squircle.
73
+
74
+ macOS adds a gray backing plate to icons without their own squircle and
75
+ shows full-bleed icons larger than system apps. The squircle therefore
76
+ occupies 824 of 1024 px, leaving room for the shadow like Finder or Maps.
77
+ """
78
+ canvas = 1024
79
+ plate = 824
80
+ margin = (canvas - plate) / 2
81
+ image = QImage(canvas, canvas, QImage.Format.Format_ARGB32_Premultiplied)
82
+ image.fill(Qt.GlobalColor.transparent)
83
+ painter = QPainter(image)
84
+ painter.setRenderHint(QPainter.RenderHint.Antialiasing)
85
+ painter.setRenderHint(QPainter.RenderHint.SmoothPixmapTransform)
86
+ rect = QRectF(margin, margin, plate, plate)
87
+ shape = _squircle(rect)
88
+ # Soft drop shadow: stacked translucent layers, widest first.
89
+ painter.setPen(Qt.PenStyle.NoPen)
90
+ for spread in range(24, 0, -1):
91
+ painter.setBrush(QColor(0, 0, 0, 2))
92
+ painter.drawPath(_squircle(rect.adjusted(-spread, -spread + 10, spread, spread + 10)))
93
+ gradient = QLinearGradient(rect.topLeft(), rect.bottomLeft())
94
+ gradient.setColorAt(0, QColor(250, 252, 254))
95
+ gradient.setColorAt(1, QColor(214, 224, 234))
96
+ painter.setBrush(gradient)
97
+ painter.drawPath(shape)
98
+ glyph = plate * 0.74
99
+ renderer = QSvgRenderer(QByteArray(TRAY_ICON_SVG))
100
+ # The artwork's circle spans 54 of the SVG's 64 units; scale it to the glyph size.
101
+ full = glyph * 64 / 54
102
+ renderer.render(
103
+ painter,
104
+ QRectF((canvas - full) / 2, (canvas - full) / 2 + 6, full, full),
105
+ )
106
+ painter.end()
107
+ if size != canvas:
108
+ return image.scaled(
109
+ size,
110
+ size,
111
+ Qt.AspectRatioMode.IgnoreAspectRatio,
112
+ Qt.TransformationMode.SmoothTransformation,
113
+ )
114
+ return image
115
+
116
+
117
+ def app_icon() -> QIcon:
118
+ """Icon for the Dock/window: identical to the bundle icon on macOS."""
119
+ if sys.platform == "darwin":
120
+ return QIcon(QPixmap.fromImage(macos_app_icon_image(1024)))
121
+ return tray_icon(template=False)
122
+
123
+
124
+ def language_icon(mode: str) -> QIcon:
125
+ pixmap = QPixmap(32, 32)
126
+ pixmap.fill("transparent")
127
+ painter = QPainter(pixmap)
128
+ painter.setRenderHint(QPainter.RenderHint.Antialiasing)
129
+ painter.setPen(QPen(QColor("#202124"), 2))
130
+ if mode == "system":
131
+ painter.drawEllipse(3, 3, 26, 26)
132
+ painter.drawEllipse(10, 3, 12, 26)
133
+ painter.drawLine(4, 16, 28, 16)
134
+ painter.drawLine(7, 9, 25, 9)
135
+ painter.drawLine(7, 23, 25, 23)
136
+ else:
137
+ font = QFont("Arial", 19 if mode == "zh" else 15)
138
+ font.setBold(True)
139
+ painter.setFont(font)
140
+ painter.drawText(pixmap.rect(), 0x84, "中" if mode == "zh" else "En")
141
+ painter.end()
142
+ return QIcon(pixmap)
@@ -1,58 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import sys
4
-
5
- from PySide6.QtCore import QByteArray
6
- from PySide6.QtGui import QColor, QFont, QIcon, QPainter, QPen, QPixmap
7
- from PySide6.QtSvg import QSvgRenderer
8
-
9
- TRAY_ICON_SVG = b"""<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
10
- <defs><radialGradient id="g"><stop offset="0" stop-color="#fff"/>
11
- <stop offset=".18" stop-color="#ffb3b3"/><stop offset=".48" stop-color="#f44336"/>
12
- <stop offset="1" stop-color="#8b0000" stop-opacity=".25"/></radialGradient></defs>
13
- <circle cx="32" cy="32" r="27" fill="url(#g)"/><circle cx="32" cy="32" r="8" fill="#fff"/>
14
- </svg>"""
15
-
16
- # macOS menu bar icons must be monochrome template images: only the alpha
17
- # channel matters and the system tints them for light/dark menu bars.
18
- TEMPLATE_ICON_SVG = b"""<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
19
- <circle cx="32" cy="32" r="24" fill="none" stroke="#000" stroke-width="6"/>
20
- <circle cx="32" cy="32" r="9" fill="#000"/>
21
- </svg>"""
22
-
23
-
24
- def tray_icon(template: bool | None = None) -> QIcon:
25
- if template is None:
26
- template = sys.platform == "darwin"
27
- renderer = QSvgRenderer(QByteArray(TEMPLATE_ICON_SVG if template else TRAY_ICON_SVG))
28
- icon = QIcon()
29
- for size in (16, 20, 24, 32, 48, 64):
30
- pixmap = QPixmap(size, size)
31
- pixmap.fill("transparent")
32
- painter = QPainter(pixmap)
33
- renderer.render(painter)
34
- painter.end()
35
- icon.addPixmap(pixmap)
36
- icon.setIsMask(template)
37
- return icon
38
-
39
-
40
- def language_icon(mode: str) -> QIcon:
41
- pixmap = QPixmap(32, 32)
42
- pixmap.fill("transparent")
43
- painter = QPainter(pixmap)
44
- painter.setRenderHint(QPainter.RenderHint.Antialiasing)
45
- painter.setPen(QPen(QColor("#202124"), 2))
46
- if mode == "system":
47
- painter.drawEllipse(3, 3, 26, 26)
48
- painter.drawEllipse(10, 3, 12, 26)
49
- painter.drawLine(4, 16, 28, 16)
50
- painter.drawLine(7, 9, 25, 9)
51
- painter.drawLine(7, 23, 25, 23)
52
- else:
53
- font = QFont("Arial", 19 if mode == "zh" else 15)
54
- font.setBold(True)
55
- painter.setFont(font)
56
- painter.drawText(pixmap.rect(), 0x84, "中" if mode == "zh" else "En")
57
- painter.end()
58
- return QIcon(pixmap)
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