Releasing Ubuntu Touch Components 1.1 with two main additions. You can install it to your project by running:

curl -s https://raw.githubusercontent.com/brennoflavio/ut-components/refs/heads/master/scripts/install.sh | bash

Which will copy the qml and python files to qml and src folder.

Here’s the features added.

Python Event Dispatcher

A new Python Singleton is added to manage async events using pyotherside. I’m prototyping a Whatsapp client for Ubuntu Touch and felt hard to send real time events like chat updates to QML in a sane way.

In Python, you can create events and schedule them:

@dataclass
class TestResponse:
    message: str


class Test(Event):
    def trigger(self, metadata: None = None) -> object:
        return TestResponse(message="hello world")

get_event_dispatcher().register_event(Test(id="test"))

def start_loop():
    get_event_dispatcher().start()


def stop_loop():
    get_event_dispatcher().stop()

Then on qml you can manage the loop and register listeners:

Python {
    id: eventLoop

    Component.onCompleted: {
        addImportPath(Qt.resolvedUrl('.'));
        importModule('event_page', function() {
            setHandler('test', function(result) {
                console.log(result);
            });
            call('event_page.start_loop', [], function() {
            });
        });
    }
    Component.onDestruction: {
        call('event_page.stop_loop', [], function() {});
    }
    onError: {
        console.log('python error: ' + traceback);
    }
}

Don’t forget to stop the loop or your page will hang.

Toast Component

Upstreamed from Sealed, a bitwarden client, it gives a visual feedback to the user when some action happens

It has a simple API to use, check the example page in the main repo for more details

You declare the component in your page

Toast {
    id: longToast
    duration: 2000
}

Then you call it to show

longToast.show("This toast stays longer on screen");