comparison libervia/web/pages/_browser/dialog.py @ 1600:0a4433a343a3

browser (calls): implement WebRTC file sharing: - Send file through WebRTC when the new `file` button is used during a call. - Show a confirmation dialog and download file sent by WebRTC. rel 442
author Goffi <goffi@goffi.org>
date Sat, 06 Apr 2024 13:06:17 +0200
parents 7228fc3c4744
children
comparison
equal deleted inserted replaced
1599:197350e8bf3b 1600:0a4433a343a3
6 log.warning = log.warn 6 log.warning = log.warn
7 7
8 8
9 class CancelError(Exception): 9 class CancelError(Exception):
10 """Dialog is cancelled""" 10 """Dialog is cancelled"""
11
12 def __init__(self, reason: str = "", text: str = "") -> None:
13 self.reason = reason
14 self.text = text
15 super().__init__(text)
11 16
12 17
13 class Confirm: 18 class Confirm:
14 19
15 def __init__(self, message, ok_label="", cancel_label="", ok_color="success"): 20 def __init__(self, message, ok_label="", cancel_label="", ok_color="success"):
32 self._notif_elt = None 37 self._notif_elt = None
33 38
34 def _default_cancel_cb(self, evt, notif_elt): 39 def _default_cancel_cb(self, evt, notif_elt):
35 notif_elt.remove() 40 notif_elt.remove()
36 41
37 def cancel(self): 42 def cancel(self, reason: str = "", text: str = ""):
38 """Cancel the dialog, without calling any callback 43 """Cancel the dialog, without calling any callback
39 44
40 will raise a CancelError 45 will raise a CancelError
41 """ 46 """
42 if self._notif_elt is None: 47 if self._notif_elt is None:
43 log.warning("calling cancel on an unshown dialog") 48 log.warning("calling cancel on an unshown dialog")
44 else: 49 else:
45 self._notif_elt.remove() 50 self._notif_elt.remove()
46 self._notif_elt = None 51 self._notif_elt = None
47 if self._reject_cb is not None: 52 if self._reject_cb is not None:
48 self._reject_cb(CancelError) 53 self._reject_cb(CancelError(reason, text))
49 else: 54 else:
50 log.warning("no reject callback set") 55 log.warning("no reject callback set")
51 self.reset() 56 self.reset()
52 57
53 def on_ok_click(self, evt): 58 def on_ok_click(self, evt):