def __init__(self, parent=None):
        super(ProjectTreeColumn, self).__init__(parent,
                                                Qt.WindowStaysOnTopHint)
        vbox = QVBoxLayout(self)
        vbox.setSizeConstraint(QVBoxLayout.SetDefaultConstraint)
        vbox.setContentsMargins(0, 0, 0, 0)
        self._buttons = []

        self._combo_project = QComboBox()
        self._combo_project.setMinimumHeight(30)
        self._combo_project.setContextMenuPolicy(Qt.CustomContextMenu)
        vbox.addWidget(self._combo_project)

        self._projects_area = QStackedLayout()
        logger.debug("This is the projects area")
        logger.debug(self._projects_area)
        vbox.addLayout(self._projects_area)

        self.projects = []

        self._combo_project.currentIndexChanged[int].connect(self._change_current_project)
        self._combo_project.customContextMenuRequested['const QPoint &'].connect(self.context_menu_for_root)
        connections = (
            {'target': 'main_container',
             'signal_name': 'addToProject',#(QString)
             'slot': self._add_file_to_project},
            {'target': 'main_container',
             'signal_name': 'showFileInExplorer',#(QString)
             'slot': self._show_file_in_explorer},
        )
        IDE.register_service('projects_explorer', self)
        IDE.register_signals('projects_explorer', connections)
        ExplorerContainer.register_tab(translations.TR_TAB_PROJECTS, self)
Ejemplo n.º 2
0
    def __init__(self, parent=None):
        super(CentralWidget, self).__init__(parent)
        self.parent = parent
        main_container = QHBoxLayout(self)
        main_container.setContentsMargins(0, 0, 0, 0)
        main_container.setSpacing(0)
        # This variables are used to save the spliiter sizes
        self.lateral_panel = LateralPanel()

        self._add_functions = {
            "central": self._insert_widget_inside,
            "lateral": self._insert_widget_base
        }
        self._items = {}

        # Toolbar
        self._toolbar = ntoolbar.NToolBar(self)
        main_container.addWidget(self._toolbar)

        # Create Splitters to divide the UI 3 regions
        self._splitter_base = dynamic_splitter.DynamicSplitter(Qt.Horizontal)
        self._splitter_inside = dynamic_splitter.DynamicSplitter(Qt.Vertical)
        self._splitter_base.addWidget(self._splitter_inside)

        vbox = QVBoxLayout()
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)

        vbox.addWidget(self._splitter_base)
        tools_dock = IDE.get_service("tools_dock")
        vbox.addWidget(tools_dock.buttons_widget)
        main_container.addLayout(vbox)
        # main_container.addWidget(self._splitter_base)
        IDE.register_service("central_container", self)
Ejemplo n.º 3
0
 def find(self, backward=False, forward=False, rehighlight=True):
     """Collect flags and execute search in the editor"""
     main_container = IDE.get_service("main_container")
     editor = main_container.get_current_editor()
     if editor is None:
         return
     cs, wo, highlight = self.search_flags
     index, matches = 0, 0
     found = editor.find_match(self.search_text, cs, wo, backward, forward)
     if found:
         if rehighlight:
             editor.clear_found_results()
             index, matches = editor.highlight_found_results(
                 self.search_text, cs, wo)
     else:
         editor.clear_found_results()
     if matches == 0 and found:
         index, matches = editor._get_find_index_results(
             self.search_text, cs, wo)
         matches = len(matches)
         if index == 1:
             ide = IDE.get_service("ide")
             ide.show_message(translations.TR_SEARCH_FROM_TOP)
     self._line_search.counter.update_count(
         index, matches, len(self.search_text) > 0)
Ejemplo n.º 4
0
 def _add_file_to_project(self, path):
     """Add the file for 'path' in the project the user choose here."""
     if self._active_project:
         pathProject = [self._active_project.project]
         addToProject = add_to_project.AddToProject(pathProject, self)
         addToProject.exec_()
         if not addToProject.pathSelected:
             return
         main_container = IDE.get_service('main_container')
         if not main_container:
             return
         editorWidget = main_container.get_current_editor()
         if not editorWidget.file_path:
             name = QInputDialog.getText(None,
                                         translations.TR_ADD_FILE_TO_PROJECT,
                                         translations.TR_FILENAME + ": ")[0]
             if not name:
                 QMessageBox.information(
                     self,
                     translations.TR_INVALID_FILENAME,
                     translations.TR_INVALID_FILENAME_ENTER_A_FILENAME)
                 return
         else:
             name = file_manager.get_basename(editorWidget.file_path)
         new_path = file_manager.create_path(addToProject.pathSelected, name)
         ide_srv = IDE.get_service("ide")
         old_file = ide_srv.get_or_create_nfile(path)
         new_file = old_file.save(editorWidget.get_text(), new_path)
         #FIXME: Make this file replace the original in the open tab
     else:
         pass
Ejemplo n.º 5
0
    def __init__(self, parent=None):
        super().__init__(parent)
        # Register signals connections
        layout = QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        self.__buttons = []
        self.__action_number = 1
        self.__buttons_visibility = {}
        self.__current_widget = None
        self.__last_index = -1

        self._stack_widgets = QStackedWidget()
        layout.addWidget(self._stack_widgets)

        # Buttons Widget
        self.buttons_widget = QWidget()
        self.buttons_widget.setObjectName("tools_dock")
        self.buttons_widget.setFixedHeight(26)
        self.buttons_widget.setLayout(QHBoxLayout())
        self.buttons_widget.layout().setContentsMargins(2, 2, 5, 2)
        self.buttons_widget.layout().setSpacing(10)

        IDE.register_service("tools_dock", self)
        _ToolsDock.__created = True
Ejemplo n.º 6
0
 def _add_file_to_project(self, path):
     """Add the file for 'path' in the project the user choose here."""
     if self._active_project:
         pathProject = [self._active_project.project]
         addToProject = add_to_project.AddToProject(pathProject, self)
         addToProject.exec_()
         if not addToProject.pathSelected:
             return
         main_container = IDE.get_service('main_container')
         if not main_container:
             return
         editorWidget = main_container.get_current_editor()
         if not editorWidget.file_path:
             name = QInputDialog.getText(None,
                 self.tr("Add File To Project"), self.tr("File Name:"))[0]
             if not name:
                 QMessageBox.information(self, self.tr("Invalid Name"),
                     self.tr("The file name is empty, please enter a name"))
                 return
         else:
             name = file_manager.get_basename(editorWidget.file_path)
         new_path = file_manager.create_path(addToProject.pathSelected, name)
         ide_srv = IDE.get_service("ide")
         old_file, ide_srv.get_or_create_nfile(path)
         new_file = old_file.save(editorWidget.get_text(), path)
         #FIXME: Make this file replace the original in the open tab
     else:
         pass
Ejemplo n.º 7
0
    def __init__(self, parent=None):
        super(TreeSymbolsWidget, self).__init__(parent,
            Qt.WindowStaysOnTopHint)
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        self.tree = QTreeWidget()
        vbox.addWidget(self.tree)
        self.tree.header().setHidden(True)
        self.tree.setSelectionMode(self.tree.SingleSelection)
        self.tree.setAnimated(True)
        self.tree.header().setHorizontalScrollMode(
            QAbstractItemView.ScrollPerPixel)
        self.tree.header().setResizeMode(0, QHeaderView.ResizeToContents)
        self.tree.header().setStretchLastSection(False)
        self.actualSymbols = ('', {})
        self.docstrings = {}
        self.collapsedItems = {}

        self.connect(self, SIGNAL("itemClicked(QTreeWidgetItem *, int)"),
            self._go_to_definition)
        self.connect(self, SIGNAL("itemActivated(QTreeWidgetItem *, int)"),
            self._go_to_definition)
        self.tree.setContextMenuPolicy(Qt.CustomContextMenu)
        self.connect(self,
            SIGNAL("customContextMenuRequested(const QPoint &)"),
            self._menu_context_tree)
        self.connect(self, SIGNAL("itemCollapsed(QTreeWidgetItem *)"),
            self._item_collapsed)
        self.connect(self, SIGNAL("itemExpanded(QTreeWidgetItem *)"),
            self._item_expanded)

        IDE.register_service('symbols_explorer', self)
        ExplorerContainer.register_tab(translations.TR_TAB_SYMBOLS, self)
