Skip to content

Commit

Permalink
CID: Remove prints, some small cleanup+type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
sonic2kk committed Jul 28, 2024
1 parent 814fcda commit 57d9cc2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pupgui2/pupgui2customiddialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,26 @@ def setup_ui(self):
self.ui.txtInstallDirectory.textChanged.connect(lambda text: self.ui.btnSave.setEnabled(self.is_valid_custom_install_path(text)))

def btn_save_clicked(self):
install_dir = os.path.expanduser(self.ui.txtInstallDirectory.text().strip())
install_dir: str = os.path.expanduser(self.ui.txtInstallDirectory.text().strip())
if not install_dir.endswith(os.sep):
install_dir += '/'
launcher = get_dict_key_from_value(self.install_locations_dict, self.ui.comboLauncher.currentText()) or ''

if self.is_valid_custom_install_path(install_dir):
config_custom_install_location(install_dir, launcher)
print(f'New Custom Install Directory set to: {install_dir}')

self.custom_id_set.emit(install_dir)
self.ui.close()

def btn_default_clicked(self):
self.ui.txtInstallDirectory.setText('')
config_custom_install_location(remove=True)
print(f'Removed custom install directory')

self.custom_id_set.emit('')

def txt_id_browse_action_triggered(self):
# Open dialog at entered path if it exists, and fall back to HOME_DIR
txt_install_dir = os.path.expanduser(self.ui.txtInstallDirectory.text())
txt_install_dir: str = os.path.expanduser(self.ui.txtInstallDirectory.text())
initial_dir = txt_install_dir if self.is_valid_custom_install_path(txt_install_dir) else HOME_DIR

dialog = QFileDialog(self.ui, directory=initial_dir)
Expand All @@ -92,10 +90,12 @@ def txt_id_browse_action_triggered(self):
dialog.open()

def set_selected_launcher(self, ctool_name: str):
if ctool_name:
index = get_combobox_index_by_value(self.ui.comboLauncher, ctool_name)
if index >= 0:
self.ui.comboLauncher.setCurrentIndex(index)
if not ctool_name:
return

index = get_combobox_index_by_value(self.ui.comboLauncher, ctool_name)
if index >= 0:
self.ui.comboLauncher.setCurrentIndex(index)

def is_valid_custom_install_path(self, path: str) -> bool:
expand_path = os.path.expanduser(path)
Expand Down

0 comments on commit 57d9cc2

Please sign in to comment.