# HG changeset patch # User Goffi # Date 1546544275 -3600 # Node ID 50f7c000b4ae49c72bb75bf2e6504276ffe11f78 # Parent c2503168fab768e9879c7b6841acd31c77d7de49 xmlui: implemented MessageDialog diff -r c2503168fab7 -r 50f7c000b4ae cagou/core/dialog.py --- a/cagou/core/dialog.py Thu Jan 03 10:52:57 2019 +0100 +++ b/cagou/core/dialog.py Thu Jan 03 20:37:55 2019 +0100 @@ -20,6 +20,7 @@ """generic dialogs""" from sat.core.i18n import _ +from cagou.core.constants import Const as C from kivy.uix.boxlayout import BoxLayout from kivy import properties from sat.core import log as logging @@ -27,6 +28,13 @@ log = logging.getLogger(__name__) +class MessageDialog(BoxLayout): + title = properties.StringProperty() + message = properties.StringProperty() + level = properties.OptionProperty(C.XMLUI_DATA_LVL_INFO, options=C.XMLUI_DATA_LVLS) + close_cb = properties.ObjectProperty() + + class ConfirmDialog(BoxLayout): title = properties.StringProperty() message = properties.StringProperty(_(u"Are you sure?")) diff -r c2503168fab7 -r 50f7c000b4ae cagou/core/xmlui.py --- a/cagou/core/xmlui.py Thu Jan 03 10:52:57 2019 +0100 +++ b/cagou/core/xmlui.py Thu Jan 03 20:37:55 2019 +0100 @@ -411,6 +411,29 @@ G.host.addNote(self.title, self.message, self.level) +class MessageDialog(xmlui.MessageDialog, dialog.MessageDialog): + + def __init__(self, _xmlui_parent, title, message, level): + dialog.MessageDialog.__init__(self, + title=title, + message=message, + level=level, + close_cb = self.close_cb) + xmlui.MessageDialog.__init__(self, _xmlui_parent) + + def close_cb(self): + self._xmluiClose() + + def _xmluiShow(self): + G.host.addNotifUI(self) + + def _xmluiClose(self): + G.host.closeUI() + + def show(self, *args, **kwargs): + G.host.showUI(self) + + class ConfirmDialog(xmlui.ConfirmDialog, dialog.ConfirmDialog): def __init__(self, _xmlui_parent, title, message, level, buttons_set): @@ -501,7 +524,8 @@ class XMLUIPanel(xmlui.XMLUIPanel, BoxLayout): widget_factory = WidgetFactory() - def __init__(self, host, parsed_xml, title=None, flags=None, callback=None, ignore=None, whitelist=None, profile=C.PROF_KEY_NONE): + def __init__(self, host, parsed_xml, title=None, flags=None, callback=None, + ignore=None, whitelist=None, profile=C.PROF_KEY_NONE): BoxLayout.__init__(self) self.close_cb = None self._post_treats = [] # list of callback to call after UI is constructed diff -r c2503168fab7 -r 50f7c000b4ae cagou/kv/dialog.kv --- a/cagou/kv/dialog.kv Thu Jan 03 10:52:57 2019 +0100 +++ b/cagou/kv/dialog.kv Thu Jan 03 20:37:55 2019 +0100 @@ -16,6 +16,43 @@ #:import _ sat.core.i18n._ + +: + orientation: "vertical" + spacing: dp(5) + canvas.before: + Color: + rgba: 0, 0, 0, 1 + Rectangle: + pos: self.pos + size: self.size + Label: + size_hint: 1, None + text_size: root.width, None + size: self.texture_size + font_size: sp(20) + padding: dp(5), dp(10) + color: 1, 1, 1, 1 + text: root.title + halign: "center" + italic: True + bold: True + Label: + text: root.message + text_size: root.width, None + size: self.texture_size + padding: dp(25), 0 + font_size: sp(20) + color: 1, 1, 1, 1 + Button: + size_hint: 1, None + height: dp(50) + background_color: 0.33, 1.0, 0.0, 1 + text: _("Close") + bold: True + on_release: root.close_cb() + + : orientation: "vertical" spacing: dp(5)