Skip to content

Commit

Permalink
feat(Menu): action items can now return not only the application clas…
Browse files Browse the repository at this point in the history
…s, but also instances of applications too

fix(QRCodeWidget): set default value of `fit_mode` to `contain`
  • Loading branch information
sassanh committed May 2, 2024
1 parent 6e4e3d5 commit b17e16d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Version 0.11.3

- feat(Menu): action items can now return not only the application class, but also
instances of applications too
- fix(QRCodeWidget): set default value of `fit_mode` to `contain`

## Version 0.11.2

- refactor(NotificationWidget): improve layout of the notification widget
Expand Down
12 changes: 6 additions & 6 deletions poetry.lock

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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ubo-gui"
version = "0.11.2"
version = "0.11.3"
description = "GUI sdk for Ubo Pod"
authors = ["Sassan Haradji <sassanh@gmail.com>"]
license = "Apache-2.0"
Expand Down
4 changes: 3 additions & 1 deletion ubo_gui/menu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ def select_action_item(self: MenuWidget, item: ActionItem) -> None:
return
if isinstance(result, type) and issubclass(result, PageWidget):
self.open_application(result())
if isinstance(result, PageWidget):
self.open_application(result)
elif isinstance(result, Menu) or callable(result):
self.open_menu(result)
else:
Expand Down Expand Up @@ -550,7 +552,7 @@ def close_application(self: MenuWidget, application: PageWidget) -> None:
self.go_back()

def leave_application(self: MenuWidget, application: PageWidget) -> None:
"""Close an application after its `on_close` event is fired."""
"""Close an application after its `on_leave` event is fired."""
if any(
isinstance(item, StackApplicationItem) and item.application is application
for item in self.stack
Expand Down
5 changes: 4 additions & 1 deletion ubo_gui/menu/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ class ActionItem(Item):
"""

action: Callable[[], Menu | Callable[[], Menu] | type[PageWidget] | None]
action: Callable[
[],
Menu | Callable[[], Menu] | type[PageWidget] | PageWidget | None,
]


class ApplicationItem(Item):
Expand Down
6 changes: 5 additions & 1 deletion ubo_gui/qrcode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@

import qrcode
from kivy.core.image import Image as CoreImage
from kivy.properties import StringProperty
from kivy.properties import OptionProperty, StringProperty
from kivy.uix.image import Image


class QRCodeWidget(Image):
"""A widget to display a QR code."""

content: str = StringProperty()
fit_mode = OptionProperty(
'contain',
options=['scale-down', 'fill', 'contain', 'cover'],
)

def on_content(self: QRCodeWidget, _: QRCodeWidget, value: str) -> None:
"""Handle the `content` property change."""
Expand Down

0 comments on commit b17e16d

Please sign in to comment.