Skip to content

Commit b612c97

Browse files
committed
fix(ui): use consistent/correct button roles
1 parent 6d1f267 commit b612c97

10 files changed

Lines changed: 68 additions & 52 deletions

File tree

‎src/tagstudio/qt/controllers/field_template_search_panel.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,18 @@ def _on_item_remove(self, item: BaseFieldTemplate) -> None:
8989
return
9090

9191
message_box = QMessageBox(
92-
QMessageBox.Icon.Question,
92+
QMessageBox.Icon.Warning,
9393
Translations["field_template.delete"],
9494
Translations.format("field_template.confirm_delete", field_template_name=item.name),
9595
QMessageBox.StandardButton.Ok | QMessageBox.StandardButton.Cancel,
9696
)
97+
unwrap(message_box.button(QMessageBox.StandardButton.Ok)).setText(
98+
Translations["generic.delete_alt"]
99+
)
100+
unwrap(message_box.button(QMessageBox.StandardButton.Cancel)).setText(
101+
Translations["generic.cancel_alt"]
102+
)
103+
message_box.setDefaultButton(QMessageBox.StandardButton.Cancel)
97104

98105
result = message_box.exec()
99106

‎src/tagstudio/qt/controllers/tag_search_panel.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def _on_item_remove(self, item: Tag) -> None:
9999
unwrap(message_box.button(QMessageBox.StandardButton.Cancel)).setText(
100100
Translations["generic.cancel_alt"]
101101
)
102+
message_box.setDefaultButton(QMessageBox.StandardButton.Cancel)
102103

103104
result = message_box.exec()
104105

