def __init__(self, parent):
        super().__init__(parent)
        self._preferences = parent
        vbox = QVBoxLayout(self)
        self._font = settings.FONT

        # Group widgets
        group_typo = QGroupBox(
            translations.TR_PREFERENCES_EDITOR_GENERAL_TYPOGRAPHY)
        group_scheme = QGroupBox("Editor Color Scheme")

        # Font settings
        grid_typo = QGridLayout(group_typo)
        self._btn_editor_font = QPushButton('')
        grid_typo.addWidget(QLabel(
            translations.TR_PREFERENCES_EDITOR_GENERAL_EDITOR_FONT), 0, 0)
        grid_typo.addWidget(self._btn_editor_font, 0, 1)
        self._check_font_antialiasing = QCheckBox("Antialiasing")
        grid_typo.addWidget(self._check_font_antialiasing, 1, 0)

        # Scheme settings
        box = QVBoxLayout(group_scheme)
        self._combo_themes = QComboBox()
        box.addWidget(self._combo_themes)
        schemes = json_manager.load_editor_schemes()
        for scheme_name, colors in schemes.items():
            self._combo_themes.addItem(scheme_name, colors)
        self.__current_scheme = settings.EDITOR_SCHEME

        # self._list_view_scheme = QListView()
        # schemes = json_manager.load_editor_schemes()
        # from collections import namedtuple
        # CategoryEntry = namedtuple('CategoryEntry', 'name color')
        # list_of_categories = []
        # for scheme_name, categories in schemes.items():
        #     for category_name in categories.keys():
        #         category = CategoryEntry(
        #             category_name,
        #             categories[category_name]['color']
        #         )
        #         list_of_categories.append(category)

        # model = ListModelScheme(list_of_categories)
        # model.set_font(self._font)
        # self._list_view_scheme.setModel(model)
        # box.addWidget(self._list_view_scheme)
        # Add group widgets
        vbox.addWidget(group_typo)
        vbox.addWidget(group_scheme)
        vbox.addItem(
            QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
        # Initial Settings
        btn_text = ', '.join(self._font.toString().split(',')[0:2])
        self._btn_editor_font.setText(btn_text)
        self._check_font_antialiasing.setChecked(settings.FONT_ANTIALIASING)
        self._combo_themes.setCurrentText(settings.EDITOR_SCHEME)
        # Connections
        self._btn_editor_font.clicked.connect(self._load_editor_font)
        self._preferences.savePreferences.connect(self._save)
    def __init__(self, parent):
        super().__init__(parent)
        self._preferences = parent
        vbox = QVBoxLayout(self)
        self._font = settings.FONT

        # Group widgets
        group_typo = QGroupBox(
            translations.TR_PREFERENCES_EDITOR_GENERAL_TYPOGRAPHY)
        group_scheme = QGroupBox("Editor Color Scheme")

        # Font settings
        grid_typo = QGridLayout(group_typo)
        self._btn_editor_font = QPushButton('')
        grid_typo.addWidget(
            QLabel(translations.TR_PREFERENCES_EDITOR_GENERAL_EDITOR_FONT), 0,
            0)
        grid_typo.addWidget(self._btn_editor_font, 0, 1)
        self._check_font_antialiasing = QCheckBox("Antialiasing")
        grid_typo.addWidget(self._check_font_antialiasing, 1, 0)

        # Scheme settings
        box = QVBoxLayout(group_scheme)
        self._combo_themes = QComboBox()
        box.addWidget(self._combo_themes)
        schemes = json_manager.load_editor_schemes()
        for scheme_name, colors in schemes.items():
            self._combo_themes.addItem(scheme_name, colors)
        self.__current_scheme = settings.EDITOR_SCHEME

        #             category_name,

        # Add group widgets
        vbox.addWidget(group_typo)
        vbox.addWidget(group_scheme)
        vbox.addItem(
            QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
        # Initial Settings
        btn_text = ', '.join(self._font.toString().split(',')[0:2])
        self._btn_editor_font.setText(btn_text)
        self._check_font_antialiasing.setChecked(settings.FONT_ANTIALIASING)
        self._combo_themes.setCurrentText(settings.EDITOR_SCHEME)
        # Connections
        self._btn_editor_font.clicked.connect(self._load_editor_font)
        self._preferences.savePreferences.connect(self._save)
Esempio n. 3
0
from PyQt5.QtCore import Qt

from PyQt5.QtTest import QTest

sys.path.append("..")

from ninja_ide.tools import json_manager
from ninja_ide import resources

from ninja_ide.core.file_handling import nfile
from ninja_ide.gui.editor import neditable
from ninja_ide.gui.editor.editor import NEditor
from ninja_ide.gui.syntax_registry import syntax_registry  # noqa

json_manager.load_syntax()
themes = json_manager.load_editor_schemes()
resources.COLOR_SCHEME = themes["Ninja Dark"]

qapp = QApplication(sys.argv)

ninja_editor = NEditor(neditable=neditable.NEditable(nfile.NFile()))
ninja_editor.side_widgets.remove("CodeFoldingWidget")
ninja_editor.side_widgets.remove("MarkerWidget")
ninja_editor.side_widgets.remove("TextChangeWidget")
ninja_editor.side_widgets.update_viewport()
ninja_editor.side_widgets.resize()
ninja_editor.register_syntax_for()
ninja_editor.showMaximized()

click_times = {}
Esempio n. 4
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 codec for strings (QString)
    # QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    # FIXME: handle this
    qsettings = ide.IDE.ninja_settings()
    data_qsettings = ide.IDE.data_settings()
    # Translator
    # 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)

    # FIXME: handle this
    # Set Stylesheet
    # style_applied = False
    # 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)

    # FIXME: handle this
    # Loading Schemes
    splash.showMessage("Loading Schemes...", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)
    all_schemes = json_manager.load_editor_schemes()
    scheme = qsettings.value("preferences/editor/scheme", "")
    resources.COLOR_SCHEME = all_schemes['Ninja Dark']
    # if scheme:
    #    color_scheme = all_schemes[scheme]
    #    resources.CUSTOM_SCHEME = color_scheme

    # print(all_schemes)
    # 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)
    ninjaide = ide.IDE()

    # Style
    app.setStyle(ninja_style.NinjaStyle())

    # 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
    # FIXME: handle this
    # 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
    files = data_qsettings.value('last_session/opened_files', [])
    projects = data_qsettings.value('last_session/projects', [])
    current_file = data_qsettings.value('last_session/current_file', '')
    if files is None:
        files = []
    if projects is None:
        projects = []
    ninjaide.load_session_files_projects(files, projects, current_file, [])
    # projects = data_qsettings.value('last_session/projects', [])
    # files = []
    # projects = []
    # if projects is None:
    #    projects = []
    # if files is None:
    #    files = []
    # current_file = ''
    # recent_files = []
    # ninjaide.load_session_files_projects(files, projects,
    #                                     current_file, recent_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)
Esempio n. 5
0
def start_ide(app, filenames, projects_path, extra_plugins, linenos):
    """Load all the settings necessary before loading the UI, and start IDE."""
    def _add_splash(message):
        splash.showMessage(message,
                           Qt.AlignTop | Qt.AlignRight | Qt.AlignAbsolute,
                           Qt.black)
        QCoreApplication.processEvents()

    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()

    qsettings = ide.IDE.ninja_settings()
    data_qsettings = ide.IDE.data_settings()
    # FIXME: handle this
    # Translator
    # 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
    _add_splash("Loading Syntax..")
    json_manager.load_syntax()

    load_fonts()

    # Loading Schemes
    _add_splash("Loading Schemes...")
    all_schemes = json_manager.load_editor_schemes()
    resources.COLOR_SCHEME = all_schemes["Ninja Dark"]
    # Load Services
    _add_splash("Loading IDE Services...")
    # Register tools dock service after load some settings
    # FIXME: Find a better way to do this
    import ninja_ide.gui.tools_dock.tools_dock  # noqa
    import ninja_ide.gui.tools_dock.console_widget  # noqa
    import ninja_ide.gui.tools_dock.run_widget  # noqa
    import ninja_ide.gui.tools_dock.find_in_files  # noqa

    import ninja_ide.gui.main_panel.main_container  # noqa
    import ninja_ide.gui.central_widget  # noqa
    import ninja_ide.gui.status_bar  # noqa
    import ninja_ide.gui.menus.menubar  # noqa

    # Explorer Container
    import ninja_ide.gui.explorer.explorer_container  # noqa
    from ninja_ide.gui.explorer.tabs import tree_projects_widget  # noqa
    from ninja_ide.gui.explorer.tabs import tree_symbols_widget  # noqa
    from ninja_ide.gui.explorer.tabs import bookmark_manager  # noqa
    # from ninja_ide.gui.explorer.tabs import web_inspector
    # Checkers
    from ninja_ide.gui.editor.checkers import errors_checker  # noqa
    from ninja_ide.gui.editor.checkers import pep8_checker  # noqa
    # from ninja_ide.gui.editor.checkers import not_import_checker  # noqa
    # from ninja_ide.gui.editor.checkers import migration_2to3
    # Preferences
    # from ninja_ide.gui.dialogs.preferences import preferences_general  # noqa
    # from ninja_ide.gui.dialogs.preferences import preferences_execution  # noqa
    # # from ninja_ide.gui.dialogs.preferences import preferences_shortcuts
    # from ninja_ide.gui.dialogs.preferences import preferences_interface  # noqa
    # from ninja_ide.gui.dialogs.preferences import preferences_editor_general  # noqa
    # from ninja_ide.gui.dialogs.preferences import preferences_editor_display  # noqa
    # from ninja_ide.gui.dialogs.preferences import preferences_editor_behavior  # noqa
    # from ninja_ide.gui.dialogs.preferences import preferences_editor_intellisense  # noqa
    from ninja_ide.intellisensei import intellisense_registry  # noqa
    from ninja_ide.intellisensei import python_intellisense  # noqa
    # from ninja_ide.gui.dialogs.preferences import preferences_editor_completion
    # from ninja_ide.gui.dialogs.preferences import preferences_plugins
    # from ninja_ide.gui.dialogs.preferences import preferences_theme
    from ninja_ide.gui.editor.checkers import errors_lists  # noqa
    from ninja_ide.gui.editor.checkers import errors_checker  # noqa
    from ninja_ide.gui.editor.checkers import pep8_checker  # noqa

    # Loading Shortcuts
    # resources.load_shortcuts()
    # Loading GUI
    _add_splash("Loading GUI...")
    ninjaide = ide.IDE(start_server)
    # Loading Session Files
    _add_splash("Loading Files and Projects...")
    # First check if we need to load last session files
    if qsettings.value('general/loadFiles', True, type=bool):
        files = data_qsettings.value('lastSession/openedFiles')
        projects = data_qsettings.value('lastSession/projects')
        current_file = data_qsettings.value('lastSession/currentFile')
        if files is None:
            files = []
        if projects is None:
            projects = []
        # Include files received from console args
        files_with_lineno = [(f[0], (f[1] - 1, 0))
                             for f in zip(filenames, linenos)]
        files_without_lineno = [(f, (0, 0)) for f in filenames[len(linenos):]]
        files += files_with_lineno + files_without_lineno
        # Include projects received from console args
        if projects_path:
            projects += projects_path
        ninjaide.load_session_files_projects(files, projects, current_file)

    # Showing GUI
    ninjaide.show()
    # OSX workaround for ninja window not in front
    try:
        ninjaide.raise_()
    except Exception:
        pass  # I really dont mind if this fails in any form
    # Load external plugins
    # if extra_plugins:
    #     ninjaide.load_external_plugins(extra_plugins)
    splash.finish(ninjaide)
Esempio n. 6
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 codec for strings (QString)
    # QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    qsettings = ide.IDE.ninja_settings()
    data_qsettings = ide.IDE.data_settings()
    # FIXME: handle this
    # Translator
    # 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)
    # Loading Schemes
    splash.showMessage("Loading Schemes...", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)
    all_schemes = json_manager.load_editor_schemes()
    scheme = qsettings.value("editor/scheme", "")
    # FIXME:
    resources.COLOR_SCHEME = all_schemes['Ninja Dark']
    # if scheme:
    #    color_scheme = all_schemes[scheme]
    #    resources.CUSTOM_SCHEME = color_scheme
    # 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)

    # Style
    app.setStyle(ninja_style.NinjaStyle())

    # Showing GUI
    ninjaide.show()
    # OSX workaround for ninja window not in front
    try:
        ninjaide.raise_()
    except Exception:
        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('general/loadFiles', True, type=bool):
        files = data_qsettings.value('lastSession/openedFiles')
        projects = data_qsettings.value('lastSession/projects')
        current_file = data_qsettings.value('lastSession/currentFile')
        # FIXME: recent files
        if files is None:
            files = []
        if projects is None:
            projects = []
        # Include files received from console args
        files_with_lineno = [(f[0], (f[1] - 1, 0))
                             for f in zip(filenames, linenos)]
        files_without_lineno = [(f, (0, 0)) for f in filenames[len(linenos):]]
        files += files_with_lineno + files_without_lineno
        # Include projects received from console args
        if projects_path:
            projects += projects_path
        ninjaide.load_session_files_projects(files, projects, current_file, [])
    # Load external plugins
    # if extra_plugins:
    #     ninjaide.load_external_plugins(extra_plugins)
    splash.finish(ninjaide)