cleanup what I just did

This commit is contained in:
2026-06-28 09:09:06 -07:00
parent 617daa0e9b
commit f10eb64332
16 changed files with 77 additions and 64 deletions
+71
View File
@@ -0,0 +1,71 @@
from PySide6.QtWidgets import QTextBrowser, QVBoxLayout, QLabel, QDialog, QHBoxLayout, QPushButton
from PySide6.QtGui import QDesktopServices, QIcon
from PySide6.QtCore import QUrl
from PySide6.QtNetwork import QNetworkAccessManager, QNetworkRequest
from src.shared.shareddata import APP_NAME, CURRENT_VERSION, resource_path
class WelcomeDialog(QDialog):
def __init__(self, parent=None, direct=True):
super().__init__(parent)
self.setWindowTitle(f"What's New - {APP_NAME.upper()}")
self.setMinimumSize(550, 450)
self.resize(800, 500)
# Main Layout
layout = QVBoxLayout(self)
# Header Layout (Logo + App Name)
header_layout = QHBoxLayout()
logo_label = QLabel(self)
logo_label.setPixmap(QIcon(resource_path("icons/main.ico")).pixmap(48, 48)) # Fits cleanly in a header
if direct:
title_label = QLabel(f"<h2>{APP_NAME.upper()} has been sucessfully updated to version {CURRENT_VERSION}!</h2>", self)
else:
title_label = QLabel(f"<h2>{APP_NAME.upper()} is currently running version {CURRENT_VERSION}.</h2>", self)
header_layout.addWidget(logo_label)
header_layout.addWidget(title_label)
header_layout.addStretch()
layout.addLayout(header_layout)
# Text Browser Area (Automatically converts Markdown syntax into clean formatted UI text)
self.text_browser = QTextBrowser(self)
self.text_browser.setHtml("<p style='color: gray;'>Loading latest updates from server...</p>")
self.text_browser.setOpenLinks(False) # Don't open links inside the viewer
self.text_browser.anchorClicked.connect(QDesktopServices.openUrl)
layout.addWidget(self.text_browser)
# Footer Controls Layout
footer_layout = QHBoxLayout()
ok_button = QPushButton("OK", self)
ok_button.setDefault(True)
ok_button.clicked.connect(self.accept) # Closes the dialog with a success signal
footer_layout.addStretch()
footer_layout.addWidget(ok_button)
layout.addLayout(footer_layout)
# Fetch markdown from the web asynchronously
self.network_manager = QNetworkAccessManager(self)
self.network_manager.finished.connect(self._on_download_complete)
md_url = "https://git.research.dezeeuw.ca/tyler/flares/raw/branch/main/changelog_major.md"
self.network_manager.get(QNetworkRequest(QUrl(md_url)))
def _on_download_complete(self, reply):
"""Processes the downloaded markdown and drops it into the view frame."""
if reply.error() == reply.NetworkError.NoError:
raw_bytes = reply.readAll()
# Convert raw bytes to standard text string
markdown_text = str(raw_bytes, encoding='utf-8')
# Qt's QTextBrowser natively renders markdown arrays beautifully!
self.text_browser.setMarkdown(markdown_text)
else:
self.text_browser.setHtml(
f"<p style='color: red;'><b>Failed to load content.</b><br>Error: {reply.errorString()}</p>"
)
reply.deleteLater()