def qgis_app(): """ Start QGIS application to test against. Based on code from Inasafe plugin. :return: Reference to QGIS application, canvas and parent widget. :rtype:(QgsApplication, QWidget, QgsMapCanvas) """ global QGIS_APP if QGIS_APP is None: gui_flag = True QCoreApplication.setOrganizationName('QGIS') QCoreApplication.setOrganizationDomain('qgis.org') QCoreApplication.setApplicationName('STDM_Testing') QGIS_APP = QgsApplication(sys.argv, gui_flag) QGIS_APP.initQgis() global PARENT if PARENT is None: PARENT = QWidget() global CANVAS if CANVAS is None: CANVAS = QgsMapCanvas(PARENT) CANVAS.resize(QSize(400, 400)) return QGIS_APP, CANVAS, PARENT
def main(args): QCoreApplication.setApplicationName("2D Scan Post Processor") QCoreApplication.setApplicationVersion("0.2") QCoreApplication.setOrganizationName("Phoseon Technology") QCoreApplication.setOrganizationDomain("phoseon.com") app = QApplication([]) form = MainDialog() # form.show() # app.exec_() sys.exit(app.exec_())
def main(): from PyQt4.QtCore import QCoreApplication import logging logging.basicConfig(level=logging.DEBUG) app = QApplication(sys.argv) # share settings with QGIS plugin QCoreApplication.setOrganizationName( "QuantumGIS" ) QCoreApplication.setOrganizationDomain( "qgis.org" ) QCoreApplication.setApplicationName( "QGIS" ) nldas() sys.exit(app.exec_())
def __init__(self, parent=None): """ Konstruktor """ self.translator_app = QTranslator() self.translator_qt = QTranslator() QApplication.installTranslator( self.translator_app ) QApplication.installTranslator( self.translator_qt ) QWidget.__init__(self, parent) QCoreApplication.setOrganizationName("Caern") QCoreApplication.setOrganizationDomain("www.caern.de") QCoreApplication.setApplicationName("DiceRoller WoD") QCoreApplication.setApplicationVersion(QString.number(PROGRAM_VERSION_MAJOR) + "." + QString.number(PROGRAM_VERSION_MINOR) + "." + QString.number(PROGRAM_VERSION_CHANGE) ) QApplication.setWindowIcon(QIcon(":/icons/logo/WoD.png")) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.createInfo() #self.createLanguageMenu() self.instantRoll = InstantRoll() self.extendedRoll = ExtendedRoll() # Dieser Zähler bestimmt, wie der rollende Würfel angezeigt wird. self.timerDice = QTimer() # Verzögert die tatsächliche Ausführung des Würfelwurfs. self.timerRoll = QTimer() self.populateUi() self.createConnections() self.initializing() self.setWindowTitle(QCoreApplication.applicationName())
def init_qgis(): """Set up a global QGIS instance. :returns: A QGIS application (for global use). :rtype: QgsApplication """ print 'Instantiating QGIS' QCoreApplication.setOrganizationName('InaSAFE') QCoreApplication.setOrganizationDomain('inasafe.org') QCoreApplication.setApplicationName('InaSAFEWeb') #noinspection PyPep8Naming gui_flag = True # app = QApplication([], gui_flag) app = QgsApplication(sys.argv, gui_flag) # Make sure QGIS_PREFIX_PATH is set in your env if needed! app.initQgis() return app
def calculate(request): """Calculates the buildings affected by flood. """ QCoreApplication.setOrganizationName('QGIS') QCoreApplication.setOrganizationDomain('qgis.org') QCoreApplication.setApplicationName('QGIS2InaSAFETesting') #noinspection PyPep8Naming gui_flag = False qgis_app = QgsApplication([], gui_flag) # Make sure QGIS_PREFIX_PATH is set in your env if needed! qgis_app.initQgis() output = os.path.join(settings.MEDIA_ROOT, 'layers', 'impact.json') roads = get_layer_data('Roads') flood = get_layer_data('Flood') impact_function = FloodVectorRoadsExperimentalFunction xmin, ymin, xmax, ymax = 121, 14.54, 121.05, 14.56 impact_file = calculate_safe_impact(layers=[roads, flood], function=impact_function, extent=[xmin, ymin, xmax, ymax], check_integrity=False) os.remove(impact_geojson) call(['ogr2ogr', '-f', 'GeoJSON', output, impact_file.filename]) impact_geojson = os.path.join(settings.MEDIA_URL, 'layers', 'impact.json') os.remove(impact_geojson) context = impact_file.keywords context = {} context['geojson'] = impact_geojson context['user'] = request.user return render(request, 'layers/calculate.html', context)
def main(): gc.set_debug(gc.DEBUG_UNCOLLECTABLE | gc.DEBUG_SAVEALL| gc.DEBUG_INSTANCES | gc.DEBUG_OBJECTS) qtTranslator = QTranslator() qtTranslator.load("qt_" + QLocale.system().name()) appTranslator = QTranslator() appTranslator.load("translations/boincgui_" + QLocale.system().name()) QCoreApplication.setOrganizationName("LinuxOS.sk") QCoreApplication.setOrganizationDomain("linuxos.sk") QCoreApplication.setApplicationName("pyboincgui") cm = ConnectionManager() app = QApplication(sys.argv) app.installTranslator(qtTranslator) app.installTranslator(appTranslator) win = MainWindow(cm) win.show() ret = app.exec_() del win del cm
def __init__(self): super().__init__() self.setupUi(self) # set python environment if getattr(sys, 'frozen', False): bundle_dir = sys._MEIPASS # pylint: disable=no-member else: # we are running in a normal Python environment bundle_dir = os.path.dirname(os.path.abspath(__file__)) # load environmental variables load_dotenv(dotenv_path = Path(bundle_dir) / ".env") # set program icon self.setWindowIcon(QtGui.QIcon(os.path.join(bundle_dir, "pickle.ico"))) # work in INI File Stuff here QCoreApplication.setOrganizationName("NRB") QCoreApplication.setOrganizationDomain("northriverboats.com") QCoreApplication.setApplicationName("Options Boat Pickler") self.settings = QSettings() # set variables self.background_thread = None self.exit_flag = False self.dir = self.settings.value("dir", os.getenv("DIR")) self.pickle_name = os.getenv("PICKLE") # set ui state self.actionCancel.setEnabled(False) self.btnCancel.hide() self.lePath.setText(self.dir) # set slots and signals self.actionExit.triggered.connect(self.closeEvent) self.actionAbout.triggered.connect(self.doAbout) self.btnBrowse.clicked.connect(self.browseEvent) self.btnRun.clicked.connect(self.startBackgroundTask)
def init(): """ Initialize the QCoreApplication.organizationDomain, applicationName, applicationVersion and the default settings format. Will only run once. .. note:: This should not be run before QApplication has been initialized. Otherwise it can break Qt's plugin search paths. """ dist = pkg_resources.get_distribution("Orange3") version = dist.version # Use only major.minor version = ".".join(version.split(".", 2)[:2]) QCoreApplication.setOrganizationDomain("biolab.si") QCoreApplication.setApplicationName("Orange Canvas") QCoreApplication.setApplicationVersion(version) QSettings.setDefaultFormat(QSettings.IniFormat) # Make it a null op. global init init = lambda: None
def main(argv): path = None first_arg = None second_arg = None config = None apath = None print("QT VERSION %s" % QT_VERSION_STR ) try: first_arg = argv[1] second_arg = argv[2] except IndexError: pass if first_arg is not None: if first_arg == "-c": config = True if second_arg is not None: path = second_arg else: path = first_arg try: #app = QApplication(argv) app = MyApp(argv) QCoreApplication.setOrganizationDomain('www.trickplay.com'); QCoreApplication.setOrganizationName('Trickplay'); QCoreApplication.setApplicationName('Trickplay Debugger'); QCoreApplication.setApplicationVersion('0.0.1'); s = QProcessEnvironment.systemEnvironment().toStringList() for item in s: k , v = str( item ).split( "=" , 1 ) if k == 'PWD': apath = v apath = os.path.join(apath, os.path.dirname(str(argv[0]))) main = MainWindow(app, apath) main.config = config main.show() main.raise_() wizard = Wizard() app.main = main path = wizard.start(path) if path: settings = QSettings() settings.setValue('path', path) app.setActiveWindow(main) main.start(path, wizard.filesToOpen()) main.show() sys.exit(app.exec_()) # TODO, better way of doing this for 'clean' exit... except KeyboardInterrupt: exit("Exited")
self.show_message("Server message", message) def show_error_from_socket(self, message): self.show_message("Server error", message, QSystemTrayIcon.Critical) def show_message_from_mod_manager(self, message): self.show_message("ModManager message", message) def show_error_from_mod_manager(self, message): self.show_message("ModManager error", message, QSystemTrayIcon.Critical) def show_message(self, title, message, icon = QSystemTrayIcon.Information): self.tray.showMessage(title, message, icon) if __name__ == '__main__': app = SingleApplication(sys.argv) app.setQuitOnLastWindowClosed(False); if app.is_running(): log.DEBUG("[main] d2mp is already running!") else: QCoreApplication.setOrganizationName("D2Modd"); QCoreApplication.setOrganizationDomain("d2modd.in"); QCoreApplication.setApplicationName("D2ModdInClient"); log.DEBUG("[main] ready to close") r = app.exec_() log.DEBUG("[main] exiting with status %d" %r)
def start_ide(app, filenames, projects_path, extra_plugins, linenos): """Load all the settings necessary before loading the UI, and start IDE.""" QCoreApplication.setOrganizationName("NINJA-IDE") QCoreApplication.setOrganizationDomain("NINJA-IDE") QCoreApplication.setApplicationName("NINJA-IDE") app.setWindowIcon(QIcon(resources.IMAGES["icon"])) # Check if there is another session of ninja-ide opened # and in that case send the filenames and projects to that session running = ipc.is_running() start_server = not running[0] if running[0] and (filenames or projects_path): sended = ipc.send_data(running[1], filenames, projects_path, linenos) running[1].close() if sended: sys.exit() else: running[1].close() # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES["splash"]) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking if not settings.IS_WINDOWS: app.setCursorFlashTime(0) # Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName("utf-8")) # Translator qsettings = QSettings(resources.SETTINGS_PATH, QSettings.IniFormat) language = QLocale.system().name() lang = qsettings.value("preferences/interface/language", defaultValue=language, type="QString") + ".qm" lang_path = file_manager.create_path(resources.LANGS, lang) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) qtTranslator = QTranslator() qtTranslator.load("qt_" + language, QLibraryInfo.location(QLibraryInfo.TranslationsPath)) app.installTranslator(qtTranslator) # Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() # Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() # Set Stylesheet style_applied = False if settings.NINJA_SKIN not in ("Default", "Classic Theme"): file_name = "%s.qss" % settings.NINJA_SKIN qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD, file_name) if file_manager.file_exists(qss_file): with open(qss_file) as f: qss = f.read() app.setStyleSheet(qss) style_applied = True if not style_applied: if settings.NINJA_SKIN == "Default": with open(resources.NINJA_THEME) as f: qss = f.read() else: with open(resources.NINJA_THEME_CLASSIC) as f: qss = f.read() app.setStyleSheet(qss) # Loading Schemes splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = qsettings.value("preferences/editor/scheme", "default", type="QString") if scheme != "default": scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + ".color") if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) # Loading Shortcuts resources.load_shortcuts() # Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ninjaide = ide.IDE(start_server) # Showing GUI ninjaide.show() # Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) # First check if we need to load last session files if qsettings.value("preferences/general/loadFiles", True, type=bool): # Files in Main Tab main_files = qsettings.value("openFiles/mainTab", []) tempFiles = [] if main_files: for file_ in main_files: fileData = list(file_) if fileData: lineno = fileData[1] tempFiles.append((fileData[0], lineno)) main_files = tempFiles # Files in Secondary Tab sec_files = qsettings.value("openFiles/secondaryTab", []) tempFiles = [] if sec_files: for file_ in sec_files: fileData = list(file_) if fileData: lineno = fileData[1] tempFiles.append((fileData[0], lineno)) sec_files = tempFiles # Recent Files recent_files = qsettings.value("openFiles/recentFiles", []) # Current File current_file = qsettings.value("openFiles/currentFile", "", type="QString") # Projects projects = qsettings.value("openFiles/projects", []) else: main_files = [] sec_files = [] recent_files = [] current_file = "" projects = [] # Include files received from console args file_with_nro = list([(f[0], f[1] - 1) for f in zip(filenames, linenos)]) file_without_nro = list([(f, 0) for f in filenames[len(linenos) :]]) main_files += file_with_nro + file_without_nro # Include projects received from console args if projects_path: projects += projects_path # FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT # ninjaide.load_session_files_projects(main_files, sec_files, # projects, current_file, recent_files) # Load external plugins # if extra_plugins: # ninjaide.load_external_plugins(extra_plugins) splash.finish(ninjaide) ninjaide.notify_plugin_errors() ninjaide.show_python_detection()
def start(): app = QApplication(sys.argv) QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('ninja-ide.org.ar') QCoreApplication.setApplicationName('Kunai') # Create and display the splash screen splash_pix = QPixmap(resources.images['splash']) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() loader.load_syntax() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignBottom, Qt.white) settings = QSettings() if not settings.value('preferences/skins/default', True).toBool(): selectedSkin = settings.value('preferences/skins/selectedSkin', '').toString() skins = loader.load_gui_skins() css = skins.get(str(selectedSkin), '') app.setStyleSheet(css) schemeColor = str(settings.value('preferences/editor/scheme', 'default').toString()) if schemeColor != 'default': resources.custom_scheme = loader.load_editor_skins().get(schemeColor, {}) #Editor Configuration EditorGeneric.codeCompletion = settings.value('preferences/editor/codeCompletion', True).toBool() EditorGeneric.indent = settings.value('preferences/editor/indent', 4).toInt()[0] EditorGeneric.findErrors = settings.value('preferences/editor/errors', False).toBool() EditorGeneric.checkStyle = settings.value('preferences/editor/checkStyle', True).toBool() EditorGeneric.highlightVariables = settings.value('preferences/editor/highlightWord', True).toBool() if not settings.value('preferences/editor/parentheses', True).toBool(): del EditorGeneric.braces_strings['('] if not settings.value('preferences/editor/brackets', True).toBool(): del EditorGeneric.braces_strings['['] if not settings.value('preferences/editor/keys', True).toBool(): del EditorGeneric.braces_strings['{'] if not settings.value('preferences/editor/simpleQuotes', True).toBool(): del EditorGeneric.braces_strings["'"] if not settings.value('preferences/editor/doubleQuotes', True).toBool(): del EditorGeneric.braces_strings['"'] ide = IDE() if settings.value('preferences/interface/centralRotate', False).toBool(): ide.main._splitter_central_rotate() if settings.value('preferences/interface/panelsRotate', False).toBool(): ide.main._splitter_main_rotate() if settings.value('preferences/interface/centralOrientation', False).toBool(): ide.main._splitter_central_orientation() #Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignBottom, Qt.white) resources.python_path = str(settings.value('preferences/general/pythonPath', 'python').toString()) if (settings.value('preferences/general/activatePlugins', Qt.Checked) == Qt.Checked): set_plugin_access(ide) ninja_ide.core.load_plugins(ide) resources.workspace = str(settings.value('preferences/general/workspace', '').toString()) supportedExtensions = settings.value('preferences/general/extensions', []).toList() if supportedExtensions: tempExtensions = [] for se in supportedExtensions: tempExtensions.append(str(se.toString())) manage_files.supported_extensions = tuple(tempExtensions) #Load Font preference font = str(settings.value('preferences/editor/font', "Monospace, 11").toString()) EditorGeneric.font_family = font.split(', ')[0] EditorGeneric.font_size = int(font.split(', ')[1]) ide.show() splash.showMessage("Loading Projects", Qt.AlignRight | Qt.AlignBottom, Qt.white) for projectFolder in settings.value('openFiles/projects', []).toStringList(): if os.path.isdir(projectFolder): ide.main.open_project_folder(str(projectFolder), False) if (settings.value('preferences/general/loadFiles', Qt.Checked) == Qt.Checked): for openFile in settings.value('openFiles/tab1', []).toList(): if len(openFile.toList()) > 0: fileList = openFile.toList() fileName = str(fileList[0].toString()) projectPath = str(fileList[1].toString()) if len(projectPath) == 0: projectPath = None cursorPosition = fileList[2].toInt()[0] if os.path.isfile(fileName): ide.main.open_document(fileName, projectPath) ide.main._central.obtain_editor().set_cursor_position(cursorPosition) for openFile2 in settings.value('openFiles/tab2', []).toList(): #ide.main.split_tab(True) if len(openFile2.toList()) > 0: ide.main._central._tabs2.show() ide.main._central._mainTabSelected = False fileList = openFile2.toList() fileName = fileList[0].toString() projectPath = fileList[1].toString() cursorPosition = fileList[2].toInt()[0] if os.path.isfile(fileName): ide.main.open_document(str(fileName), str(projectPath)) ide.main._central.obtain_editor().set_cursor_position(cursorPosition) ide.main._central._mainTabSelected = True filenames, projects_path = ninja_ide.core.cliparser.parse() for filename in filenames: ide.main.open_document(filename) for project_path in projects_path: ide.main.open_project_folder(project_path) splash.finish(ide) sys.exit(app.exec_())
from PyQt4.QtCore import QCoreApplication, QSettings def chunks(l, n): for i in xrange(0, len(l), n): yield l[i:i + n] QCoreApplication.setOrganizationName("QGIS") QCoreApplication.setOrganizationDomain("qgis.org") QCoreApplication.setApplicationName("QGIS2") s = QSettings() ba = s.value("/UI/geometry").toByteArray() f = open("src/app/ui_defaults.h", "w") f.write( "#ifndef UI_DEFAULTS_H\n#define UI_DEFAULTS_H\n\nstatic const unsigned char defaultUIgeometry[] =\n{\n" ) for chunk in chunks(ba, 16): f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % ord(x), chunk))) f.write("};\n\nstatic const unsigned char defaultUIstate[] =\n{\n") ba = s.value("/UI/state").toByteArray() for chunk in chunks(ba, 16): f.write(" %s,\n" % ", ".join(map(lambda x: "0x%02x" % ord(x), chunk)))
def main(argv): path = None first_arg = None second_arg = None config = None apath = None print("QT VERSION %s" % QT_VERSION_STR) try: first_arg = argv[1] second_arg = argv[2] except IndexError: pass if first_arg is not None: if first_arg == "-c": config = True if second_arg is not None: path = second_arg else: path = first_arg try: #app = QApplication(argv) app = MyApp(argv) QCoreApplication.setOrganizationDomain('www.trickplay.com') QCoreApplication.setOrganizationName('Trickplay') QCoreApplication.setApplicationName('Trickplay Debugger') QCoreApplication.setApplicationVersion('0.0.1') s = QProcessEnvironment.systemEnvironment().toStringList() for item in s: k, v = str(item).split("=", 1) if k == 'PWD': apath = v apath = os.path.join(apath, os.path.dirname(str(argv[0]))) main = MainWindow(app, apath) main.config = config main.show() main.raise_() wizard = Wizard() app.main = main path = wizard.start(path) if path: settings = QSettings() settings.setValue('path', path) app.setActiveWindow(main) main.start(path, wizard.filesToOpen()) main.show() sys.exit(app.exec_()) # TODO, better way of doing this for 'clean' exit... except KeyboardInterrupt: exit("Exited")
def start_ide(app, filenames, projects_path, extra_plugins, linenos): """Load all the settings necessary before loading the UI, and start IDE.""" QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(":img/icon")) # Check if there is another session of ninja-ide opened # and in that case send the filenames and projects to that session running = ipc.is_running() start_server = not running[0] if running[0] and (filenames or projects_path): sended = ipc.send_data(running[1], filenames, projects_path, linenos) running[1].close() if sended: sys.exit() else: running[1].close() # Create and display the splash screen splash_pix = QPixmap(":img/splash") splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking if not settings.IS_WINDOWS: app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = ide.IDE.ninja_settings() data_qsettings = ide.IDE.data_settings() language = QLocale.system().name() lang = qsettings.value('preferences/interface/language', defaultValue=language, type='QString') + '.qm' lang_path = file_manager.create_path(resources.LANGS, lang) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) qtTranslator = QTranslator() qtTranslator.load("qt_" + language, QLibraryInfo.location(QLibraryInfo.TranslationsPath)) app.installTranslator(qtTranslator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() #Set Stylesheet style_applied = False if settings.NINJA_SKIN not in ('Default', 'Classic Theme'): file_name = ("%s.qss" % settings.NINJA_SKIN) qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD, file_name) if file_manager.file_exists(qss_file): with open(qss_file) as f: qss = f.read() app.setStyleSheet(qss) style_applied = True if not style_applied: if settings.NINJA_SKIN == 'Default': with open(resources.NINJA_THEME) as f: qss = f.read() else: with open(resources.NINJA_THEME_CLASSIC) as f: qss = f.read() app.setStyleSheet(qss) #Loading Schemes splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = qsettings.value('preferences/editor/scheme', "default", type='QString') if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ninjaide = ide.IDE(start_server) #Showing GUI ninjaide.show() #OSX workaround for ninja window not in front try: ninjaide.raise_() except: pass # I really dont mind if this fails in any form #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #First check if we need to load last session files if qsettings.value('preferences/general/loadFiles', True, type=bool): #Files in Main Tab files = data_qsettings.value('lastSession/openedFiles', []) tempFiles = [] if files: for file_ in files: fileData = tuple(file_) if fileData: tempFiles.append(fileData) files = tempFiles # Recent Files recent_files = data_qsettings.value('lastSession/recentFiles', []) #Current File current_file = data_qsettings.value( 'lastSession/currentFile', '', type='QString') #Projects projects = data_qsettings.value('lastSession/projects', []) else: files = [] recent_files = [] current_file = '' projects = [] #Include files received from console args file_with_nro = list([(f[0], f[1] - 1) for f in zip(filenames, linenos)]) file_without_nro = list([(f, 0) for f in filenames[len(linenos):]]) files += file_with_nro + file_without_nro #Include projects received from console args if projects_path: projects += projects_path #FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT ninjaide.load_session_files_projects(files, projects, current_file, recent_files) #Load external plugins #if extra_plugins: #ninjaide.load_external_plugins(extra_plugins) splash.finish(ninjaide) ninjaide.notify_plugin_errors() ninjaide.show_python_detection()
def testSmewtDaemon(self): # we need to remove traces of previous test runs, even though we're supposed to have cleaned it after the test, # a previous run of the test that failed might not have done that os.system('rm -fr ~/.config/Falafelton_tmp') os.system('rm -fr /tmp/smewt_test_daemon') import smewt orgname = smewt.ORG_NAME appname = smewt.APP_NAME smewt.ORG_NAME = 'Falafelton_tmp' smewt.APP_NAME = 'Smewt_tmp' from PyQt4.QtCore import QCoreApplication app = QCoreApplication([]) app.setOrganizationName(smewt.ORG_NAME) app.setOrganizationDomain('smewt.com') app.setApplicationName(smewt.APP_NAME) smewtd = SmewtDaemon() # create fake database cmds = '''mkdir -p /tmp/smewt_test_daemon/Monk touch /tmp/smewt_test_daemon/Monk/Monk.2x05.Mr.Monk.And.The.Very,.Very.Old.Man.DVDRip.XviD-MEDiEVAL.[tvu.org.ru].avi touch /tmp/smewt_test_daemon/Monk/Monk.2x05.Mr.Monk.And.The.Very,.Very.Old.Man.DVDRip.XviD-MEDiEVAL.[tvu.org.ru].English.srt ''' for cmd in cmds.split('\n'): os.system(cmd.strip()) smewtd.episodeCollection.folders = { '/tmp/smewt_test_daemon': True } # make sure we don't have a residual collection from previous test runs self.assertEqual(len(list(smewtd.database.nodes())), 0) # initial import of the collection smewtd.episodeCollection.rescan() smewtd.taskManager.queue.join() # wait for all import tasks to finish #smewtd.database.display_graph() self.collectionTestIncomplete(smewtd.database) # update collection, as we haven't changed anything it should be the same smewtd.episodeCollection.update() smewtd.taskManager.queue.join() # wait for all import tasks to finish #smewtd.database.display_graph() self.collectionTestIncomplete(smewtd.database) # fully rescan collection, should still be the same smewtd.episodeCollection.rescan() smewtd.taskManager.queue.join() # wait for all import tasks to finish #smewtd.database.display_graph() self.collectionTestIncomplete(smewtd.database) # add some more files cmds = '''mkdir -p /tmp/smewt_test_daemon/Monk touch /tmp/smewt_test_daemon/Monk/Monk.2x06.Mr.Monk.Goes.To.The.Theater.DVDRip.XviD-MEDiEVAL.[tvu.org.ru].avi touch /tmp/smewt_test_daemon/Monk/Monk.2x06.Mr.Monk.Goes.To.The.Theater.DVDRip.XviD-MEDiEVAL.[tvu.org.ru].English.srt ''' for cmd in cmds.split('\n'): os.system(cmd.strip()) # update collection smewtd.episodeCollection.update() smewtd.taskManager.queue.join() # wait for all import tasks to finish #smewtd.database.display_graph() self.collectionTest(smewtd.database) # clean up our mess before we exit os.system('rm -fr ~/.config/Falafelton_tmp') os.system('rm -fr /tmp/smewt_test_daemon') smewt.ORG_NAME = orgname smewt.APP_NAME = appname
def start(listener, filenames=None, projects_path=None, extra_plugins=None): app = QApplication(sys.argv) QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(resources.IMAGES['icon'])) # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES['splash']) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = QSettings() language = QLocale.system().language() lang = unicode(qsettings.value( 'preferences/interface/language', language).toString()) + '.qm' lang_path = file_manager.create_path(resources.LANGS, unicode(lang)) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path elif file_manager.file_exists(file_manager.create_path( resources.LANGS_DOWNLOAD, unicode(lang))): settings.LANGUAGE = file_manager.create_path( resources.LANGS_DOWNLOAD, unicode(lang)) translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() #Loading Themes splash.showMessage("Loading Themes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = unicode(qsettings.value('preferences/editor/scheme', "default").toString()) if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ide = IDE() #Showing GUI ide.show() #Connect listener signals ide.connect(listener, SIGNAL("fileOpenRequested(QString)"), ide.open_file) ide.connect(listener, SIGNAL("projectOpenRequested(QString)"), ide.open_project) #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #Files in Main Tab mainFiles = qsettings.value('openFiles/mainTab', []).toList() tempFiles = [] for file_ in mainFiles: fileData = file_.toList() tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0])) mainFiles = tempFiles #Files in Secondary Tab secondaryFiles = qsettings.value('openFiles/secondaryTab', []).toList() tempFiles = [] for file_ in secondaryFiles: fileData = file_.toList() tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0])) secondaryFiles = tempFiles #Projects projects = qsettings.value('openFiles/projects', []).toList() projects = [unicode(project.toString()) for project in projects] #Include files received from console args if filenames: mainFiles += [(f, 0) for f in filenames] #Include projects received from console args if projects_path: projects += projects_path ide.load_session_files_projects(mainFiles, secondaryFiles, projects) #Load external plugins if extra_plugins: ide.load_external_plugins(extra_plugins) splash.finish(ide) ide.notify_plugin_errors() sys.exit(app.exec_())
def start(filenames=None, projects_path=None, extra_plugins=None, linenos=None): app = QApplication(sys.argv) QCoreApplication.setOrganizationName("NINJA-IDE") QCoreApplication.setOrganizationDomain("NINJA-IDE") QCoreApplication.setApplicationName("NINJA-IDE") app.setWindowIcon(QIcon(resources.IMAGES["icon"])) # Check if there is another session of ninja-ide opened # and in that case send the filenames and projects to that session running = ipc.is_running() start_server = not running[0] if running[0] and (filenames or projects_path): sended = ipc.send_data(running[1], filenames, projects_path, linenos) running[1].close() if sended: sys.exit() else: running[1].close() # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES["splash"]) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking global cursor_flash_time cursor_flash_time = app.cursorFlashTime() app.setCursorFlashTime(0) # Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName("utf-8")) # Translator qsettings = QSettings() language = QLocale.system().language() lang = unicode(qsettings.value("preferences/interface/language", language).toString()) + ".qm" lang_path = file_manager.create_path(resources.LANGS, unicode(lang)) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path elif file_manager.file_exists(file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang))): settings.LANGUAGE = file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang)) translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) # Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() # Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() # Set Stylesheet if settings.USE_STYLESHEET: with open(resources.NINJA_THEME) as f: qss = f.read() app.setStyleSheet(qss) # Loading Themes splash.showMessage("Loading Themes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = unicode(qsettings.value("preferences/editor/scheme", "default").toString()) if scheme != "default": scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + ".color") if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) # Loading Shortcuts resources.load_shortcuts() # Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ide = IDE(start_server) # Showing GUI ide.show() # Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) # Files in Main Tab mainFiles = qsettings.value("openFiles/mainTab", []).toList() tempFiles = [] for file_ in mainFiles: fileData = file_.toList() tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0])) mainFiles = tempFiles # Files in Secondary Tab secondaryFiles = qsettings.value("openFiles/secondaryTab", []).toList() tempFiles = [] for file_ in secondaryFiles: fileData = file_.toList() tempFiles.append((unicode(fileData[0].toString()), fileData[1].toInt()[0])) secondaryFiles = tempFiles # Current File current_file = unicode(qsettings.value("openFiles/currentFile", "").toString()) # Projects projects = qsettings.value("openFiles/projects", []).toList() projects = [unicode(project.toString()) for project in projects] # Include files received from console args file_with_nro = map(lambda f: (f[0], f[1] - 1), zip(filenames, linenos)) file_without_nro = map(lambda f: (f, 0), filenames[len(linenos) :]) mainFiles += file_with_nro + file_without_nro # Include projects received from console args if projects_path: projects += projects_path mainFiles.reverse() secondaryFiles.reverse() ide.load_session_files_projects(mainFiles, secondaryFiles, projects, current_file) # Load external plugins if extra_plugins: ide.load_external_plugins(extra_plugins) splash.finish(ide) ide.notify_plugin_errors() sys.exit(app.exec_())
def ok(self): self.hide() self.save_settings() archiver = storage.IMAPMailArchiver(str(self.ui.server_input.text()), str(self.ui.port_input.value()), True, str(self.ui.username_input.text()), str(self.ui.password_input.text())) global plugin plugin = Plugin(archiver) def cancel(self): app.quit() QCoreApplication.setOrganizationName("Y-NODE Software") QCoreApplication.setOrganizationDomain("y-node.com") QCoreApplication.setApplicationName("SkypeLogsLikeGTalk") app = QtGui.QApplication(sys.argv) dialog = OptionsDialog() dialog.show() sys.exit(app.exec_())
def get_qgis_app(): """ Start one QGIS application to test against. :returns: Handle to QGIS app, canvas, iface and parent. If there are any errors the tuple members will be returned as None. :rtype: (QgsApplication, CANVAS, IFACE, PARENT) If QGIS is already running the handle to that app will be returned. """ try: from qgis.core import QgsApplication from qgis.gui import QgsMapCanvas # pylint: disable=no-name-in-module # noinspection PyPackageRequirements from PyQt4 import QtGui, QtCore # pylint: disable=W0621 # noinspection PyPackageRequirements from PyQt4.QtCore import QCoreApplication, QSettings from safe.gis.qgis_interface import QgisInterface except ImportError: return None, None, None, None global QGIS_APP # pylint: disable=W0603 if QGIS_APP is None: gui_flag = True # All test will run qgis in gui mode # AG: For testing purposes, we use our own configuration file instead # of using the QGIS apps conf of the host # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationName('QGIS') # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationDomain('qgis.org') # noinspection PyCallByClass,PyArgumentList QCoreApplication.setApplicationName('QGIS2InaSAFETesting') # noinspection PyPep8Naming QGIS_APP = QgsApplication(sys.argv, gui_flag) # Make sure QGIS_PREFIX_PATH is set in your env if needed! QGIS_APP.initQgis() s = QGIS_APP.showSettings() LOGGER.debug(s) # Save some settings settings = QSettings() settings.setValue('locale/overrideFlag', True) settings.setValue('locale/userLocale', 'en_US') # We disabled message bars for now for extent selector as # we don't have a main window to show them in TS - version 3.2 settings.setValue('inasafe/show_extent_confirmations', False) settings.setValue('inasafe/show_extent_warnings', False) settings.setValue('inasafe/showRubberBands', True) settings.setValue('inasafe/analysis_extents_mode', 'HazardExposure') global PARENT # pylint: disable=W0603 if PARENT is None: # noinspection PyPep8Naming PARENT = QtGui.QWidget() global CANVAS # pylint: disable=W0603 if CANVAS is None: # noinspection PyPep8Naming CANVAS = QgsMapCanvas(PARENT) CANVAS.resize(QtCore.QSize(400, 400)) global IFACE # pylint: disable=W0603 if IFACE is None: # QgisInterface is a stub implementation of the QGIS plugin interface # noinspection PyPep8Naming IFACE = QgisInterface(CANVAS) register_impact_functions() return QGIS_APP, CANVAS, IFACE, PARENT
def get_qgis_app(): """ Start one QGIS application to test against. :returns: Handle to QGIS app, canvas, iface and parent. If there are any errors the tuple members will be returned as None. :rtype: (QgsApplication, CANVAS, IFload_standard_layersACE, PARENT) If QGIS is already running the handle to that app will be returned. """ try: from qgis.core import QgsApplication from qgis.gui import QgsMapCanvas # pylint: disable=no-name-in-module # noinspection PyPackageRequirements from PyQt4 import QtGui, QtCore # pylint: disable=W0621 # noinspection PyPackageRequirements from PyQt4.QtCore import QCoreApplication, QSettings from qgis.gui import QgisInterface except ImportError: return None, None, None, None global QGIS_APP # pylint: disable=W0603 if QGIS_APP is None: gui_flag = True # All test will run qgis in gui mode # AG: For testing purposes, we use our own configuration file instead # of using the QGIS apps conf of the host # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationName('QGIS') # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationDomain('qgis.org') # noinspection PyCallByClass,PyArgumentList QCoreApplication.setApplicationName('IsochronesTesting') # noinspection PyPep8Naming QGIS_APP = QgsApplication(sys.argv, gui_flag) # Make sure QGIS_PREFIX_PATH is set in your env if needed! QGIS_APP.initQgis() s = QGIS_APP.showSettings() # Save some settings settings = QSettings() settings.setValue('locale/overrideFlag', True) settings.setValue('locale/userLocale', 'en_US') # We disabled message bars for now for extent selector as # we don't have a main window to show them in TS - version 3.2 global PARENT # pylint: disable=W0603 if PARENT is None: # noinspection PyPep8Naming PARENT = QtGui.QWidget() global CANVAS # pylint: disable=W0603 if CANVAS is None: # noinspection PyPep8Naming CANVAS = QgsMapCanvas(PARENT) CANVAS.resize(QtCore.QSize(400, 400)) global IFACE # pylint: disable=W0603 if IFACE is None: # QgisInterface is a stub implementation of the QGIS plugin interface # noinspection PyPep8Naming IFACE = QgisInterface(CANVAS) return QGIS_APP, CANVAS, IFACE, PARENT
def get_qgis_app(): """ Start one QGIS application to test against. :returns: Handle to QGIS app, canvas, iface and parent. If there are any errors the tuple members will be returned as None. :rtype: (QgsApplication, CANVAS, IFACE, PARENT) If QGIS is already running the handle to that app will be returned. """ global QGIS_APP, PARENT, IFACE, CANVAS # pylint: disable=W0603 if iface: from qgis.core import QgsApplication QGIS_APP = QgsApplication CANVAS = iface.mapCanvas() PARENT = iface.mainWindow() IFACE = iface return QGIS_APP, CANVAS, IFACE, PARENT try: from qgis.core import QgsApplication from qgis.gui import QgsMapCanvas # pylint: disable=no-name-in-module # noinspection PyPackageRequirements from PyQt4 import QtGui, QtCore # pylint: disable=W0621 # noinspection PyPackageRequirements from PyQt4.QtCore import QCoreApplication, QSettings from safe.test.qgis_interface import QgisInterface except ImportError: return None, None, None, None if QGIS_APP is None: gui_flag = True # All test will run qgis in gui mode # AG: For testing purposes, we use our own configuration file instead # of using the QGIS apps conf of the host # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationName('QGIS') # noinspection PyCallByClass,PyArgumentList QCoreApplication.setOrganizationDomain('qgis.org') # noinspection PyCallByClass,PyArgumentList QCoreApplication.setApplicationName('QGIS2InaSAFETesting') # noinspection PyPep8Naming if 'argv' in dir(sys): QGIS_APP = QgsApplication(sys.argv, gui_flag) else: QGIS_APP = QgsApplication([], gui_flag) # Make sure QGIS_PREFIX_PATH is set in your env if needed! QGIS_APP.initQgis() s = QGIS_APP.showSettings() LOGGER.debug(s) # Save some settings settings = QSettings() settings.setValue('locale/overrideFlag', True) settings.setValue('locale/userLocale', 'en_US') # We disabled message bars for now for extent selector as # we don't have a main window to show them in TS - version 3.2 settings.setValue('inasafe/show_extent_confirmations', False) settings.setValue('inasafe/show_extent_warnings', False) settings.setValue('inasafe/showRubberBands', True) settings.setValue('inasafe/analysis_extents_mode', HAZARD_EXPOSURE) if PARENT is None: # noinspection PyPep8Naming PARENT = QtGui.QWidget() if CANVAS is None: # noinspection PyPep8Naming CANVAS = QgsMapCanvas(PARENT) CANVAS.resize(QtCore.QSize(400, 400)) if IFACE is None: # QgisInterface is a stub implementation of the QGIS plugin interface # noinspection PyPep8Naming IFACE = QgisInterface(CANVAS) return QGIS_APP, CANVAS, IFACE, PARENT
def start(filenames=None, projects_path=None, extra_plugins=None, linenos=None): app = QApplication(sys.argv) QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(resources.IMAGES['icon'])) # Check if there is another session of ninja-ide opened # and in that case send the filenames and projects to that session running = ipc.is_running() start_server = not running[0] if running[0] and (filenames or projects_path): sended = ipc.send_data(running[1], filenames, projects_path, linenos) running[1].close() if sended: sys.exit() else: running[1].close() # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES['splash']) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking global cursor_flash_time cursor_flash_time = app.cursorFlashTime() app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = QSettings() language = QLocale.system().name() lang = qsettings.value('preferences/interface/language', language) + '.qm' lang_path = file_manager.create_path(resources.LANGS, lang) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path elif file_manager.file_exists(file_manager.create_path( resources.LANGS_DOWNLOAD, lang)): settings.LANGUAGE = file_manager.create_path( resources.LANGS_DOWNLOAD, lang) translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() #Set Stylesheet style_applied = False if settings.NINJA_SKIN not in ('Default', 'Classic Theme'): file_name = ("%s.qss" % settings.NINJA_SKIN) qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD, file_name) if file_manager.file_exists(qss_file): with open(qss_file) as f: qss = f.read() app.setStyleSheet(qss) style_applied = True if not style_applied: if settings.NINJA_SKIN == 'Default': with open(resources.NINJA_THEME) as f: qss = f.read() else: with open(resources.NINJA__THEME_CLASSIC) as f: qss = f.read() app.setStyleSheet(qss) #Loading Schemes splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = qsettings.value('preferences/editor/scheme', "default") if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ide = IDE(start_server) #Showing GUI ide.show() #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #Files in Main Tab main_files = qsettings.value('openFiles/mainTab', []) if main_files is not None: mainFiles = list(main_files) else: mainFiles = list() tempFiles = [] for file_ in mainFiles: fileData = list(file_) tempFiles.append((fileData[0], int(fileData[1]))) mainFiles = tempFiles #Files in Secondary Tab sec_files = qsettings.value('openFiles/secondaryTab', []) if sec_files is not None: secondaryFiles = list(sec_files) else: secondaryFiles = list() tempFiles = [] for file_ in secondaryFiles: fileData = list(file_) tempFiles.append((fileData[0], int(fileData[1]))) secondaryFiles = tempFiles # Recent Files recent = qsettings.value('openFiles/recentFiles', []) if recent is not None: recent_files = list(recent) else: recent_files = list() recent_files = [file_ for file_ in recent_files] #Current File current_file = qsettings.value('openFiles/currentFile', '') #Projects projects_list = qsettings.value('openFiles/projects', []) if projects_list is not None: projects = list(projects_list) else: projects = list() projects = [project for project in projects] #Include files received from console args file_with_nro = list(map(lambda f: (f[0], f[1] - 1), zip(filenames, linenos))) file_without_nro = list(map(lambda f: (f, 0), filenames[len(linenos):])) mainFiles += file_with_nro + file_without_nro #Include projects received from console args if projects_path: projects += projects_path ide.load_session_files_projects(mainFiles, secondaryFiles, projects, current_file, recent_files) #Load external plugins if extra_plugins: ide.load_external_plugins(extra_plugins) splash.finish(ide) ide.notify_plugin_errors() sys.exit(app.exec_())
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Importe este módulo para registrar ao PyQt detalhes desta aplicação, tais como nome, organização e domínio. Revision history: $Log: register_application.py,v $ Revision 1.2 2012/10/16 18:50:17 diogenes-silva First version ''' from PyQt4.QtCore import QCoreApplication, QSettings QCoreApplication.setOrganizationDomain( 'fis.unb.br' ) QCoreApplication.setOrganizationName( 'labfis2' ) QCoreApplication.setApplicationName( 'DrDaq' ) QSettings.setDefaultFormat( QSettings.IniFormat ) del QCoreApplication del QSettings
def get_qgis_app(): """ Start one QGIS application to test against. :returns: Handle to QGIS app, canvas, iface and parent. If there are any errors the tuple members will be returned as None. :rtype: (QgsApplication, CANVAS, IFACE, PARENT) If QGIS is already running the handle to that app will be returned. """ try: from PyQt4 import QtGui, QtCore from PyQt4.QtCore import QCoreApplication, QSettings from qgis.core import QgsApplication from qgis.gui import QgsMapCanvas from safe.common.qgis_interface import QgisInterface except ImportError: return None, None, None, None global QGIS_APP # pylint: disable=W0603 if QGIS_APP is None: gui_flag = True # All test will run qgis in gui mode # AG: For testing purposes, we use our own configuration file instead # of using the QGIS apps conf of the host QCoreApplication.setOrganizationName('QGIS') QCoreApplication.setOrganizationDomain('qgis.org') QCoreApplication.setApplicationName('QGIS2InaSAFETesting') # noinspection PyPep8Naming QGIS_APP = QgsApplication(sys.argv, gui_flag) # Make sure QGIS_PREFIX_PATH is set in your env if needed! QGIS_APP.initQgis() s = QGIS_APP.showSettings() LOGGER.debug(s) # Save some settings settings = QSettings() settings.setValue('locale/overrideFlag', True) settings.setValue('locale/userLocale', 'en_US') global PARENT # pylint: disable=W0603 if PARENT is None: # noinspection PyPep8Naming PARENT = QtGui.QWidget() global CANVAS # pylint: disable=W0603 if CANVAS is None: # noinspection PyPep8Naming CANVAS = QgsMapCanvas(PARENT) CANVAS.resize(QtCore.QSize(400, 400)) global IFACE # pylint: disable=W0603 if IFACE is None: # QgisInterface is a stub implementation of the QGIS plugin interface # noinspection PyPep8Naming IFACE = QgisInterface(CANVAS) return QGIS_APP, CANVAS, IFACE, PARENT
from PyQt4.QtCore import QCoreApplication, QSettings def chunks(l, n): for i in xrange(0, len(l), n): yield l[i:i+n] QCoreApplication.setOrganizationName( "QGIS" ) QCoreApplication.setOrganizationDomain( "qgis.org" ) QCoreApplication.setApplicationName( "QGIS2" ) s = QSettings() ba = s.value("/UI/geometry").toByteArray() f = open("src/app/ui_defaults.h", "w") f.write( "#ifndef UI_DEFAULTS_H\n#define UI_DEFAULTS_H\n\nstatic const unsigned char defaultUIgeometry[] =\n{\n" ) for chunk in chunks(ba,16): f.write( " %s,\n" % ", ".join( map( lambda x : "0x%02x" % ord(x), chunk ) ) ) f.write( "};\n\nstatic const unsigned char defaultUIstate[] =\n{\n" ) ba = s.value("/UI/state").toByteArray() for chunk in chunks(ba,16): f.write( " %s,\n" % ", ".join( map( lambda x : "0x%02x" % ord(x), chunk ) ) ) ba = s.value("/Composer/geometry").toByteArray() f.write( "};\n\nstatic const unsigned char defaultComposerUIgeometry[] =\n{\n" )
def start_ide(app, filenames, projects_path, extra_plugins, linenos): """Load all the settings necessary before loading the UI, and start IDE.""" QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(":img/icon")) # Check if there is another session of ninja-ide opened # and in that case send the filenames and projects to that session running = ipc.is_running() start_server = not running[0] if running[0] and (filenames or projects_path): sended = ipc.send_data(running[1], filenames, projects_path, linenos) running[1].close() if sended: sys.exit() else: running[1].close() # Create and display the splash screen splash_pix = QPixmap(":img/splash") splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking #if not settings.IS_WINDOWS: #app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = ide.IDE.ninja_settings() data_qsettings = ide.IDE.data_settings() language = QLocale.system().name() lang = qsettings.value('preferences/interface/language', defaultValue=language, type='QString') + '.qm' lang_path = file_manager.create_path(resources.LANGS, lang) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) qtTranslator = QTranslator() qtTranslator.load("qt_" + language, QLibraryInfo.location(QLibraryInfo.TranslationsPath)) app.installTranslator(qtTranslator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) #Set Stylesheet style_applied = False print(settings.NINJA_SKIN) if settings.NINJA_SKIN not in ('Default'): file_name = ("%s.qss" % settings.NINJA_SKIN) qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD, file_name) if file_manager.file_exists(qss_file): with open(qss_file) as fileaccess: qss = fileaccess.read() app.setStyleSheet(qss) style_applied = True if not style_applied: if settings.NINJA_SKIN == 'Default': with open(resources.NINJA_THEME) as fileaccess: qss = fileaccess.read() app.setStyleSheet(qss) #Loading Schemes splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = qsettings.value('preferences/editor/scheme', "default", type='QString') if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ninjaide = ide.IDE(start_server) #Showing GUI ninjaide.show() #OSX workaround for ninja window not in front try: ninjaide.raise_() except: pass # I really dont mind if this fails in any form #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #First check if we need to load last session files if qsettings.value('preferences/general/loadFiles', True, type=bool): #Files in Main Tab files = data_qsettings.value('lastSession/openedFiles', []) tempFiles = [] if files: for file_ in files: fileData = tuple(file_) if fileData: tempFiles.append(fileData) files = tempFiles # Recent Files recent_files = data_qsettings.value('lastSession/recentFiles', []) #Current File current_file = data_qsettings.value('lastSession/currentFile', '', type='QString') #Projects projects = data_qsettings.value('lastSession/projects', []) else: files = [] recent_files = [] current_file = '' projects = [] #Include files received from console args file_with_nro = list([(f[0], (f[1] - 1, 0), 0) for f in zip(filenames, linenos)]) file_without_nro = list([(f, (0, 0), 0) for f in filenames[len(linenos):]]) files += file_with_nro + file_without_nro #Include projects received from console args if projects_path: projects += projects_path #FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT ninjaide.load_session_files_projects(files, projects, current_file, recent_files) #Load external plugins #if extra_plugins: #ninjaide.load_external_plugins(extra_plugins) splash.finish(ninjaide) ninjaide.notify_plugin_errors() ninjaide.show_python_detection()
def start(filenames=None, projects_path=None, extra_plugins=None, linenos=None): app = QApplication(sys.argv) QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(resources.IMAGES['icon'])) # Check if there is another session of ninja-ide opened # and in that case send the filenames and projects to that session running = ipc.is_running() start_server = not running[0] if running[0] and (filenames or projects_path): sended = ipc.send_data(running[1], filenames, projects_path, linenos) running[1].close() if sended: sys.exit() else: running[1].close() # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES['splash']) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking global cursor_flash_time cursor_flash_time = app.cursorFlashTime() app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = QSettings() language = QLocale.system().name() lang = qsettings.value('preferences/interface/language', language) + '.qm' lang_path = file_manager.create_path(resources.LANGS, lang) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path elif file_manager.file_exists( file_manager.create_path(resources.LANGS_DOWNLOAD, lang)): settings.LANGUAGE = file_manager.create_path(resources.LANGS_DOWNLOAD, lang) translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() #Set Stylesheet style_applied = False if settings.NINJA_SKIN not in ('Default', 'Classic Theme'): file_name = ("%s.qss" % settings.NINJA_SKIN) qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD, file_name) if file_manager.file_exists(qss_file): with open(qss_file) as f: qss = f.read() app.setStyleSheet(qss) style_applied = True if not style_applied: if settings.NINJA_SKIN == 'Default': with open(resources.NINJA_THEME) as f: qss = f.read() else: with open(resources.NINJA__THEME_CLASSIC) as f: qss = f.read() app.setStyleSheet(qss) #Loading Schemes splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = qsettings.value('preferences/editor/scheme', "default") if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ide = IDE(start_server) #Showing GUI ide.show() #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #Files in Main Tab main_files = qsettings.value('openFiles/mainTab', []) if main_files is not None: mainFiles = list(main_files) else: mainFiles = list() tempFiles = [] for file_ in mainFiles: fileData = list(file_) tempFiles.append((fileData[0], int(fileData[1]))) mainFiles = tempFiles #Files in Secondary Tab sec_files = qsettings.value('openFiles/secondaryTab', []) if sec_files is not None: secondaryFiles = list(sec_files) else: secondaryFiles = list() tempFiles = [] for file_ in secondaryFiles: fileData = list(file_) tempFiles.append((fileData[0], int(fileData[1]))) secondaryFiles = tempFiles # Recent Files recent = qsettings.value('openFiles/recentFiles', []) if recent is not None: recent_files = list(recent) else: recent_files = list() recent_files = [file_ for file_ in recent_files] #Current File current_file = qsettings.value('openFiles/currentFile', '') #Projects projects_list = qsettings.value('openFiles/projects', []) if projects_list is not None: projects = list(projects_list) else: projects = list() projects = [project for project in projects] #Include files received from console args file_with_nro = list( map(lambda f: (f[0], f[1] - 1), zip(filenames, linenos))) file_without_nro = list(map(lambda f: (f, 0), filenames[len(linenos):])) mainFiles += file_with_nro + file_without_nro #Include projects received from console args if projects_path: projects += projects_path ide.load_session_files_projects(mainFiles, secondaryFiles, projects, current_file, recent_files) #Load external plugins if extra_plugins: ide.load_external_plugins(extra_plugins) splash.finish(ide) ide.notify_plugin_errors() sys.exit(app.exec_())
def start(listener, filenames=None, projects_path=None, extra_plugins=None): app = QApplication(sys.argv) QCoreApplication.setOrganizationName('NINJA-IDE') QCoreApplication.setOrganizationDomain('NINJA-IDE') QCoreApplication.setApplicationName('NINJA-IDE') app.setWindowIcon(QIcon(resources.IMAGES['icon'])) # Create and display the splash screen splash_pix = QPixmap(resources.IMAGES['splash']) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Set the cursor to unblinking app.setCursorFlashTime(0) #Set the codec for strings (QString) QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8')) #Translator qsettings = QSettings() language = QLocale.system().language() lang = unicode( qsettings.value('preferences/interface/language', language).toString()) + '.qm' lang_path = file_manager.create_path(resources.LANGS, unicode(lang)) if file_manager.file_exists(lang_path): settings.LANGUAGE = lang_path elif file_manager.file_exists( file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang))): settings.LANGUAGE = file_manager.create_path(resources.LANGS_DOWNLOAD, unicode(lang)) translator = QTranslator() if settings.LANGUAGE: translator.load(settings.LANGUAGE) app.installTranslator(translator) #Loading Syntax splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black) json_manager.load_syntax() #Read Settings splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black) settings.load_settings() #Loading Themes splash.showMessage("Loading Themes", Qt.AlignRight | Qt.AlignTop, Qt.black) scheme = unicode( qsettings.value('preferences/editor/scheme', "default").toString()) if scheme != 'default': scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + '.color') if file_manager.file_exists(scheme): resources.CUSTOM_SCHEME = json_manager.parse(open(scheme)) #Loading Shortcuts resources.load_shortcuts() #Loading GUI splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black) ide = IDE() #Showing GUI ide.show() #Connect listener signals ide.connect(listener, SIGNAL("fileOpenRequested(QString)"), ide.open_file) ide.connect(listener, SIGNAL("projectOpenRequested(QString)"), ide.open_project) #Loading Session Files splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black) #Files in Main Tab mainFiles = qsettings.value('openFiles/mainTab', []).toList() tempFiles = [] for file_ in mainFiles: fileData = file_.toList() tempFiles.append( (unicode(fileData[0].toString()), fileData[1].toInt()[0])) mainFiles = tempFiles #Files in Secondary Tab secondaryFiles = qsettings.value('openFiles/secondaryTab', []).toList() tempFiles = [] for file_ in secondaryFiles: fileData = file_.toList() tempFiles.append( (unicode(fileData[0].toString()), fileData[1].toInt()[0])) secondaryFiles = tempFiles #Projects projects = qsettings.value('openFiles/projects', []).toList() projects = [unicode(project.toString()) for project in projects] #Include files received from console args if filenames: mainFiles += [(f, 0) for f in filenames] #Include projects received from console args if projects_path: projects += projects_path ide.load_session_files_projects(mainFiles, secondaryFiles, projects) #Load external plugins if extra_plugins: ide.load_external_plugins(extra_plugins) splash.finish(ide) ide.notify_plugin_errors() sys.exit(app.exec_())