Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit aec3120

Browse files
committed
feat(#55): add "Copy as new..." functionality for icons
1 parent 4c73e65 commit aec3120

File tree

6 files changed

+19
-7
lines changed

6 files changed

+19
-7
lines changed

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ ignore = ["E501", "W504"]
2222
max-complexity = 10
2323

2424
[tool.pytest.ini_options]
25-
addopts = "--cov=src --cov=test --cov-report=term-missing:skip-covered --cov-fail-under=26"
25+
addopts = "--cov=src --cov=test --cov-report=term-missing:skip-covered --cov-fail-under=63"
2626
pythonpath = ["src/progman"]
2727
testpaths = ["test"]
2828

29+
[tool.coverage.run]
30+
omit = ["src/progman/ui/*"]
31+
2932
[tool.ruff]
3033
exclude = [".venv", "scripts"]
3134
lint.ignore = ["E501"]

src/progman/core/language.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class Language:
1818
"window_list": "Window list"
1919
},
2020
"icon": {
21-
"copy": "Copy",
22-
"copy_to": "Copy to...",
23-
"move_to": "Move to...",
21+
"copy_as_new": "Copy as new...",
22+
"copy_to": "Copy to",
23+
"move_to": "Move to",
2424
"delete": "Delete",
2525
"properties": "Properties..."
2626
},
@@ -37,6 +37,7 @@ class Language:
3737
"browse": "Browse...",
3838
"cancel": "Cancel",
3939
"change_icon": "Change icon...",
40+
"copy_as_new": "Copy as new...",
4041
"edit_icon": "Edit icon properties",
4142
"name": "Name:",
4243
"new_icon": "New icon properties",

src/progman/core/state.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def add_group(self, group: Group) -> None:
3838

3939
def add_shortcut(self, new_item: Shortcut) -> None:
4040
self.shortcuts.append(new_item)
41+
for tag in new_item.tags:
42+
group = self.group_windows[tag]
43+
group.add_icon(new_item)
4144
for tag in new_item.tags:
4245
self._groups[tag].append(new_item)
4346

src/progman/ui/appicon.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def __init__(self, shortcut: Shortcut, *args: any, **kwargs: any) -> None:
1414
Icon.__init__(self, *args, **kwargs)
1515
self._shortcut = shortcut
1616
self._menu_items = [
17+
MenuItem("copy_as_new", command=self.copy_as_new),
1718
MenuItem("copy_to", type="submenu"),
1819
MenuItem("move_to", type="submenu"),
1920
MenuItem("delete", command=self.delete_icon),
@@ -95,3 +96,8 @@ def _move_to_group(self, group: str) -> None:
9596

9697
def _copy_to_group(self, group: str) -> None:
9798
self.app_state.copy_shortcut_to_new_group(self._shortcut, group)
99+
100+
def copy_as_new(self) -> None:
101+
dialog = IconPropertiesDialog(self, "copy_as_new", self._shortcut)
102+
if dialog.result:
103+
self.app_state.add_shortcut(dialog.result)

src/progman/ui/mainwindow.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,4 @@ def show_new_icon_dialog(self) -> None:
101101
dialog = IconPropertiesDialog(self, "new_icon")
102102
if dialog.result:
103103
self.app_state.add_shortcut(dialog.result)
104-
for tag in dialog.result.tags:
105-
group = self.app_state.group_windows[tag]
106-
group.add_icon(dialog.result)
107104
# endregion

test/test_core/test_state.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ def test_add_group(self, set_geometry: Mock):
2424
def test_add_shortcut(self):
2525
mock_shortcut = Mock(tags=["foo"])
2626
self.test_object._groups["foo"] = Mock()
27+
self.test_object.group_windows = {"foo": Mock()}
2728
self.test_object.add_shortcut(mock_shortcut)
2829
assert self.test_object.shortcuts == [mock_shortcut]
2930
self.test_object._groups["foo"].append.assert_called_once_with(mock_shortcut)
31+
self.test_object.group_windows["foo"].add_icon.assert_called_once_with(mock_shortcut)
3032

3133
def test_public_groups(self):
3234
self.test_object._groups = {"foo": Mock(), "bar": Mock(), "baz": Mock(), "New": Mock()}

0 commit comments

Comments
 (0)