Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): add configurable splash screens #703

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
},
"play_icon": {
"path": "qt/images/play.svg",
"mode": "rb"
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
Loading