Skip to content

Commit

Permalink
fix(ui): same default confirm button on win/mac
Browse files Browse the repository at this point in the history
- Make "Yes" the default choice in the delete file modal for both Windows and macOS (Linux untested)
- Change status messages to be more broad, since they also are displayed when cancelling the operation
  • Loading branch information
CyanVoxel committed Aug 31, 2024
1 parent 02c2455 commit c8dde27
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions tagstudio/src/qt/ts_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,10 @@ def delete_files_callback(self, origin_path: str | Path):
pending.append(filepath)

if pending:
if self.delete_file_confirmation(len(pending), pending[0]) == 3:
return_code = self.delete_file_confirmation(len(pending), pending[0])
logging.info(return_code)
# If there was a confirmation and not a cancellation
if return_code == 2 and return_code != 3:
for i, f in enumerate(pending):
if (origin_path == f) or (not origin_path):
self.preview_panel.stop_file_use()
Expand All @@ -887,18 +890,14 @@ def delete_files_callback(self, origin_path: str | Path):
self.preview_panel.update_widgets()

if len(self.selected) <= 1 and deleted_count == 0:
self.main_window.statusbar.showMessage(
"No files deleted. Check if any of the files are currently in use."
)
self.main_window.statusbar.showMessage("No files deleted.")
elif len(self.selected) <= 1 and deleted_count == 1:
self.main_window.statusbar.showMessage(f"Deleted {deleted_count} file!")
elif len(self.selected) > 1 and deleted_count == 0:
self.main_window.statusbar.showMessage(
"No files deleted! Check if any of the files are currently in use."
)
self.main_window.statusbar.showMessage("No files deleted.")
elif len(self.selected) > 1 and deleted_count < len(self.selected):
self.main_window.statusbar.showMessage(
f"Only deleted {deleted_count} file{'' if deleted_count == 1 else 's'}! Check if any of the files are currently in use"
f"Only deleted {deleted_count} file{'' if deleted_count == 1 else 's'}! Check if any of the files are currently missing or in use."
)
elif len(self.selected) > 1 and deleted_count == len(self.selected):
self.main_window.statusbar.showMessage(f"Deleted {deleted_count} files!")
Expand Down Expand Up @@ -941,8 +940,10 @@ def delete_file_confirmation(self, count: int, filename: Path | None = None) ->
"<h4>This will remove them from TagStudio <i>AND</i> your file system!</h4>"
f"{perm_warning}<br>"
)

yes_button: QPushButton = msg.addButton("&Yes", QMessageBox.ButtonRole.YesRole)
msg.addButton("&No", QMessageBox.ButtonRole.NoRole)
msg.addButton("&Yes", QMessageBox.ButtonRole.YesRole)
msg.setDefaultButton(yes_button)

return msg.exec()

Expand Down

0 comments on commit c8dde27

Please sign in to comment.