Exemple #1
0
    def __init__(self, start_server=False):
        QMainWindow.__init__(self)
        self.setWindowTitle('NINJA-IDE {Ninja-IDE Is Not Just Another IDE}')
        self.setMinimumSize(750, 500)
        QToolTip.setFont(QFont(settings.FONT.family(), 10))
        # Load the size and the position of the main window
        self.load_window_geometry()
        # self.__project_to_open = 0
        # Editables
        self.__neditables = {}
        # Filesystem
        self.filesystem = nfilesystem.NVirtualFileSystem()
        # Interpreter service
        self.interpreter = interpreter_service.InterpreterService()
        # Sessions handler
        self._session_manager = session_manager.SessionsManager(self)
        IDE.register_service("session_manager", self._session_manager)
        self._session = None
        # Opacity
        self.opacity = settings.MAX_OPACITY
        # ToolBar
        # self.toolbar = QToolBar(self)
        # if settings.IS_MAC_OS:
        #     self.toolbar.setIconSize(QSize(36, 36))
        # else:
        #     self.toolbar.setIconSize(QSize(24, 24))
        # self.toolbar.setToolTip(translations.TR_IDE_TOOLBAR_TOOLTIP)
        # self.toolbar.setToolButtonStyle(Qt.ToolButtonIconOnly)
        # # Set toggleViewAction text and tooltip
        # self.toggleView = self.toolbar.toggleViewAction()
        # self.toggleView.setText(translations.TR_TOOLBAR_VISIBILITY)
        # self.toggleView.setToolTip(translations.TR_TOOLBAR_VISIBILITY)
        # self.addToolBar(settings.TOOLBAR_AREA, self.toolbar)
        # if settings.HIDE_TOOLBAR:
        #     self.toolbar.hide()
        # Notificator
        self.notification = notification.Notification(self)

        # Plugin Manager
        # CHECK ACTIVATE PLUGINS SETTING
        # services = {
        #    'editor': plugin_services.MainService(),
        #    'toolbar': plugin_services.ToolbarService(self.toolbar),
        #    'menuApp': plugin_services.MenuAppService(self.pluginsMenu),
        #    'menuApp': plugin_services.MenuAppService(None),
        #    'explorer': plugin_services.ExplorerService(),
        #    'misc': plugin_services.MiscContainerService(self.misc)}
        # serviceLocator = plugin_manager.ServiceLocator(services)
        # serviceLocator = plugin_manager.ServiceLocator(None)
        # self.plugin_manager = plugin_manager.PluginManager(resources.PLUGINS,
        #                                                   serviceLocator)
        # self.plugin_manager.discover()
        # load all plugins!
        # self.plugin_manager.load_all()

        # Tray Icon
        # self.trayIcon = updates.TrayIconUpdates(self)
        # self.trayIcon.closeTrayIcon.connect(self._close_tray_icon)
        # self.trayIcon.show()

        # TODO:
        # key = Qt.Key_1
        # for i in range(10):
        #    if settings.IS_MAC_OS:
        #        short = ui_tools.TabShortcuts(
        #            QKeySequence(Qt.CTRL + Qt.ALT + key), self, i)
        #    else:
        #        short = ui_tools.TabShortcuts(
        #            QKeySequence(Qt.ALT + key), self, i)
        #    key += 1
        #    short.activated.connect(self._change_tab_index)
        # short = ui_tools.TabShortcuts(
        #       QKeySequence(Qt.ALT + Qt.Key_0), self, 10)
        # short.activated.connect(self._change_tab_index)

        # Register menu categories
        IDE.register_bar_category(translations.TR_MENU_FILE, 100)
        IDE.register_bar_category(translations.TR_MENU_EDIT, 110)
        IDE.register_bar_category(translations.TR_MENU_VIEW, 120)
        IDE.register_bar_category(translations.TR_MENU_SOURCE, 130)
        IDE.register_bar_category(translations.TR_MENU_PROJECT, 140)
        IDE.register_bar_category(translations.TR_MENU_EXTENSIONS, 150)
        IDE.register_bar_category(translations.TR_MENU_ABOUT, 160)
        # Register General Menu Items
        ui_tools.install_shortcuts(self, actions.ACTIONS_GENERAL, self)
        self.register_service("ide", self)
        self.register_service("interpreter", self.interpreter)
        # self.register_service('toolbar', self.toolbar)
        self.register_service("filesystem", self.filesystem)
        self.toolbar = IDE.get_service("toolbar")
        # Register signals connections
        connections = ({
            "target": "main_container",
            "signal_name": "fileSaved",
            "slot": self.show_message
        }, {
            "target": "main_container",
            "signal_name": "currentEditorChanged",
            "slot": self.change_window_title
        }, {
            "target": "main_container",
            "signal_name": "openPreferences",
            "slot": self.show_preferences
        }, {
            "target": "main_container",
            "signal_name": "currentEditorChanged",
            "slot": self._change_item_in_project
        }, {
            "target": "main_container",
            "signal_name": "allFilesClosed",
            "slot": self.change_window_title
        }, {
            "target": "projects_explorer",
            "signal_name": "activeProjectChanged",
            "slot": self.change_window_title
        })
        self.register_signals('ide', connections)
        # connections = (
        #    {'target': 'main_container',
        #     'signal_name': 'openPreferences()',
        #     'slot': self.show_preferences},
        #    {'target': 'main_container',
        #     'signal_name': 'allTabsClosed()',
        #     'slot': self._last_tab_closed},
        #    {'target': 'explorer_container',
        #     'signal_name': 'changeWindowTitle(QString)',
        #     'slot': self.change_window_title},
        #    {'target': 'explorer_container',
        #     'signal_name': 'projectClosed(QString)',
        #     'slot': self.close_project},
        #    )
        # Central Widget MUST always exists
        self.central = IDE.get_service('central_container')
        self.setCentralWidget(self.central)
        # Install Services
        for service_name in self.__IDESERVICES:
            self.install_service(service_name)
        IDE.__created = True
        # Place Status Bar
        main_container = IDE.get_service('main_container')
        status_bar = IDE.get_service('status_bar')
        main_container.add_status_bar(status_bar)
        # Load Menu Bar
        menu_bar = IDE.get_service('menu_bar')
        if menu_bar:
            # These two are the same service, I think that's ok
            menu_bar.load_menu(self)
            menu_bar.load_toolbar(self)

        # Start server if needed
        self.s_listener = None
        if start_server:
            self.s_listener = QLocalServer()
            self.s_listener.listen("ninja_ide")
            self.s_listener.newConnection.connect(self._process_connection)

        # Load interpreters
        self.load_interpreters()

        IDE.__instance = self