Ejemplo n.º 8
0
    def __init__(self, parent=None):
        super(CentralWidget, self).__init__(parent)
        self.parent = parent
        #This variables are used to save the splitter sizes before hide
        self._splitterBaseSizes = None
        self._splitterInsideSizes = None
        self.lateralPanel = LateralPanel()

        self._add_functions = {
            "central": self._insert_widget_region0,
            "lateral": self._insert_widget_region1,
        }
        self._items = {}

        hbox = QHBoxLayout(self)
        hbox.setContentsMargins(0, 0, 0, 0)
        hbox.setSpacing(0)
        #Create Splitters to divide the UI 3 regions
        self._splitterBase = dynamic_splitter.DynamicSplitter(Qt.Horizontal)
        self._splitterInside = dynamic_splitter.DynamicSplitter(Qt.Vertical)
        self._splitterBase.addWidget(self._splitterInside)

        #Add to Main Layout
        hbox.addWidget(self._splitterBase)
        connects = (
            {"target": "main_container",
            "signal_name": "cursorPositionChange(int, int)",
            "slot": self.update_column_number},
        )
        IDE.register_service('central_container', self)
        IDE.register_signals("central_container", connects)
Ejemplo n.º 9
0
    def install(self):
        ide = IDE.get_service('ide')
        ide.place_me_on("explorer_container", self, "lateral")
        #Searching the Preferences
        self.tree_projects = None
        self._treeSymbols = None
        if settings.SHOW_SYMBOLS_LIST:
            self.add_tab_symbols()
        self._inspector = None
        if settings.SHOW_WEB_INSPECTOR and settings.WEBINSPECTOR_SUPPORTED:
            self.add_tab_inspector()
        self._listErrors = None
        if settings.SHOW_ERRORS_LIST:
            self.add_tab_errors()
        self._listMigration = None
        if settings.SHOW_MIGRATION_LIST:
            self.add_tab_migration()

        if self.count() == 0:
            central_container = IDE.get_service("central_container")
            central_container.change_explorer_visibility(force_hide=True)
        ui_tools.install_shortcuts(self, actions.ACTIONS, ide)
        for each_tab in self.__tabs:
            if hasattr(each_tab, "install"):
                each_tab.install()
Ejemplo n.º 10
0
    def __init__(self, parent=None):
        super(CentralWidget, self).__init__(parent)
        self.parent = parent
        #This variables are used to save the splitter sizes before hide
        self.lateralPanel = LateralPanel()

        self._add_functions = {
            "central": self._insert_widget_inside,
            "lateral": self._insert_widget_base,
        }
        self._items = {}

        hbox = QHBoxLayout(self)
        hbox.setContentsMargins(0, 0, 0, 0)
        hbox.setSpacing(0)
        #Create Splitters to divide the UI 3 regions
        self._splitterBase = dynamic_splitter.DynamicSplitter(Qt.Horizontal)
        self._splitterBase.setOpaqueResize(True)
        self._splitterInside = dynamic_splitter.DynamicSplitter(Qt.Vertical)
        self._splitterInside.setOpaqueResize(True)
        self._splitterBase.addWidget(self._splitterInside)

        #Add to Main Layout
        hbox.addWidget(self._splitterBase)
        IDE.register_service('central_container', self)
    def _save(self):
        qsettings = IDE.ninja_settings()
        editor_settings = IDE.editor_settings()

        qsettings.beginGroup("editor")
        editor_settings.beginGroup("editor")
        qsettings.beginGroup("behavior")
        editor_settings.beginGroup("behavior")

        settings.REMOVE_TRAILING_SPACES = self._check_remove_spaces.isChecked()
        qsettings.setValue("removeTrailingSpaces",
                           settings.REMOVE_TRAILING_SPACES)
        settings.ADD_NEW_LINE_AT_EOF = self._check_add_new_line.isChecked()
        qsettings.setValue("addNewLineAtEnd", settings.ADD_NEW_LINE_AT_EOF)
        settings.HIDE_MOUSE_CURSOR = self._check_hide_cursor.isChecked()
        qsettings.setValue("hideMouseCursor", settings.HIDE_MOUSE_CURSOR)
        settings.SCROLL_WHEEL_ZOMMING = self._check_scroll_wheel.isChecked()
        qsettings.setValue("scrollWheelZomming", settings.SCROLL_WHEEL_ZOMMING)

        settings.USE_TABS = bool(self._combo_tab_policy.currentIndex())
        editor_settings.setValue("use_tabs", settings.USE_TABS)
        settings.INDENT = self._spin_indent_size.value()
        editor_settings.setValue("indentation_width", settings.INDENT)

        qsettings.endGroup()
        qsettings.endGroup()
        editor_settings.endGroup()
        editor_settings.endGroup()
Ejemplo n.º 12
0
 def _rename_file(self):
     path = self.model().filePath(self.currentIndex())
     name = file_manager.get_basename(path)
     new_name, ok = QInputDialog.getText(
         self, translations.TR_RENAME_FILE,
         translations.TR_ENTER_NEW_FILENAME,
         text=name)
     if ok and new_name.strip():
         filename = file_manager.create_path(
             file_manager.get_folder(path), new_name)
         if path == filename:
             return
         ninjaide = IDE.get_service("ide")
         print(ninjaide.filesystem.get_files())
         current_nfile = ninjaide.get_or_create_nfile(path)
         editable = ninjaide.get_editable(nfile=current_nfile)
         current_nfile.move(filename)
         if editable is not None:
             main_container = IDE.get_service("main_container")
             main_container.combo_area.bar.update_item_text(
                 editable, new_name)
             tree = ninjaide.filesystem.get_files()
             # FIXME: this is bad
             tree[filename] = tree.pop(path)
         print(ninjaide.filesystem.get_files())
Ejemplo n.º 13
0
    def __init__(self, parent=None):
        super(ExplorerContainer, self).__init__(Qt.Vertical, parent)
        self.create_tab_widget()

        IDE.register_service('explorer_container', self)

        connections = (
            {'target': 'central_container',
             'signal_name': "splitterBaseRotated()",
             'slot': self.rotate_tab_position},
            {'target': 'central_container',
             'signal_name': 'splitterBaseRotated()',
             'slot': self.rotate_tab_position},
        )

        self._point = None
        self._widget_index = 0
        self.menu = QMenu()
        self.actionSplit = self.menu.addAction(translations.TR_SPLIT_TAB)
        self.connect(
            self.actionSplit, SIGNAL("triggered()"), self._split_widget)
        self.actionUndock = self.menu.addAction(translations.TR_UNDOCK)
        self.connect(
            self.actionUndock, SIGNAL("triggered()"), self._undock_widget)
        self.actionCloseSplit = self.menu.addAction(translations.TR_CLOSE_SPLIT)
        self.connect(
            self.actionCloseSplit, SIGNAL("triggered()"), self._close_split)
        self.menuMoveToSplit = self.menu.addMenu(translations.TR_MOVE_TO_SPLIT)

        IDE.register_signals('explorer_container', connections)
        self.__created = True