‎src/tagstudio/qt/controllers/tiles/color_data.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ def delete_color(self, color_group: TagColorGroup):
126126
cancel_button = message_box.addButton(
127127
Translations["generic.cancel_alt"], QMessageBox.ButtonRole.RejectRole
128128
)
129-
message_box.addButton(
130-
Translations["generic.delete_alt"], QMessageBox.ButtonRole.DestructiveRole
129+
delete_button = message_box.addButton(
130+
Translations["generic.delete_alt"], QMessageBox.ButtonRole.AcceptRole
131131
)
132132
message_box.setEscapeButton(cancel_button)
133-
result = message_box.exec_()
134-
logger.info(QMessageBox.ButtonRole.DestructiveRole.value)
135-
if result != QMessageBox.ButtonRole.ActionRole.value:
133+
message_box.setDefaultButton(cancel_button)
134+
message_box.exec()
135+
if message_box.clickedButton() != delete_button:
136136
return
137137

138138
logger.info("[ColorData] Removing color", color=color_group)

‎src/tagstudio/qt/controllers/tiles/tile_list.py‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,19 +418,20 @@ def update_datetime_field(self, field: DatetimeField, name: str, value: str) ->
418418
self.lib.update_datetime_field(entry_ids, field, name, dt.fromisoformat(value))
419419

420420
def remove_message_box(self, prompt: str, callback: Callable[..., None]) -> None:
421-
remove_mb = QMessageBox()
422-
remove_mb.setText(prompt)
423-
remove_mb.setWindowTitle(Translations["field.remove"])
424-
remove_mb.setIcon(QMessageBox.Icon.Warning)
425-
cancel_button = remove_mb.addButton(
421+
message_box = QMessageBox()
422+
message_box.setText(prompt)
423+
message_box.setWindowTitle(Translations["field.remove"])
424+
message_box.setIcon(QMessageBox.Icon.Warning)
425+
cancel_button = message_box.addButton(
426426
Translations["generic.cancel_alt"], QMessageBox.ButtonRole.RejectRole
427427
)
428-
remove_mb.addButton(
429-
Translations["generic.remove_alt"], QMessageBox.ButtonRole.DestructiveRole
428+
remove_button = message_box.addButton(
429+
Translations["generic.remove_alt"], QMessageBox.ButtonRole.AcceptRole
430430
)
431-
remove_mb.setEscapeButton(cancel_button)
432-
result = remove_mb.exec_()
433-
if result == QMessageBox.ButtonRole.ActionRole.value:
431+
message_box.setEscapeButton(cancel_button)
432+
message_box.setDefaultButton(cancel_button)
433+
message_box.exec()
434+
if message_box.clickedButton() == remove_button:
434435
callback()
435436

436437
@property

‎src/tagstudio/qt/controllers/update_available_message_box.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(self):
5454
partial(QDesktopServices.openUrl, GITHUB_RELEASE_URL)
5555
)
5656
self.button(QMessageBox.StandardButton.Ignore).setText(Translations["generic.dont_remind"])
57+
self.button(QMessageBox.StandardButton.Close).setText(Translations["generic.close"])
5758

5859
red = get_ui_color(ColorType.PRIMARY, UiColor.RED)
5960
green = get_ui_color(ColorType.PRIMARY, UiColor.GREEN)

‎src/tagstudio/qt/mixed/drop_import_modal.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def __init__(self, driver: QtDriver):
6363
self.button_layout.setContentsMargins(6, 6, 6, 6)
6464
self.button_layout.addStretch(1)
6565

66+
self.cancel_button = QPushButton(Translations["generic.cancel_alt"])
67+
self.cancel_button.clicked.connect(lambda: self.begin_transfer(DuplicateChoice.CANCEL))
68+
self.button_layout.addWidget(self.cancel_button)
69+
6670
self.skip_button = QPushButton(Translations["generic.skip_alt"])
6771
self.skip_button.setDefault(True)
6872
self.skip_button.clicked.connect(lambda: self.begin_transfer(DuplicateChoice.SKIP))
@@ -78,10 +82,6 @@ def __init__(self, driver: QtDriver):
7882
self.rename_button.clicked.connect(lambda: self.begin_transfer(DuplicateChoice.RENAME))
7983
self.button_layout.addWidget(self.rename_button)
8084

81-
self.cancel_button = QPushButton(Translations["generic.cancel_alt"])
82-
self.cancel_button.clicked.connect(lambda: self.begin_transfer(DuplicateChoice.CANCEL))
83-
self.button_layout.addWidget(self.cancel_button)
84-
8585
# Layout =====================
8686
self.root_layout.addWidget(self.desc_widget)
8787
self.root_layout.addWidget(self.list_view)

‎src/tagstudio/qt/mixed/migration_modal.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ def update_sql_value_ui(self, show_msg_box: bool = True):
462462
Translations["json_migration.discrepancies_found.description"],
463463
)
464464
msg_box.setDetailedText("\n".join(self.discrepancies))
465+
msg_box.addButton(Translations["generic.close"], QMessageBox.ButtonRole.AcceptRole)
465466
msg_box.exec()
466467

467468
def finish_migration(self):

‎src/tagstudio/qt/mixed/tag_color_manager.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,13 @@ def delete_namespace_dialog(self, prompt: str, callback: Callable[..., Any]) ->
200200
cancel_button = message_box.addButton(
201201
Translations["generic.cancel_alt"], QMessageBox.ButtonRole.RejectRole
202202
)
203-
message_box.addButton(
204-
Translations["generic.delete_alt"], QMessageBox.ButtonRole.DestructiveRole
203+
delete_button = message_box.addButton(
204+
Translations["generic.delete_alt"], QMessageBox.ButtonRole.AcceptRole
205205
)
206206
message_box.setEscapeButton(cancel_button)
207-
result = message_box.exec_()
208-
if result != QMessageBox.ButtonRole.ActionRole.value:
207+
message_box.setDefaultButton(cancel_button)
208+
message_box.exec()
209+
if message_box.clickedButton() != delete_button:
209210
return
210211
callback()
211212

‎src/tagstudio/qt/qt_driver.py‎

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -979,25 +979,19 @@ def delete_files_callback(self, origin_path: str | Path, origin_id: int | None =
979979
filepath: Path = entry.path
980980
pending.append((item, filepath))
981981

982-
if pending:
983-
return_code = self.delete_file_confirmation(len(pending), pending[0][1])
984-
# If there was a confirmation and not a cancellation
985-
if (
986-
return_code == QMessageBox.ButtonRole.DestructiveRole.value
987-
and return_code != QMessageBox.ButtonRole.ActionRole.value
988-
):
989-
for e_id, f in pending:
990-
if (origin_path == f) or (not origin_path):
991-
self.main_window.inspector.stop_media_playback()
992-
993-
if e_id is not None:
994-
self.lib.remove_entries([e_id])
995-
delete_file(library_dir / f)
996-
997-
self.clear_select_action_callback()
998-
self.update_browsing_state()
999-
1000-
def delete_file_confirmation(self, count: int, filename: Path | None = None) -> int:
982+
if pending and self.delete_file_confirmation(len(pending), pending[0][1]):
983+
for e_id, f in pending:
984+
if (origin_path == f) or (not origin_path):
985+
self.main_window.inspector.stop_media_playback()
986+
987+
if e_id is not None:
988+
self.lib.remove_entries([e_id])
989+
delete_file(library_dir / f)
990+
991+
self.clear_select_action_callback()
992+
self.update_browsing_state()
993+
994+
def delete_file_confirmation(self, count: int, filename: Path | None = None) -> bool:
1001995
"""A confirmation dialogue box for deleting files.
1002996
1003997
Args:
@@ -1048,13 +1042,23 @@ def delete_file_confirmation(self, count: int, filename: Path | None = None) ->
10481042
f"{perm_warning}<br>"
10491043
)
10501044

1051-
yes_button: QPushButton = msg.addButton(
1052-
Translations["generic.yes"], QMessageBox.ButtonRole.YesRole
1045+
move_key = (
1046+
"menu.delete_selected_files_singular"
1047+
if count <= 1
1048+
else "menu.delete_selected_files_plural"
1049+
)
1050+
cancel_button = msg.addButton(
1051+
Translations["generic.cancel_alt"], QMessageBox.ButtonRole.RejectRole
1052+
)
1053+
move_button: QPushButton = msg.addButton(
1054+
Translations.format(move_key, trash_term=trash_term()),
1055+
QMessageBox.ButtonRole.AcceptRole,
10531056
)
1054-
msg.addButton(Translations["generic.no"], QMessageBox.ButtonRole.NoRole)
1055-
msg.setDefaultButton(yes_button)
1057+
msg.setEscapeButton(cancel_button)
1058+
msg.setDefaultButton(cancel_button)
10561059

1057-
return msg.exec()
1060+
msg.exec()
1061+
return msg.clickedButton() == move_button
10581062

10591063
def _run_sync_step(
10601064
self,

‎src/tagstudio/resources/translations/en.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@
7070
"entries.tags": "Tags",
7171
"entries.unlinked.description": "Unlinked entries are file entries that can no longer find their original file on disk. Most entries are automatically relinked during a library sync, however some cases require manual review.",
7272
"entries.unlinked.description.ambiguous": "For unlinked entries that have ambiguous matches to multiple files in your library, you may manually choose how they get relinked.",
73-
"entries.unlinked.description.deleted": "When you delete files outside of TagStudio, their associated entries become unlinked. You may manually delete any unlinked entries at your own discretion.",
73+
"entries.unlinked.description.deleted": "When you delete files outside of TagStudio, their associated entries become unlinked. You may manually remove any unlinked entries at your own discretion.",
7474
"entries.unlinked.relink.manual": "&Manual Relink",
75-
"entries.unlinked.remove": "Delete Unlinked Entries",
76-
"entries.unlinked.remove_alt": "&Delete Unlinked Entries",
75+
"entries.unlinked.remove": "Remove Unlinked Entries",
76+
"entries.unlinked.remove_alt": "Remo&ve Unlinked Entries",
7777
"entries.unlinked.review": "Manual &Review",
7878
"entries.unlinked.title": "Fix Unlinked Entries",
7979
"entries.unlinked.unlinked_count": "Unlinked Entries: {count}",
@@ -106,7 +106,7 @@
106106
"file.date_modified": "Date Modified",
107107
"file.dimensions": "Dimensions",
108108
"file.duplicates.description": "TagStudio supports importing DupeGuru results to manage duplicate files.",
109-
"file.duplicates.dupeguru.advice": "After mirroring, you're free to use DupeGuru to delete the unwanted files. Afterwards, use TagStudio's \"Fix Unlinked Entries\" feature in the Tools menu in order to delete the unlinked Entries.",
109+
"file.duplicates.dupeguru.advice": "After mirroring, you're free to use DupeGuru to delete the unwanted files. Afterwards, use TagStudio's \"Fix Unlinked Entries\" feature in the Tools menu in order to remove the unlinked Entries.",
110110
"file.duplicates.dupeguru.file_extension": "DupeGuru Files (*.dupeguru)",
111111
"file.duplicates.dupeguru.load_file": "&Load DupeGuru File",
112112
"file.duplicates.dupeguru.no_file": "No DupeGuru File Selected",

0 commit comments

Comments
 (0)