Connect loading code to main window