Skip to content

Commit a02c43c

Browse files
authored
feat(ui): add configurable splash screens (#703)
* refactor: move splash images to resource_manager * feat(ui): add new splash screen widget * style: restore old resource manager log style * fix: scale font size for Segoe UI
1 parent 857f40f commit a02c43c

File tree

9 files changed

+204
-25477
lines changed

9 files changed

+204
-25477
lines changed
-397 KB
Binary file not shown.
Loading
Loading

tagstudio/src/qt/resource_manager.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77

88
import structlog
99
import ujson
10-
from PIL import Image
10+
from PIL import (
11+
Image,
12+
ImageQt,
13+
)
14+
from PySide6.QtGui import QPixmap
1115

1216
logger = structlog.get_logger(__name__)
1317

@@ -25,7 +29,10 @@ def __init__(self) -> None:
2529
if not ResourceManager._initialized:
2630
with open(Path(__file__).parent / "resources.json", encoding="utf-8") as f:
2731
ResourceManager._map = ujson.load(f)
28-
logger.info("resources registered", count=len(ResourceManager._map.items()))
32+
logger.info(
33+
"[ResourceManager] Resources Registered:",
34+
count=len(ResourceManager._map.items()),
35+
)
2936
ResourceManager._initialized = True
3037

3138
@staticmethod
@@ -76,12 +83,15 @@ def get(self, id: str) -> Any:
7683
elif res and res.get("mode") == "pil":
7784
data = Image.open(ResourceManager._res_folder / "resources" / res.get("path"))
7885
return data
79-
elif res.get("mode") in ["qt"]:
80-
# TODO: Qt resource loading logic
81-
pass
86+
elif res.get("mode") in ["qpixmap"]:
87+
data = Image.open(ResourceManager._res_folder / "resources" / res.get("path"))
88+
qim = ImageQt.ImageQt(data)
89+
pixmap = QPixmap.fromImage(qim)
90+
ResourceManager._cache[id] = pixmap
91+
return pixmap
8292
except FileNotFoundError:
8393
path: Path = ResourceManager._res_folder / "resources" / res.get("path")
84-
logger.error("[ResourceManager][ERROR]: Could not find resource: ", path)
94+
logger.error("[ResourceManager][ERROR]: Could not find resource: ", path=path)
8595
return None
8696

8797
def __getattr__(self, __name: str) -> Any:

tagstudio/src/qt/resources.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
{
2+
"splash_classic": {
3+
"path": "qt/images/splash/classic.png",
4+
"mode": "qpixmap"
5+
},
6+
"splash_goo_gears": {
7+
"path": "qt/images/splash/goo_gears.png",
8+
"mode": "qpixmap"
9+
},
210
"logo": {
311
"path": "icon.png",
412
"mode": "pil"

tagstudio/src/qt/resources.qrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
<!-- <file alias = "images/edit_icon_128.png">../../resources/qt/images/edit_icon_128.png</file> -->
99
<!-- <file alias = "images/trash_icon_128.png">../../resources/qt/images/trash_icon_128.png</file> -->
1010
<!-- <file alias = "images/clipboard_icon_128.png">../../resources/qt/images/clipboard_icon_128.png</file> -->
11-
<file alias = "images/splash.png">../../resources/qt/images/splash.png</file>
1211
</qresource>
1312
</RCC>

0 commit comments

Comments
 (0)