add option to import scenario on very first use

This commit is contained in:
2025-07-08 16:56:26 +02:00
parent bca2c50e68
commit f54472df2c
+20 -7
View File
@@ -679,13 +679,26 @@ class MainWindow(QtWidgets.QMainWindow):
self.refresh_window_list() self.refresh_window_list()
if not scenarios: if not scenarios:
name, ok = QtWidgets.QInputDialog.getText(self, 'New Scenario', 'No scenarios found. Enter a name for your first scenario:') choice_dialog = QtWidgets.QMessageBox(self)
if ok and name: choice_dialog.setWindowTitle('No Scenarios Found')
logger.info(f'Creating new scenario: {name}') choice_dialog.setText('No scenarios found. Would you like to create a new scenario or import one?')
s = Scenario(name) create_btn = choice_dialog.addButton('Create New', QtWidgets.QMessageBox.ButtonRole.AcceptRole)
s.save() import_btn = choice_dialog.addButton('Import', QtWidgets.QMessageBox.ButtonRole.ActionRole)
self.combo.addItem(name) choice_dialog.setDefaultButton(create_btn)
self.combo.setCurrentText(name) choice_dialog.exec()
clicked = choice_dialog.clickedButton()
if clicked == create_btn:
name, ok = QtWidgets.QInputDialog.getText(self, 'New Scenario', 'Enter a name for your first scenario:')
if ok and name:
logger.info(f'Creating new scenario: {name}')
s = Scenario(name)
s.save()
self.combo.addItem(name)
self.combo.setCurrentText(name)
else:
self.refresh_lists()
elif clicked == import_btn:
self.import_scenario()
else: else:
self.refresh_lists() self.refresh_lists()
else: else: