Added DB autoload on startup option

This commit is contained in:
Marco Dalla Tiezza
2024-06-06 19:06:45 +02:00
parent faf9a5293a
commit 485eccb373
6 changed files with 223 additions and 165 deletions

View File

@@ -10,6 +10,7 @@ from artemis.utils.path_utils import DATA_DIR
from artemis.utils.network_utils import NetworkManager
from artemis.utils.generic_utils import generate_filter_query
from artemis.utils.path_utils import normalize_dialog_path
from artemis.utils.config_utils import CONFIGURE_QT
from artemis.ui.preferences import UIPreferences
from artemis.ui.dbmanager import UIdbmanager
@@ -69,6 +70,8 @@ class UIArtemis(QObject):
self.network_manager = NetworkManager(self)
self.autoload_db()
def _connect(self):
# QML > Python connections
@@ -331,6 +334,13 @@ class UIArtemis(QObject):
self.cateditor.load_cateditor_ui()
def autoload_db(self):
sig_id_path = DATA_DIR / 'SigID' / Constants.SQL_NAME
autoload = CONFIGURE_QT.get_or_default("Database", "autoload", 0)
if sig_id_path.exists() and int(autoload):
self.load_db('SigID')
def dialog_popup(self, message_type, title, message):
""" Opens a general dialog popup

View File

@@ -9,6 +9,7 @@ class UIPreferences(QObject):
show_ui = Signal()
load_material_accent = Signal(str)
load_material_theme = Signal(str)
load_autoload = Signal(int)
def __init__(self, parent):
@@ -27,11 +28,13 @@ class UIPreferences(QObject):
# QML > Python connections
self._window.saveMaterialAccent.connect(self.save_material_accent)
self._window.saveMaterialTheme.connect(self.save_material_theme)
self._window.saveAutoload.connect(self.save_autoload)
# Python > QML connections
self.show_ui.connect(self._window.show)
self.load_material_accent.connect(self._window.loadMaterialAccent)
self.load_material_theme.connect(self._window.loadMaterialTheme)
self.load_autoload.connect(self._window.loadAutoload)
def load_preferences_ui(self):
@@ -39,6 +42,7 @@ class UIPreferences(QObject):
"""
self.load_material_accent.emit(CONFIGURE_QT.get_or_default("Material", "Accent", "Green"))
self.load_material_theme.emit(CONFIGURE_QT.get_or_default("Material", "Theme", "System"))
self.load_autoload.emit(int(CONFIGURE_QT.get_or_default("Database", "autoload", 0)))
self.show_ui.emit()
@@ -54,3 +58,10 @@ class UIPreferences(QObject):
""" Saving material theme setting
"""
CONFIGURE_QT.set("Material", "Theme", material_theme)
@Slot(int)
def save_autoload(self, autoload):
""" Saving autoload setting
"""
CONFIGURE_QT.set("Database", "autoload", str(autoload))