# HG changeset patch # User Goffi # Date 1563549185 -7200 # Node ID b2727877bad41943d0525a53a4e4eef362dbe070 # Parent 00e2bcf0d9dfccfc3e6e0e6de64337ce1ff522b9 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 diff -r 00e2bcf0d9df -r b2727877bad4 cagou/core/profile_manager.py --- a/cagou/core/profile_manager.py Wed Jul 10 08:38:39 2019 +0200 +++ b/cagou/core/profile_manager.py Fri Jul 19 17:13:05 2019 +0200 @@ -142,7 +142,7 @@ self.add_widget(self.screen_manager) self.bind(selected=self.onProfileSelect) - def closeUI(self, xmlui): + def closeUI(self, xmlui, reason=None): self.screen_manager.transition.direction = 'right' self.screen_manager.current = 'profiles' diff -r 00e2bcf0d9df -r b2727877bad4 cagou/core/xmlui.py --- a/cagou/core/xmlui.py Wed Jul 10 08:38:39 2019 +0200 +++ b/cagou/core/xmlui.py Fri Jul 19 17:13:05 2019 +0200 @@ -20,7 +20,6 @@ from sat.core.i18n import _ from .constants import Const as C from sat.core.log import getLogger -log = getLogger(__name__) from sat_frontends.tools import xmlui from kivy.uix.scrollview import ScrollView from kivy.uix.boxlayout import BoxLayout @@ -37,6 +36,7 @@ from cagou.core import dialog from functools import partial +log = getLogger(__name__) ## Widgets ## @@ -405,7 +405,7 @@ def _xmluiShow(self): G.host.addNotifUI(self) - def _xmluiClose(self): + def _xmluiClose(self, reason=None): G.host.closeUI() def show(self, *args, **kwargs): @@ -433,7 +433,7 @@ def _xmluiShow(self): G.host.addNotifUI(self) - def _xmluiClose(self): + def _xmluiClose(self, reason=None): G.host.closeUI() def show(self, *args, **kwargs): @@ -454,7 +454,7 @@ def _xmluiShow(self): G.host.addNotifUI(self) - def _xmluiClose(self): + def _xmluiClose(self, reason=None): # FIXME: notif UI is not removed if dialog is not shown yet G.host.closeUI() @@ -554,9 +554,9 @@ def setCloseCb(self, close_cb): self.close_cb = close_cb - def _xmluiClose(self, *__): + def _xmluiClose(self, __=None, reason=None): if self.close_cb is not None: - self.close_cb(self) + self.close_cb(self, reason) else: G.host.closeUI() @@ -598,12 +598,12 @@ self.layout.add_widget(self.save_btn) elif self.type == 'window': cancel_btn = CancelButton(text=_(u"Cancel")) - cancel_btn.bind(on_press=self._xmluiClose) + cancel_btn.bind( + on_press=partial(self._xmluiClose, reason=C.XMLUI_DATA_CANCELLED)) self.layout.add_widget(cancel_btn) def onHeight(self, __, height): if isinstance(self.main_cont, TabsContainer): - # when the main other_children_height = sum([c.height for c in self.layout.children if c is not self.main_cont]) self.main_cont.height = height - other_children_height diff -r 00e2bcf0d9df -r b2727877bad4 cagou/plugins/plugin_wid_remote.kv --- a/cagou/plugins/plugin_wid_remote.kv Wed Jul 10 08:38:39 2019 +0200 +++ b/cagou/plugins/plugin_wid_remote.kv Fri Jul 19 17:13:05 2019 +0200 @@ -16,21 +16,25 @@ : - float_layout: float_layout + layout: layout + BoxLayout: + id: layout + + +: layout: layout - FloatLayout: - id: float_layout - ScrollView: - size_hint: 1, 1 - pos_hint: {'x': 0, 'y': 0} - do_scroll_x: False - scroll_type: ['bars', 'content'] - bar_width: dp(6) - StackLayout: - id: layout - size_hint: 1, None - height: self.minimum_height - spacing: 0 + size_hint: 1, 1 + ScrollView: + size_hint: 1, 1 + pos_hint: {'x': 0, 'y': 0} + do_scroll_x: False + scroll_type: ['bars', 'content'] + bar_width: dp(6) + StackLayout: + id: layout + size_hint: 1, None + height: self.minimum_height + spacing: 0 : diff -r 00e2bcf0d9df -r b2727877bad4 cagou/plugins/plugin_wid_remote.py --- 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,