Skip to content

Commit

Permalink
HotStrings: Fix for new/empty setups. a2#232
Browse files Browse the repository at this point in the history
  • Loading branch information
ewerybody committed May 24, 2021
1 parent 58e794e commit 3003769
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
14 changes: 9 additions & 5 deletions HotStrings/a2_local_element_hotstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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, {}))
Expand Down
6 changes: 3 additions & 3 deletions HotStrings/a2module.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion HotStrings/hotstrings_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 2 additions & 2 deletions a2modsource.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 3003769

Please sign in to comment.