2024-12-21 20:50:09 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
2024-12-23 17:12:21 +01:00
|
|
|
import os
|
|
|
|
from pathlib import Path
|
|
|
|
|
2024-12-21 20:50:09 +01:00
|
|
|
|
|
|
|
class Utils:
|
2024-12-23 17:12:21 +01:00
|
|
|
home_path = str(Path.home())
|
|
|
|
wobuzz_location = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
settings_location = f"{wobuzz_location}/settings.json"
|
|
|
|
|
2024-12-21 20:50:09 +01:00
|
|
|
def __init__(self, app):
|
|
|
|
self.app = app
|
|
|
|
|
|
|
|
def format_time(self, ms):
|
|
|
|
seconds = int(ms / 1000) % 60
|
|
|
|
minutes = int(ms / (1000 * 60)) % 60
|
|
|
|
hours = int(ms / (1000 * 60 * 60))
|
|
|
|
|
|
|
|
seconds_str, minutes_str, hours_str = ("",) * 3 # create empty strings
|
|
|
|
|
|
|
|
if hours > 0:
|
|
|
|
hours_str = f"{hours}:"
|
|
|
|
|
|
|
|
minutes_str = f"{minutes}:".zfill(2)
|
|
|
|
seconds_str = f"{seconds}".zfill(2)
|
|
|
|
|
|
|
|
output = hours_str + minutes_str + seconds_str
|
|
|
|
|
|
|
|
return output
|
|
|
|
|
2024-12-23 17:12:21 +01:00
|
|
|
def on_close(self, event):
|
|
|
|
self.app.settings.window_size = (self.app.gui.window.width(), self.app.gui.window.height())
|
|
|
|
self.app.settings.window_maximized = self.app.gui.window.isMaximized()
|
|
|
|
|
|
|
|
self.app.settings.save(self.settings_location)
|
|
|
|
|
2024-12-21 20:50:09 +01:00
|
|
|
|