diff --git a/src/tagstudio/qt/mixed/color_box.py b/src/tagstudio/qt/mixed/color_box.py index 20866c438..451465e0f 100644 --- a/src/tagstudio/qt/mixed/color_box.py +++ b/src/tagstudio/qt/mixed/color_box.py @@ -121,7 +121,7 @@ def set_colors(self, colors: Iterable[TagColorGroup]): TagColorGroup( slug="slug", namespace=self.namespace, - name="Color", + name=Translations["color.placeholder"], primary="#FFFFFF", secondary=None, ) diff --git a/src/tagstudio/qt/mixed/field_containers.py b/src/tagstudio/qt/mixed/field_containers.py index ae8df9107..63721fab9 100644 --- a/src/tagstudio/qt/mixed/field_containers.py +++ b/src/tagstudio/qt/mixed/field_containers.py @@ -479,13 +479,14 @@ def update_field(self, field: BaseField, content: str) -> None: def remove_message_box(self, prompt: str, callback: Callable) -> None: remove_mb = QMessageBox() remove_mb.setText(prompt) - remove_mb.setWindowTitle("Remove Field") + remove_mb.setWindowTitle(Translations["library.field.remove"]) remove_mb.setIcon(QMessageBox.Icon.Warning) - cancel_button = remove_mb.addButton( - Translations["generic.cancel_alt"], QMessageBox.ButtonRole.DestructiveRole + cancel_button = remove_mb.addButton(QMessageBox.StandardButton.Cancel) + cancel_button.setText(Translations["generic.cancel_alt"]) + remove_mb.addButton(QMessageBox.StandardButton.Discard).setText( + Translations["generic.remove_alt"] ) - remove_mb.addButton("&Remove", QMessageBox.ButtonRole.RejectRole) remove_mb.setEscapeButton(cancel_button) - result = remove_mb.exec_() - if result == QMessageBox.ButtonRole.ActionRole.value: + result = remove_mb.exec() + if result == QMessageBox.StandardButton.Discard: callback() diff --git a/src/tagstudio/qt/mixed/folders_to_tags.py b/src/tagstudio/qt/mixed/folders_to_tags.py index f7051f775..0e17f7c89 100644 --- a/src/tagstudio/qt/mixed/folders_to_tags.py +++ b/src/tagstudio/qt/mixed/folders_to_tags.py @@ -184,13 +184,9 @@ def __init__(self, library: "Library", driver: "QtDriver"): self.title_widget.setStyleSheet("font-weight:bold;font-size:14px;padding-top: 6px") self.title_widget.setAlignment(Qt.AlignmentFlag.AlignCenter) - self.desc_widget = QLabel() + self.desc_widget = QLabel(Translations["folders_to_tags.description"]) self.desc_widget.setObjectName("descriptionLabel") self.desc_widget.setWordWrap(True) - self.desc_widget.setText( - """Creates tags based on your folder structure and applies them to your entries. - This tree shows all tags to be created and which entries they will be applied to.""" - ) self.desc_widget.setAlignment(Qt.AlignmentFlag.AlignCenter) self.open_close_button_w = QWidget() diff --git a/src/tagstudio/qt/mixed/settings_panel.py b/src/tagstudio/qt/mixed/settings_panel.py index 609ed5b05..1836c0005 100644 --- a/src/tagstudio/qt/mixed/settings_panel.py +++ b/src/tagstudio/qt/mixed/settings_panel.py @@ -39,32 +39,6 @@ class SettingsPanel(PanelWidget): driver: "QtDriver" - filepath_option_map: dict[ShowFilepathOption, str] = { - ShowFilepathOption.SHOW_FULL_PATHS: Translations["settings.filepath.option.full"], - ShowFilepathOption.SHOW_RELATIVE_PATHS: Translations["settings.filepath.option.relative"], - ShowFilepathOption.SHOW_FILENAMES_ONLY: Translations["settings.filepath.option.name"], - } - - theme_map: dict[Theme, str] = { - Theme.SYSTEM: Translations["settings.theme.system"], - Theme.DARK: Translations["settings.theme.dark"], - Theme.LIGHT: Translations["settings.theme.light"], - } - - splash_map: dict[Splash, str] = { - Splash.DEFAULT: Translations["settings.splash.option.default"], - Splash.RANDOM: Translations["settings.splash.option.random"], - Splash.CLASSIC: Translations["settings.splash.option.classic"], - Splash.GOO_GEARS: Translations["settings.splash.option.goo_gears"], - Splash.NINETY_FIVE: Translations["settings.splash.option.ninety_five"], - } - - tag_click_action_map: dict[TagClickActionOption, str] = { - TagClickActionOption.OPEN_EDIT: Translations["settings.tag_click_action.open_edit"], - TagClickActionOption.SET_SEARCH: Translations["settings.tag_click_action.set_search"], - TagClickActionOption.ADD_TO_SEARCH: Translations["settings.tag_click_action.add_to_search"], - } - date_format_map: dict[str, str] = { "%d/%m/%y": "21/08/24", "%d/%m/%Y": "21/08/2024", @@ -85,8 +59,6 @@ class SettingsPanel(PanelWidget): def __init__(self, driver: "QtDriver"): super().__init__() - # set these "constants" because language will be loaded from config shortly after startup - # and we want to use the current language for the dropdowns self.driver = driver self.setMinimumSize(400, 500) @@ -206,25 +178,39 @@ def on_page_size_changed(): # Show Filepath self.filepath_combobox = QComboBox() - for k in SettingsPanel.filepath_option_map: - self.filepath_combobox.addItem(SettingsPanel.filepath_option_map[k], k) + self.filepath_combobox.addItem( + Translations["settings.filepath.option.full"], ShowFilepathOption.SHOW_FULL_PATHS + ) + self.filepath_combobox.addItem( + Translations["settings.filepath.option.relative"], + ShowFilepathOption.SHOW_RELATIVE_PATHS, + ) + self.filepath_combobox.addItem( + Translations["settings.filepath.option.name"], ShowFilepathOption.SHOW_FILENAMES_ONLY + ) filepath_option: ShowFilepathOption = self.driver.settings.show_filepath - if filepath_option not in SettingsPanel.filepath_option_map: + if self.filepath_combobox.findData(filepath_option) == -1: filepath_option = ShowFilepathOption.DEFAULT - self.filepath_combobox.setCurrentIndex( - list(SettingsPanel.filepath_option_map.keys()).index(filepath_option) - ) + self.filepath_combobox.setCurrentIndex(self.filepath_combobox.findData(filepath_option)) form_layout.addRow(Translations["settings.filepath.label"], self.filepath_combobox) # Tag Click Action self.tag_click_action_combobox = QComboBox() - for k in SettingsPanel.tag_click_action_map: - self.tag_click_action_combobox.addItem(SettingsPanel.tag_click_action_map[k], k) + self.tag_click_action_combobox.addItem( + Translations["settings.tag_click_action.open_edit"], TagClickActionOption.OPEN_EDIT + ) + self.tag_click_action_combobox.addItem( + Translations["settings.tag_click_action.set_search"], TagClickActionOption.SET_SEARCH + ) + self.tag_click_action_combobox.addItem( + Translations["settings.tag_click_action.add_to_search"], + TagClickActionOption.ADD_TO_SEARCH, + ) tag_click_action = self.driver.settings.tag_click_action - if tag_click_action not in SettingsPanel.tag_click_action_map: + if self.tag_click_action_combobox.findData(tag_click_action) == -1: tag_click_action = TagClickActionOption.DEFAULT self.tag_click_action_combobox.setCurrentIndex( - list(SettingsPanel.tag_click_action_map.keys()).index(tag_click_action) + self.tag_click_action_combobox.findData(tag_click_action) ) form_layout.addRow( Translations["settings.tag_click_action.label"], self.tag_click_action_combobox @@ -232,23 +218,31 @@ def on_page_size_changed(): # Dark Mode self.theme_combobox = QComboBox() - for k in SettingsPanel.theme_map: - self.theme_combobox.addItem(SettingsPanel.theme_map[k], k) + self.theme_combobox.addItem(Translations["settings.theme.system"], Theme.SYSTEM) + self.theme_combobox.addItem(Translations["settings.theme.dark"], Theme.DARK) + self.theme_combobox.addItem(Translations["settings.theme.light"], Theme.LIGHT) theme = self.driver.settings.theme - if theme not in SettingsPanel.theme_map: + if self.theme_combobox.findData(theme) == -1: theme = Theme.DEFAULT - self.theme_combobox.setCurrentIndex(list(SettingsPanel.theme_map.keys()).index(theme)) + self.theme_combobox.setCurrentIndex(self.theme_combobox.findData(theme)) self.theme_combobox.currentIndexChanged.connect(self.__update_restart_label) form_layout.addRow(Translations["settings.theme.label"], self.theme_combobox) # Splash Screen self.splash_combobox = QComboBox() - for k in SettingsPanel.splash_map: - self.splash_combobox.addItem(SettingsPanel.splash_map[k], k) + self.splash_combobox.addItem(Translations["settings.splash.option.default"], Splash.DEFAULT) + self.splash_combobox.addItem(Translations["settings.splash.option.random"], Splash.RANDOM) + self.splash_combobox.addItem(Translations["settings.splash.option.classic"], Splash.CLASSIC) + self.splash_combobox.addItem( + Translations["settings.splash.option.goo_gears"], Splash.GOO_GEARS + ) + self.splash_combobox.addItem( + Translations["settings.splash.option.ninety_five"], Splash.NINETY_FIVE + ) splash = self.driver.settings.splash - if splash not in SettingsPanel.splash_map: + if self.splash_combobox.findData(splash) == -1: splash = Splash.DEFAULT - self.splash_combobox.setCurrentIndex(list(SettingsPanel.splash_map.keys()).index(splash)) + self.splash_combobox.setCurrentIndex(self.splash_combobox.findData(splash)) form_layout.addRow(Translations["settings.splash.label"], self.splash_combobox) # Date Format diff --git a/src/tagstudio/qt/mixed/tag_database.py b/src/tagstudio/qt/mixed/tag_database.py index 180cee9c7..6d94cd34c 100644 --- a/src/tagstudio/qt/mixed/tag_database.py +++ b/src/tagstudio/qt/mixed/tag_database.py @@ -60,15 +60,20 @@ def delete_tag(self, tag: Tag): return message_box = QMessageBox( - QMessageBox.Question, # type: ignore + QMessageBox.Warning, # type: ignore Translations["tag.remove"], Translations.format("tag.confirm_delete", tag_name=self.lib.tag_display_name(tag)), - QMessageBox.Ok | QMessageBox.Cancel, # type: ignore + ) + message_box.addButton(QMessageBox.StandardButton.Discard).setText( + Translations["generic.remove"] + ) + message_box.addButton(QMessageBox.StandardButton.Cancel).setText( + Translations["generic.cancel"] ) result = message_box.exec() - if result != QMessageBox.Ok: # type: ignore + if result != QMessageBox.StandardButton.Discard: return self.lib.remove_tag(tag.id) diff --git a/src/tagstudio/qt/mixed/tag_search.py b/src/tagstudio/qt/mixed/tag_search.py index 3a3e120b4..da8cc6a6e 100644 --- a/src/tagstudio/qt/mixed/tag_search.py +++ b/src/tagstudio/qt/mixed/tag_search.py @@ -70,7 +70,7 @@ class TagSearchPanel(PanelWidget): is_tag_chooser: bool exclude: list[int] - _limit_items: list[int | str] = [25, 50, 100, 250, 500, Translations["tag.all_tags"]] + _limit_items: list[int | str] = [25, 50, 100, 250, 500] _default_limit_idx: int = 0 # 50 Tag Limit (Default) cur_limit_idx: int = _default_limit_idx tag_limit: int | str = _limit_items[_default_limit_idx] @@ -105,6 +105,7 @@ def __init__( self.limit_combobox = QComboBox() self.limit_combobox.setEditable(False) self.limit_combobox.addItems([str(x) for x in TagSearchPanel._limit_items]) + self.limit_combobox.addItem(Translations["tag.all_tags"]) self.limit_combobox.setCurrentIndex(TagSearchPanel._default_limit_idx) self.limit_combobox.currentIndexChanged.connect(self.update_limit) self.previous_limit: int = ( diff --git a/src/tagstudio/qt/ts_qt.py b/src/tagstudio/qt/ts_qt.py index ab81b4e27..12d67a588 100644 --- a/src/tagstudio/qt/ts_qt.py +++ b/src/tagstudio/qt/ts_qt.py @@ -995,9 +995,9 @@ def delete_file_confirmation(self, count: int, filename: Path | None = None) -> msg.setStyleSheet("font-weight:normal;") msg.setTextFormat(Qt.TextFormat.RichText) msg.setWindowTitle( - Translations["trash.title.singular"] + Translations["trash.dialog.title.singular"] if count == 1 - else Translations["trash.title.plural"] + else Translations["trash.dialog.title.plural"] ) msg.setIcon(QMessageBox.Icon.Warning) if count <= 1: @@ -1022,8 +1022,10 @@ def delete_file_confirmation(self, count: int, filename: Path | None = None) -> f"{perm_warning}
" ) - yes_button: QPushButton = msg.addButton("&Yes", QMessageBox.ButtonRole.YesRole) - msg.addButton("&No", QMessageBox.ButtonRole.NoRole) + yes_button: QPushButton = msg.addButton( + Translations["generic.yes"], QMessageBox.ButtonRole.YesRole + ) + msg.addButton(Translations["generic.no"], QMessageBox.ButtonRole.NoRole) msg.setDefaultButton(yes_button) return msg.exec() diff --git a/src/tagstudio/qt/views/main_window.py b/src/tagstudio/qt/views/main_window.py index a4c0485a5..b900ae794 100644 --- a/src/tagstudio/qt/views/main_window.py +++ b/src/tagstudio/qt/views/main_window.py @@ -443,14 +443,6 @@ def rebuild_open_recent_library_menu( # View Component class MainWindow(QMainWindow): - THUMB_SIZES: list[tuple[str, int]] = [ - (Translations["home.thumbnail_size.extra_large"], 256), - (Translations["home.thumbnail_size.large"], 192), - (Translations["home.thumbnail_size.medium"], 128), - (Translations["home.thumbnail_size.small"], 96), - (Translations["home.thumbnail_size.mini"], 76), - ] - def __init__(self, driver: "QtDriver", parent: QWidget | None = None) -> None: super().__init__(parent) self.rm = ResourceManager() @@ -669,8 +661,11 @@ def setup_extra_input_bar(self): self.thumb_size_combobox.setMinimumWidth(128) self.thumb_size_combobox.setMaximumWidth(352) self.extra_input_layout.addWidget(self.thumb_size_combobox) - for size in MainWindow.THUMB_SIZES: - self.thumb_size_combobox.addItem(size[0], size[1]) + self.thumb_size_combobox.addItem(Translations["home.thumbnail_size.extra_large"], 256) + self.thumb_size_combobox.addItem(Translations["home.thumbnail_size.large"], 192) + self.thumb_size_combobox.addItem(Translations["home.thumbnail_size.medium"], 128) + self.thumb_size_combobox.addItem(Translations["home.thumbnail_size.small"], 96) + self.thumb_size_combobox.addItem(Translations["home.thumbnail_size.mini"], 76) self.thumb_size_combobox.setCurrentIndex(2) # Default: Medium self.central_layout.addLayout(self.extra_input_layout, 5, 0, 1, 1)