Add mock mode support and input validation
This commit is contained in:
@@ -8,17 +8,19 @@ from .pages.additional_modules import ModulesPage
|
||||
from .pages.install_mode import InstallModePage
|
||||
from .pages.partitioning import PartitioningPage, calculate_auto_partitions
|
||||
from .pages.storage import StoragePage
|
||||
from .pages.summary import SummaryPage
|
||||
from .pages.user import UserPage
|
||||
from .pages.welcome import WelcomePage
|
||||
from .pages.summary import SummaryPage
|
||||
|
||||
|
||||
class InstallerWindow(Adw.ApplicationWindow):
|
||||
def __init__(self, *args, **kwargs):
|
||||
def __init__(self, mock_mode=False, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.mock_mode = mock_mode
|
||||
|
||||
self.set_default_size(900, 650)
|
||||
self.set_title("Iridium Installer")
|
||||
self.set_title("Iridium Installer" + (" (MOCK MODE)" if mock_mode else ""))
|
||||
|
||||
self.toolbar_view = Adw.ToolbarView()
|
||||
self.set_content(self.toolbar_view)
|
||||
@@ -71,6 +73,7 @@ class InstallerWindow(Adw.ApplicationWindow):
|
||||
self.partitioning_page = PartitioningPage()
|
||||
self.modules_page = ModulesPage()
|
||||
self.user_page = UserPage()
|
||||
self.user_page.connect("validity-changed", self.on_user_validity_changed)
|
||||
self.summary_page = SummaryPage()
|
||||
|
||||
# Add Pages
|
||||
@@ -94,6 +97,9 @@ class InstallerWindow(Adw.ApplicationWindow):
|
||||
def on_disk_selected(self, page, device_name):
|
||||
self.update_buttons()
|
||||
|
||||
def on_user_validity_changed(self, page, valid):
|
||||
self.update_buttons()
|
||||
|
||||
def update_buttons(self):
|
||||
# Back button state
|
||||
self.back_button.set_sensitive(self.current_page_index > 0)
|
||||
@@ -105,11 +111,15 @@ class InstallerWindow(Adw.ApplicationWindow):
|
||||
forced_selection = True
|
||||
if current_page_name == "storage":
|
||||
forced_selection = self.storage_page.get_selected_disk() is not None
|
||||
elif current_page_name == "user":
|
||||
forced_selection = self.user_page.is_valid()
|
||||
|
||||
self.next_button.set_sensitive(forced_selection)
|
||||
|
||||
if current_page_name == "summary":
|
||||
self.next_button.set_label("Install")
|
||||
self.next_button.set_label(
|
||||
"Install" + (" (MOCK)" if self.mock_mode else "")
|
||||
)
|
||||
self.next_button.add_css_class("destructive-action")
|
||||
self.next_button.remove_css_class("suggested-action")
|
||||
else:
|
||||
@@ -173,30 +183,36 @@ class InstallerWindow(Adw.ApplicationWindow):
|
||||
mode=mode,
|
||||
partitions=partitions_config,
|
||||
user_info=user_info,
|
||||
modules=modules
|
||||
modules=modules,
|
||||
)
|
||||
# Proceed to summary page (which is next_index after user)
|
||||
|
||||
|
||||
if current_page_name == "summary":
|
||||
# THIS IS THE REAL INSTALL TRIGGER
|
||||
print("Install process triggered!")
|
||||
disk = self.storage_page.get_selected_disk()
|
||||
print(f"Disk: {disk}")
|
||||
mode = self.install_mode_page.get_mode()
|
||||
print(f"Mode: {mode}")
|
||||
modules = self.modules_page.get_modules()
|
||||
print(f"Modules: {modules}")
|
||||
user_info = self.user_page.get_user_info()
|
||||
print(f"User: {user_info}")
|
||||
|
||||
# Recalculate or retrieve partitions just to be safe/consistent
|
||||
|
||||
partitions_config = {}
|
||||
if mode == "manual":
|
||||
partitions_config = self.partitioning_page.get_config()
|
||||
elif mode == "automatic":
|
||||
partitions = calculate_auto_partitions(disk)
|
||||
partitions_config = {"partitions": partitions}
|
||||
print(f"Partitioning: {partitions_config}")
|
||||
|
||||
if self.mock_mode:
|
||||
print("!!! MOCK MODE ENABLED - NO CHANGES WILL BE MADE !!!")
|
||||
print(f"Target Disk: {disk}")
|
||||
print(f"Mode: {mode}")
|
||||
print(f"Modules: {modules}")
|
||||
print(f"User: {user_info}")
|
||||
print(f"Partition Config: {partitions_config}")
|
||||
print("Simulation complete.")
|
||||
else:
|
||||
print("NOT IMPLEMENTED")
|
||||
|
||||
return
|
||||
|
||||
if next_index < len(self.page_ids):
|
||||
|
||||
Reference in New Issue
Block a user