Ejemplo n.º 14
0
    def __init__(self):
        super().__init__()
        self.current_status = _STATUSBAR_STATE_SEARCH
        vbox = QVBoxLayout(self)
        title = QLabel(translations.TR_SEARCH_TITLE)
        font = title.font()
        font.setPointSize(9)
        title.setFont(font)
        vbox.addWidget(title)
        spacing = 3
        if settings.IS_MAC_OS:
            spacing = 0
        vbox.setSpacing(spacing)
        # Search Layout
        self._search_widget = SearchWidget()
        vbox.addWidget(self._search_widget)
        # Replace Layout
        self._replace_widget = ReplaceWidget()
        self._replace_widget.hide()
        vbox.addWidget(self._replace_widget)
        # Not configurable shortcuts
        short_esc_status = QShortcut(QKeySequence(Qt.Key_Escape), self)
        short_esc_status.activated.connect(self.hide_status_bar)

        IDE.register_service("status_bar", self)
Ejemplo n.º 15
0
 def __init__(self, parent=None):
     super(_ToolsDock, self).__init__(parent)
     #Register signals connections
     connections = (
         {'target': 'main_container',
         'signal_name': "findOcurrences(QString)",
         'slot': self.show_find_occurrences},
         {'target': 'main_container',
         'signal_name': "updateFileMetadata()",
         'slot': self.show_find_occurrences},
         {'target': 'main_container',
         'signal_name': "findOcurrences(QString)",
         'slot': self.show_find_occurrences},
         {'target': 'main_container',
         'signal_name': "runFile(QString)",
         'slot': self.execute_file},
         {'target': 'explorer_container',
         'signal_name': "removeProjectFromConsole(QString)",
         'slot': self.remove_project_from_console},
         {'target': 'explorer_container',
         'signal_name': "addProjectToConsole(QString)",
         'slot': self.add_project_to_console},
         )
     IDE.register_signals('tools_dock', connections)
     IDE.register_service("tools_dock", self)
Ejemplo n.º 16
0
    def __init__(self):
        QTreeWidget.__init__(self)
        self.header().setHidden(True)
        self.setSelectionMode(self.SingleSelection)
        self.setAnimated(True)
        self.header().setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)
        self.header().setResizeMode(0, QHeaderView.ResizeToContents)
        self.header().setStretchLastSection(False)
        self.actualSymbols = ('', {})
        self.docstrings = {}
        self.collapsedItems = {}

        self.connect(self, SIGNAL("itemClicked(QTreeWidgetItem *, int)"),
            self._go_to_definition)
        self.connect(self, SIGNAL("itemActivated(QTreeWidgetItem *, int)"),
            self._go_to_definition)
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.connect(self,
            SIGNAL("customContextMenuRequested(const QPoint &)"),
            self._menu_context_tree)
        self.connect(self, SIGNAL("itemCollapsed(QTreeWidgetItem *)"),
            self._item_collapsed)
        self.connect(self, SIGNAL("itemExpanded(QTreeWidgetItem *)"),
            self._item_expanded)

        IDE.register_service('symbols_explorer', self)
        ExplorerContainer.register_tab(translations.TR_TAB_SYMBOLS, self)
Ejemplo n.º 17
0
    def __init__(self, parent=None):
        super(MigrationWidget, self).__init__(parent, Qt.WindowStaysOnTopHint)
        self._migration = {}
        vbox = QVBoxLayout(self)
        lbl_title = QLabel(self.tr("Current code:"))
        self.current_list = QListWidget()
        lbl_suggestion = QLabel(self.tr("Suggested changes:"))
        self.suggestion = QPlainTextEdit()
        self.suggestion.setReadOnly(True)

        self.btn_apply = QPushButton(self.tr("Apply change!"))
        hbox = QHBoxLayout()
        hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding))
        hbox.addWidget(self.btn_apply)

        vbox.addWidget(lbl_title)
        vbox.addWidget(self.current_list)
        vbox.addWidget(lbl_suggestion)
        vbox.addWidget(self.suggestion)
        vbox.addLayout(hbox)

        self.connect(self.current_list,
            SIGNAL("itemClicked(QListWidgetItem*)"), self.load_suggestion)
        self.connect(self.btn_apply, SIGNAL("clicked()"), self.apply_changes)

        IDE.register_service('tab_migration', self)
        ExplorerContainer.register_tab(translations.TR_TAB_MIGRATION, self)
Ejemplo n.º 18
0
 def __init__(self, parent=None):
     super(MigrationWidget, self).__init__(parent, Qt.WindowStaysOnTopHint)
     self._migration, vbox, hbox = {}, QVBoxLayout(self), QHBoxLayout()
     lbl_title = QLabel(translations.TR_CURRENT_CODE)
     lbl_suggestion = QLabel(translations.TR_SUGGESTED_CHANGES)
     self.current_list, self.suggestion = QListWidget(), QPlainTextEdit()
     self.suggestion.setReadOnly(True)
     self.btn_apply = QPushButton(translations.TR_APPLY_CHANGES + " !")
     self.suggestion.setToolTip(translations.TR_SAVE_BEFORE_APPLY + " !")
     self.btn_apply.setToolTip(translations.TR_SAVE_BEFORE_APPLY + " !")
     # pack up all widgets
     hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding))
     hbox.addWidget(self.btn_apply)
     vbox.addWidget(lbl_title)
     vbox.addWidget(self.current_list)
     vbox.addWidget(lbl_suggestion)
     vbox.addWidget(self.suggestion)
     vbox.addLayout(hbox)
     # connections
     self.connect(
         self.current_list, SIGNAL("itemClicked(QListWidgetItem*)"),
         self.load_suggestion)
     self.connect(self.btn_apply, SIGNAL("clicked()"), self.apply_changes)
     # registers
     IDE.register_service('tab_migration', self)
     ExplorerContainer.register_tab(translations.TR_TAB_MIGRATION, self)
Ejemplo n.º 19
0
    def __init__(self, parent):
        super(FindInFilesWidget, self).__init__(parent)
        self._main_container = IDE.get_service('main_container')
        self._explorer_container = IDE.get_service('explorer')
        self._result_widget = FindInFilesResult()
        self._open_find_button = QPushButton(translations.TR_FIND + "!")
        self._stop_button = QPushButton(translations.TR_STOP + "!")
        self._clear_button = QPushButton(translations.TR_CLEAR + "!")
        self._replace_button = QPushButton(translations.TR_REPLACE)
        self._find_widget = FindInFilesDialog(self._result_widget, self)
        self._error_label = QLabel(translations.TR_NO_RESULTS)
        self._error_label.setVisible(False)
        #Replace Area
        self.replace_widget = QWidget()
        hbox_replace = QHBoxLayout(self.replace_widget)
        hbox_replace.setContentsMargins(0, 0, 0, 0)
        self.lbl_replace = QLabel(translations.TR_REPLACE_RESULTS_WITH)
        self.lbl_replace.setTextFormat(Qt.PlainText)
        self.replace_edit = QLineEdit()
        hbox_replace.addWidget(self.lbl_replace)
        hbox_replace.addWidget(self.replace_edit)
        self.replace_widget.setVisible(False)
        #Main Layout
        main_hbox = QHBoxLayout(self)
        #Result Layout
        tree_vbox = QVBoxLayout()
        tree_vbox.addWidget(self._result_widget)
        tree_vbox.addWidget(self._error_label)
        tree_vbox.addWidget(self.replace_widget)

        main_hbox.addLayout(tree_vbox)
        #Buttons Layout
        vbox = QVBoxLayout()
        vbox.addWidget(self._open_find_button)
        vbox.addWidget(self._stop_button)
        vbox.addWidget(self._clear_button)
        vbox.addSpacerItem(
            QSpacerItem(0, 50, QSizePolicy.Fixed, QSizePolicy.Expanding))
        vbox.addWidget(self._replace_button)
        main_hbox.addLayout(vbox)

        self._open_find_button.setFocus()
        #signals
        self.connect(self._open_find_button, SIGNAL("clicked()"), self.open)
        self.connect(self._stop_button, SIGNAL("clicked()"), self._find_stop)
        self.connect(self._clear_button, SIGNAL("clicked()"),
                     self._clear_results)
        self.connect(self._result_widget,
                     SIGNAL("itemActivated(QTreeWidgetItem *, int)"),
                     self._go_to)
        self.connect(self._result_widget,
                     SIGNAL("itemClicked(QTreeWidgetItem *, int)"),
                     self._go_to)
        self.connect(self._find_widget, SIGNAL("finished()"),
                     self._find_finished)
        self.connect(self._find_widget, SIGNAL("findStarted()"),
                     self._find_started)
        self.connect(self._replace_button, SIGNAL("clicked()"),
                     self._replace_results)
Ejemplo n.º 20
0
    def __init__(self):
        QObject.__init__(self)
        self.__providers = {}
        self.__thread = None
        # self._main_container = IDE.get_service("main_container")

        # Register service
        IDE.register_service("intellisense", self)
Ejemplo n.º 21
0
    def __init__(self, parent=None):
        super(_MainContainer, self).__init__(parent)
        self._parent = parent
        self.stack = QStackedLayout(self)
        self.stack.setStackingMode(QStackedLayout.StackAll)

        self.splitter = dynamic_splitter.DynamicSplitter()
        self.setAcceptDrops(True)
        self.tabs_handler = tabs_handler.TabsHandler(self)

        #documentation browser
        self.docPage = None
        #Code Navigation
        self._locator = locator.GoToDefinition()
        self.__codeBack = []
        self.__codeForward = []
        self.__bookmarksFile = ''
        self.__bookmarksPos = -1
        self.__breakpointsFile = ''
        self.__breakpointsPos = -1
        self.__operations = {
            0: self._navigate_code_jumps,
            1: self._navigate_bookmarks,
            2: self._navigate_breakpoints}

        self.connect(self, SIGNAL("locateFunction(QString, QString, bool)"),
            self.locate_function)

        IDE.register_service('main_container', self)

        #Register signals connections
        connections = (
            {'target': 'menu_file',
            'signal_name': 'openFile(QString)',
            'slot': self.open_file},
            {'target': 'explorer_container',
            'signal_name': 'goToDefinition(int)',
            'slot': self.editor_go_to_line},
            {'target': 'explorer_container',
            'signal_name': 'pep8Activated(bool)',
            'slot': self.reset_pep8_warnings},
            {'target': 'explorer_container',
            'signal_name': 'lintActivated(bool)',
            'slot': self.reset_lint_warnings},
            )

        IDE.register_signals('main_container', connections)

        self.selector = main_selector.MainSelector(self)
        self.add_widget(self.selector)

        if settings.SHOW_START_PAGE:
            self.show_start_page()

        self.connect(self.selector, SIGNAL("changeCurrent(int)"),
            self._change_current_stack)
        self.connect(self.selector, SIGNAL("ready()"),
            self._selector_ready)
Ejemplo n.º 22
0
    def __init__(self):
        super(_StatusBar, self).__init__()

        self._widgetStatus = QWidget()
        vbox = QVBoxLayout(self._widgetStatus)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        #Search Layout
        self._searchWidget = SearchWidget(self)
        vbox.addWidget(self._searchWidget)
        #Replace Layout
        self._replaceWidget = ReplaceWidget(self)
        vbox.addWidget(self._replaceWidget)
        self._replaceWidget.setVisible(False)
        #Code Locator
        self._codeLocator = locator.CodeLocatorWidget(self)
        vbox.addWidget(self._codeLocator)
        self._codeLocator.setVisible(False)
        #File system completer
        self._fileSystemOpener = FileSystemOpener()
        vbox.addWidget(self._fileSystemOpener)
        self._fileSystemOpener.setVisible(False)

        self.addWidget(self._widgetStatus)
        # Not Configurable Shortcuts
        shortEscStatus = QShortcut(QKeySequence(Qt.Key_Escape), self)

        self.connect(self, SIGNAL("messageChanged(QString)"), self.message_end)
        self.connect(self._replaceWidget._btnCloseReplace, SIGNAL("clicked()"),
            lambda: self._replaceWidget.setVisible(False))
        self.connect(self._replaceWidget._btnReplace, SIGNAL("clicked()"),
            self.replace)
        self.connect(self._replaceWidget._btnReplaceAll, SIGNAL("clicked()"),
            self.replace_all)
        self.connect(self._replaceWidget._btnReplaceSelection,
            SIGNAL("clicked()"), self.replace_selected)
        self.connect(self._fileSystemOpener.btnClose, SIGNAL("clicked()"),
            self.hide_status)
        self.connect(self._fileSystemOpener, SIGNAL("requestHide()"),
            self.hide_status)
        self.connect(shortEscStatus, SIGNAL("activated()"), self.hide_status)

        IDE.register_service('status_bar', self)

        #Register signals connections
        connections = (
            {'target': 'main_container',
            'signal_name': 'currentEditorChanged(QString)',
            'slot': self.handle_tab_changed},
            {'target': 'main_container',
            'signal_name': 'updateLocator(QString)',
            'slot': self.explore_file_code},
            {'target': 'explorer_container',
            'signal_name': 'updateLocator()',
            'slot': self.explore_code},
            )

        IDE.register_signals('status_bar', connections)
Ejemplo n.º 23
0
 def __init__(self, parent=None):
     super().__init__(parent)
     IDE.register_service("errors_tree", self)
     box = QVBoxLayout(self)
     box.setContentsMargins(0, 0, 0, 0)
     self._tree = QTreeWidget()
     self._tree.header().setHidden(True)
     self._tree.setAnimated(True)
     box.addWidget(self._tree)
Ejemplo n.º 24
0
    def _replace(self):
        """Replace one occurrence of the word"""

        status_search = IDE.get_service("status_search")
        cs, wo, highlight = status_search.search_flags
        main_container = IDE.get_service("main_container")
        editor_widget = main_container.get_current_editor()
        editor_widget.replace_match(
            status_search.search_text, self._line_replace.text(), cs, wo)
Ejemplo n.º 25
0
    def __init__(self):
        super(_MenuBar, self).__init__()
        self._roots = {}
        self._children = {}
        self._submenu = {}
        self._menu_refs = {}
        self._toolbar_index = {}

        IDE.register_service('menu_bar', self)
Ejemplo n.º 26
0
    def __init__(self, parent=None):
        super(ProjectTreeColumn, self).__init__(parent)
        vbox = QVBoxLayout(self)
        vbox.setSizeConstraint(QVBoxLayout.SetDefaultConstraint)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        self._buttons = []
        frame = QFrame()
        frame.setObjectName("actionbar")
        box = QVBoxLayout(frame)
        box.setContentsMargins(1, 1, 1, 1)
        box.setSpacing(0)

        self._combo_project = QComboBox()
        self._combo_project.setSizePolicy(
            QSizePolicy.Expanding, QSizePolicy.Fixed)
        self._combo_project.setSizeAdjustPolicy(
            QComboBox.AdjustToMinimumContentsLengthWithIcon)
        self._combo_project.setObjectName("combo_projects")
        box.addWidget(self._combo_project)
        vbox.addWidget(frame)
        self._combo_project.setContextMenuPolicy(Qt.CustomContextMenu)
        self._projects_area = QStackedLayout()
        logger.debug("This is the projects area")
        vbox.addLayout(self._projects_area)

        # Empty widget
        self._empty_proj = QLabel(translations.TR_NO_PROJECTS)
        self._empty_proj.setAlignment(Qt.AlignCenter)
        self._empty_proj.setAutoFillBackground(True)
        self._empty_proj.setBackgroundRole(QPalette.Base)
        self._projects_area.addWidget(self._empty_proj)
        self._projects_area.setCurrentWidget(self._empty_proj)

        self.projects = []

        self._combo_project.activated.connect(
            self._change_current_project)
        self._combo_project.customContextMenuRequested[
            'const QPoint&'].connect(self.context_menu_for_root)

        connections = (
            {
                "target": "main_container",
                "signal_name": "addToProject",
                "slot": self._add_file_to_project
            },
            {
                "target": "main_container",
                "signal_name": "showFileInExplorer",
                "slot": self._show_file_in_explorer
            },
        )
        IDE.register_service('projects_explorer', self)
        IDE.register_signals('projects_explorer', connections)
        ExplorerContainer.register_tab(translations.TR_TAB_PROJECTS, self)
Ejemplo n.º 27
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setAcceptDrops(True)
        self._vbox = QVBoxLayout(self)
        self._vbox.setContentsMargins(0, 0, 0, 0)
        self._vbox.setSpacing(0)
        self.stack = QStackedLayout()
        self.stack.setStackingMode(QStackedLayout.StackAll)
        self._vbox.addLayout(self.stack)
        self.splitter = dynamic_splitter.DynamicSplitter()
        self._files_handler = files_handler.FilesHandler(self)

        # Code Navigation
        self.__code_back = []
        self.__code_forward = []
        self.__operations = {
            0: self._navigate_code_jumps,
            1: self._navigate_bookmarks
        }
        # Recent files list
        self.__last_opened_files = []
        # QML UI
        self._add_file_folder = add_file_folder.AddFileFolderWidget(self)

        if settings.SHOW_START_PAGE:
            self.show_start_page()

        IDE.register_service("main_container", self)
        # Register signals connections
        connections = (
            # {
            #     "target": "main_container",
            #     "signal_name": "updateLocator",
            #     "slot": self._explore_code
            # },
            {
                "target": "filesystem",
                "signal_name": "projectOpened",
                "slot": self._explore_code
            },
            # {
            #     "target": "projects_explore",
            #     "signal_name": "updateLocator",
            #     "slot": self._explore_code
            # }
            {
                "target": "filesystem",
                "signal_name": "projectClosed",
                "slot": self._explore_code
            }
        )

        IDE.register_signals("main_container", connections)

        fhandler_short = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Tab), self)
        fhandler_short.activated.connect(self.show_files_handler)
Ejemplo n.º 28
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        vbox = QVBoxLayout(self)
        self._webInspector = QWebInspector(self)
        vbox.addWidget(self._webInspector)
        self.btnDock = QPushButton(translations.TR_UNDOCK)
        vbox.addWidget(self.btnDock)

        ExplorerContainer.register_tab(translations.TR_TAB_WEB_INSPECTOR, self)
        IDE.register_service('web_inspector', self)
Ejemplo n.º 29
0
    def _replace_all(self, selected=False):
        """Replace all the occurrences of the word"""

        status_search = IDE.get_service("status_search")
        cs, wo, highlight = status_search.search_flags
        main_container = IDE.get_service("main_container")
        editor_widget = main_container.get_current_editor()
        editor_widget.replace_all(
            status_search.search_text, self._line_replace.text(), cs, wo)
        editor_widget.extra_selections.remove("find")
Ejemplo n.º 30
0
 def replace_all(self, selected=False):
     """Replace all the occurrences of the word."""
     status_search = IDE.get_service("status_search")
     main_container = IDE.get_service("main_container")
     editor = None
     if main_container:
         editor = main_container.get_current_editor()
     if editor:
         editor.replace_match(status_search.search_text,
                              self._lineReplace.text(), True,
                              selected)
Ejemplo n.º 31
0
    def show_search(self):
        """Show the status bar with the search widget."""
        self.current_status = _STATUSBAR_STATE_SEARCH
        self._searchWidget.setVisible(True)
        self.show()
        main_container = IDE.get_service("main_container")
        editor = None
        if main_container:
            editor = main_container.get_current_editor()

        if editor and editor.hasSelectedText():
            text = editor.selectedText()
            self._searchWidget._line.setText(text)
            self._searchWidget.find()
        self._searchWidget._line.setFocus()
        self._searchWidget._line.selectAll()
Ejemplo n.º 32
0
 def execute_file(self):
     """Execute the current file."""
     main_container = IDE.get_service('main_container')
     if not main_container:
         return
     editorWidget = main_container.get_current_editor()
     if editorWidget:
         #emit a signal for plugin!
         self.emit(SIGNAL("fileExecuted(QString)"), editorWidget.file_path)
         main_container.save_file(editorWidget)
         ext = file_manager.get_file_extension(editorWidget.file_path)
         #TODO: Remove the IF statment with polymorphism using Handler
         if ext == 'py':
             self.run_application(editorWidget.ID)
         elif ext == 'html':
             self.render_web_page(editorWidget.ID)
Ejemplo n.º 33
0
 def execute_file(self):
     """Execute the current file"""
     main_container = IDE.get_service("main_container")
     editor_widget = main_container.get_current_editor()
     if editor_widget is not None and (editor_widget.is_modified or
                                       editor_widget.file_path):
         main_container.save_file(editor_widget)
         file_path = editor_widget.file_path
         if file_path is None:
             return
         # Emit signal for plugin!
         self.fileExecuted.emit(editor_widget.file_path)
         extension = file_manager.get_file_extension(file_path)
         # TODO: Remove the IF statment and use Handlers
         if extension == "py":
             self.start_process(filename=file_path)
Ejemplo n.º 34
0
 def hide_status(self):
     """Hide the Status Bar and its widgets."""
     self.hide()
     self._searchWidget._checkSensitive.setCheckState(Qt.Unchecked)
     self._searchWidget._checkWholeWord.setCheckState(Qt.Unchecked)
     self._searchWidget.setVisible(False)
     self._replaceWidget.setVisible(False)
     self._fileSystemOpener.setVisible(False)
     main_container = IDE.get_service("main_container")
     widget = None
     if main_container:
         widget = main_container.get_current_widget()
     if widget:
         widget.setFocus()
         if widget == main_container.get_current_editor():
             widget.highlight_selected_word(reset=True)
Ejemplo n.º 35
0
    def _handle_tab_changed(self, new_tab):
        """
        Re-run search if tab changed, we use the find of search widget because
        we want the widget to be updated.
        """
        main_container = IDE.get_service("main_container")
        if main_container:
            editor = main_container.get_current_editor()
        else:
            return

        if editor:
            self.disconnect(editor, SIGNAL("textChanged()"),
                            self._notify_editor_changed)
            self.connect(editor, SIGNAL("textChanged()"),
                         self._notify_editor_changed)
    def install(self):
        ninjaide = IDE.get_service("ide")
        ninjaide.place_me_on("main_container", self, "central", top=True)

        self.combo_area = combo_editor.ComboEditor(original=True)
        self.combo_area.allFilesClosed.connect(self._files_closed)
        self.combo_area.allFilesClosed.connect(
            lambda: self.allFilesClosed.emit())
        self.splitter.add_widget(self.combo_area)
        self.add_widget(self.splitter)
        # self.current_widget = self.combo_area
        # Code Locator
        self._code_locator = locator_widget.LocatorWidget(ninjaide)

        ui_tools.install_shortcuts(self, actions.ACTIONS, ninjaide)
        self.fileSaved.connect(self._show_message_about_saved)
Ejemplo n.º 37
0
    def execute_search(self, backward=False, find_next=False):
        """Collect flags and execute search in the editor"""

        cs = self._check_sensitive.isChecked()
        wo = self._check_sensitive.isChecked()

        main_container = IDE.get_service("main_container")
        editor_widget = main_container.get_current_editor()
        if editor_widget is not None:
            index, matches = editor_widget.find_matches(self.search_text,
                                                        case_sensitive=cs,
                                                        whole_word=wo,
                                                        backward=backward,
                                                        find_next=find_next)
            self._line_search.counter.update_count(index, len(matches),
                                                   len(self.search_text) > 0)
Ejemplo n.º 38
0
    def open_project_folder(self):
        if settings.WORKSPACE:
            directory = settings.WORKSPACE
        else:
            directory = os.path.expanduser("~")

        folderName = QFileDialog.getExistingDirectory(
            self, self.tr("Open Project Directory"), directory)
        logger.debug("Choosing Foldername")
        if folderName:
            logger.debug("Opening %s" % folderName)
            ninjaide = IDE.get_service("ide")
            project = NProject(folderName)
            qfsm = ninjaide.filesystem.open_project(project)
            if qfsm:
                self.add_project(project)
 def execute_file(self):
     """Execute the current file."""
     main_container = IDE.get_service('main_container')
     if not main_container:
         return
     editorWidget = main_container.get_current_editor()
     if editorWidget:
         #emit a signal for plugin!
         self.fileExecuted.emit(editorWidget.file_path)
         main_container.save_file(editorWidget)
         ext = file_manager.get_file_extension(editorWidget.file_path)
         #TODO: Remove the IF statment and use Handlers
         if ext == 'py':
             self._run_application(editorWidget.file_path)
         elif ext == 'html':
             self.render_web_page(editorWidget.file_path)
Ejemplo n.º 40
0
    def show_search(self):
        """Show the status bar with search widget"""

        main_container = IDE.get_service("main_container")
        editor = main_container.get_current_editor()
        if editor is not None:
            self.current_status = _STATUSBAR_STATE_SEARCH
            self._search_widget.setVisible(True)
            self.show()
            text = editor.selected_text()
            if not text:
                text = editor.word_under_cursor().selectedText()
            self._search_widget._line_search.setText(text)
            self._search_widget.find()
        self._search_widget._line_search.setFocus()
        self._search_widget._line_search.selectAll()
    def _save(self):

        qsettings = IDE.editor_settings()

        qsettings.beginGroup("editor")
        qsettings.beginGroup("intellisense")

        settings.AUTOCOMPLETE_BRACKETS = self._check_braces.isChecked()
        qsettings.setValue("autocomplete_brackets",
                           settings.AUTOCOMPLETE_BRACKETS)
        settings.AUTOCOMPLETE_QUOTES = self._check_quotes.isChecked()
        qsettings.setValue("autocomplete_quotes",
                           settings.AUTOCOMPLETE_QUOTES)

        qsettings.endGroup()
        qsettings.endGroup()
Ejemplo n.º 42
0
 def _move_file(self):
     path = self.model().filePath(self.currentIndex())
     global projectsColumn
     pathProjects = [p.project for p in projectsColumn.projects]
     addToProject = add_to_project.AddToProject(pathProjects, self)
     addToProject.setWindowTitle(translations.TR_COPY_FILE_TO)
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     name = file_manager.get_basename(path)
     new_path = file_manager.create_path(addToProject.pathSelected, name)
     ide_srv = IDE.get_service("ide")
     current_nfile = ide_srv.get_or_create_nfile(path)
     current_nfile.close()
     # FIXME: Catch willOverWrite and willMove signals
     current_nfile.move(new_path)
Ejemplo n.º 43
0
    def open_file(self,
                  filename='',
                  cursorPosition=-1,
                  tabIndex=None,
                  positionIsLineNumber=False,
                  ignore_checkers=False):
        logger.debug("will try to open %s" % filename)
        if not filename:
            logger.debug("has nofilename")
            if settings.WORKSPACE:
                directory = settings.WORKSPACE
            else:
                directory = os.path.expanduser("~")
                editorWidget = self.get_current_editor()
                ninjaide = IDE.get_service('ide')
                if ninjaide:
                    current_project = ninjaide.get_current_project()
                    if current_project is not None:
                        directory = current_project
                    elif editorWidget is not None and editorWidget.file_path:
                        directory = file_manager.get_folder(
                            editorWidget.file_path)
            extensions = ';;'.join([
                '(*%s)' % e
                for e in settings.SUPPORTED_EXTENSIONS + ['.*', '']
            ])
            fileNames = list(
                QFileDialog.getOpenFileNames(self, self.tr("Open File"),
                                             directory, extensions))
        else:
            logger.debug("has filename")
            fileNames = [filename]
        if not fileNames:
            return

        for filename in fileNames:
            if file_manager.get_file_extension(filename) in ('jpg', 'png'):
                logger.debug("will open as image")
                self.open_image(filename)
            elif file_manager.get_file_extension(filename).endswith('ui'):
                logger.debug("will load in ui editor")
                self.w = uic.loadUi(filename)
                self.w.show()
            else:
                logger.debug("will try to open")
                self.__open_file(filename, cursorPosition, tabIndex,
                                 positionIsLineNumber, ignore_checkers)
Ejemplo n.º 44
0
 def _open_project_folder(self, folderName):
     ninjaide = IDE.get_service("ide")
     project = NProject(folderName)
     qfsm = ninjaide.filesystem.open_project(project)
     if qfsm:
         self.add_project(project)
         self.save_recent_projects(folderName)
         # FIXME: show editor area?
         # main_container = IDE.get_service('main_container')
         # if main_container:
         #    main_container.show_editor_area()
         if len(self.projects) > 1:
             title = "%s (%s)" % (translations.TR_TAB_PROJECTS,
                                  len(self.projects))
         else:
             title = translations.TR_TAB_PROJECTS
         self.changeTitle.emit(self, title)
Ejemplo n.º 45
0
    def _rename_file(self):
        path = self.model().filePath(self.currentIndex())
        name = file_manager.get_basename(path)
        result = QInputDialog.getText(self,
                                      translations.TR_RENAME_FILE,
                                      translations.TR_ENTER_NEW_FILENAME,
                                      text=name)
        fileName = result[0]

        if result[1] and fileName.strip() != '':
            fileName = os.path.join(file_manager.get_folder(path), fileName)
            if path == fileName:
                return
            ide_srv = IDE.get_service("ide")
            current_nfile = ide_srv.get_or_create_nfile(path)
            # FIXME: Catch willOverWrite and willMove signals
            current_nfile.move(fileName)
Ejemplo n.º 46
0
    def install_widget(self):
        container = QHBoxLayout(self)
        container.setContentsMargins(3, 0, 3, 0)
        self._actions = FindInFilesActions(self)
        container.addWidget(self._actions)
        self._tree_results = SearchResultTreeView(self)
        container.addWidget(self._tree_results)
        self._main_container = IDE.get_service("main_container")
        # Search worker
        self._search_worker = FindInFilesWorker()
        self._search_thread = QThread()
        self._search_worker.moveToThread(self._search_thread)
        self._search_worker.finished.connect(self._on_worker_finished)
        # self._search_thread.finished.connect(self._search_worker.deleteLater)

        self._actions.searchRequested.connect(self._on_search_requested)
        self._tree_results.activated.connect(self._go_to)
Ejemplo n.º 47
0
    def __init__(self, neditable):
        QObject.__init__(self)
        self._neditable = neditable
        self.__dirty = False

        self.__filename = None

        self.__timer = QTimer(self)
        self.__timer.setSingleShot(True)
        self.__timer.timeout.connect(self._autosave)

        ninjaide = IDE.get_service("ide")
        # Connections
        ninjaide.goingDown.connect(self._on_ide_going_down)
        self._neditable.fileLoaded.connect(self._on_file_loaded)
        self._neditable.fileSaved.connect(self._on_file_saved)
        self._neditable.fileClosing.connect(self._on_file_closing)
Ejemplo n.º 48
0
    def __init__(self, original=False):
        super(ComboEditor, self).__init__(None, Qt.WindowStaysOnTopHint)
        self.__original = original
        self.__undocked = []
        self._symbols_index = []
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)

        self.bar = ActionBar(main_combo=original)
        vbox.addWidget(self.bar)

        self.stacked = QStackedLayout()
        vbox.addLayout(self.stacked)

        self._main_container = IDE.get_service('main_container')

        if not self.__original:
            self.connect(self._main_container, SIGNAL("fileOpened(QString)"),
                self._file_opened_by_main)

        self.connect(self.bar.combo, SIGNAL("showComboSelector()"),
            lambda: self.emit(SIGNAL("showComboSelector()")))
        self.connect(self.bar, SIGNAL("changeCurrent(PyQt_PyObject, int)"),
            self._set_current)
        self.connect(self.bar, SIGNAL("splitEditor(bool)"), self.split_editor)
        self.connect(self.bar, SIGNAL("runFile(QString)"),
            self._run_file)
        self.connect(self.bar, SIGNAL("closeSplit()"),
            lambda: self.emit(SIGNAL("closeSplit(PyQt_PyObject)"), self))
        self.connect(self.bar, SIGNAL("addToProject(QString)"),
            self._add_to_project)
        self.connect(self.bar, SIGNAL("showFileInExplorer(QString)"),
            self._show_file_in_explorer)
        self.connect(self.bar, SIGNAL("goToSymbol(int)"),
            self._go_to_symbol)
        self.connect(self.bar, SIGNAL("undockEditor()"),
            self.undock_editor)
        self.connect(self.bar, SIGNAL("reopenTab(QString)"),
            lambda path: self._main_container.open_file(path))
        self.connect(self.bar, SIGNAL("recentTabsModified()"),
            lambda: self._main_container.recent_files_changed())
        self.connect(self.bar.code_navigator.btnPrevious, SIGNAL("clicked()"),
            lambda: self._navigate_code(False))
        self.connect(self.bar.code_navigator.btnNext, SIGNAL("clicked()"),
            lambda: self._navigate_code(True))
 def _close_project(self, widget):
     """Close the project related to the tree widget."""
     index = self._projects_area.currentIndex()
     self.projects.remove(widget)
     self._projects_area.takeAt(index)
     self._combo_project.removeItem(index)
     index = self._combo_project.currentIndex()
     self._projects_area.setCurrentIndex(index)
     ninjaide = IDE.getInstance()
     ninjaide.filesystem.close_project(widget.project.path)
     widget.deleteLater()
     if len(self.projects) > 1:
         title = "%s (%s)" % (translations.TR_TAB_PROJECTS,
                              len(self.projects))
     else:
         title = translations.TR_TAB_PROJECTS
     self.changeTitle.emit(self, title)
Ejemplo n.º 50
0
    def __init__(self, original=False):
        super(ComboEditor, self).__init__(None)
        self.__original = original
        self.__undocked = []
        self._symbols_index = []
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)

        self.bar = ActionBar(main_combo=original)
        vbox.addWidget(self.bar)

        # Info bar
        self.info_bar = InfoBar(self)
        self.info_bar.setVisible(False)
        vbox.addWidget(self.info_bar)

        self.stacked = QStackedLayout()
        vbox.addLayout(self.stacked)

        self._main_container = IDE.get_service('main_container')

        if not self.__original:
            self._main_container.fileOpened['QString'].connect(
                self._file_opened_by_main)

        self.bar.combo_files.showComboSelector.connect(
            self._main_container.show_files_handler)
        self.bar.combo_files.hideComboSelector.connect(
            self._main_container.hide_files_handler)
        self.bar.needUpdateFocus.connect(self._editor_with_focus)
        self.bar.change_current['PyQt_PyObject',
                                int].connect(self._set_current)
        self.bar.splitEditor[bool].connect(self.split_editor)
        self.bar.runFile['QString'].connect(self._run_file)
        self.bar.closeSplit.connect(lambda: self.closeSplit.emit(self))
        self.bar.addToProject['QString'].connect(self._add_to_project)
        self.bar.showFileInExplorer['QString'].connect(
            self._show_file_in_explorer)
        self.bar.goToSymbol[int].connect(self._go_to_symbol)
        self.bar.undockEditor.connect(self.undock_editor)
        self.bar.reopenTab['QString'].connect(
            lambda path: self._main_container.open_file(path))
        self.bar.closeImageViewer.connect(self._close_image)
        self.bar.code_navigator.previousPressed.connect(self._navigate_code)
        self.bar.code_navigator.nextPressed.connect(self._navigate_code)
Ejemplo n.º 51
0
    def install(self):
        ide = IDE.get_service('ide')
        ide.place_me_on("explorer_container", self, "lateral")
        ide.goingDown.connect(self.save_configuration)

        for obj in ExplorerContainer.__TABS:
            tabname, icon = ExplorerContainer.__TABS[obj]
            self.add_tab(tabname, obj, icon)
            obj.dockWidget['PyQt_PyObject'].connect(self._dock_widget)
            obj.undockWidget.connect(self._undock_widget)
            logger.debug("Falta conectar change_tab_title")
            # obj.changeTitle.connect(self._change_tab_title)
            # obj.changeTitle['PyQt_PyObject',
            #                'QString'].connect(self._change_tab_title)

        if self.count() == 0:
            self.hide()
Ejemplo n.º 52
0
 def find(self, forward=True):
     """Collect flags and execute search in the editor."""
     reg = False
     cs = self.sensitive_checked
     wo = self.wholeword_checked
     main_container = IDE.get_service("main_container")
     editor = None
     if main_container:
         editor = main_container.get_current_editor()
     if editor:
         index, matches = editor.find_match(self.search_text,
                                            reg,
                                            cs,
                                            wo,
                                            forward=forward)
         self._line.counter.update_count(index, matches,
                                         len(self.search_text) > 0)
Ejemplo n.º 53
0
 def _add_model(self):
     ninjaide = IDE.get_service("ide")
     files = ninjaide.opened_files
     # Update model
     old = set(self._model.keys())
     new = set([nfile.file_path for nfile in files])
     result = old - new
     for item in result:
         del self._model[item]
     current_editor = self._main_container.get_current_editor()
     current_path = None
     if current_editor:
         current_path = current_editor.file_path
     model = []
     for nfile in files:
         if (nfile.file_path not in self._model
                 and nfile.file_path is not None):
             self._model[nfile.file_path] = 0
         neditable = ninjaide.get_or_create_editable(nfile=nfile)
         checkers = neditable.sorted_checkers
         checks = []
         for items in checkers:
             checker, color, _ = items
             if checker.dirty:
                 # Colors needs to be reversed for QML
                 color = "#%s" % color[::-1]
                 checks.append({
                     "checker_text": checker.dirty_text,
                     "checker_color": color
                 })
         modified = neditable.editor.is_modified
         temp_file = str(uuid.uuid4()) if nfile.file_path is None else ""
         filepath = nfile.file_path if nfile.file_path is not None else ""
         model.append(
             [nfile.file_name, filepath, checks, modified, temp_file])
         if temp_file:
             self._temp_files[temp_file] = nfile
     if current_path:
         index = self._model[current_path]
         self._max_index = max(self._max_index, index) + 1
         self._model[current_path] = self._max_index
     model = sorted(model,
                    key=lambda x: self._model.get(x[1], False),
                    reverse=True)
     self._root.set_model(model)
Ejemplo n.º 54
0
    def __init__(self, parent=None):
        super(NewProjectManager, self).__init__(parent, Qt.Dialog)
        self.setWindowTitle(translations.TR_NEW_PROJECT)
        self.setMinimumHeight(500)
        vbox = QVBoxLayout(self)
        vbox.addWidget(QLabel(translations.TR_CHOOSE_TEMPLATE))
        vbox.addWidget(QLabel(translations.TR_TAB_PROJECTS))

        hbox = QHBoxLayout()
        self.list_projects = QListWidget()
        self.list_projects.setProperty("wizard", True)
        hbox.addWidget(self.list_projects)

        self.list_templates = QListWidget()
        self.list_templates.setProperty("wizard", True)
        hbox.addWidget(self.list_templates)

        self.text_info = QTextBrowser()
        self.text_info.setProperty("wizard", True)
        hbox.addWidget(self.text_info)

        vbox.addLayout(hbox)

        hbox2 = QHBoxLayout()
        cancel = QPushButton(translations.TR_CANCEL)
        choose = QPushButton(translations.TR_CHOOSE)
        hbox2.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding,
                            QSizePolicy.Fixed))
        hbox2.addWidget(cancel)
        hbox2.addWidget(choose)
        vbox.addLayout(hbox2)

        self.template_registry = IDE.get_service("template_registry")
        categories = self.template_registry.list_project_categories()
        for category in categories:
            self.list_projects.addItem(category)

        self.connect(cancel, SIGNAL("clicked()"), self.close)
        self.connect(choose, SIGNAL("clicked()"), self._start_wizard)
        self.connect(self.list_projects,
                     SIGNAL("itemSelectionChanged()"),
                     self._project_selected)
        self.connect(self.list_templates,
                     SIGNAL("itemSelectionChanged()"),
                     self._template_selected)
Ejemplo n.º 55
0
 def _load_symbols(self, neditable):
     # Get symbols handler by language
     symbols_handler = handlers.get_symbols_handler(neditable.language())
     if symbols_handler is None:
         return
     source = neditable.editor.text
     source = source.encode(neditable.editor.encoding)
     symbols, symbols_simplified = symbols_handler.obtain_symbols(
         source, simple=True)
     self._symbols_index = sorted(symbols_simplified.keys())
     symbols_simplified = sorted(list(symbols_simplified.items()),
                                 key=lambda x: x[0])
     self.bar.add_symbols(symbols_simplified)
     line, _ = neditable.editor.cursor_position
     self._set_current_symbol(line, True)
     tree_symbols = IDE.get_service('symbols_explorer')
     if tree_symbols is not None:
         tree_symbols.update_symbols_tree(symbols, neditable.file_path)
Ejemplo n.º 56
0
 def _show_file_in_explorer(self, path):
     '''Iterate through the list of available projects and show
     the current file in the explorer view for the first
     project that contains it (i.e. if the same file is
     included in multiple open projects, the path will be
     expanded for the first project only).
     Note: This slot is connected to the main container's
     "showFileInExplorer(QString)" signal.'''
     central = IDE.get_service('central_container')
     if central and not central.is_lateral_panel_visible():
         return
     for project in self.projects:
         index = project.model().index(path)
         if index.isValid():
             # This highlights the index in the tree for us
             project.scrollTo(index, QAbstractItemView.EnsureVisible)
             project.setCurrentIndex(index)
             break
Ejemplo n.º 57
0
def build_highlighter(language, force=False):
    syntax_registry = IDE.get_service("syntax_registry")
    syntax = syntax_registry.get_syntax_for(language)
    if syntax is None:
        syntax_structure = settings.SYNTAX.get(language)
        if syntax_structure is None:
            print("Error")
            return None
        part_scanner = PartitionScanner(syntax_structure.get("partitions"))
        scanners = {}
        for scanner in syntax_structure.get("scanner"):
            name = scanner.get("partition_name")
            scanners[name] = Scanner(scanner.get("tokens"))
        syntax = Syntax(part_scanner, scanners)
        syntax.build_context()
        syntax_registry.register_syntax(language, syntax)

    return syntax
Ejemplo n.º 58
0
 def group_tabs_together(self):
     """Group files that belongs to the same project together."""
     ninjaide = IDE.get_service('ide')
     projects = ninjaide.get_opened_projects()
     for project in projects:
         project_name = projects[project].name
         project_path = projects[project].path
         tabGroup = tab_group.TabGroup(project_path, project_name, self)
         self.connect(tabGroup, SIGNAL("expandAll()"),
             self.deactivate_tabs_groups)
         for index in reversed(list(range(self.tabs.count()))):
             widget = self.tabs.widget(index)
             if (isinstance(widget, editor.Editor) and
                 widget.project == projects[project]):
                 tabGroup.add_widget(widget)
                 self.tabs.removeTab(index)
         if tabGroup.tabs:
             self.tabs.add_tab(tabGroup, project_name)
 def _filter_tabs(self, filterOptions, index):
     at_start = (index == 0)
     if at_start:
         ninjaide = IDE.getInstance()
         opened = ninjaide.filesystem.get_files()
         self.tempLocations = [
             locator.ResultItem(
                 locator.FILTERS['files'],
                 opened[f].file_name, opened[f].file_path) for f in opened]
         search = filterOptions[index + 1].lstrip().lower()
         self.tempLocations = [
             x for x in self.tempLocations
             if x.comparison.lower().find(search) > -1]
         index += 2
     else:
         del filterOptions[index + 1]
         del filterOptions[index]
     return index
    def __init__(self, original=False, Force_Free=False):
        super(ComboEditor, self).__init__(None)  #, Qt.WindowStaysOnTopHint)
        self.__original = original
        self.Force_Free = Force_Free
        self.__undocked = []
        self._single_undocked = []
        self._symbols_index = []
        self.__OFiles = []
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)

        self.bar = ActionBar(self, main_combo=original)
        vbox.addWidget(self.bar)

        self.stackedEditor = QStackedLayout()
        vbox.addLayout(self.stackedEditor)

        self._main_container = IDE.get_service('main_container')

        if not self.__original and not self.Force_Free:
            self._main_container.fileOpened.connect(self._file_opened_by_main)

        # QApplication.instance().focusChanged["QWidget*", "QWidget*"].connect(\
        #     lambda w1, w2: QTimer.singleShot(10, lambda w1=w1, w2=w2: print("\n\nQApplication::focusChanged::", w1, w2)))

        self.bar.combo.showComboSelector.connect(
            self._main_container.change_tab)
        self.bar.changeCurrent.connect(self._set_current)
        self.bar.editorSplited.connect(self.split_editor)
        self.bar.runFile[str].connect(self._run_file)
        self.bar.closeFile.connect(lambda: self.closeSplit.emit(self))
        self.bar.addToProject[str].connect(self._add_to_project)
        self.bar.showFileInExplorer.connect(self._show_file_in_explorer)
        self.bar.goToSymbol.connect(self._go_to_symbol)
        self.bar.undockEditor.connect(self.undock_editor)
        self.bar.undockThisEditor.connect(self.single_undock_editor)
        self.bar.reopenTab[str].connect(self._main_container.open_file)
        self.bar.recentTabsModified.connect(
            self._main_container.recent_files_changed)
        self.bar.code_navigator.btnPrevious.clicked['bool'].connect(
            lambda: self._navigate_code(self.NAVIGATE.prev))
        self.bar.code_navigator.btnNext.clicked['bool'].connect(
            lambda: self._navigate_code(self.NAVIGATE.prev))