Mercurial > libervia-desktop-kivy
diff cagou/plugins/plugin_wid_remote.py @ 305:b2727877bad4
remote: fixed workflow and size for XMLUI panel used with Ad-Hoc commands:
the XMLUI panel was added to the StackLayout used for discovery, resulting in a bad
sizing. This patch fixes this by moving discovery panel to a new widget, and adding a main
BoxLayout where the XMLUI panel are added.
The XMLUI close callback is now handled properly.
fix 325
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 19 Jul 2019 17:13:05 +0200 |
parents | 1b835bcfa663 |
children | e2afbec1d178 |
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_remote.py Wed Jul 10 08:38:39 2019 +0200 +++ b/cagou/plugins/plugin_wid_remote.py Fri Jul 19 17:13:05 2019 +0200 @@ -34,6 +34,7 @@ from kivy import properties from kivy.uix.label import Label from kivy.uix.boxlayout import BoxLayout +from kivy.uix.floatlayout import FloatLayout from kivy.core.window import Window from cagou import G from functools import partial @@ -146,17 +147,22 @@ self.main_wid.showRootWidget() xml_ui.show() else: - xml_ui.size_hint_y = None - self.main_wid.layout.clear_widgets() + xml_ui.setCloseCb(self.onClose) self.main_wid.layout.add_widget(xml_ui) else: if data: log.warning(_(u"Unhandled data: {data}").format(data=data)) self.main_wid.showRootWidget() + def onClose(self, __, reason): + if reason == C.XMLUI_DATA_CANCELLED: + self.main_wid.showRootWidget() + else: + self.main_wid.layout.clear_widgets() + def adHocRunCb(self, data): xml_ui = xmlui.create(G.host, data, callback=self.xmluiCb, profile=self.profile) - xml_ui.size_hint_y = None + xml_ui.setCloseCb(self.onClose) self.main_wid.layout.add_widget(xml_ui) def do_item_action(self, touch): @@ -165,6 +171,11 @@ callback=self.adHocRunCb, errback=self.main_wid.errback) +class DevicesLayout(FloatLayout): + """Layout used to show devices""" + layout = properties.ObjectProperty() + + class RemoteControl(quick_widgets.QuickWidget, cagou_widget.CagouWidget, FilterBehavior, TouchMenuBehaviour): SINGLE=False @@ -176,6 +187,7 @@ FilterBehavior.__init__(self) TouchMenuBehaviour.__init__(self) Window.bind(on_keyboard=self.key_input) + self.stack_layout = None self.showRootWidget() def errback(self, failure_): @@ -193,6 +205,9 @@ def showRootWidget(self): self.layout.clear_widgets() + devices_layout = DevicesLayout() + self.stack_layout = devices_layout.layout + self.layout.add_widget(devices_layout) found = [] self.get_remotes(found) self.discover_devices(found) @@ -245,12 +260,12 @@ remotes_data, (entities_services, entities_own, entities_roster) = found if remotes_data: title = _(u"media players remote controls") - self.layout.add_widget(CategorySeparator(text=title)) + self.stack_layout.add_widget(CategorySeparator(text=title)) for remote_data in remotes_data: device_jid, node, name = remote_data wid = RemoteItemWidget(device_jid, node, name, self) - self.layout.add_widget(wid) + self.stack_layout.add_widget(wid) for entities_map, title in ((entities_services, _(u'services')), @@ -259,15 +274,15 @@ (entities_roster, _(u'your contacts devices'))): if entities_map: - self.layout.add_widget(CategorySeparator(text=title)) + self.stack_layout.add_widget(CategorySeparator(text=title)) for entity_str, entity_ids in entities_map.iteritems(): entity_jid = jid.JID(entity_str) item = RemoteDeviceWidget( self, entity_jid, Identities(entity_ids)) - self.layout.add_widget(item) + self.stack_layout.add_widget(item) if (not remotes_data and not entities_services and not entities_own and not entities_roster): - self.layout.add_widget(Label( + self.stack_layout.add_widget(Label( size_hint=(1, 1), halign='center', text_size=self.size,