mirror of
https://github.com/darkzoul5/YoutubePlaylistSync.git
synced 2026-09-22 06:12:21 +03:00
feat: add app version to about page
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _resource_base() -> Path:
|
||||
# PyInstaller sets sys._MEIPASS to the temp extraction dir.
|
||||
base = getattr(sys, "_MEIPASS", None)
|
||||
if base:
|
||||
return Path(str(base))
|
||||
return Path.cwd()
|
||||
|
||||
|
||||
def _read_text(path: Path) -> str | None:
|
||||
try:
|
||||
if path.exists():
|
||||
text = path.read_text(encoding="utf-8").strip()
|
||||
return text or None
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
def get_app_version() -> str:
|
||||
"""
|
||||
Returns the packaged app version.
|
||||
|
||||
In release builds this reads from `version.txt` bundled into the EXE.
|
||||
"""
|
||||
candidates = [
|
||||
Path("version.txt"),
|
||||
_resource_base() / "version.txt",
|
||||
]
|
||||
for candidate in candidates:
|
||||
text = _read_text(candidate)
|
||||
if text:
|
||||
return text
|
||||
|
||||
return "dev"
|
||||
@@ -2,6 +2,8 @@ from __future__ import annotations
|
||||
|
||||
from PySide6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
from ...core.utils.version import get_app_version
|
||||
|
||||
|
||||
class AboutPage(QtWidgets.QWidget):
|
||||
def __init__(self, parent: QtWidgets.QWidget | None = None) -> None:
|
||||
@@ -79,6 +81,10 @@ class AboutPage(QtWidgets.QWidget):
|
||||
author = self._muted_label("Dark_Zoul")
|
||||
form.addRow("Author", author)
|
||||
|
||||
version_text = get_app_version()
|
||||
version = self._muted_label(f"v{version_text}" if version_text != "unknown" else version_text)
|
||||
form.addRow("Version", version)
|
||||
|
||||
repo_row = QtWidgets.QHBoxLayout()
|
||||
repo_row.setContentsMargins(0, 0, 0, 0)
|
||||
repo_row.setSpacing(10)
|
||||
|
||||
Reference in New Issue
Block a user