From 4f993a3a62d67e7856fc4641bfb3950b9cb12281 Mon Sep 17 00:00:00 2001 From: NinjaCheetah <58050615+NinjaCheetah@users.noreply.github.com> Date: Tue, 22 Apr 2025 21:50:27 -0400 Subject: [PATCH] Fix setting custom download dir to cwd when canceling file dialog --- NUSGet.py | 7 +++++-- qt/py/ui_MainMenu.py | 2 +- qt/ui/MainMenu.ui | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/NUSGet.py b/NUSGet.py index 52885a9..9cf2a2d 100644 --- a/NUSGet.py +++ b/NUSGet.py @@ -85,8 +85,6 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.ui.custom_out_dir_chkbox.toggled.connect( lambda: connect_is_enabled_to_checkbox([self.ui.custom_out_dir_entry, self.ui.custom_out_dir_btn], self.ui.custom_out_dir_chkbox)) - self.ui.custom_out_dir_chkbox.toggled.connect( - lambda: update_setting(config_data, "use_out_path", self.ui.custom_out_dir_chkbox.isChecked())) # Load auto-update settings, and initialize them if they don't exist. try: self.ui.auto_update_chkbox.setChecked(config_data["auto_update"]) @@ -104,6 +102,9 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.ui.custom_out_dir_chkbox.setChecked(True) except KeyError: pass + # Register this callback after the previous check to avoid an extra config write. + self.ui.custom_out_dir_chkbox.toggled.connect( + lambda: update_setting(config_data, "use_out_path", self.ui.custom_out_dir_chkbox.isChecked())) self.ui.tid_entry.textChanged.connect(self.tid_updated) self.ui.custom_out_dir_entry.textChanged.connect(self.custom_output_dir_changed) # Basic intro text set to automatically show when the app loads. This may be changed in the future. @@ -532,6 +533,8 @@ class MainWindow(QMainWindow, Ui_MainWindow): # that the directory does indeed exist and is a directory, and we can save it as the output directory. selected_dir = QFileDialog.getExistingDirectory(self, app.translate("MainWindow", "Open Directory"), "", QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks) + if selected_dir == "": + return out_path = pathlib.Path(selected_dir) if not out_path.exists() or not out_path.is_dir(): msg_box = QMessageBox() diff --git a/qt/py/ui_MainMenu.py b/qt/py/ui_MainMenu.py index 3efc004..0ab0937 100644 --- a/qt/py/ui_MainMenu.py +++ b/qt/py/ui_MainMenu.py @@ -499,7 +499,7 @@ class Ui_MainWindow(object): self.custom_out_dir_chkbox.setText("") self.custom_out_dir_chkbox_lbl.setText(QCoreApplication.translate("MainWindow", u"Use a custom download directory", None)) self.custom_out_dir_entry.setPlaceholderText(QCoreApplication.translate("MainWindow", u"Output Path", None)) - self.custom_out_dir_btn.setText(QCoreApplication.translate("MainWindow", u"Open...", None)) + self.custom_out_dir_btn.setText(QCoreApplication.translate("MainWindow", u"Select...", None)) self.log_text_browser.setMarkdown("") self.log_text_browser.setHtml(QCoreApplication.translate("MainWindow", u"\n" "