Skip to content

Commit

Permalink
refactor(core): make the power-off menu, a sub-menu with power-off an…
Browse files Browse the repository at this point in the history
…d reboot action items - closes #123
  • Loading branch information
sassanh committed Jul 19, 2024
1 parent f5f0913 commit ce72c6c
Show file tree
Hide file tree
Showing 16 changed files with 245 additions and 67 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- feat(notifications): add `progress` and `progress_weight` properties to `Notification` object and show the progress on the header of the app
- feat(core): show the progress of the update using the new `progress` property of the `Notification` object
- fix(camera): render the viewfinder on the display even if the display is paused - closes #78
- refactor(core): make the power-off menu, a sub-menu with power-off and reboot action items - closes #123

## Version 0.15.4

Expand Down
21 changes: 5 additions & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ python-redux = "^0.15.9"
pyzbar = "^0.1.9"
sdbus-networkmanager = { version = "^2.0.0", markers = "platform_machine=='aarch64'" }
rpi_ws281x = { version = "^5.0.0", markers = "platform_machine=='aarch64'" }
python-debouncer = "^0.1.4"
python-debouncer = "^0.1.5"
pulsectl = "^23.5.2"
aiohttp = "^3.9.1"
semver = "^3.0.2"
Expand All @@ -55,13 +55,13 @@ optional = true

[tool.poetry.group.dev.dependencies]
poethepoet = "^0.24.4"
pyright = "^1.1.371"
pyright = "^1.1.372"
pytest = "^8.0.0"
pytest-asyncio = "^0.23.5.post1"
pytest-cov = "^4.1.0"
pytest-timeout = "^2.3.1"
pytest-xdist = "^3.5.0"
ruff = "^0.5.1"
ruff = "^0.5.3"
tenacity = "^8.2.3"
toml = "^0.10.2"
pytest-mock = "^3.14.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@
}
},
{
"action": "<function:<lambda>>",
"background_color": "#68B7FF",
"color": [
1,
Expand All @@ -214,9 +213,45 @@
],
"icon": "󰐥",
"is_short": true,
"label": "Turn off",
"label": "",
"opacity": null,
"progress": null
"progress": null,
"sub_menu": {
"items": [
{
"action": "<function:<lambda>>",
"background_color": "#68B7FF",
"color": [
1,
1,
1,
1
],
"icon": "󰜉",
"is_short": false,
"label": "Reboot",
"opacity": null,
"progress": null
},
{
"action": "<function:<lambda>>",
"background_color": "#68B7FF",
"color": [
1,
1,
1,
1
],
"icon": "󰤂",
"is_short": false,
"label": "Power off",
"opacity": null,
"progress": null
}
],
"placeholder": null,
"title": "󰐥Power"
}
}
],
"placeholder": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@
}
},
{
"action": "<function:<lambda>>",
"background_color": "#68B7FF",
"color": [
1,
Expand All @@ -214,9 +213,45 @@
],
"icon": "󰐥",
"is_short": true,
"label": "Turn off",
"label": "",
"opacity": null,
"progress": null
"progress": null,
"sub_menu": {
"items": [
{
"action": "<function:<lambda>>",
"background_color": "#68B7FF",
"color": [
1,
1,
1,
1
],
"icon": "󰜉",
"is_short": false,
"label": "Reboot",
"opacity": null,
"progress": null
},
{
"action": "<function:<lambda>>",
"background_color": "#68B7FF",
"color": [
1,
1,
1,
1
],
"icon": "󰤂",
"is_short": false,
"label": "Power off",
"opacity": null,
"progress": null
}
],
"placeholder": null,
"title": "󰐥Power"
}
}
],
"placeholder": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@
}
},
{
"action": "<function:<lambda>>",
"background_color": "#68B7FF",
"color": [
1,
Expand All @@ -519,9 +518,45 @@
],
"icon": "󰐥",
"is_short": true,
"label": "Turn off",
"label": "",
"opacity": null,
"progress": null
"progress": null,
"sub_menu": {
"items": [
{
"action": "<function:<lambda>>",
"background_color": "#68B7FF",
"color": [
1,
1,
1,
1
],
"icon": "󰜉",
"is_short": false,
"label": "Reboot",
"opacity": null,
"progress": null
},
{
"action": "<function:<lambda>>",
"background_color": "#68B7FF",
"color": [
1,
1,
1,
1
],
"icon": "󰤂",
"is_short": false,
"label": "Power off",
"opacity": null,
"progress": null
}
],
"placeholder": null,
"title": "󰐥Power"
}
}
],
"placeholder": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@
}
},
{
"action": "<function:<lambda>>",
"background_color": "#68B7FF",
"color": [
1,
Expand All @@ -519,9 +518,45 @@
],
"icon": "󰐥",
"is_short": true,
"label": "Turn off",
"label": "",
"opacity": null,
"progress": null
"progress": null,
"sub_menu": {
"items": [
{
"action": "<function:<lambda>>",
"background_color": "#68B7FF",
"color": [
1,
1,
1,
1
],
"icon": "󰜉",
"is_short": false,
"label": "Reboot",
"opacity": null,
"progress": null
},
{
"action": "<function:<lambda>>",
"background_color": "#68B7FF",
"color": [
1,
1,
1,
1
],
"icon": "󰤂",
"is_short": false,
"label": "Power off",
"opacity": null,
"progress": null
}
],
"placeholder": null,
"title": "󰐥Power"
}
}
],
"placeholder": null,
Expand Down
7 changes: 5 additions & 2 deletions ubo_app/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from numpy._typing import NDArray


from ubo_app.constants import BYTES_PER_PIXEL
from ubo_app.utils import IS_RPI
from ubo_app.utils.fake import Fake

Expand Down Expand Up @@ -101,12 +102,14 @@ def __init__(self: _State, splash_screen: bytes | None = None) -> None:

self.block(
(0, 0, WIDTH - 1, HEIGHT - 1),
bytes(WIDTH * HEIGHT * 2) if splash_screen is None else splash_screen,
bytes(WIDTH * HEIGHT * BYTES_PER_PIXEL)
if splash_screen is None
else splash_screen,
)
atexit.register(
lambda: self.block(
(0, 0, WIDTH - 1, HEIGHT - 1),
bytes(WIDTH * HEIGHT * 2),
np.zeros((WIDTH, HEIGHT, BYTES_PER_PIXEL), dtype=np.uint8).tobytes(),
),
)

Expand Down
2 changes: 1 addition & 1 deletion ubo_app/menu_app/menu_central.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self: MenuAppCentral, **kwargs: object) -> None:

@autorun(lambda state: state.main.menu)
@debounce(0.1, DebounceOptions(leading=True, trailing=True, time_window=0.1))
async def _(menu: Menu | None) -> None:
def _(menu: Menu | None) -> None:
self = _self()
if not self or not menu:
return
Expand Down
4 changes: 3 additions & 1 deletion ubo_app/services/040-camera/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from debouncer import DebounceOptions, debounce
from kivy.clock import Clock, mainthread
from pyzbar.pyzbar import decode
from typing_extensions import override
from ubo_gui.page import PageWidget

from ubo_app import display
Expand Down Expand Up @@ -59,11 +60,12 @@ def resize_image(
wait=THROTTL_TIME,
options=DebounceOptions(leading=True, trailing=False, time_window=THROTTL_TIME),
)
async def check_codes(codes: list[str]) -> None:
def check_codes(codes: list[str]) -> None:
dispatch(CameraReportBarcodeAction(codes=codes))


class CameraApplication(PageWidget):
@override
def go_back(self: CameraApplication) -> bool:
return True

Expand Down
Loading

0 comments on commit ce72c6c

Please sign in to comment.