def codimensionMain(): """The codimension driver""" # Parse command line arguments helpMessaege = """ %prog [options] [project file | python files] Runs codimension UI""" parser = OptionParser(helpMessaege, version="%prog " + VER) parser.add_option("--debug", action="store_true", dest="debug", default=False, help="switch on debug and info messages (default: Off)") parser.add_option("--clean-start", action="store_true", dest="cleanStart", default=False, help="do not restore previous IDE state (default: Off)") options, args = parser.parse_args() # Configure logging setupLogging(options.debug) # The default exception handler can be replaced sys.excepthook = exceptionHook # Create global data singleton. # It's unlikely to throw any exceptions. globalData = GlobalData() globalData.version = VER # Loading settings - they have to be loaded before the application is # created. This is because the skin name is saved there. settings = Settings() copySkin() # Load the skin globalData.skin = Skin() globalData.skin.load(SETTINGS_DIR + "skins" + os.path.sep + settings['skin']) global __delayedWarnings __delayedWarnings += settings.validateZoom(globalData.skin.minTextZoom, globalData.skin.minCFlowZoom) # QT on UBUNTU has a bug - the main menu bar does not generate the # 'aboutToHide' signal (though 'aboutToShow' is generated properly. This # prevents codimension working properly so this hack below disables the # global menu bar for codimension and makes it working properly. os.environ["QT_X11_NO_NATIVE_MENUBAR"] = "1" # Create QT application codimensionApp = CodimensionApplication(sys.argv, settings['style']) globalData.application = codimensionApp logging.debug("Starting codimension v.%s", VER) try: # Process command line arguments projectFile = processCommandLineArgs(args) except Exception as exc: logging.error(str(exc)) parser.print_help() return 1 # Show splash screen splash = SplashScreen() globalData.splash = splash screenSize = codimensionApp.desktop().screenGeometry() globalData.screenWidth = screenSize.width() globalData.screenHeight = screenSize.height() splash.showMessage("Importing packages...") from ui.mainwindow import CodimensionMainWindow splash.showMessage("Generating main window...") mainWindow = CodimensionMainWindow(splash, settings) codimensionApp.setMainWindow(mainWindow) globalData.mainWindow = mainWindow codimensionApp.lastWindowClosed.connect(codimensionApp.quit) # Loading project if given or the recent one needSignal = True if options.cleanStart: # Codimension will not load anything. pass elif projectFile: splash.showMessage("Loading project...") globalData.project.loadProject(projectFile) needSignal = False elif args: # There are arguments and they are python files # The project should not be loaded but the files should # be opened for fName in args: mainWindow.openFile(os.path.abspath(fName), -1) elif settings['projectLoaded']: if not settings['recentProjects']: # Some project was loaded but now it is not available. pass else: splash.showMessage("Loading recent project...") if os.path.exists(settings['recentProjects'][0]): globalData.project.loadProject(settings['recentProjects'][0]) needSignal = False else: __delayedWarnings.append( "Cannot open the most recent project: " + settings['recentProjects'][0] + ". Ignore and continue.") else: mainWindow.editorsManagerWidget.editorsManager.restoreTabs( settings.tabStatus) # Signal for triggering browsers layout if needSignal: globalData.project.sigProjectChanged.emit( CodimensionProject.CompleteProject) mainWindow.show() mainWindow.restoreWindowPosition() mainWindow.restoreSplitterSizes() # The editors positions can be restored properly only when the editors have # actually been drawn. Otherwise the first visible line is unknown. # So, I load the project first and let object browsers initialize # themselves and then manually call the main window handler to restore the # editors. The last step is to connect the signal. mainWindow.onProjectChanged(CodimensionProject.CompleteProject) globalData.project.sigProjectChanged.connect(mainWindow.onProjectChanged) # Launch the user interface QTimer.singleShot(1, launchUserInterface) # Run the application main cycle retVal = codimensionApp.exec_() return retVal
def main(self): """The codimension driver""" usageMessage = 'Usage: %prog [options] [project file | python files]' parser = OptionParser(usage=usageMessage, version='%prog ' + VER) parser.add_option( '--debug', action='store_true', dest='debug', default=False, help='switch on debug and info messages (default: Off)') parser.add_option( '--clean-start', action='store_true', dest='cleanStart', default=False, help='do not restore previous IDE state (default: Off)') self.__options, self.__args = parser.parse_args() self.setupLogging() # The default exception handler can be replaced sys.excepthook = exceptionHook # Create global data singleton. # It's unlikely to throw any exceptions. globalData = GlobalData() globalData.version = VER # Loading settings - they have to be loaded before the application is # created. This is because the skin name is saved there. settings = Settings() populateSampleSkin() # Load the skin globalData.skin = Skin() globalData.skin.loadByName(settings['skin']) self.__delayedWarnings += settings.validateZoom( globalData.skin.minTextZoom, globalData.skin.minCFlowZoom) # QT on UBUNTU has a bug - the main menu bar does not generate the # 'aboutToHide' signal (though 'aboutToShow' is generated properly. This # prevents codimension working properly so the hack below disables the # global menu bar for codimension and makes it working properly. os.environ['QT_X11_NO_NATIVE_MENUBAR'] = '1' # Create QT application codimensionApp = CodimensionApplication(sys.argv, settings['style']) globalData.application = codimensionApp logging.debug('Starting codimension v.%s', VER) try: # Process command line arguments self.__projectFile = self.processCommandLineArgs() except Exception as exc: logging.error(str(exc)) parser.print_help() return 1 # Show splash screen self.__splash = SplashScreen() screenSize = codimensionApp.desktop().screenGeometry() globalData.screenWidth = screenSize.width() globalData.screenHeight = screenSize.height() self.__splash.showMessage('Importing packages...') from ui.mainwindow import CodimensionMainWindow self.__splash.showMessage('Generating main window...') mainWindow = CodimensionMainWindow(self.__splash, settings) codimensionApp.setMainWindow(mainWindow) globalData.mainWindow = mainWindow codimensionApp.lastWindowClosed.connect(codimensionApp.quit) mainWindow.show() mainWindow.restoreWindowPosition() mainWindow.restoreSplitterSizes() # Launch the user interface QTimer.singleShot(1, self.launchUserInterface) # Run the application main cycle retVal = codimensionApp.exec_() return retVal