diff --git a/HotStrings/a2_local_element_hotstrings.py b/HotStrings/a2_local_element_hotstrings.py index 0e8b324..17fe3e1 100644 --- a/HotStrings/a2_local_element_hotstrings.py +++ b/HotStrings/a2_local_element_hotstrings.py @@ -169,6 +169,9 @@ def groups(self): return self.user_cfg.get(Args.groups, {}) def _get_group_name(self, group_name=None): + if not self.groups: + return Args.default + current_groups = list(self.groups) if group_name not in current_groups: group_name = self.user_cfg.get(Args.last_group) @@ -207,7 +210,8 @@ def fill_group_combo(self): self.group_combo.addItem(ICONS[group.get(Args.scope_type)], name) else: self.current_name = Args.default - self.current_scope = self.user_cfg[Args.groups] = {Args.default: {}} + self.user_cfg[Args.groups] = {Args.default: {}} + self.current_group = self.groups[self.current_name] self.group_combo.addItem(ICONS[None], Args.default) self.group_combo.addItem(a2ctrl.Icons.list_add, ADD_SCOPE_TXT) @@ -217,6 +221,7 @@ def fill_group_combo(self): def check(self, *args): """Write the hotstrings AHK code and call `change()`.""" self.current_group[Args.hotstrings] = deepcopy(self.editor.data) + self.user_cfg[Args.groups][self.current_name] = self.current_group self.set_user_value(self.user_cfg) hs_dict = hotstrings_io.groups_to_scopes(self.groups) @@ -279,8 +284,10 @@ def remove_group(self): return del self.user_cfg[Args.groups][self.current_name] + # self.current_name = self._get_group_name() + # self.current_group = self.groups.get(self.current_name, {}) + self.select_group(self.current_name) self.fill_and_check() - self.select_group() def _check_hs_include_file(self): """Make sure at least an empty file is there to be included.""" @@ -394,9 +401,6 @@ def _on_group_change(self, name): self.select_group(self.user_cfg.get(Args.last_group)) return - if name == self.current_name: - return - self.current_name = name self.current_group = self.groups.get(name, {}) self.editor.set_data(self.current_group.get(Args.hotstrings, {})) diff --git a/HotStrings/a2module.json b/HotStrings/a2module.json index 016ad34..505aea4 100644 --- a/HotStrings/a2module.json +++ b/HotStrings/a2module.json @@ -1,15 +1,15 @@ [ { "author": "eRiC", - "date": "2016 10 23", + "date": "", "description": "System wide typing triggered actions! To correct spelling, insert longer words with tricky letters or even whole texts as well as fire Autohotkey ... by writing shortcuts.", "display_name": "", "tags": [ "text" ], "typ": "nfo", - "url": "https://github.com/ewerybody/a2.modules/wiki/Hotstrings", - "version": "0.2" + "url": "https://github.com/ewerybody/a2.modules/tree/master/HotStrings", + "version": "0.3" }, { "label": "Import Hotstrings", diff --git a/HotStrings/hotstrings_io.py b/HotStrings/hotstrings_io.py index 4d05003..70237a6 100644 --- a/HotStrings/hotstrings_io.py +++ b/HotStrings/hotstrings_io.py @@ -51,7 +51,7 @@ def groups_to_scopes(group_dict: dict) -> dict: for scope_str in group.get(Args.scopes): target_dict.setdefault(scope_str, {}).update(group.get(Args.hotstrings)) else: - hs_dict.setdefault('', {}).update(group.get(Args.hotstrings)) + hs_dict.setdefault('', {}).update(group.get(Args.hotstrings, {})) return hs_dict diff --git a/a2modsource.json b/a2modsource.json index 5cbb9d7..537e2b8 100644 --- a/a2modsource.json +++ b/a2modsource.json @@ -3,9 +3,9 @@ "maintainer": "ewerybody", "maintainer_at": "gmail.com", "name": "a2.modules", - "news": "* Added Cancel items to `getWinfo` & `DetailsPopup` menus\n* Some work on new Module `WindowControl`\n* new Module `VolumeControl`\n* `HotStrings`: Biiig update!\n + file removed archive attr after write from UI\n + So its not autoreloaded and loaded at the same time causing double runtimes in flight.\n + group add and change finished\n + widget remembers last group selected\n + fixed remove empty group dialog check\n + added groups property, fixed move op\n + fixed group selection remembering\n + group renaming done\n + rename group remembers last selection, current name now also in dialog\n + Scope dialog reimplemented\n + move multiple hotstrings between groups\n + fixed import/export options for the module menu\n + `scopes_to_groups` made to handle impored hotstrings as well\n + fixed hotstrings `remove_group` to properly select afterwards\n + import finished\n + format selection now in File Save Dialog\n + adding and removing groups properly selects new/old group\n + Adding new shortcuts selects Text fields afterwards\n + Disabled groups show an X icon in group list drop down\n + Moving hotstrings can now happen to New Group as well!\n + README.md updated with its documentaion", + "news": "* `HotStrings`: Fix for new/empty setups. a2#232", "update_url": "https://github.com/ewerybody/a2.modules", "url": "https://github.com/ewerybody/a2.modules/wiki", - "version": "0.1.0", + "version": "0.1.1", "zip_size": 88441 } \ No newline at end of file