Skip to content
Snippets Groups Projects
Commit 624dd963 authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Load schedule without asking if there is a single schedule in the file

parent a3aad905
No related branches found
No related tags found
1 merge request!150Load schedule without asking if there is a single schedule in the file
Pipeline #88720 passed
...@@ -255,35 +255,39 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -255,35 +255,39 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self, self,
self.tr("File not found"), self.tr("File not found"),
self.tr( self.tr(
"Could not find any Schedule object in file '{}'." "Cannot find any Schedule object in file '{}'."
).format(os.path.basename(abs_path_filename)), ).format(os.path.basename(abs_path_filename)),
) )
log.info( log.info(
"Could not find any Schedule object in file '{}'.".format( "Cannot find any Schedule object in file '{}'.".format(
os.path.basename(abs_path_filename) os.path.basename(abs_path_filename)
) )
) )
del module del module
return return
ret_tuple = QInputDialog.getItem( if len(schedule_obj_list) == 1:
self, schedule = [val for val in schedule_obj_list.values()][0]
self.tr("Load object"), else:
self.tr( ret_tuple = QInputDialog.getItem(
"Found the following Schedule object(s) in file.\n\n" self,
"Select an object to proceed:" self.tr("Load object"),
), self.tr(
schedule_obj_list.keys(), "Found the following Schedule objects in file.\n\n"
0, "Select an object to proceed:"
False, ),
) schedule_obj_list.keys(),
0,
False,
)
if not ret_tuple[1]: # User canceled the operation if not ret_tuple[1]: # User canceled the operation
log.debug("Load schedule operation: user canceled") log.debug("Load schedule operation: user canceled")
del module del module
return return
schedule = schedule_obj_list[ret_tuple[0]]
self.open(schedule_obj_list[ret_tuple[0]]) self.open(schedule)
del module del module
settings.setValue("mainwindow/last_opened_file", abs_path_filename) settings.setValue("mainwindow/last_opened_file", abs_path_filename)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment