Skip to content

Commit

Permalink
feat(ui): add configurable splash screens (#703)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
CyanVoxel authored Jan 23, 2025
1 parent 857f40f commit a02c43c
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 25,477 deletions.
Binary file removed tagstudio/resources/qt/images/splash.png
Binary file not shown.
Binary file added tagstudio/resources/qt/images/splash/classic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 16 additions & 6 deletions tagstudio/src/qt/resource_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

import structlog
import ujson
from PIL import Image
from PIL import (
Image,
ImageQt,
)
from PySide6.QtGui import QPixmap

logger = structlog.get_logger(__name__)

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

@staticmethod
Expand Down Expand Up @@ -76,12 +83,15 @@ def get(self, id: str) -> Any:
elif res and res.get("mode") == "pil":
data = Image.open(ResourceManager._res_folder / "resources" / res.get("path"))
return data
elif res.get("mode") in ["qt"]:
# TODO: Qt resource loading logic
pass
elif res.get("mode") in ["qpixmap"]:
data = Image.open(ResourceManager._res_folder / "resources" / res.get("path"))
qim = ImageQt.ImageQt(data)
pixmap = QPixmap.fromImage(qim)
ResourceManager._cache[id] = pixmap
return pixmap
except FileNotFoundError:
path: Path = ResourceManager._res_folder / "resources" / res.get("path")
logger.error("[ResourceManager][ERROR]: Could not find resource: ", path)
logger.error("[ResourceManager][ERROR]: Could not find resource: ", path=path)
return None

def __getattr__(self, __name: str) -> Any:
Expand Down
8 changes: 8 additions & 0 deletions tagstudio/src/qt/resources.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"splash_classic": {
"path": "qt/images/splash/classic.png",
"mode": "qpixmap"
},
"splash_goo_gears": {
"path": "qt/images/splash/goo_gears.png",
"mode": "qpixmap"
},
"logo": {
"path": "icon.png",
"mode": "pil"
Expand Down
1 change: 0 additions & 1 deletion tagstudio/src/qt/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
<!-- <file alias = "images/edit_icon_128.png">../../resources/qt/images/edit_icon_128.png</file> -->
<!-- <file alias = "images/trash_icon_128.png">../../resources/qt/images/trash_icon_128.png</file> -->
<!-- <file alias = "images/clipboard_icon_128.png">../../resources/qt/images/clipboard_icon_128.png</file> -->
<file alias = "images/splash.png">../../resources/qt/images/splash.png</file>
</qresource>
</RCC>
Loading

0 comments on commit a02c43c

Please sign in to comment.