mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-29 08:40:36 +01:00
Improved settings saving
This commit is contained in:
parent
b716855d61
commit
5cc047c758
@ -313,7 +313,6 @@ class SidebandApp(MDApp):
|
|||||||
ok_button.bind(on_release=dl_ok)
|
ok_button.bind(on_release=dl_ok)
|
||||||
dialog.open()
|
dialog.open()
|
||||||
|
|
||||||
|
|
||||||
def on_pause(self):
|
def on_pause(self):
|
||||||
if self.sideband:
|
if self.sideband:
|
||||||
if self.sideband.getstate("flag.focusfix_pause"):
|
if self.sideband.getstate("flag.focusfix_pause"):
|
||||||
@ -1149,7 +1148,9 @@ class SidebandApp(MDApp):
|
|||||||
def settings_init(self, sender=None):
|
def settings_init(self, sender=None):
|
||||||
if not self.settings_ready:
|
if not self.settings_ready:
|
||||||
self.root.ids.settings_scrollview.effect_cls = ScrollEffect
|
self.root.ids.settings_scrollview.effect_cls = ScrollEffect
|
||||||
|
|
||||||
def save_disp_name(sender=None, event=None):
|
def save_disp_name(sender=None, event=None):
|
||||||
|
if not sender.focus:
|
||||||
in_name = self.root.ids.settings_display_name.text
|
in_name = self.root.ids.settings_display_name.text
|
||||||
if in_name == "":
|
if in_name == "":
|
||||||
new_name = "Anonymous Peer"
|
new_name = "Anonymous Peer"
|
||||||
@ -1160,6 +1161,7 @@ class SidebandApp(MDApp):
|
|||||||
self.sideband.save_configuration()
|
self.sideband.save_configuration()
|
||||||
|
|
||||||
def save_prop_addr(sender=None, event=None):
|
def save_prop_addr(sender=None, event=None):
|
||||||
|
if not sender.focus:
|
||||||
in_addr = self.root.ids.settings_propagation_node_address.text
|
in_addr = self.root.ids.settings_propagation_node_address.text
|
||||||
|
|
||||||
new_addr = None
|
new_addr = None
|
||||||
@ -1206,6 +1208,7 @@ class SidebandApp(MDApp):
|
|||||||
self.sideband.save_configuration()
|
self.sideband.save_configuration()
|
||||||
|
|
||||||
def save_print_command(sender=None, event=None):
|
def save_print_command(sender=None, event=None):
|
||||||
|
if not sender.focus:
|
||||||
in_cmd = self.root.ids.settings_print_command.text
|
in_cmd = self.root.ids.settings_print_command.text
|
||||||
if in_cmd == "":
|
if in_cmd == "":
|
||||||
new_cmd = "lp"
|
new_cmd = "lp"
|
||||||
@ -1239,14 +1242,12 @@ class SidebandApp(MDApp):
|
|||||||
self.root.ids.settings_identity_hash.text = RNS.hexrep(self.sideband.lxmf_destination.identity.hash, delimit=False)
|
self.root.ids.settings_identity_hash.text = RNS.hexrep(self.sideband.lxmf_destination.identity.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"]
|
||||||
self.root.ids.settings_display_name.bind(on_text_validate=save_disp_name)
|
|
||||||
self.root.ids.settings_display_name.bind(focus=save_disp_name)
|
self.root.ids.settings_display_name.bind(focus=save_disp_name)
|
||||||
|
|
||||||
if RNS.vendor.platformutils.is_android():
|
if RNS.vendor.platformutils.is_android():
|
||||||
self.widget_hide(self.root.ids.settings_print_command, True)
|
self.widget_hide(self.root.ids.settings_print_command, True)
|
||||||
else:
|
else:
|
||||||
self.root.ids.settings_print_command.text = self.sideband.config["print_command"]
|
self.root.ids.settings_print_command.text = self.sideband.config["print_command"]
|
||||||
self.root.ids.settings_print_command.bind(on_text_validate=save_print_command)
|
|
||||||
self.root.ids.settings_print_command.bind(focus=save_print_command)
|
self.root.ids.settings_print_command.bind(focus=save_print_command)
|
||||||
|
|
||||||
if self.sideband.config["lxmf_propagation_node"] == None:
|
if self.sideband.config["lxmf_propagation_node"] == None:
|
||||||
@ -1255,7 +1256,6 @@ class SidebandApp(MDApp):
|
|||||||
prop_node_addr = RNS.hexrep(self.sideband.config["lxmf_propagation_node"], delimit=False)
|
prop_node_addr = RNS.hexrep(self.sideband.config["lxmf_propagation_node"], delimit=False)
|
||||||
|
|
||||||
self.root.ids.settings_propagation_node_address.text = prop_node_addr
|
self.root.ids.settings_propagation_node_address.text = prop_node_addr
|
||||||
self.root.ids.settings_propagation_node_address.bind(on_text_validate=save_prop_addr)
|
|
||||||
self.root.ids.settings_propagation_node_address.bind(focus=save_prop_addr)
|
self.root.ids.settings_propagation_node_address.bind(focus=save_prop_addr)
|
||||||
|
|
||||||
if not RNS.vendor.platformutils.is_android() or android_api_version >= 26:
|
if not RNS.vendor.platformutils.is_android() or android_api_version >= 26:
|
||||||
|
@ -124,6 +124,7 @@ class SidebandCore():
|
|||||||
self.exports_dir = self.app_dir+"/exports"
|
self.exports_dir = self.app_dir+"/exports"
|
||||||
|
|
||||||
self.first_run = True
|
self.first_run = True
|
||||||
|
self.saving_configuration = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not os.path.isfile(self.config_path):
|
if not os.path.isfile(self.config_path):
|
||||||
@ -409,9 +410,20 @@ class SidebandCore():
|
|||||||
|
|
||||||
def __save_config(self):
|
def __save_config(self):
|
||||||
RNS.log("Saving Sideband configuration...", RNS.LOG_DEBUG)
|
RNS.log("Saving Sideband configuration...", RNS.LOG_DEBUG)
|
||||||
|
def save_function():
|
||||||
|
while self.saving_configuration:
|
||||||
|
time.sleep(0.15)
|
||||||
|
try:
|
||||||
|
self.saving_configuration = True
|
||||||
config_file = open(self.config_path, "wb")
|
config_file = open(self.config_path, "wb")
|
||||||
config_file.write(msgpack.packb(self.config))
|
config_file.write(msgpack.packb(self.config))
|
||||||
config_file.close()
|
config_file.close()
|
||||||
|
self.saving_configuration = False
|
||||||
|
except Exception as e:
|
||||||
|
self.saving_configuration = False
|
||||||
|
RNS.log("Error while saving Sideband configuration: "+str(e), RNS.LOG_ERROR)
|
||||||
|
|
||||||
|
threading.Thread(target=save_function, daemon=True).start()
|
||||||
|
|
||||||
if self.is_client:
|
if self.is_client:
|
||||||
self.setstate("wants.settings_reload", True)
|
self.setstate("wants.settings_reload", True)
|
||||||
|
Loading…
Reference in New Issue
Block a user