Exemple #2
0
    def __init__(self, start_server=False):
        QMainWindow.__init__(self)
        self.setWindowTitle('NINJA-IDE {Ninja-IDE Is Not Just Another IDE}')
        self.setMinimumSize(750, 500)
        QToolTip.setFont(QFont(settings.FONT.family(), 10))
        # Load the size and the position of the main window
        self.load_window_geometry()
        # Editables
        self.__neditables = {}
        # Filesystem
        self.filesystem = nfilesystem.NVirtualFileSystem()
        # Interpreter service
        self.interpreter = interpreter_service.InterpreterService()
        # Sessions handler
        self._session_manager = session_manager.SessionsManager(self)
        IDE.register_service("session_manager", self._session_manager)
        self._session = None
        # Opacity
        self.opacity = settings.MAX_OPACITY
        # ToolBar
        # # Set toggleViewAction text and tooltip
        # Notificator
        self.notification = notification.Notification(self)

        # Plugin Manager
        # CHECK ACTIVATE PLUGINS SETTING
        #    'misc': plugin_services.MiscContainerService(self.misc)}
        # self.plugin_manager = plugin_manager.PluginManager(resources.PLUGINS,
        #                                                   serviceLocator)
        # load all plugins!

        # Tray Icon

        # TODO:
        #            QKeySequence(Qt.CTRL + Qt.ALT + key), self, i)
        #            QKeySequence(Qt.ALT + key), self, i)
        #       QKeySequence(Qt.ALT + Qt.Key_0), self, 10)

        # Register menu categories
        IDE.register_bar_category(translations.TR_MENU_FILE, 100)
        IDE.register_bar_category(translations.TR_MENU_EDIT, 110)
        IDE.register_bar_category(translations.TR_MENU_VIEW, 120)
        IDE.register_bar_category(translations.TR_MENU_SOURCE, 130)
        IDE.register_bar_category(translations.TR_MENU_PROJECT, 140)
        IDE.register_bar_category(translations.TR_MENU_EXTENSIONS, 150)
        IDE.register_bar_category(translations.TR_MENU_ABOUT, 160)
        # Register General Menu Items
        ui_tools.install_shortcuts(self, actions.ACTIONS_GENERAL, self)
        self.register_service("ide", self)
        self.register_service("interpreter", self.interpreter)
        self.register_service("filesystem", self.filesystem)
        self.toolbar = IDE.get_service("toolbar")
        # Register signals connections
        connections = (
            {
                "target": "main_container",
                "signal_name": "fileSaved",
                "slot": self.show_message
            },
            {
                "target": "main_container",
                "signal_name": "currentEditorChanged",
                "slot": self.change_window_title
            },
            {
                "target": "main_container",
                "signal_name": "openPreferences",
                "slot": self.show_preferences
            },
            {
                "target": "main_container",
                "signal_name": "currentEditorChanged",
                "slot": self._change_item_in_project
            },
            {
                "target": "main_container",
                "signal_name": "allFilesClosed",
                "slot": self.change_window_title
            },
            {
                "target": "projects_explorer",
                "signal_name": "activeProjectChanged",
                "slot": self.change_window_title
            }
        )
        self.register_signals('ide', connections)
        #    {'target': 'main_container',
        #    {'target': 'main_container',
        #    {'target': 'explorer_container',
        #    {'target': 'explorer_container',
        # Central Widget MUST always exists
        self.central = IDE.get_service('central_container')
        self.setCentralWidget(self.central)
        # Install Services
        for service_name in self.__IDESERVICES:
            self.install_service(service_name)
        IDE.__created = True
        # Place Status Bar
        main_container = IDE.get_service('main_container')
        status_bar = IDE.get_service('status_bar')
        main_container.add_status_bar(status_bar)
        # Load Menu Bar
        menu_bar = IDE.get_service('menu_bar')
        if menu_bar:
            # These two are the same service, I think that's ok
            menu_bar.load_menu(self)
            menu_bar.load_toolbar(self)

        # Start server if needed
        self.s_listener = None
        if start_server:
            self.s_listener = QLocalServer()
            self.s_listener.listen("ninja_ide")
            self.s_listener.newConnection.connect(self._process_connection)

        # Load interpreters
        self.load_interpreters()

        IDE.__instance = self