Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

frontend-qt: the dark card look of the SwiftUI app, and a Windows/macOS build workflow

LNPANDY64f036ff6e54
diff --git a/.github/workflows/build-qt.yml b/.github/workflows/build-qt.yml
new file mode 100644
index 00000000..4d1add00
--- /dev/null
+++ b/.github/workflows/build-qt.yml
@@ -0,0 +1,89 @@
+# Build the Qt front end for Windows and macOS and attach it to a release.
+#
+# PyInstaller cannot cross-compile: a Windows .exe must be built on Windows and a Mac .app on
+# macOS. This workflow runs both on GitHub's runners, so a release carries both without anyone
+# needing a local toolchain.
+#
+# - push a tag vX.Y.Z → both builds run, attached to that release
+# - workflow_dispatch → both builds run, uploaded as workflow artifacts only
+name: Build NS Port Builder (Qt)
+
+on:
+ push:
+ tags: ['v*']
+ workflow_dispatch:
+
+permissions:
+ contents: write
+
+jobs:
+ build:
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os: windows-latest
+ artifact: NS-Port-Builder-qt-windows-x64
+ sep: ';'
+ - os: macos-latest
+ artifact: NS-Port-Builder-qt-macos-arm64
+ sep: ':'
+ runs-on: ${{ matrix.os }}
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: actions/setup-python@v5
+ with:
+ python-version: '3.12'
+
+ - name: Install PySide6 and PyInstaller
+ run: |
+ python -m pip install --upgrade pip
+ python -m pip install PySide6 pyinstaller
+
+ - name: Generate the localisation table
+ run: python frontend-qt/gen_localization.py
+
+ - name: Build
+ working-directory: frontend-qt
+ shell: bash
+ run: |
+ # --windowed: no console window. --name: the exe/bundle name.
+ # --collect-all PySide6 keeps the Qt plugins (platforms/, styles/) that a
+ # windowed build otherwise drops, which is the usual "could not find the
+ # Qt platform plugin windows" failure.
+ pyinstaller --noconfirm --clean --windowed \
+ --name "NS Port Builder" \
+ --collect-all PySide6 \
+ --paths . \
+ run_gui.py
+
+ - name: Package (Windows)
+ if: runner.os == 'Windows'
+ shell: bash
+ run: |
+ cd frontend-qt/dist
+ powershell -Command "Compress-Archive -Path 'NS Port Builder' -DestinationPath '../${{ matrix.artifact }}.zip'"
+
+ - name: Package (macOS)
+ if: runner.os == 'macOS'
+ shell: bash
+ run: |
+ cd frontend-qt/dist
+ ditto -c -k --keepParent "NS Port Builder.app" "../${{ matrix.artifact }}.zip"
+
+ - uses: actions/upload-artifact@v4
+ with:
+ name: ${{ matrix.artifact }}
+ path: frontend-qt/${{ matrix.artifact }}.zip
+ if-no-files-found: error
+
+ - name: Attach to the release
+ if: startsWith(github.ref, 'refs/tags/')
+ shell: bash
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1 || \
+ gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes "Qt front end build"
+ gh release upload "$GITHUB_REF_NAME" "frontend-qt/${{ matrix.artifact }}.zip" --clobber
diff --git a/frontend-qt/nspb_qt/__main__.py b/frontend-qt/nspb_qt/__main__.py
index 897d0e14..2e0894e8 100644
--- a/frontend-qt/nspb_qt/__main__.py
+++ b/frontend-qt/nspb_qt/__main__.py
@@ -6,6 +6,7 @@ import sys
from PySide6.QtWidgets import QApplication
from .model import Model
+from .style import STYLE
from .ui import MainWindow
@@ -13,6 +14,8 @@ def main() -> int:
app = QApplication(sys.argv)
app.setApplicationName('NS Port Builder')
app.setApplicationDisplayName('NS Port Builder')
+ app.setStyleSheet(STYLE)
+ app.setStyle('Fusion') # the same widget look on Windows and macOS
model = Model()
win = MainWindow(model)
win.show()
diff --git a/frontend-qt/nspb_qt/style.py b/frontend-qt/nspb_qt/style.py
new file mode 100644
index 00000000..03e7b420
--- /dev/null
+++ b/frontend-qt/nspb_qt/style.py
@@ -0,0 +1,135 @@
+"""Visual language: the dark card look of the SwiftUI app, in Qt style sheets.
+
+The SwiftUI window uses rounded cards on a dark background, a coloured dot per state and
+monospaced secondary text. Qt can do all of that with a style sheet; keeping it in one module
+means the two front ends stay recognisable as the same product.
+"""
+from __future__ import annotations
+
+# The palette, taken from the SwiftUI app's screenshots.
+BG = '#1c1f24' # window background
+CARD = '#252a31' # a card's fill
+CARD_EDGE = '#31373f' # a card's hairline
+TEXT = '#e6e9ed'
+MUTED = '#8b949e'
+GREEN = '#34c759' # ok / done
+ORANGE = '#ff9f0a' # attention
+RED = '#ff453a' # missing / failed
+ACCENT = '#0a84ff' # buttons
+
+STYLE = f"""
+QMainWindow, QDialog, QScrollArea, QWidget#body {{
+ background: {BG};
+}}
+QWidget {{
+ color: {TEXT};
+ font-size: 13px;
+}}
+QLabel {{
+ background: transparent;
+}}
+
+QScrollArea > QWidget > QWidget {{
+ background: {BG};
+}}
+
+/* ---- cards: a plain frame, the title is a label inside it ---- */
+QFrame#card {{
+ background: {CARD};
+ border: 1px solid {CARD_EDGE};
+ border-radius: 10px;
+}}
+
+/* ---- buttons ---- */
+QPushButton {{
+ background: #333a43;
+ border: 1px solid #3d444d;
+ border-radius: 7px;
+ padding: 6px 14px;
+ color: {TEXT};
+}}
+QPushButton:hover {{ background: #3c444e; }}
+QPushButton:pressed {{ background: #2b3138; }}
+QPushButton:disabled {{ color: #5c646e; background: #2a2f36; border-color: #333940; }}
+
+QPushButton#primary {{
+ background: {ACCENT};
+ border: none;
+ color: white;
+ font-size: 14px;
+ font-weight: 600;
+ padding: 9px 20px;
+}}
+QPushButton#primary:hover {{ background: #3a9bff; }}
+QPushButton#primary:disabled {{ background: #2c3a4a; color: #6b7683; }}
+
+QPushButton#danger {{
+ background: {RED};
+ border: none;
+ color: white;
+ font-size: 14px;
+ font-weight: 600;
+ padding: 9px 20px;
+}}
+
+/* ---- labels ---- */
+QLabel#title {{ font-size: 26px; font-weight: 700; background: transparent; }}
+QLabel#subtitle {{ color: {MUTED}; font-size: 13px; background: transparent; }}
+QLabel#note {{ color: {MUTED}; font-size: 12px; background: transparent; }}
+QLabel#mono {{ color: {MUTED}; font-family: Menlo, Consolas, monospace; font-size: 12px; background: transparent; }}
+QLabel#ok {{ color: {GREEN}; font-weight: 600; background: transparent; }}
+QLabel#warn {{ color: {ORANGE}; font-weight: 600; }}
+QLabel#bad {{ color: {RED}; font-weight: 600; background: transparent; }}
+QLabel#rowname {{ font-size: 14px; background: transparent; }}
+QLabel#footer {{ color: {MUTED}; font-size: 12px; padding: 8px 4px; background: transparent; }}
+
+/* ---- the log ---- */
+QTextEdit {{
+ background: #14171b;
+ border: 1px solid {CARD_EDGE};
+ border-radius: 8px;
+ padding: 8px;
+ color: #b9c2cc;
+ font-family: Menlo, Consolas, monospace;
+ font-size: 11px;
+}}
+
+/* ---- progress ---- */
+QProgressBar {{
+ background: #2a2f36;
+ border: none;
+ border-radius: 4px;
+ height: 7px;
+ text-align: center;
+ color: transparent;
+}}
+QProgressBar::chunk {{
+ background: {GREEN};
+ border-radius: 4px;
+}}
+
+/* ---- scrollbars ---- */
+QScrollBar:vertical {{
+ background: transparent;
+ width: 10px;
+ margin: 0;
+}}
+QScrollBar::handle:vertical {{
+ background: #3d444d;
+ border-radius: 5px;
+ min-height: 30px;
+}}
+QScrollBar::handle:vertical:hover {{ background: #4a525c; }}
+QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {{ height: 0; }}
+QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {{ background: transparent; }}
+
+/* ---- dialogs inherit the dark look ---- */
+QFileDialog, QMessageBox {{ background: {BG}; }}
+QLineEdit, QComboBox {{
+ background: #2a2f36;
+ border: 1px solid {CARD_EDGE};
+ border-radius: 6px;
+ padding: 5px 8px;
+ color: {TEXT};
+}}
+"""
diff --git a/frontend-qt/nspb_qt/ui.py b/frontend-qt/nspb_qt/ui.py
index fa0b65ce..086b0f9a 100644
--- a/frontend-qt/nspb_qt/ui.py
+++ b/frontend-qt/nspb_qt/ui.py
@@ -1,19 +1,22 @@
-"""The window: header, repository, inputs, dependencies, build, log. Mirrors the SwiftUI app."""
+"""The window: header, repository, inputs, dependencies, build progress, log.
+
+The layout follows the SwiftUI app section for section, so a user who has seen one recognises
+the other: rounded cards on a dark background, a coloured dot per row, monospaced paths.
+"""
from __future__ import annotations
-import os
from pathlib import Path
-from PySide6.QtCore import Qt, QTimer
-from PySide6.QtGui import QFont, QFontDatabase
+from PySide6.QtCore import Qt
+from PySide6.QtGui import QFontDatabase
from PySide6.QtWidgets import (
- QCheckBox, QFileDialog, QFrame, QGridLayout, QGroupBox, QHBoxLayout, QLabel,
- QMainWindow, QMessageBox, QProgressBar, QPushButton, QScrollArea, QSizePolicy,
- QTextEdit, QVBoxLayout, QWidget,
+ QFileDialog, QFrame, QGridLayout, QHBoxLayout, QLabel, QMainWindow,
+ QProgressBar, QPushButton, QScrollArea, QSizePolicy, QTextEdit, QVBoxLayout, QWidget,
)
from . import platform_util as pu
-from .model import Dep, DepState, Model
+from .model import DepState, Model
+from .style import GREEN, MUTED, ORANGE, RED
class MainWindow(QMainWindow):
@@ -21,7 +24,7 @@ class MainWindow(QMainWindow):
super().__init__()
self.m = model
self.setWindowTitle('NS Port Builder')
- self.resize(980, 900)
+ self.resize(1000, 980)
self._mono = QFontDatabase.systemFont(QFontDatabase.FixedFont)
root = QWidget()
@@ -34,9 +37,10 @@ class MainWindow(QMainWindow):
scroll.setWidgetResizable(True)
scroll.setFrameShape(QFrame.NoFrame)
body = QWidget()
+ body.setObjectName('body')
self.body = QVBoxLayout(body)
- self.body.setContentsMargins(16, 14, 16, 14)
- self.body.setSpacing(12)
+ self.body.setContentsMargins(22, 20, 22, 18)
+ self.body.setSpacing(14)
scroll.setWidget(body)
outer.addWidget(scroll, 1)
@@ -44,7 +48,7 @@ class MainWindow(QMainWindow):
self._build_repository()
self._build_inputs()
self._build_deps()
- self._build_actions()
+ self._build_progress()
self._build_log()
outer.addWidget(self._separator())
self._build_footer()
@@ -59,20 +63,23 @@ class MainWindow(QMainWindow):
self._refresh_all()
self.m.check_deps()
- # ---------------------------------------------------------------- sections
+ # ---------------------------------------------------------------- header
def _build_header(self) -> None:
row = QHBoxLayout()
- title = QLabel('NS Port Builder')
- f = title.font()
- f.setPointSize(20)
- f.setBold(True)
- title.setFont(f)
- self.subtitle = QLabel(self.m.t('app.subtitle'))
- self.subtitle.setStyleSheet('color: palette(mid);')
+ row.setSpacing(14)
+ badge = QLabel('🎮')
+ badge.setFixedSize(54, 54)
+ badge.setAlignment(Qt.AlignCenter)
+ badge.setStyleSheet(f'background: {GREEN}; border-radius: 13px; font-size: 26px;')
+ row.addWidget(badge)
left = QVBoxLayout()
- left.setSpacing(2)
- left.addWidget(title)
+ left.setSpacing(3)
+ self.title = QLabel('NS Port Builder')
+ self.title.setObjectName('title')
+ self.subtitle = QLabel(self.m.t('app.subtitle'))
+ self.subtitle.setObjectName('subtitle')
+ left.addWidget(self.title)
left.addWidget(self.subtitle)
row.addLayout(left)
row.addStretch(1)
@@ -81,16 +88,40 @@ class MainWindow(QMainWindow):
row.addWidget(self.lang_btn, 0, Qt.AlignTop)
self.body.addLayout(row)
+ # ---------------------------------------------------------------- cards
+
+ def _card(self, title: str, note: str = '') -> tuple[QFrame, QVBoxLayout]:
+ box = QFrame()
+ box.setObjectName('card')
+ lay = QVBoxLayout(box)
+ lay.setContentsMargins(18, 16, 18, 16)
+ lay.setSpacing(10)
+ head = QHBoxLayout()
+ head.setSpacing(8)
+ t = QLabel(title)
+ f = t.font()
+ f.setBold(True)
+ f.setPointSize(13)
+ t.setFont(f)
+ head.addWidget(t)
+ if note:
+ n = QLabel(note)
+ n.setObjectName('note')
+ head.addWidget(n)
+ head.addStretch(1)
+ lay.addLayout(head)
+ self.body.addWidget(box)
+ return box, lay
+
def _build_repository(self) -> None:
- box = QGroupBox(self.m.t('repo.title'))
+ box, lay = self._card(self.m.t('repo.title'), self.m.t('repo.note'))
self.repo_box = box
- lay = QVBoxLayout(box)
- note = QLabel(self.m.t('repo.note'))
- note.setStyleSheet('color: palette(mid);')
- lay.addWidget(note)
row = QHBoxLayout()
+ self.repo_dot = QLabel('●')
+ self.repo_dot.setFixedWidth(14)
+ row.addWidget(self.repo_dot)
self.repo_path_label = QLabel('')
- self.repo_path_label.setFont(self._mono)
+ self.repo_path_label.setObjectName('mono')
self.repo_path_label.setTextInteractionFlags(Qt.TextSelectableByMouse)
row.addWidget(self.repo_path_label, 1)
self.choose_btn = QPushButton(self.m.t('repo.choose'))
@@ -98,76 +129,71 @@ class MainWindow(QMainWindow):
row.addWidget(self.choose_btn)
lay.addLayout(row)
self.repo_status = QLabel('')
- self.repo_status.setStyleSheet('color: palette(mid);')
+ self.repo_status.setObjectName('note')
lay.addWidget(self.repo_status)
- box.setStyleSheet('QGroupBox { margin-top: 10px; padding-top: 6px; } QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 4px; }')
- self.body.addWidget(box)
def _build_inputs(self) -> None:
- box = QGroupBox(self.m.t('data.title'))
+ box, lay = self._card(self.m.t('data.title'), self.m.t('data.note'))
self.data_box = box
- lay = QVBoxLayout(box)
- note = QLabel(self.m.t('data.note'))
- note.setStyleSheet('color: palette(mid);')
- lay.addWidget(note)
+ self.folder_label = QLabel(self.m.t('data.folderHint'))
+ self.folder_label.setObjectName('mono')
+ lay.addWidget(self.folder_label)
grid = QGridLayout()
- grid.setColumnStretch(1, 1)
- self.input_labels: dict[str, QLabel] = {}
- rows = [('base', 'data.base'), ('update', 'data.update'), ('dlc', 'data.dlc'), ('keys', 'data.keys')]
- for i, (key, l10n) in enumerate(rows):
+ grid.setHorizontalSpacing(10)
+ grid.setVerticalSpacing(9)
+ grid.setColumnStretch(2, 1)
+ self.input_rows: dict[str, tuple[QLabel, QLabel]] = {}
+ specs = [('base', 'data.base', False), ('update', 'data.update', True),
+ ('dlc', 'data.dlc', True), ('keys', 'data.keys', False)]
+ for i, (key, l10n, optional) in enumerate(specs):
+ dot = QLabel('○')
+ dot.setFixedWidth(14)
name = QLabel(self.m.t(l10n))
+ name.setFixedWidth(150)
val = QLabel('—')
- val.setFont(self._mono)
+ val.setObjectName('mono')
val.setTextInteractionFlags(Qt.TextSelectableByMouse)
- val.setStyleSheet('color: palette(mid);')
- grid.addWidget(name, i, 0)
- grid.addWidget(val, i, 1)
- self.input_labels[key] = val
+ btn = QPushButton(self.m.t('data.choose'))
+ btn.setFixedWidth(92)
+ btn.clicked.connect(lambda _=False, k=key: self._choose_input(k))
+ grid.addWidget(dot, i, 0)
+ grid.addWidget(name, i, 1)
+ grid.addWidget(val, i, 2)
+ grid.addWidget(btn, i, 3)
+ self.input_rows[key] = (dot, val)
lay.addLayout(grid)
row = QHBoxLayout()
- self.folder_label = QLabel(self.m.t('data.folderHint'))
- self.folder_label.setStyleSheet('color: palette(mid);')
- row.addWidget(self.folder_label, 1)
+ row.addStretch(1)
pick = QPushButton(self.m.t('data.pickFolder'))
pick.clicked.connect(self._pick_folder)
row.addWidget(pick)
lay.addLayout(row)
- box.setStyleSheet('QGroupBox { margin-top: 10px; padding-top: 6px; } QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 4px; }')
- self.body.addWidget(box)
def _build_deps(self) -> None:
- box = QGroupBox(self.m.t('dep.title'))
+ box, lay = self._card(self.m.t('dep.title'))
self.deps_box = box
- lay = QVBoxLayout(box)
head = QHBoxLayout()
self.deps_summary = QLabel('')
- head.addWidget(self.deps_summary, 1)
+ head.addWidget(self.deps_summary)
+ head.addStretch(1)
recheck = QPushButton(self.m.t('dep.recheck'))
recheck.clicked.connect(self.m.check_deps)
head.addWidget(recheck)
lay.addLayout(head)
self.deps_container = QVBoxLayout()
+ self.deps_container.setSpacing(7)
lay.addLayout(self.deps_container)
- box.setStyleSheet('QGroupBox { margin-top: 10px; padding-top: 6px; } QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 4px; }')
- self.body.addWidget(box)
- def _build_actions(self) -> None:
- row = QHBoxLayout()
- self.build_btn = QPushButton(self.m.t('build.start'))
- self.build_btn.setMinimumHeight(38)
- f = self.build_btn.font()
- f.setPointSize(13)
- f.setBold(True)
- self.build_btn.setFont(f)
- self.build_btn.clicked.connect(self.m.start_build)
- row.addWidget(self.build_btn, 1)
- self.out_btn = QPushButton(self.m.t('build.outDir'))
- self.out_btn.clicked.connect(self._choose_out)
- row.addWidget(self.out_btn)
- self.body.addLayout(row)
+ def _build_progress(self) -> None:
+ box, lay = self._card(self.m.t('prog.title'))
+ self.progress_box = box
+ self.progress_box.setVisible(False)
+ self.overall = QProgressBar()
+ self.overall.setTextVisible(False)
+ lay.addWidget(self.overall)
self.stages_container = QVBoxLayout()
- self.body.addLayout(self.stages_container)
- self.body.addStretch(1)
+ self.stages_container.setSpacing(7)
+ lay.addLayout(self.stages_container)
def _build_log(self) -> None:
self.log = QTextEdit()
@@ -179,19 +205,28 @@ class MainWindow(QMainWindow):
self.body.addWidget(self.log, 1)
def _build_footer(self) -> None:
- row = QHBoxLayout()
- row.setContentsMargins(16, 8, 16, 10)
+ wrap = QWidget()
+ row = QHBoxLayout(wrap)
+ row.setContentsMargins(22, 10, 22, 12)
+ row.setSpacing(10)
+ self.build_btn = QPushButton(self.m.t('build.start'))
+ self.build_btn.setObjectName('primary')
+ self.build_btn.setMinimumWidth(150)
+ self.build_btn.clicked.connect(self._build_clicked)
+ row.addWidget(self.build_btn)
self.footer = QLabel('')
+ self.footer.setObjectName('footer')
row.addWidget(self.footer, 1)
- wrap = QWidget()
- wrap.setLayout(row)
+ self.out_btn = QPushButton(self.m.t('build.outDir'))
+ self.out_btn.clicked.connect(self._choose_out)
+ row.addWidget(self.out_btn)
self.centralWidget().layout().addWidget(wrap)
@staticmethod
def _separator() -> QFrame:
line = QFrame()
line.setFrameShape(QFrame.HLine)
- line.setFrameShadow(QFrame.Sunken)
+ line.setStyleSheet('color: #31373f;')
return line
# ---------------------------------------------------------------- refresh
@@ -199,28 +234,42 @@ class MainWindow(QMainWindow):
def _refresh_all(self) -> None:
self.subtitle.setText(self.m.t('app.subtitle'))
self.lang_btn.setText(self.m.lang.toggle_label)
- self.repo_box.setTitle(self.m.t('repo.title'))
- self.choose_btn.setText(self.m.t('repo.choose'))
- self.data_box.setTitle(self.m.t('data.title'))
- self.deps_box.setTitle(self.m.t('dep.title'))
+ self.repo_path_label.setText(
+ pu.short_path(self.m.repo_path) if self.m.repo_ok
+ else (self.m.repo_path or self.m.t('repo.notFound')))
if self.m.repo_ok:
- self.repo_path_label.setText(pu.short_path(self.m.repo_path))
- self.repo_path_label.setStyleSheet('')
+ self.repo_dot.setStyleSheet(f'color: {GREEN};')
self.repo_status.setText(self.m.t('repo.ok') if self.m.repo_is_git else self.m.t('repo.noGit'))
else:
- self.repo_path_label.setText(self.m.repo_path or self.m.t('repo.notFound'))
- self.repo_path_label.setStyleSheet('color: palette(highlight);')
+ self.repo_dot.setStyleSheet(f'color: {RED};')
self.repo_status.setText(self.m.t('repo.firstHint'))
- for key, lbl in self.input_labels.items():
- v = {'base': self.m.base_path, 'update': self.m.update_path,
- 'keys': self.m.keys_path}.get(key)
- if key == 'dlc':
- v = f'{len(self.m.dlc_paths)} 个' if self.m.dlc_paths else ''
- lbl.setText(Path(v).name if v else '—')
- lbl.setStyleSheet('' if v else 'color: palette(mid);')
- self.folder_label.setText(pu.short_path(self.m.game_dir) if self.m.game_dir else self.m.t('data.folderHint'))
+ self._refresh_inputs()
self._refresh_deps()
+ def _refresh_inputs(self) -> None:
+ self.folder_label.setText(pu.short_path(self.m.game_dir) if self.m.game_dir
+ else self.m.t('data.folderHint'))
+ vals = {'base': self.m.base_path, 'update': self.m.update_path, 'keys': self.m.keys_path}
+ for key, (dot, val) in self.input_rows.items():
+ if key == 'dlc':
+ n = len(self.m.dlc_paths)
+ text = (Path(self.m.dlc_paths[0]).name + (f' +{n - 1}' if n > 1 else '')) if n else ''
+ set_, optional = bool(n), True
+ else:
+ v = vals.get(key, '')
+ text, set_, optional = (Path(v).name if v else ''), bool(v), key == 'update'
+ if set_:
+ dot.setText('●')
+ dot.setStyleSheet(f'color: {GREEN};')
+ val.setText(text)
+ val.setStyleSheet(f'color: {MUTED};')
+ else:
+ dot.setText('○' if optional else '✕')
+ dot.setStyleSheet(f'color: {MUTED if optional else RED};')
+ val.setText(self.m.t('data.notSelectedOptional') if optional else self.m.t('data.notSelected'))
+ val.setStyleSheet(f'color: {MUTED if optional else ORANGE};')
+ self._refresh_running()
+
def _refresh_deps(self) -> None:
while self.deps_container.count():
item = self.deps_container.takeAt(0)
@@ -229,12 +278,15 @@ class MainWindow(QMainWindow):
for d in self.m.deps:
row = QWidget()
h = QHBoxLayout(row)
- h.setContentsMargins(0, 1, 0, 1)
- mark = QLabel('✓' if d.ok else ('!' if d.state is DepState.OLD else '✗'))
- mark.setFixedWidth(18)
- mark.setStyleSheet(f'color: {"#2e9e4f" if d.ok else "#c0392b"}; font-weight: bold;')
+ h.setContentsMargins(0, 0, 0, 0)
+ h.setSpacing(8)
+ mark = QLabel('●' if d.ok else ('◐' if d.state is DepState.OLD else '✕'))
+ mark.setFixedWidth(14)
+ mark.setStyleSheet(f'color: {GREEN if d.ok else (ORANGE if d.state is DepState.OLD else RED)};')
h.addWidget(mark)
- h.addWidget(QLabel(self.m.t(d.title_key)), 0)
+ name = QLabel(self.m.t(d.title_key))
+ name.setFixedWidth(190)
+ h.addWidget(name)
detail = d.detail
if detail.startswith('dep.'):
if ':' in detail:
@@ -245,8 +297,7 @@ class MainWindow(QMainWindow):
elif detail:
detail = pu.short_path(detail)
lab = QLabel(detail)
- lab.setFont(self._mono)
- lab.setStyleSheet('color: palette(mid);')
+ lab.setObjectName('mono')
lab.setTextInteractionFlags(Qt.TextSelectableByMouse)
h.addWidget(lab, 1)
if not d.ok:
@@ -257,20 +308,20 @@ class MainWindow(QMainWindow):
h.addWidget(btn)
else:
hint = QLabel(self.m.t(d.hint_key))
- hint.setStyleSheet('color: palette(mid);')
+ hint.setObjectName('note')
h.addWidget(hint)
self.deps_container.addWidget(row)
if self.m.deps_checked:
- n_ok = sum(1 for d in self.m.deps if d.ok)
if self.m.all_deps_ok:
- self.deps_summary.setText(self.m.t('dep.allReady'))
- self.deps_summary.setStyleSheet('color: #2e9e4f;')
+ self.deps_summary.setText('● ' + self.m.t('dep.allReady'))
+ self.deps_summary.setStyleSheet(f'color: {GREEN}; font-weight: 600;')
else:
- self.deps_summary.setText(self.m.t('dep.missing', len(self.m.deps) - n_ok))
- self.deps_summary.setStyleSheet('color: #c0392b;')
+ n = sum(1 for d in self.m.deps if not d.ok)
+ self.deps_summary.setText(self.m.t('dep.missing', n))
+ self.deps_summary.setStyleSheet(f'color: {RED}; font-weight: 600;')
else:
self.deps_summary.setText(self.m.t('dep.checking'))
- self.deps_summary.setStyleSheet('color: palette(mid);')
+ self.deps_summary.setStyleSheet(f'color: {MUTED};')
self._refresh_running()
def _refresh_stages(self) -> None:
@@ -278,33 +329,49 @@ class MainWindow(QMainWindow):
item = self.stages_container.takeAt(0)
if w := item.widget():
w.deleteLater()
+ if not self.m.stages:
+ self.progress_box.setVisible(False)
+ return
+ self.progress_box.setVisible(True)
for st in self.m.stages:
row = QWidget()
h = QHBoxLayout(row)
- h.setContentsMargins(0, 1, 0, 1)
- mark = {'done': '✓', 'running': '…', 'failed': '✗'}.get(st.state, '·')
- colour = {'done': '#2e9e4f', 'failed': '#c0392b'}.get(st.state, 'palette(mid)')
+ h.setContentsMargins(0, 0, 0, 0)
+ h.setSpacing(8)
+ mark = {'done': '●', 'running': '◐', 'failed': '✕'}.get(st.state, '○')
+ colour = {'done': GREEN, 'failed': RED}.get(st.state, MUTED)
lab = QLabel(mark)
- lab.setFixedWidth(16)
+ lab.setFixedWidth(14)
lab.setStyleSheet(f'color: {colour};')
h.addWidget(lab)
- h.addWidget(QLabel(st.name), 0)
+ name = QLabel(st.name)
+ h.addWidget(name, 0)
+ if st.state == 'running':
+ bar = QProgressBar()
+ bar.setTextVisible(False)
+ bar.setFixedWidth(150)
+ bar.setRange(0, 0)
+ h.addWidget(bar)
det = QLabel(st.detail)
- det.setFont(self._mono)
- det.setStyleSheet('color: palette(mid);')
+ det.setObjectName('mono')
h.addWidget(det, 1)
self.stages_container.addWidget(row)
+ done = sum(1 for s in self.m.stages if s.state == 'done')
+ self.overall.setRange(0, len(self.m.stages))
+ self.overall.setValue(done)
def _refresh_running(self) -> None:
running = self.m.running
self.build_btn.setText(self.m.t('build.cancel') if running else self.m.t('build.start'))
+ self.build_btn.setObjectName('danger' if running else 'primary')
+ self.build_btn.style().unpolish(self.build_btn)
+ self.build_btn.style().polish(self.build_btn)
self.build_btn.setEnabled(running or self.m.can_build)
- if not running:
- try:
- self.build_btn.clicked.disconnect()
- except (RuntimeError, TypeError):
- pass
- self.build_btn.clicked.connect(self.m.cancel_build if running else self.m.start_build)
+ if not running and not self.footer.text():
+ if not self.m.base_path:
+ self.footer.setText(self.m.t('status.needInputs'))
+ elif not self.m.repo_ok:
+ self.footer.setText(self.m.t('status.chooseRepo'))
def _append_log(self, s: str) -> None:
self.log.moveCursor(self.log.textCursor().MoveOperation.End)
@@ -313,16 +380,17 @@ class MainWindow(QMainWindow):
def _on_finished(self, ok: bool, note: str) -> None:
if ok:
- msg = self.m.t('msg.done') if not note else note
+ msg = note or self.m.t('msg.done')
if self.m.ipa_path:
- msg += '\n' + self.m.t('msg.ipaAt', self.m.ipa_path)
+ msg += ' ' + self.m.t('msg.ipaAt', self.m.ipa_path)
if self.m.archive_path:
- msg += '\n' + self.m.t('msg.archiveAt', self.m.archive_path)
- self.footer.setText(msg)
- self.footer.setStyleSheet('color: #2e9e4f;')
+ msg += ' ' + self.m.t('msg.archiveAt', self.m.archive_path)
+ self.footer.setStyleSheet(f'color: {GREEN};')
else:
- self.footer.setText(note or self.m.t('msg.buildFailed'))
- self.footer.setStyleSheet('color: #c0392b;')
+ msg = note or self.m.t('msg.buildFailed')
+ self.footer.setStyleSheet(f'color: {RED};')
+ self.footer.setText(msg)
+ self._refresh_running()
# ---------------------------------------------------------------- actions
@@ -330,6 +398,14 @@ class MainWindow(QMainWindow):
self.m.toggle_lang()
self._refresh_all()
+ def _build_clicked(self) -> None:
+ if self.m.running:
+ self.m.cancel_build()
+ else:
+ self.footer.setText('')
+ self.footer.setStyleSheet('')
+ self.m.start_build()
+
def _choose_repo(self) -> None:
d = QFileDialog.getExistingDirectory(self, self.m.t('repo.pickMessage'))
if d:
@@ -341,6 +417,21 @@ class MainWindow(QMainWindow):
if d:
self.m.scan_game_dir(d)
+ def _choose_input(self, key: str) -> None:
+ path, _ = QFileDialog.getOpenFileName(self, self.m.t('data.choose'))
+ if not path:
+ return
+ if key == 'base':
+ self.m.base_path = path
+ elif key == 'update':
+ self.m.update_path = path
+ elif key == 'keys':
+ self.m.keys_path = path
+ else:
+ if path not in self.m.dlc_paths:
+ self.m.dlc_paths.append(path)
+ self.m.repoChanged.emit()
+
def _choose_out(self) -> None:
d = QFileDialog.getExistingDirectory(self, self.m.t('build.outDir'))
if d:
diff --git a/frontend-qt/run_gui.py b/frontend-qt/run_gui.py
new file mode 100644
index 00000000..35e4e5d1
--- /dev/null
+++ b/frontend-qt/run_gui.py
@@ -0,0 +1,18 @@
+"""Entry point for the packaged build (PyInstaller uses this, not -m nspb_qt).
+
+Kept as a plain script so a frozen executable has a real __main__ to start from: the package
+form (-m) works for development, this for the .exe / .app.
+"""
+from __future__ import annotations
+
+import os
+import sys
+
+# A frozen build puts the package next to the executable; a source run has it on the path.
+if getattr(sys, 'frozen', False):
+ sys.path.insert(0, os.path.dirname(sys.executable))
+
+from nspb_qt.__main__ import main # noqa: E402
+
+if __name__ == '__main__':
+ raise SystemExit(main())