1717 QWidget ,
1818)
1919
20- from tagstudio .core .enums import ShowFilepathOption
20+ from tagstudio .core .enums import ShowFilepathOption , TagClickActionOption
2121from tagstudio .core .global_settings import Theme
2222from tagstudio .qt .translations import DEFAULT_TRANSLATION , LANGUAGES , Translations
2323from tagstudio .qt .widgets .panel import PanelModal , PanelWidget
2424
2525if TYPE_CHECKING :
2626 from tagstudio .qt .ts_qt import QtDriver
2727
28- FILEPATH_OPTION_MAP : dict [ShowFilepathOption , str ] = {
29- ShowFilepathOption .SHOW_FULL_PATHS : Translations ["settings.filepath.option.full" ],
30- ShowFilepathOption .SHOW_RELATIVE_PATHS : Translations ["settings.filepath.option.relative" ],
31- ShowFilepathOption .SHOW_FILENAMES_ONLY : Translations ["settings.filepath.option.name" ],
32- }
28+ FILEPATH_OPTION_MAP : dict [ShowFilepathOption , str ] = {}
3329
34- THEME_MAP : dict [Theme , str ] = {
35- Theme .DARK : Translations ["settings.theme.dark" ],
36- Theme .LIGHT : Translations ["settings.theme.light" ],
37- Theme .SYSTEM : Translations ["settings.theme.system" ],
38- }
30+ THEME_MAP : dict [Theme , str ] = {}
31+
32+ TAG_CLICK_ACTION_MAP : dict [TagClickActionOption , str ] = {}
3933
4034DATE_FORMAT_MAP : dict [str , str ] = {
4135 "%d/%m/%y" : "21/08/24" ,
@@ -61,6 +55,29 @@ class SettingsPanel(PanelWidget):
6155
6256 def __init__ (self , driver : "QtDriver" ):
6357 super ().__init__ ()
58+ # set these "constants" because language will be loaded from config shortly after startup
59+ # and we want to use the current language for the dropdowns
60+ global FILEPATH_OPTION_MAP , THEME_MAP , TAG_CLICK_ACTION_MAP
61+ FILEPATH_OPTION_MAP = {
62+ ShowFilepathOption .SHOW_FULL_PATHS : Translations ["settings.filepath.option.full" ],
63+ ShowFilepathOption .SHOW_RELATIVE_PATHS : Translations [
64+ "settings.filepath.option.relative"
65+ ],
66+ ShowFilepathOption .SHOW_FILENAMES_ONLY : Translations ["settings.filepath.option.name" ],
67+ }
68+ THEME_MAP = {
69+ Theme .DARK : Translations ["settings.theme.dark" ],
70+ Theme .LIGHT : Translations ["settings.theme.light" ],
71+ Theme .SYSTEM : Translations ["settings.theme.system" ],
72+ }
73+ TAG_CLICK_ACTION_MAP = {
74+ TagClickActionOption .OPEN_EDIT : Translations ["settings.tag_click_action.open_edit" ],
75+ TagClickActionOption .SET_SEARCH : Translations ["settings.tag_click_action.set_search" ],
76+ TagClickActionOption .ADD_TO_SEARCH : Translations [
77+ "settings.tag_click_action.add_to_search"
78+ ],
79+ }
80+
6481 self .driver = driver
6582 self .setMinimumSize (400 , 300 )
6683
@@ -158,13 +175,27 @@ def on_page_size_changed():
158175 self .theme_combobox = QComboBox ()
159176 for k in THEME_MAP :
160177 self .theme_combobox .addItem (THEME_MAP [k ], k )
161- theme : Theme = self .driver .settings .theme
178+ theme = self .driver .settings .theme
162179 if theme not in THEME_MAP :
163180 theme = Theme .DEFAULT
164181 self .theme_combobox .setCurrentIndex (list (THEME_MAP .keys ()).index (theme ))
165182 self .theme_combobox .currentIndexChanged .connect (self .__update_restart_label )
166183 form_layout .addRow (Translations ["settings.theme.label" ], self .theme_combobox )
167184
185+ # Tag Click Action
186+ self .tag_click_action_combobox = QComboBox ()
187+ for k in TAG_CLICK_ACTION_MAP :
188+ self .tag_click_action_combobox .addItem (TAG_CLICK_ACTION_MAP [k ], k )
189+ tag_click_action = self .driver .settings .tag_click_action
190+ if tag_click_action not in TAG_CLICK_ACTION_MAP :
191+ tag_click_action = TagClickActionOption .DEFAULT
192+ self .tag_click_action_combobox .setCurrentIndex (
193+ list (TAG_CLICK_ACTION_MAP .keys ()).index (tag_click_action )
194+ )
195+ form_layout .addRow (
196+ Translations ["settings.tag_click_action.label" ], self .tag_click_action_combobox
197+ )
198+
168199 # Date Format
169200 self .dateformat_combobox = QComboBox ()
170201 for k in DATE_FORMAT_MAP :
@@ -206,6 +237,7 @@ def get_settings(self) -> dict:
206237 "page_size" : int (self .page_size_line_edit .text ()),
207238 "show_filepath" : self .filepath_combobox .currentData (),
208239 "theme" : self .theme_combobox .currentData (),
240+ "tag_click_action" : self .tag_click_action_combobox .currentData (),
209241 "date_format" : self .dateformat_combobox .currentData (),
210242 "hour_format" : self .hourformat_checkbox .isChecked (),
211243 "zero_padding" : self .zeropadding_checkbox .isChecked (),
@@ -221,6 +253,7 @@ def update_settings(self, driver: "QtDriver"):
221253 driver .settings .page_size = settings ["page_size" ]
222254 driver .settings .show_filepath = settings ["show_filepath" ]
223255 driver .settings .theme = settings ["theme" ]
256+ driver .settings .tag_click_action = settings ["tag_click_action" ]
224257 driver .settings .date_format = settings ["date_format" ]
225258 driver .settings .hour_format = settings ["hour_format" ]
226259 driver .settings .zero_padding = settings ["zero_padding" ]
0 commit comments