Exemplo n.º 1
0
def main():
    # For the translations to work, the initialization of QApplication and
    # the loading of the translations must be done here instead of the
    # gui module:
    #
    from PyQt4.QtGui import QApplication
    from PyQt4.QtCore import QTranslator, QLocale, QLibraryInfo
    app = QApplication(sys.argv)
    translator = QTranslator()
    success = translator.load(
        QLocale.system(), 'qt', '_',
        QLibraryInfo.location(QLibraryInfo.TranslationsPath))
    if not success:
        success = translator.load(QLocale.system(), 'qt', '_',
                                  utils.qt_translations_dir())
    app.installTranslator(translator)
    if len(sys.argv) >= 2:
        filename = utils.path_to_unicode(sys.argv[1])
    else:
        filename = None
    try:
        interface = gui.Interface(app,
                                  False,
                                  False, [],
                                  preferred_styles=utils.config['gui-styles'])
        manager = ProgramManager(interface, session_file=filename)
        manager.run()
    except utils.EyegradeException as ex:
        print(unicode(ex).encode(sys.stdout.encoding))
        sys.exit(1)
Exemplo n.º 2
0
Arquivo: run.py Projeto: ekimdev/edis
def correr_interfaz(app):
    ESettings().cargar()
    import src.ui.inicio  # lint:ok
    # Traductor
    local = QLocale.system().name()
    qtraductor = QTranslator()
    qtraductor.load("qt_" + local, QLibraryInfo.location(
                    QLibraryInfo.TranslationsPath))

    edis = EDIS()
    app.setWindowIcon(QIcon(paths.ICONOS['icon']))
    # Aplicar estilo
    with open(os.path.join(paths.PATH,
              "extras", "temas", "default.qss")) as tema:
        estilo = tema.read()
    app.setStyleSheet(estilo)
    # Archivos de última sesión
    archivos = ESettings.get('general/archivos')
    # Archivos recientes
    recents_files = ESettings.get('general/recientes')
    if recents_files is None:
        recents_files = []
    edis.cargar_archivos(archivos, recents_files)
    edis.show()
    sys.exit(app.exec_())
Exemplo n.º 3
0
def initGlobals():
    """
    Sets the values of globals that need more than a simple assignment.
    """
    global platBinDir, modDir, pyModDir, apisDir

    if sys.platform.startswith("win"):
        platBinDir = sys.exec_prefix
        if platBinDir.endswith("\\"):
            platBinDir = platBinDir[:-1]
    else:
        platBinDir = "/usr/local/bin"

    modDir = distutils.sysconfig.get_python_lib(True)
    pyModDir = modDir
    
    pyqtDataDir = os.path.join(modDir, "PyQt4")
    if os.path.exists(os.path.join(pyqtDataDir, "qsci")):
        # it's the installer
        qtDataDir = pyqtDataDir
    else:
        try:
            from PyQt4.QtCore import QLibraryInfo
            qtDataDir = unicode(QLibraryInfo.location(QLibraryInfo.DataPath))
        except ImportError:
            qtDataDir = None
    if qtDataDir:
        apisDir = os.path.join(qtDataDir, "qsci", "api")
    else:
        apisDir = None
Exemplo n.º 4
0
def install_gettext_trans_under_qt(base_folder, lang=None):
    # So, we install the gettext locale, great, but we also should try to install qt_*.qm if
    # available so that strings that are inside Qt itself over which I have no control are in the
    # right language.
    from PyQt4.QtCore import QCoreApplication, QTranslator, QLocale, QLibraryInfo
    if not lang:
        lang = str(QLocale.system().name())[:2]
    localename = get_locale_name(lang)
    if localename is not None:
        try:
            locale.setlocale(locale.LC_ALL, localename)
        except locale.Error:
            logging.warning("Couldn't set locale %s", localename)
    qmname = 'qt_%s' % lang
    if ISLINUX:
        # Under linux, a full Qt installation is already available in the system, we didn't bundle
        # up the qm files in our package, so we have to load translations from the system.
        qmpath = op.join(QLibraryInfo.location(QLibraryInfo.TranslationsPath),
                         qmname)
    else:
        qmpath = op.join(base_folder, qmname)
    qtr = QTranslator(QCoreApplication.instance())
    qtr.load(qmpath)
    QCoreApplication.installTranslator(qtr)
    install_gettext_trans(base_folder, lang)
Exemplo n.º 5
0
 def process_designer_plugins(self, attrs):
 
     if "qt_designer_plugins" not in attrs:
         return attrs
     
     plugins = attrs["qt_designer_plugins"]
     del attrs["qt_designer_plugins"]
     
     if "install" not in attrs["script_args"]:
         return attrs
     
     from PyQt4.QtCore import QLibraryInfo
     info = QLibraryInfo.location(QLibraryInfo.PluginsPath)
     plugins_path = os.path.join(unicode(info), "designer", "python")
     if not os.path.exists(plugins_path):
         os.makedirs(plugins_path)
     
     for plugin in plugins:
     
         path = plugin.replace("/", os.sep)
         directory, file_name = os.path.split(path)
         output_path = os.path.join(plugins_path, file_name)
         print "Copying", path, "to", plugins_path
         open(output_path, "wb").write(open(path, "rb").read())
     
     return attrs
Exemplo n.º 6
0
 def __init__(self, args=[], **kw):
     QApplication.__init__(self, args)
     locale = QLocale.system().name()
     translator=QTranslator ()
     translator.load("qt_" + locale,
                   QLibraryInfo.location(QLibraryInfo.TranslationsPath))
     self.installTranslator(translator)
     self._print_signal.connect(self._print)
Exemplo n.º 7
0
def copy_qt_plugins(folder_names, dest): # This is only for Windows
    from PyQt4.QtCore import QLibraryInfo
    qt_plugin_dir = QLibraryInfo.location(QLibraryInfo.PluginsPath)
    def ignore(path, names):
        if path == qt_plugin_dir:
            return [n for n in names if n not in folder_names]
        else:
            return [n for n in names if not n.endswith('.dll')]
    shutil.copytree(qt_plugin_dir, dest, ignore=ignore)
Exemplo n.º 8
0
 def __init__(self, args=[], **kw):
     QApplication.__init__(self, args)
     locale = QLocale.system().name()
     translator=QTranslator ()
     translator.load("qt_" + locale,
                   QLibraryInfo.location(QLibraryInfo.TranslationsPath))
     self.installTranslator(translator)
     if param.style_Qt:
         self.setStyle(param.style_Qt)
Exemplo n.º 9
0
def install_translator(qapp):
    """Install Qt translator to the QApplication instance"""
    global QT_TRANSLATOR
    if QT_TRANSLATOR is None:
        qt_translator = QTranslator()
        if qt_translator.load("qt_"+QLocale.system().name(),
                      QLibraryInfo.location(QLibraryInfo.TranslationsPath)):
            QT_TRANSLATOR = qt_translator # Keep reference alive
    if QT_TRANSLATOR is not None:
        qapp.installTranslator(QT_TRANSLATOR)
Exemplo n.º 10
0
 def __init__(self, args=[], **kw):
     QApplication.__init__(self, args)
     locale = QLocale.system().name()
     translator=QTranslator ()
     translator.load("qt_" + locale,
                   QLibraryInfo.location(QLibraryInfo.TranslationsPath))
     self.installTranslator(translator)
     self._print_signal.connect(self._print)
     # Pour Mac OS X
     self.setAttribute(Qt.AA_DontUseNativeMenuBar)
Exemplo n.º 11
0
def install_translator(qapp):
    """Install Qt translator to the QApplication instance"""
    global QT_TRANSLATOR
    if QT_TRANSLATOR is None:
        qt_translator = QTranslator()
        if qt_translator.load(
                "qt_" + QLocale.system().name(),
                QLibraryInfo.location(QLibraryInfo.TranslationsPath)):
            QT_TRANSLATOR = qt_translator  # Keep reference alive
    if QT_TRANSLATOR is not None:
        qapp.installTranslator(QT_TRANSLATOR)
Exemplo n.º 12
0
def copy_qt_plugins(folder_names, dest):  # This is only for Windows
    from PyQt4.QtCore import QLibraryInfo
    qt_plugin_dir = QLibraryInfo.location(QLibraryInfo.PluginsPath)

    def ignore(path, names):
        if path == qt_plugin_dir:
            return [n for n in names if n not in folder_names]
        else:
            return [n for n in names if not n.endswith('.dll')]

    shutil.copytree(qt_plugin_dir, dest, ignore=ignore)
Exemplo n.º 13
0
    def _build_translations(self, basepath):
        """Build translations_rc.py which inclues qt_xx.qm"""
        from tortoisehg.hgqt.qtcore import QT_API
        if QT_API == 'PyQt4':
            if os.name == 'nt':
                import PyQt4
                trpath = os.path.join(os.path.dirname(PyQt4.__file__),
                                      'translations')
            else:
                from PyQt4.QtCore import QLibraryInfo
                trpath = unicode(
                    QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        else:
            if os.name == 'nt':
                import PyQt5
                trpath = os.path.join(os.path.dirname(PyQt5.__file__),
                                      'translations')
            else:
                from PyQt5.QtCore import QLibraryInfo
                trpath = unicode(
                    QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        builddir = os.path.join(
            self.get_finalized_command('build').build_base, 'qt-translations')
        self.mkpath(builddir)

        # we have to copy .qm files to build directory because .qrc file must
        # specify files by relative paths
        qmfiles = []
        for e in os.listdir(trpath):
            if (not e.startswith(('qt_', 'qscintilla_'))
                    or e.startswith('qt_help_') or not e.endswith('.qm')):
                continue
            f = os.path.join(builddir, e)
            self.copy_file(os.path.join(trpath, e), f)
            qmfiles.append(f)
        pyfile = os.path.join(basepath, 'translations_rc.py')
        self.make_file(qmfiles,
                       pyfile,
                       self._build_rc,
                       (qmfiles, pyfile, builddir, '/translations'),
                       exec_msg='generating %s from Qt translation' % pyfile)
Exemplo n.º 14
0
def simpleAppStartup(argv, appinfo, mwFactory, kqOptions = [], 
                     quitOnLastWindowClosed = True, raiseIt = True):
    """
    Function to start up an application that doesn't need a specialized start up.
    
    This function is used by all of eric4's helper programs.
    
    @param argv list of commandline parameters (list of strings)
    @param appinfo dictionary describing the application
    @param mwFactory factory function generating the main widget. This
        function must accept the following parameter.
        <dl>
            <dt>argv</dt>
            <dd>list of commandline parameters (list of strings)</dd>
        </dl>
    @keyparam kqOptions list of acceptable command line options. This is only
        used, if the application is running under KDE and pyKDE can be loaded
        successfully.
    @keyparam quitOnLastWindowClosed flag indicating to quit the application,
        if the last window was closed (boolean)
    @keyparam raiseIt flag indicating to raise the generated application window
        (boolean)
    """
    ddindex = handleArgs(argv, appinfo)
    app = KQApplication(argv, kqOptions)
    app.setQuitOnLastWindowClosed(quitOnLastWindowClosed)
    try:
        sys.setappdefaultencoding(str(Preferences.getSystem("StringEncoding")))
    except AttributeError:
        pass

    setLibraryPaths()
    initializeResourceSearchPath()
    QApplication.setWindowIcon(UI.PixmapCache.getIcon("eric.png"))
    
    qt4TransDir = Preferences.getQt4TranslationsDir()
    if not qt4TransDir:
        qt4TransDir = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
    loadTranslators(qt4TransDir, app)
    
    QTextCodec.setCodecForCStrings(\
        QTextCodec.codecForName(str(Preferences.getSystem("StringEncoding")))
    )
    
    w = mwFactory(argv)
    if quitOnLastWindowClosed:
        app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
    w.show()
    if raiseIt:
        w.raise_()
    
    return app.exec_()
Exemplo n.º 15
0
    def locale(self, lang=None):
        try:
            lang = lang or self.lang
            translate_path = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
            transl = self.transl = QTranslator(self)
            fn = 'zebratrace_%s' % lang
            if not(transl.load(fn, translate_path)):
                transl.load(fn, self.translations_dir)
            self.installTranslator(transl)
            self.tr = lambda a: QApplication.translate("ZQApplication", a)
            dialogs.tr = lambda a: QApplication.translate("@default", a)
            utils.tr = lambda a: QApplication.translate("@default", a)

        except locale.Error:
            pass
Exemplo n.º 16
0
    def locale(self, lang=None):
        try:
            lang = lang or self.lang
            translate_path = QLibraryInfo.location(
                QLibraryInfo.TranslationsPath)
            transl = self.transl = QTranslator(self)
            fn = 'zebratrace_%s' % lang
            if not (transl.load(fn, translate_path)):
                transl.load(fn, self.translations_dir)
            self.installTranslator(transl)
            self.tr = lambda a: QApplication.translate("ZQApplication", a)
            dialogs.tr = lambda a: QApplication.translate("@default", a)
            utils.tr = lambda a: QApplication.translate("@default", a)

        except locale.Error:
            pass
Exemplo n.º 17
0
 def _build_translations(self, basepath):
     """Build translations_rc.py which inclues qt_xx.qm"""
     from PyQt4.QtCore import QLibraryInfo
     trpath = unicode(QLibraryInfo.location(QLibraryInfo.TranslationsPath))
     d = tempfile.mkdtemp()
     try:
         for e in os.listdir(trpath):
             if re.match(r'qt_[a-z]{2}(_[A-Z]{2})?\.ts$', e):
                 r = os.system('lrelease "%s" -qm "%s"' % (os.path.join(
                     trpath, e), os.path.join(d, e[:-3] + '.qm')))
                 if r > 0:
                     self.warn('Unable to generate Qt message file'
                               ' from %s' % e)
         self.build_rc(os.path.join(basepath, 'translations_rc.py'), d,
                       '/translations')
     finally:
         shutil.rmtree(d)
Exemplo n.º 18
0
 def __init__(self):
     self.translators = {}
     self.conf = Conf()
     if hasattr(sys, "frozen"):
         translationPath = os.path.abspath(
             os.path.join(os.path.dirname(sys.executable),
                          "resources/i18n"))
         self.addTranslationPath(os.path.join(translationPath, "qt_"))
         self.addTranslationPath(os.path.join(translationPath, "Dff_"))
     else:
         self.addTranslationPath(
             os.path.join(
                 unicode(
                     QLibraryInfo.location(
                         QLibraryInfo.TranslationsPath)), "qt_"))
         self.addTranslationPath("dff/ui/gui/i18n/Dff_")
     self.loadLanguage()
Exemplo n.º 19
0
 def _build_translations(self, basepath):
     """Build translations_rc.py which inclues qt_xx.qm"""
     from PyQt4.QtCore import QLibraryInfo
     trpath = unicode(QLibraryInfo.location(QLibraryInfo.TranslationsPath))
     d = tempfile.mkdtemp()
     try:
         for e in os.listdir(trpath):
             if re.match(r'qt_[a-z]{2}(_[A-Z]{2})?\.ts$', e):
                 r = os.system('lrelease "%s" -qm "%s"'
                               % (os.path.join(trpath, e),
                                  os.path.join(d, e[:-3] + '.qm')))
                 if r > 0:
                     self.warn('Unable to generate Qt message file'
                               ' from %s' % e)
         self.build_rc(os.path.join(basepath, 'translations_rc.py'),
                       d, '/translations')
     finally:
         shutil.rmtree(d)
Exemplo n.º 20
0
def build_localizations(ui, edition):
    build_base_localizations()
    if ui == 'cocoa':
        app = cocoa_app(edition)
        loc.build_cocoa_localizations(app, en_stringsfile=op.join('cocoa', 'base', 'en.lproj', 'Localizable.strings'))
        locale_dest = op.join(app.resources, 'locale')
    elif ui == 'qt':
        build_qt_localizations()
        locale_dest = op.join('build', 'locale')
    if op.exists(locale_dest):
        shutil.rmtree(locale_dest)
    shutil.copytree('locale', locale_dest, ignore=shutil.ignore_patterns('*.po', '*.pot'))
    if ui == 'qt' and not ISLINUX:
        print("Copying qt_*.qm files into the 'locale' folder")
        from PyQt4.QtCore import QLibraryInfo
        trfolder = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
        for lang in loc.get_langs('locale'):
            qmname = 'qt_%s.qm' % lang
            src = op.join(trfolder, qmname)
            if op.exists(src):
                copy(src, op.join('build', 'locale', qmname))
Exemplo n.º 21
0
def build_localizations(ui):
    build_base_localizations()
    if ui == 'cocoa':
        app = cocoa_app()
        loc.build_cocoa_localizations(app)
        locale_dest = op.join(app.resources, 'locale')
    elif ui == 'qt':
        build_qt_localizations()
        locale_dest = op.join('build', 'locale')
    if op.exists(locale_dest):
        shutil.rmtree(locale_dest)
    shutil.copytree('locale', locale_dest, ignore=shutil.ignore_patterns('*.po', '*.pot'))
    if ui == 'qt' and not ISLINUX:
        print("Copying qt_*.qm files into the 'locale' folder")
        from PyQt4.QtCore import QLibraryInfo
        trfolder = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
        for lang in loc.get_langs('locale'):
            qmname = 'qt_%s.qm' % lang
            src = op.join(trfolder, qmname)
            if op.exists(src):
                copy(src, op.join('build', 'locale', qmname))
Exemplo n.º 22
0
def main():
    # For the translations to work, the initialization of QApplication and
    # the loading of the translations must be done here instead of the
    # gui module:
    #
    from PyQt4.QtGui import QApplication
    from PyQt4.QtCore import QTranslator, QLocale, QLibraryInfo
    app = QApplication(sys.argv)
    translator = QTranslator()
    success = translator.load(QLocale.system(), 'qt', '_',
                    QLibraryInfo.location(QLibraryInfo.TranslationsPath))
    if not success:
        success = translator.load(QLocale.system(), 'qt', '_',
                                  utils.qt_translations_dir())
    app.installTranslator(translator)
    if len(sys.argv) >= 2:
        filename = sys.argv[1]
    else:
        filename = None
    interface = gui.Interface(app, False, False, [])
    manager = ProgramManager(interface, session_file=filename)
    manager.run()
Exemplo n.º 23
0
def main():
    # For the translations to work, the initialization of QApplication and
    # the loading of the translations must be done here instead of the
    # gui module:
    #
    from PyQt4.QtGui import QApplication
    from PyQt4.QtCore import QTranslator, QLocale, QLibraryInfo
    app = QApplication(sys.argv)
    translator = QTranslator()
    success = translator.load(
        QLocale.system(), 'qt', '_',
        QLibraryInfo.location(QLibraryInfo.TranslationsPath))
    if not success:
        success = translator.load(QLocale.system(), 'qt', '_',
                                  utils.qt_translations_dir())
    app.installTranslator(translator)
    if len(sys.argv) >= 2:
        filename = sys.argv[1]
    else:
        filename = None
    interface = gui.Interface(app, False, False, [])
    manager = ProgramManager(interface, session_file=filename)
    manager.run()
Exemplo n.º 24
0
def qapplication(translate=True):
    """
    Return QApplication instance
    Creates it if it doesn't already exist
    """
    if QApplication.startingUp():
        app = QApplication([])
        if translate:
            locale = QLocale.system().name()
            # Qt-specific translator
            qt_translator = QTranslator()
            TRANSLATORS.append(qt_translator) # Keep reference alive
            paths = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
            if qt_translator.load("qt_"+locale, paths):
                app.installTranslator(qt_translator)
            # Spyder-specific translator
            app_translator = QTranslator()
            TRANSLATORS.append(app_translator) # Keep reference alive
            if app_translator.load("spyder_"+locale, DATA_PATH):
                app.installTranslator(app_translator)
    else:
        app = QApplication.instance()
    return app
Exemplo n.º 25
0
def install_gettext_trans_under_qt(base_folder, lang=None):
    # So, we install the gettext locale, great, but we also should try to install qt_*.qm if
    # available so that strings that are inside Qt itself over which I have no control are in the
    # right language.
    from PyQt4.QtCore import QCoreApplication, QTranslator, QLocale, QLibraryInfo
    if not lang:
        lang = str(QLocale.system().name())[:2]
    localename = get_locale_name(lang)
    if localename is not None:
        try:
            locale.setlocale(locale.LC_ALL, localename)
        except locale.Error:
            logging.warning("Couldn't set locale %s", localename)
    qmname = 'qt_%s' % lang
    if ISLINUX:
        # Under linux, a full Qt installation is already available in the system, we didn't bundle
        # up the qm files in our package, so we have to load translations from the system.
        qmpath = op.join(QLibraryInfo.location(QLibraryInfo.TranslationsPath), qmname)
    else:
        qmpath = op.join(base_folder, qmname)
    qtr = QTranslator(QCoreApplication.instance())
    qtr.load(qmpath)
    QCoreApplication.installTranslator(qtr)
    install_gettext_trans(base_folder, lang)
Exemplo n.º 26
0
 def _init_translations(self):
     self.qTrans = QTranslator()
     self.qTrans.load("qt_" + QLocale.system().name(),
             QLibraryInfo.location(QLibraryInfo.TranslationsPath))
     self.installTranslator(self.qTrans)
Exemplo n.º 27
0
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
    if sys.platform != 'win32':
        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',
        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
    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)

        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)
    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_)
        if fileData:
            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', '', type='QString')
    #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([(f[0], f[1] - 1) for f in zip(filenames, linenos)])
    file_without_nro = list([(f, 0) for f in 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_())
Exemplo n.º 28
0
  INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND
  FITNESS FOR A PARTICULAR PURPOSE.
"""

import sys
from PyQt4.QtGui import QApplication
from PyQt4.QtCore import QTranslator, QLocale, QLibraryInfo
import eyeBlocks.mainwindow
import os

app = QApplication(sys.argv)

# Qt's lanquage files
qtTranslator = QTranslator()
qtTranslator.load("qt_" + QLocale.system().name(),
                  QLibraryInfo.location(QLibraryInfo.TranslationsPath))
app.installTranslator(qtTranslator)

# this application's language files are in eyeBlocks module's directory
langPath = os.path.join(os.path.dirname(eyeBlocks.mainwindow.__file__), "lang")
myTranslator = QTranslator()
myTranslator.load(QLocale.system().name(), langPath)
app.installTranslator(myTranslator)

######## Creating the main window
window = eyeBlocks.mainwindow.BlockMainWindow()
window.show()
if len(sys.argv) > 1:
    window.loadFile(sys.argv[1])
sys.exit(app.exec_())
Exemplo n.º 29
0
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()
Exemplo n.º 30
0
def main():
    """
    Main entry point into the application.
    """
    global args, mainWindow, splash, restartArgs
    
    sys.excepthook = excepthook
    
    options = [\
        ("--config=configDir", 
         "use the given directory as the one containing the config files"), 
        ("--debug", "activate debugging output to the console"), 
        ("--nosplash", "don't show the splash screen"),
        ("--noopen", "don't open anything at startup except that given in command"), 
        ("--nokde" , "don't use KDE widgets"),
        ("--plugin=plugin-file", "load the given plugin file (plugin development)"), 
        ("--start-session", "load the global session file"), 
        ("--", "indicate that there are options for the program to be debugged"),
        ("", "(everything after that is considered arguments for this program)")
    ]
    kqOptions = [\
        ("config \\", "use the given directory as the one containing the config files"), 
        ("debug", "activate debugging output to the console"), 
        ("nosplash", "don't show the splash screen"),
        ("noopen", "don't open anything at startup except that given in command"), 
        ("nokde" , "don't use KDE widgets"),
        ("plugin \\", "load the given plugin file (plugin development)"), 
        ("start-session", "load the global session file"), 
        ("!+file", "")
    ]
    appinfo = Startup.makeAppInfo(sys.argv,
                                  "Eric4",
                                  "[project | files... [--] [debug-options]]",
                                  "A Python IDE",
                                  options)
    ddindex = Startup.handleArgs(sys.argv, appinfo)
    
    if not Utilities.checkBlacklistedVersions():
        sys.exit(100)
    
    app = KQApplication(sys.argv, kqOptions)
    
    if Preferences.getUI("SingleApplicationMode"):
        handleSingleApplication(ddindex)
    
    # set the library paths for plugins
    Startup.setLibraryPaths()
    
    # set the search path for icons
    Startup.initializeResourceSearchPath()

    # generate and show a splash window, if not suppressed
    if "--nosplash" in sys.argv and sys.argv.index("--nosplash") < ddindex:
        del sys.argv[sys.argv.index("--nosplash")]
        splash = NoneSplashScreen()
    elif not Preferences.getUI("ShowSplash"):
        splash = NoneSplashScreen()
    else:
        splash = SplashScreen()
    
    # modify the executable search path for the PyQt4 installer
    if Utilities.isWindowsPlatform():
        pyqtDataDir = Utilities.getPyQt4ModulesDirectory()
        if os.path.exists(os.path.join(pyqtDataDir, "bin")):
            path = os.path.join(pyqtDataDir, "bin") + os.pathsep + os.environ["PATH"]
        else:
            path = pyqtDataDir + os.pathsep + os.environ["PATH"]
        os.environ["PATH"] = path
    
    pluginFile = None
    noopen = False
    if "--noopen" in sys.argv and sys.argv.index("--noopen") < ddindex:
        del sys.argv[sys.argv.index("--noopen")]
        noopen = True
    for arg in sys.argv:
        if arg.startswith("--plugin=") and sys.argv.index(arg) < ddindex:
            # extract the plugin development option
            pluginFile = arg.replace("--plugin=", "").replace('"', "")
            sys.argv.remove(arg)
            pluginFile = os.path.expanduser(pluginFile)
            pluginFile = Utilities.normabspath(pluginFile)
            break
    
    # is there a set of filenames or options on the command line,
    # if so, pass them to the UI
    if len(sys.argv) > 1:
        args = sys.argv[1:]
    
    # Set the applications string encoding
    try:
        sys.setappdefaultencoding(str(Preferences.getSystem("StringEncoding")))
    except AttributeError:
        pass
    
    # get the Qt4 translations directory
    qt4TransDir = Preferences.getQt4TranslationsDir()
    if not qt4TransDir:
        qt4TransDir = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
    
    # Load translation files and install them
    loc = Startup.loadTranslators(qt4TransDir, app, ("qscintilla",))
    
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName(\
        str(Preferences.getSystem("StringEncoding"))))
    
    splash.showMessage(QApplication.translate("eric4", "Importing packages..."))
    # We can only import these after creating the KQApplication because they
    # make Qt calls that need the KQApplication to exist.
    from UI.UserInterface import UserInterface

    splash.showMessage(QApplication.translate("eric4", "Generating Main Window..."))
    try:
        mainWindow = UserInterface(app, loc, splash, pluginFile, noopen, restartArgs)
        app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
        mainWindow.show()
        
        QTimer.singleShot(0, uiStartUp)
        
        # generate a graphical error handler
        eMsg = QErrorMessage.qtHandler()
        eMsg.setMinimumSize(600, 400)
        
        # start the event loop
        res = app.exec_()
        logging.debug("Shutting down, result %d" % res)
        logging.shutdown()
        sys.exit(res)
    except Exception, err:
        raise err
Exemplo n.º 31
0
#!/usr/bin/python
# vim: set fileencoding=utf-8 :

from PyQt4.QtCore import QLibraryInfo, QPluginLoader
import os.path

main_plugin_path = str(QLibraryInfo.location(QLibraryInfo.PluginsPath))
designer_plugin_path = os.path.join(main_plugin_path, 'designer')
kdewidgets_path = os.path.join(designer_plugin_path, 'kdewidgets.so')
kdelibs_present = QPluginLoader(kdewidgets_path).load()

if __name__ == '__main__':
    print "Plugin Path", main_plugin_path
    print "Designer plugin path", designer_plugin_path
    print "Widgets Path", kdewidgets_path
    print "Result", kdelibs_present
Exemplo n.º 32
0
Arquivo: qtscod.py Projeto: elemc/scod
def get_lang_code(full_lang_name):
    llang = str(full_lang_name).split('_')
    if len(llang) > 1:
        return llang[0]
    return None

if __name__ == '__main__':
    app = QApplication(sys.argv)
    app.setOrganizationName( "RussianFedora" )
    app.setOrganizationDomain( "www.russianfedora.ru" )
    app.setApplicationName( "Qt SCOD Client" )
    
    locale = QLocale.system()
    
    trans_path = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
    translator = QTranslator(app)
    stranslator = QTranslator(app)
    lang = get_lang_code(locale.name())
    if lang is not None:
        trans_file = QString("qt_%s" % lang)
        #print trans_file
        translator.load(trans_file ,  trans_path)
        app.installTranslator(translator)

        # self translate
        strans_file = QString(":/lang/qtscod-%s" % QLocale.system().name())
        print(strans_file)
        stranslator.load(strans_file, "")
        print (app.applicationFilePath())
        app.installTranslator(stranslator)
Exemplo n.º 33
0
def get_translator():
    translator = QTranslator()
    locale = QLocale.system().name()
    translator.load('qt_%s' % locale,
        			QLibraryInfo.location(QLibraryInfo.TranslationsPath))
    return translator
Exemplo n.º 34
0
 def _init_translations(self):
     self.qTrans = QTranslator()
     self.qTrans.load("qt_" + QLocale.system().name(),
                      QLibraryInfo.location(QLibraryInfo.TranslationsPath))
     self.installTranslator(self.qTrans)
Exemplo n.º 35
0
def load_qt_locale(app):
     translator = QTranslator(app)
     language = get_language()
     directory = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
     translator.load("qt_" + language, directory)
     app.installTranslator(translator)
Exemplo n.º 36
0
    def qt4_plugins(subdir, *libs):
        from PyQt4.QtCore import QLibraryInfo
        pluginsdir = unicode(QLibraryInfo.location(QLibraryInfo.PluginsPath))

        return ('qt_plugins/' + subdir,
                [os.path.join(pluginsdir, subdir, e) for e in libs])
Exemplo n.º 37
0
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()
Exemplo n.º 38
0
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()
Exemplo n.º 39
0
def run_edis(app):
    """ Se carga la interfáz """

    DEBUG("Running Edis...")
    qsettings = QSettings(paths.CONFIGURACION, QSettings.IniFormat)
    # Ícono
    app.setWindowIcon(QIcon(":image/edis"))
    # Lenguaje
    local = QLocale.system().name()
    DEBUG("Loading language...")
    language = settings.get_setting('general/language')
    if language:
        edis_translator = QTranslator()
        edis_translator.load(os.path.join(paths.PATH,
                             "extras", "i18n", language))
        app.installTranslator(edis_translator)
        # Qt translator
        qtranslator = QTranslator()
        qtranslator.load("qt_" + local, QLibraryInfo.location(
                         QLibraryInfo.TranslationsPath))
        app.installTranslator(qtranslator)
    pixmap = QPixmap(":image/splash")
    # Splash screen
    show_splash = False
    if settings.get_setting('general/show-splash'):
        DEBUG("Showing splash...")
        splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint)
        splash.setMask(pixmap.mask())
        splash.show()
        app.processEvents()
        show_splash = True

    # Style Sheet
    style = settings.get_setting('window/style-sheet')
    path_style = None
    style_sheet = None
    if style == 'Edark':
        path_style = os.path.join(paths.PATH, 'extras', 'theme', 'edark.qss')
    elif style != 'Default':
        path_style = os.path.join(paths.EDIS, style + '.qss')
    if path_style is not None:
        with open(path_style, mode='r') as f:
            style_sheet = f.read()
    app.setStyleSheet(style_sheet)

    # Fuente en Tooltips
    QToolTip.setFont(QFont(settings.DEFAULT_FONT, 9))

    # GUI
    if show_splash:
        alignment = Qt.AlignBottom | Qt.AlignLeft
        splash.showMessage("Loading UI...", alignment, Qt.white)
    DEBUG("Loading GUI...")
    edis = Edis()
    edis.show()
    # Archivos de última sesión
    files, recents_files, projects = [], [], []
    projects = qsettings.value('general/projects')
    #FIXME:
    if projects is None:
        projects = []
    if settings.get_setting('general/load-files'):
        DEBUG("Loading files and projects...")
        if show_splash:
            splash.showMessage("Loading files...", alignment, Qt.white)
        files = qsettings.value('general/files')
        if files is None:
            files = []
        # Archivos recientes
        recents_files = qsettings.value('general/recents-files')
        if recents_files is None:
            recents_files = []
    # Archivos desde línea de comandos
    files += cmd_parser.parse()
    edis.load_files_and_projects(files, recents_files, projects)
    if show_splash:
        splash.finish(edis)
    DEBUG("Edis is Ready!")
    sys.exit(app.exec_())
Exemplo n.º 40
0
    # Create dir
    settings.create_dir()
    info = __get_versions()
    DEBUG("Executing Pireal from source")
    INFO("Python {0} - Qt {1} on {2} {3}".format(
         info['python'], info['qt'], info['os'], info['name']))

    # Import resources
    from src import resources  # lint:ok

    qapp = QApplication(sys.argv)
    qapp.setWindowIcon(QIcon(":img/logo"))
    # System language
    local = QLocale.system().name()
    translator = QTranslator()
    translator.load("qt_" + local, QLibraryInfo.location(
                    QLibraryInfo.TranslationsPath))
    qapp.installTranslator(translator)
    # Load services
    from src.gui.main_window import Pireal
    from src.gui import status_bar  # lint:ok
    from src.gui import container  # lint:ok
    from src.gui import table_widget  # lint:ok
    from src.gui.query_editor import query_widget  # lint:ok
    from src.gui import lateral_widget  # lint:ok

    # Style
    qapp.setStyle(QStyleFactory.create("gtk"))
    INFO("Loading GUI...")
    gui = Pireal()
    # Style sheet
    with open('src/gui/style.qss') as f:
Exemplo n.º 41
0
def start(filenames=None,
          projects_path=None,
          extra_plugins=None,
          linenos=None):
    app = QApplication(sys.argv)
    QCoreApplication.setOrganizationName('AL\'EXA-IDE')
    QCoreApplication.setOrganizationDomain('AL\'EXA-IDE')
    QCoreApplication.setApplicationName('AL\'EXA-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 sys.platform != 'win32':
        app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    #qsettings = QSettings()
    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
    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)

        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)
    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_)
        if fileData:
            lineno = fileData[1]
            tempFiles.append((fileData[0], lineno))
    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_)
        lineno = fileData[1]
        tempFiles.append((fileData[0], lineno))
    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', '', type='QString')
    #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([(f[0], f[1] - 1) for f in zip(filenames, linenos)])
    file_without_nro = list([(f, 0) for f in 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()
    ide.show_python_detection()
    sys.exit(app.exec_())
Exemplo n.º 42
0
def run_edis(app):
    """ Se carga la interfáz """

    DEBUG("Running Edis...")
    qsettings = QSettings(paths.CONFIGURACION, QSettings.IniFormat)
    # Ícono
    app.setWindowIcon(QIcon(":image/edis"))
    # Lenguaje
    local = QLocale.system().name()
    DEBUG("Loading language...")
    language = settings.get_setting('general/language')
    if language:
        edis_translator = QTranslator()
        edis_translator.load(
            os.path.join(paths.PATH, "extras", "i18n", language))
        app.installTranslator(edis_translator)
        # Qt translator
        qtranslator = QTranslator()
        qtranslator.load("qt_" + local,
                         QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        app.installTranslator(qtranslator)
    pixmap = QPixmap(":image/splash")
    # Splash screen
    show_splash = False
    if settings.get_setting('general/show-splash'):
        DEBUG("Showing splash...")
        splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint)
        splash.setMask(pixmap.mask())
        splash.show()
        app.processEvents()
        show_splash = True

    # Style Sheet
    style = settings.get_setting('window/style-sheet')
    path_style = None
    style_sheet = None
    if style == 'Edark':
        path_style = os.path.join(paths.PATH, 'extras', 'theme', 'edark.qss')
    elif style != 'Default':
        path_style = os.path.join(paths.EDIS, style + '.qss')
    if path_style is not None:
        with open(path_style, mode='r') as f:
            style_sheet = f.read()
    app.setStyleSheet(style_sheet)

    # Fuente en Tooltips
    QToolTip.setFont(QFont(settings.DEFAULT_FONT, 9))

    # GUI
    if show_splash:
        alignment = Qt.AlignBottom | Qt.AlignLeft
        splash.showMessage("Loading UI...", alignment, Qt.white)
    DEBUG("Loading GUI...")
    edis = Edis()
    edis.show()
    # Archivos de última sesión
    files, recents_files, projects = [], [], []
    projects = qsettings.value('general/projects')
    #FIXME:
    if projects is None:
        projects = []
    if settings.get_setting('general/load-files'):
        DEBUG("Loading files and projects...")
        if show_splash:
            splash.showMessage("Loading files...", alignment, Qt.white)
        files = qsettings.value('general/files')
        if files is None:
            files = []
        # Archivos recientes
        recents_files = qsettings.value('general/recents-files')
        if recents_files is None:
            recents_files = []
    # Archivos desde línea de comandos
    files += cmd_parser.parse()
    edis.load_files_and_projects(files, recents_files, projects)
    if show_splash:
        splash.finish(edis)
    DEBUG("Edis is Ready!")
    sys.exit(app.exec_())