Added auto sync interval to settings. Improved settings layout.

This commit is contained in:
Mark Qvist 2022-10-08 21:12:36 +02:00
parent 6c19fc85b9
commit d5231da5bb
3 changed files with 198 additions and 117 deletions

View File

@ -837,6 +837,25 @@ class SidebandApp(MDApp):
self.sideband.config["lxmf_sync_limit"] = self.root.ids.settings_lxmf_sync_limit.active self.sideband.config["lxmf_sync_limit"] = self.root.ids.settings_lxmf_sync_limit.active
self.sideband.save_configuration() self.sideband.save_configuration()
def save_lxmf_periodic_sync(sender=None, event=None, save=True):
if self.root.ids.settings_lxmf_periodic_sync.active:
self.widget_hide(self.root.ids.lxmf_syncslider_container, False)
else:
self.widget_hide(self.root.ids.lxmf_syncslider_container, True)
if save:
self.sideband.config["lxmf_periodic_sync"] = self.root.ids.settings_lxmf_periodic_sync.active
self.sideband.save_configuration()
def sync_interval_change(sender=None, event=None, save=True):
interval = (self.root.ids.settings_lxmf_sync_interval.value//300)*300
interval_text = RNS.prettytime(interval)
pre = self.root.ids.settings_lxmf_sync_periodic.text
self.root.ids.settings_lxmf_sync_periodic.text = "Auto sync every "+interval_text
if pre != self.root.ids.settings_lxmf_sync_periodic.text:
if save:
self.sideband.save_configuration()
self.root.ids.settings_lxmf_address.text = RNS.hexrep(self.sideband.lxmf_destination.hash, delimit=False) self.root.ids.settings_lxmf_address.text = RNS.hexrep(self.sideband.lxmf_destination.hash, delimit=False)
self.root.ids.settings_display_name.text = self.sideband.config["display_name"] self.root.ids.settings_display_name.text = self.sideband.config["display_name"]
@ -861,6 +880,15 @@ class SidebandApp(MDApp):
self.root.ids.settings_lxmf_delivery_by_default.active = self.sideband.config["propagation_by_default"] self.root.ids.settings_lxmf_delivery_by_default.active = self.sideband.config["propagation_by_default"]
self.root.ids.settings_lxmf_delivery_by_default.bind(active=save_lxmf_delivery_by_default) self.root.ids.settings_lxmf_delivery_by_default.bind(active=save_lxmf_delivery_by_default)
self.root.ids.settings_lxmf_periodic_sync.active = self.sideband.config["lxmf_periodic_sync"]
self.root.ids.settings_lxmf_periodic_sync.bind(active=save_lxmf_periodic_sync)
save_lxmf_periodic_sync(save=False)
self.root.ids.settings_lxmf_sync_interval.bind(value=sync_interval_change)
self.root.ids.settings_lxmf_sync_interval.value = self.sideband.config["lxmf_sync_interval"]
sync_interval_change(save=False)
if self.sideband.config["lxmf_sync_limit"] == None or self.sideband.config["lxmf_sync_limit"] == False: if self.sideband.config["lxmf_sync_limit"] == None or self.sideband.config["lxmf_sync_limit"] == False:
sync_limit = False sync_limit = False
else: else:

View File

@ -169,6 +169,8 @@ class SidebandCore():
self.config["lxmf_propagation_node"] = None self.config["lxmf_propagation_node"] = None
self.config["lxmf_sync_limit"] = None self.config["lxmf_sync_limit"] = None
self.config["lxmf_sync_max"] = 3 self.config["lxmf_sync_max"] = 3
self.config["lxmf_periodic_sync"] = False
self.config["lxmf_sync_interval"] = 43200
self.config["last_lxmf_propagation_node"] = None self.config["last_lxmf_propagation_node"] = None
self.config["nn_home_node"] = None self.config["nn_home_node"] = None
# Connectivity # Connectivity
@ -212,6 +214,10 @@ class SidebandCore():
# Migration actions from earlier config formats # Migration actions from earlier config formats
if not "dark_ui" in self.config: if not "dark_ui" in self.config:
self.config["dark_ui"] = True self.config["dark_ui"] = True
if not "lxmf_periodic_sync" in self.config:
self.config["lxmf_periodic_sync"] = False
if not "lxmf_sync_interval" in self.config:
self.config["lxmf_sync_interval"] = 43200
# Make sure we have a database # Make sure we have a database
if not os.path.isfile(self.db_path): if not os.path.isfile(self.db_path):

View File

@ -779,7 +779,14 @@ MDNavigationLayout:
MDBoxLayout: MDBoxLayout:
orientation: "vertical" orientation: "vertical"
spacing: "24dp" spacing: 0
size_hint_y: None
height: self.minimum_height
padding: [0, 0, 0, 0]
MDBoxLayout:
orientation: "vertical"
spacing: "16dp"
size_hint_y: None size_hint_y: None
height: self.minimum_height height: self.minimum_height
padding: [dp(28), dp(16), dp(28), dp(16)] padding: [dp(28), dp(16), dp(28), dp(16)]
@ -824,10 +831,18 @@ MDNavigationLayout:
max_text_length: 32 max_text_length: 32
font_size: dp(24) font_size: dp(24)
MDBoxLayout:
orientation: "vertical"
# spacing: "24dp"
size_hint_y: None
height: self.minimum_height
padding: [dp(28), dp(16), dp(28), dp(16)]
MDBoxLayout: MDBoxLayout:
orientation: "horizontal" orientation: "horizontal"
size_hint_y: None size_hint_y: None
padding: [0,0,dp(24),0] padding: [0,0,dp(24),dp(0)]
height: dp(48) height: dp(48)
MDLabel: MDLabel:
@ -842,7 +857,7 @@ MDNavigationLayout:
MDBoxLayout: MDBoxLayout:
orientation: "horizontal" orientation: "horizontal"
size_hint_y: None size_hint_y: None
padding: [0,0,dp(24),0] padding: [0,0,dp(24),dp(0)]
height: dp(48) height: dp(48)
MDLabel: MDLabel:
@ -857,7 +872,7 @@ MDNavigationLayout:
MDBoxLayout: MDBoxLayout:
orientation: "horizontal" orientation: "horizontal"
size_hint_y: None size_hint_y: None
padding: [0,0,dp(24),0] padding: [0,0,dp(24),dp(0)]
height: dp(48) height: dp(48)
MDLabel: MDLabel:
@ -873,7 +888,7 @@ MDNavigationLayout:
MDBoxLayout: MDBoxLayout:
orientation: "horizontal" orientation: "horizontal"
size_hint_y: None size_hint_y: None
padding: [0,0,dp(24),0] padding: [0,0,dp(24),dp(0)]
height: dp(48) height: dp(48)
MDLabel: MDLabel:
@ -889,7 +904,39 @@ MDNavigationLayout:
MDBoxLayout: MDBoxLayout:
orientation: "horizontal" orientation: "horizontal"
size_hint_y: None size_hint_y: None
padding: [0,0,dp(24),0] padding: [0,0,dp(24),dp(0)]
height: dp(48)
MDLabel:
id: settings_lxmf_sync_periodic
text: "Sync with Propagation Node periodically"
font_style: "H6"
MDSwitch:
id: settings_lxmf_periodic_sync
pos_hint: {"center_y": 0.3}
disabled: False
active: False
MDBoxLayout:
id: lxmf_syncslider_container
orientation: "vertical"
size_hint_y: None
padding: [0,0,dp(0),0]
height: dp(68)
MDSlider
min: 300
max: 172800
value: 43200
id: settings_lxmf_sync_interval
sensitivity: "all"
hint: False
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None
padding: [0,0,dp(24),dp(0)]
height: dp(48) height: dp(48)
MDLabel: MDLabel:
@ -905,7 +952,7 @@ MDNavigationLayout:
MDBoxLayout: MDBoxLayout:
orientation: "horizontal" orientation: "horizontal"
size_hint_y: None size_hint_y: None
padding: [0,0,dp(24),0] padding: [0,0,dp(24),dp(0)]
height: dp(48) height: dp(48)
MDLabel: MDLabel: