comparison cagou/core/menu.py @ 417:5b50b7ef2617

menu (TransferMenu): UI improvments: - a white background is now used - ToggleButton have been replaced by SymbolButtonLabel - transfer info message now displays with emphasis if the file will be encrypted or not, and explain when the file goes to the server - various padding/spacing/color adjustments
author Goffi <goffi@goffi.org>
date Sun, 23 Feb 2020 17:16:27 +0100
parents 5761b5f03c0c
children cebf657d78ef
comparison
equal deleted inserted replaced
416:3e2333a11f61 417:5b50b7ef2617
204 class TransferMenu(SideMenu): 204 class TransferMenu(SideMenu):
205 """transfer menu which handle display and callbacks""" 205 """transfer menu which handle display and callbacks"""
206 # callback will be called with path to file to transfer 206 # callback will be called with path to file to transfer
207 # profiles if set will be sent to transfer widget, may be used to get specific files 207 # profiles if set will be sent to transfer widget, may be used to get specific files
208 profiles = properties.ObjectProperty() 208 profiles = properties.ObjectProperty()
209 transfer_txt = _("Beware! The file will be sent to your server and stay unencrypted " 209 transfer_txt = properties.StringProperty()
210 "there\nServer admin(s) can see the file, and they choose how, " 210 transfer_info = properties.ObjectProperty()
211 "when and if it will be deleted") 211 upload_btn = properties.ObjectProperty()
212 send_txt = _("The file will be sent unencrypted directly to your contact " 212 encrypted = properties.BooleanProperty(False)
213 "(without transiting by the server), except in some cases")
214 items_layout = properties.ObjectProperty() 213 items_layout = properties.ObjectProperty()
215 size_hint_close = (1, 0) 214 size_hint_close = (1, 0)
216 size_hint_open = (1, 0.5) 215 size_hint_open = (1, 0.5)
217 bg_color = properties.ListProperty([1, 1, 1, 1])
218 216
219 def __init__(self, **kwargs): 217 def __init__(self, **kwargs):
220 super(TransferMenu, self).__init__(**kwargs) 218 super(TransferMenu, self).__init__(**kwargs)
221 if self.profiles is None: 219 if self.profiles is None:
222 self.profiles = iter(G.host.profiles) 220 self.profiles = iter(G.host.profiles)
223 for plug_info in G.host.getPluggedWidgets(type_=C.PLUG_TYPE_TRANSFER): 221 for plug_info in G.host.getPluggedWidgets(type_=C.PLUG_TYPE_TRANSFER):
224 item = TransferItem( 222 item = TransferItem(
225 plug_info = plug_info 223 plug_info = plug_info
226 ) 224 )
227 self.items_layout.add_widget(item) 225 self.items_layout.add_widget(item)
226
227 def on_kv_post(self, __):
228 self.updateTransferInfo()
229
230 def getTransferInfo(self):
231 if self.upload_btn.state == "down":
232 # upload
233 if self.encrypted:
234 return _(
235 "The file will be [color=00aa00][b]encrypted[/b][/color] and sent to "
236 "your server\nServer admin(s) can delete the file, but they won't be "
237 "able to see its content"
238 )
239 else:
240 return _(
241 "Beware! The file will be sent to your server and stay "
242 "[color=ff0000][b]unencrypted[/b][/color] there\nServer admin(s) "
243 "can see the file, and they choose how, when and if it will be "
244 "deleted"
245 )
246 else:
247 # P2P
248 if self.encrypted:
249 return _(
250 "The file will be sent [color=ff0000][b]unencrypted[/b][/color] "
251 "directly to your contact (it may be transiting by the "
252 "server if direct connection is not possible).\n[color=ff0000]"
253 "Please not that end-to-end encryption is not yet implemented for "
254 "P2P transfer."
255 )
256 else:
257 return _(
258 "The file will be sent [color=ff0000][b]unencrypted[/b][/color] "
259 "directly to your contact (it [i]may be[/i] transiting by the "
260 "server if direct connection is not possible)."
261 )
262
263 def updateTransferInfo(self):
264 self.transfer_info.text = self.getTransferInfo()
228 265
229 def _onTransferCb(self, file_path, external, wid_cont, cleaning_cb=None): 266 def _onTransferCb(self, file_path, external, wid_cont, cleaning_cb=None):
230 if not external: 267 if not external:
231 wid = wid_cont[0] 268 wid = wid_cont[0]
232 self._closeUI(wid) 269 self._closeUI(wid)