mirror of
https://github.com/liberatedsystems/Sideband_CE.git
synced 2024-09-03 04:13:27 +02:00
Added map cache control
This commit is contained in:
parent
5110ef3b37
commit
a1aa0544b3
@ -783,6 +783,9 @@ class SidebandApp(MDApp):
|
||||
self.map_action(self)
|
||||
|
||||
if len(modifiers) > 0 and modifiers[0] == 'ctrl' and (text == "p"):
|
||||
if self.root.ids.screen_manager.current == "map_screen":
|
||||
self.map_settings_action()
|
||||
else:
|
||||
self.settings_action(self)
|
||||
|
||||
if len(modifiers) > 0 and modifiers[0] == 'ctrl' and (text == "t"):
|
||||
@ -3517,6 +3520,42 @@ class SidebandApp(MDApp):
|
||||
self.root.ids.nav_drawer.set_state("closed")
|
||||
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
|
||||
|
||||
def update_cache_size(dt):
|
||||
size = self.sideband.get_map_cache_size()
|
||||
size_str = RNS.prettysize(size)
|
||||
self.map_settings_screen.ids.map_cache_button.text = f"Clear {size_str} map cache"
|
||||
if size > 0.0:
|
||||
self.map_settings_screen.ids.map_cache_button.disabled = False
|
||||
else:
|
||||
self.map_settings_screen.ids.map_cache_button.disabled = True
|
||||
self.map_settings_screen.ids.map_cache_button.text = f"No data in map cache"
|
||||
|
||||
Clock.schedule_once(update_cache_size, 0.35)
|
||||
|
||||
def map_clear_cache(self, sender=None):
|
||||
yes_button = MDRectangleFlatButton(text="Yes",font_size=dp(18), theme_text_color="Custom", line_color=self.color_reject, text_color=self.color_reject)
|
||||
no_button = MDRectangleFlatButton(text="No",font_size=dp(18))
|
||||
dialog = MDDialog(
|
||||
title="Clear map cache?",
|
||||
buttons=[ yes_button, no_button ],
|
||||
# elevation=0,
|
||||
)
|
||||
def dl_yes(s):
|
||||
dialog.dismiss()
|
||||
self.sideband.clear_map_cache()
|
||||
|
||||
def cb(dt):
|
||||
self.map_settings_action()
|
||||
self.map_settings_screen.ids.map_cache_button.disabled = True
|
||||
Clock.schedule_once(cb, 1.2)
|
||||
|
||||
def dl_no(s):
|
||||
dialog.dismiss()
|
||||
|
||||
yes_button.bind(on_release=dl_yes)
|
||||
no_button.bind(on_release=dl_no)
|
||||
dialog.open()
|
||||
|
||||
def close_location_error_dialog(self, sender=None):
|
||||
if hasattr(self, "location_error_dialog") and self.location_error_dialog != None:
|
||||
self.location_error_dialog.dismiss()
|
||||
|
@ -348,6 +348,19 @@ class SidebandCore():
|
||||
|
||||
self.__save_config()
|
||||
|
||||
def clear_map_cache(self):
|
||||
for entry in os.scandir(self.map_cache):
|
||||
os.unlink(entry.path)
|
||||
|
||||
def get_map_cache_size(self):
|
||||
total = 0
|
||||
for entry in os.scandir(self.map_cache):
|
||||
if entry.is_dir(follow_symlinks=False):
|
||||
pass
|
||||
else:
|
||||
total += entry.stat(follow_symlinks=False).st_size
|
||||
return total
|
||||
|
||||
def should_persist_data(self):
|
||||
if self.reticulum != None:
|
||||
self.reticulum._should_persist_data()
|
||||
|
@ -946,11 +946,12 @@ MDScreen:
|
||||
MDBoxLayout:
|
||||
orientation: "vertical"
|
||||
size_hint_y: None
|
||||
spacing: dp(24)
|
||||
height: self.minimum_height
|
||||
padding: [0, dp(24), 0, 0]
|
||||
|
||||
MDRectangleFlatIconButton:
|
||||
id: telemetry_icons_button
|
||||
id: map_select_button
|
||||
icon: "list-box-outline"
|
||||
text: "Select MBTiles Map"
|
||||
padding: [dp(0), dp(14), dp(0), dp(14)]
|
||||
@ -959,6 +960,17 @@ MDScreen:
|
||||
size_hint: [1.0, None]
|
||||
on_release: root.app.map_select_file_action(self)
|
||||
disabled: False
|
||||
|
||||
MDRectangleFlatIconButton:
|
||||
id: map_cache_button
|
||||
icon: "map-clock-outline"
|
||||
text: "Clear map cache"
|
||||
padding: [dp(0), dp(14), dp(0), dp(14)]
|
||||
icon_size: dp(24)
|
||||
font_size: dp(16)
|
||||
size_hint: [1.0, None]
|
||||
on_release: root.app.map_clear_cache(self)
|
||||
disabled: False
|
||||
"""
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user