From 87905eab2bb1170a463aefb92fd1111c48ed9189 Mon Sep 17 00:00:00 2001 From: NinjaCheetah <58050615+NinjaCheetah@users.noreply.github.com> Date: Sun, 5 Jan 2025 01:18:44 -0500 Subject: [PATCH] Clicking the labels for checkboxes now toggles the checkboxes again --- NUSGet.py | 24 +++++++++------- build_translations.py | 2 +- modules/core.py | 11 ++++++- modules/download_batch.py | 2 +- modules/download_dsi.py | 2 +- modules/download_wii.py | 2 +- modules/tree.py | 2 +- qt/py/ui_MainMenu.py | 60 +++++++++++++++++++-------------------- qt/ui/MainMenu.ui | 8 +++--- update_translations.py | 2 +- 10 files changed, 64 insertions(+), 51 deletions(-) diff --git a/NUSGet.py b/NUSGet.py index b8db8bb..6658118 100644 --- a/NUSGet.py +++ b/NUSGet.py @@ -1,5 +1,5 @@ # "NUSGet.py", licensed under the MIT license -# Copyright 2024 NinjaCheetah +# Copyright 2024-2025 NinjaCheetah # Nuitka options. These determine compilation settings based on the current OS. # nuitka-project-if: {OS} == "Darwin": @@ -82,7 +82,8 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.threadpool = QThreadPool() self.ui.download_btn.clicked.connect(self.download_btn_pressed) self.ui.script_btn.clicked.connect(self.script_btn_pressed) - self.ui.pack_archive_chkbox.clicked.connect(self.pack_wad_chkbox_toggled) + self.ui.pack_archive_chkbox.toggled.connect( + lambda: self.ui.archive_file_entry.setEnabled(self.ui.pack_archive_chkbox.isChecked())) self.ui.tid_entry.textChanged.connect(self.tid_updated) # Basic intro text set to automatically show when the app loads. This may be changed in the future. libwiipy_version = "v" + version("libWiiPy") @@ -123,6 +124,15 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.trees[tree].collapsed.connect(lambda: self.resize_tree(self.ui.platform_tabs.currentIndex())) # Prevent resizing. self.setFixedSize(self.size()) + # These connections allow for clicking the checkbox labels to toggle the checkboxes, if they're enabled. This is + # required because checkboxes can't word wrap, so regular labels must be used in their place. + connect_label_to_checkbox(self.ui.pack_archive_chkbox_lbl, self.ui.pack_archive_chkbox) + connect_label_to_checkbox(self.ui.keep_enc_chkbox_lbl, self.ui.keep_enc_chkbox) + connect_label_to_checkbox(self.ui.create_dec_chkbox_lbl, self.ui.create_dec_chkbox) + connect_label_to_checkbox(self.ui.use_local_chkbox_lbl, self.ui.use_local_chkbox) + connect_label_to_checkbox(self.ui.use_wiiu_nus_chkbox_lbl, self.ui.use_wiiu_nus_chkbox) + connect_label_to_checkbox(self.ui.patch_ios_chkbox_lbl, self.ui.patch_ios_chkbox) + connect_label_to_checkbox(self.ui.pack_vwii_mode_chkbox_lbl, self.ui.pack_vwii_mode_chkbox) # Do a quick check to see if there's a newer release available, and inform the user if there is. worker = Worker(check_nusget_updates, app, nusget_version) worker.signals.result.connect(self.prompt_for_update) @@ -241,6 +251,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.ui.keep_enc_chkbox.setEnabled(False) self.ui.create_dec_chkbox.setEnabled(False) self.ui.use_local_chkbox.setEnabled(False) + self.ui.patch_ios_chkbox.setEnabled(False) self.ui.use_wiiu_nus_chkbox.setEnabled(False) self.ui.pack_vwii_mode_chkbox.setEnabled(False) self.ui.archive_file_entry.setEnabled(False) @@ -258,6 +269,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.ui.keep_enc_chkbox.setEnabled(True) self.ui.create_dec_chkbox.setEnabled(True) self.ui.use_local_chkbox.setEnabled(True) + self.ui.patch_ios_chkbox.setEnabled(True) self.ui.use_wiiu_nus_chkbox.setEnabled(True) self.ui.console_select_dropdown.setEnabled(True) if self.ui.pack_archive_chkbox.isChecked() is True: @@ -373,14 +385,6 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.update_log_text(f" - {title}") self.unlock_ui() - def pack_wad_chkbox_toggled(self): - # Simple function to catch when the WAD/TAD checkbox is toggled and enable/disable the file name entry box - # accordingly. - if self.ui.pack_archive_chkbox.isChecked() is True: - self.ui.archive_file_entry.setEnabled(True) - else: - self.ui.archive_file_entry.setEnabled(False) - def selected_console_changed(self): # Callback function to enable or disable console-specific settings based on the selected console. if self.ui.console_select_dropdown.currentText() == "vWii": diff --git a/build_translations.py b/build_translations.py index d4d0f55..bc515e8 100644 --- a/build_translations.py +++ b/build_translations.py @@ -1,5 +1,5 @@ # "build_translations.py", licensed under the MIT license -# Copyright 2024 NinjaCheetah +# Copyright 2024-2025 NinjaCheetah # This script exists to work around an issue in PySide6 where the "pyside6-project build" command incorrectly places # translation files in the root of the project directory while building. diff --git a/modules/core.py b/modules/core.py index 6c0033a..de79849 100644 --- a/modules/core.py +++ b/modules/core.py @@ -1,10 +1,12 @@ # "modules/core.py", licensed under the MIT license -# Copyright 2024 NinjaCheetah +# Copyright 2024-2025 NinjaCheetah import requests from dataclasses import dataclass from typing import List +from PySide6.QtCore import Qt as _Qt + @dataclass class TitleData: @@ -36,6 +38,13 @@ class BatchResults: failed_titles: List[str] +def connect_label_to_checkbox(label, checkbox): + def toggle_checkbox(event): + if checkbox.isEnabled() and event.button() == _Qt.LeftButton: + checkbox.toggle() + label.mousePressEvent = toggle_checkbox + + def check_nusget_updates(app, current_version: str, progress_callback=None) -> str | None: # Simple function to make a request to the GitHub API and then check if the latest available version is newer. gh_api_request = requests.get(url="https://api.github.com/repos/NinjaCheetah/NUSGet/releases/latest", stream=True) diff --git a/modules/download_batch.py b/modules/download_batch.py index d2c3cb9..bc86208 100644 --- a/modules/download_batch.py +++ b/modules/download_batch.py @@ -1,5 +1,5 @@ # "modules/download_batch.py", licensed under the MIT license -# Copyright 2024 NinjaCheetah +# Copyright 2024-2025 NinjaCheetah import pathlib from typing import List diff --git a/modules/download_dsi.py b/modules/download_dsi.py index 285acc4..fcf8585 100644 --- a/modules/download_dsi.py +++ b/modules/download_dsi.py @@ -1,5 +1,5 @@ # "modules/download_dsi.py", licensed under the MIT license -# Copyright 2024 NinjaCheetah +# Copyright 2024-2025 NinjaCheetah import pathlib from typing import List, Tuple diff --git a/modules/download_wii.py b/modules/download_wii.py index 5ee485c..433f813 100644 --- a/modules/download_wii.py +++ b/modules/download_wii.py @@ -1,5 +1,5 @@ # "modules/download_wii.py", licensed under the MIT license -# Copyright 2024 NinjaCheetah +# Copyright 2024-2025 NinjaCheetah import pathlib from typing import List, Tuple diff --git a/modules/tree.py b/modules/tree.py index 3b407d8..10fb3c9 100644 --- a/modules/tree.py +++ b/modules/tree.py @@ -1,5 +1,5 @@ # "modules/tree.py", licensed under the MIT license -# Copyright 2024 NinjaCheetah +# Copyright 2024-2025 NinjaCheetah from modules.core import TitleData from PySide6.QtCore import QAbstractItemModel, QModelIndex, Qt, QSortFilterProxyModel diff --git a/qt/py/ui_MainMenu.py b/qt/py/ui_MainMenu.py index b5334c7..62329a0 100644 --- a/qt/py/ui_MainMenu.py +++ b/qt/py/ui_MainMenu.py @@ -189,16 +189,16 @@ class Ui_MainWindow(object): self.pack_archive_row.addWidget(self.pack_archive_chkbox) - self.label_7 = QLabel(self.centralwidget) - self.label_7.setObjectName(u"label_7") + self.pack_archive_chkbox_lbl = QLabel(self.centralwidget) + self.pack_archive_chkbox_lbl.setObjectName(u"pack_archive_chkbox_lbl") sizePolicy4 = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.MinimumExpanding) sizePolicy4.setHorizontalStretch(0) sizePolicy4.setVerticalStretch(0) - sizePolicy4.setHeightForWidth(self.label_7.sizePolicy().hasHeightForWidth()) - self.label_7.setSizePolicy(sizePolicy4) - self.label_7.setWordWrap(True) + sizePolicy4.setHeightForWidth(self.pack_archive_chkbox_lbl.sizePolicy().hasHeightForWidth()) + self.pack_archive_chkbox_lbl.setSizePolicy(sizePolicy4) + self.pack_archive_chkbox_lbl.setWordWrap(True) - self.pack_archive_row.addWidget(self.label_7) + self.pack_archive_row.addWidget(self.pack_archive_chkbox_lbl) self.verticalLayout_7.addLayout(self.pack_archive_row) @@ -221,13 +221,13 @@ class Ui_MainWindow(object): self.keep_enc_row.addWidget(self.keep_enc_chkbox) - self.label_6 = QLabel(self.centralwidget) - self.label_6.setObjectName(u"label_6") - sizePolicy4.setHeightForWidth(self.label_6.sizePolicy().hasHeightForWidth()) - self.label_6.setSizePolicy(sizePolicy4) - self.label_6.setWordWrap(True) + self.keep_enc_chkbox_lbl = QLabel(self.centralwidget) + self.keep_enc_chkbox_lbl.setObjectName(u"keep_enc_chkbox_lbl") + sizePolicy4.setHeightForWidth(self.keep_enc_chkbox_lbl.sizePolicy().hasHeightForWidth()) + self.keep_enc_chkbox_lbl.setSizePolicy(sizePolicy4) + self.keep_enc_chkbox_lbl.setWordWrap(True) - self.keep_enc_row.addWidget(self.label_6) + self.keep_enc_row.addWidget(self.keep_enc_chkbox_lbl) self.verticalLayout_7.addLayout(self.keep_enc_row) @@ -314,14 +314,14 @@ class Ui_MainWindow(object): self.patch_ios_row.addWidget(self.patch_ios_chkbox) - self.patch_ios_lbl = QLabel(self.centralwidget) - self.patch_ios_lbl.setObjectName(u"patch_ios_lbl") - self.patch_ios_lbl.setEnabled(True) - sizePolicy4.setHeightForWidth(self.patch_ios_lbl.sizePolicy().hasHeightForWidth()) - self.patch_ios_lbl.setSizePolicy(sizePolicy4) - self.patch_ios_lbl.setWordWrap(True) + self.patch_ios_chkbox_lbl = QLabel(self.centralwidget) + self.patch_ios_chkbox_lbl.setObjectName(u"patch_ios_chkbox_lbl") + self.patch_ios_chkbox_lbl.setEnabled(True) + sizePolicy4.setHeightForWidth(self.patch_ios_chkbox_lbl.sizePolicy().hasHeightForWidth()) + self.patch_ios_chkbox_lbl.setSizePolicy(sizePolicy4) + self.patch_ios_chkbox_lbl.setWordWrap(True) - self.patch_ios_row.addWidget(self.patch_ios_lbl) + self.patch_ios_row.addWidget(self.patch_ios_chkbox_lbl) self.verticalLayout_7.addLayout(self.patch_ios_row) @@ -357,17 +357,17 @@ class Ui_MainWindow(object): self.pack_vwii_mode_row.addWidget(self.pack_vwii_mode_chkbox) - self.pack_vwii_mode_lbl = QLabel(self.centralwidget) - self.pack_vwii_mode_lbl.setObjectName(u"pack_vwii_mode_lbl") - self.pack_vwii_mode_lbl.setEnabled(True) + self.pack_vwii_mode_chkbox_lbl = QLabel(self.centralwidget) + self.pack_vwii_mode_chkbox_lbl.setObjectName(u"pack_vwii_mode_chkbox_lbl") + self.pack_vwii_mode_chkbox_lbl.setEnabled(True) sizePolicy5 = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Preferred) sizePolicy5.setHorizontalStretch(0) sizePolicy5.setVerticalStretch(0) - sizePolicy5.setHeightForWidth(self.pack_vwii_mode_lbl.sizePolicy().hasHeightForWidth()) - self.pack_vwii_mode_lbl.setSizePolicy(sizePolicy5) - self.pack_vwii_mode_lbl.setWordWrap(True) + sizePolicy5.setHeightForWidth(self.pack_vwii_mode_chkbox_lbl.sizePolicy().hasHeightForWidth()) + self.pack_vwii_mode_chkbox_lbl.setSizePolicy(sizePolicy5) + self.pack_vwii_mode_chkbox_lbl.setWordWrap(True) - self.pack_vwii_mode_row.addWidget(self.pack_vwii_mode_lbl) + self.pack_vwii_mode_row.addWidget(self.pack_vwii_mode_chkbox_lbl) self.verticalLayout_8.addLayout(self.pack_vwii_mode_row) @@ -426,15 +426,15 @@ class Ui_MainWindow(object): self.download_btn.setText(QCoreApplication.translate("MainWindow", u"Start Download", None)) self.script_btn.setText(QCoreApplication.translate("MainWindow", u"Run Script", None)) self.label_3.setText(QCoreApplication.translate("MainWindow", u"General Settings", None)) - self.label_7.setText(QCoreApplication.translate("MainWindow", u"Pack installable archive (WAD/TAD)", None)) + self.pack_archive_chkbox_lbl.setText(QCoreApplication.translate("MainWindow", u"Pack installable archive (WAD/TAD)", None)) self.archive_file_entry.setPlaceholderText(QCoreApplication.translate("MainWindow", u"File Name", None)) - self.label_6.setText(QCoreApplication.translate("MainWindow", u"Keep encrypted contents", None)) + self.keep_enc_chkbox_lbl.setText(QCoreApplication.translate("MainWindow", u"Keep encrypted contents", None)) self.create_dec_chkbox_lbl.setText(QCoreApplication.translate("MainWindow", u"Create decrypted contents (*.app)", None)) self.use_local_chkbox_lbl.setText(QCoreApplication.translate("MainWindow", u"Use local files, if they exist", None)) self.use_wiiu_nus_chkbox_lbl.setText(QCoreApplication.translate("MainWindow", u"Use the Wii U NUS (faster, only effects Wii/vWii)", None)) - self.patch_ios_lbl.setText(QCoreApplication.translate("MainWindow", u"Apply patches to IOS (Applies to WADs only)", None)) + self.patch_ios_chkbox_lbl.setText(QCoreApplication.translate("MainWindow", u"Apply patches to IOS (Applies to WADs only)", None)) self.label_4.setText(QCoreApplication.translate("MainWindow", u"vWii Title Settings", None)) - self.pack_vwii_mode_lbl.setText(QCoreApplication.translate("MainWindow", u"Re-encrypt title using the Wii Common Key", None)) + self.pack_vwii_mode_chkbox_lbl.setText(QCoreApplication.translate("MainWindow", u"Re-encrypt title using the Wii Common Key", None)) self.log_text_browser.setMarkdown("") self.log_text_browser.setHtml(QCoreApplication.translate("MainWindow", u"\n" "