Exemplo n.º 1
0
 def done(self, result):
     logger.debug("Done")
     if result == 1:
         page = self.currentPage()
         if type(page) == PageProjectProperties:
             venv = unicode(page.vtxtPlace.text())
             if venv:
                 if sys.platform == 'win32':
                     venv = os.path.join(venv, 'Scripts', 'python.exe')
                 else:
                     venv = os.path.join(venv, 'bin', 'python')
                 #check if venv folder exists
                 if  not os.path.exists(venv):
                     btnPressed = QMessageBox.information(self,
                         self.tr("Virtualenv Folder"),
                         self.tr("Folder don't exists or this is not a " \
                             "valid Folder.\n If you want to set " \
                             "or modify, go to project properties"),
                         self.tr("Back"),
                         self.tr("Continue"))
                     if btnPressed == QMessageBox.NoButton:
                         return
                     else:
                         self.currentPage().vtxtPlace.setText("")
             page.vtxtPlace.setText(venv)
         settings.get_project_type_handler(self.option)\
             .on_wizard_finish(self)
     super(WizardNewProject, self).done(result)
Exemplo n.º 2
0
    def _menu_context_tree(self, point, isRoot=False, root_path=None):
        index = self.indexAt(point)
        if not index.isValid() and not isRoot:
            return

        handler = None
        menu = QMenu(self)
        if isRoot or self.model().isDir(index):
            self._add_context_menu_for_folders(menu, isRoot, root_path)
        else:
            filename = self.model().fileName(index)
            lang = file_manager.get_file_extension(filename)
            self._add_context_menu_for_files(menu, lang)
        if isRoot:
            #get the extra context menu for this projectType
            handler = settings.get_project_type_handler(
                self.project.project_type)
            self._add_context_menu_for_root(menu)

        menu.addMenu(self._folding_menu)

        #menu for the Project Type(if present)
        if handler:
            for m in handler.get_context_menus():
                if isinstance(m, QMenu):
                    menu.addSeparator()
                    menu.addMenu(m)
        #show the menu!
        menu.exec_(QCursor.pos())
Exemplo n.º 3
0
    def _menu_context_tree(self, point):
        index = self.indexAt(point)
        if not index.isValid():
            return

        item = self.itemAt(point)
        handler = None
        menu = QMenu(self)
        if item.isFolder or item.parent() is None:
            self._add_context_menu_for_folders(menu, item)
        elif not item.isFolder:
            self._add_context_menu_for_files(menu, item)
        if item.parent() is None:
            #get the extra context menu for this projectType
            handler = settings.get_project_type_handler(item.projectType)
            self._add_context_menu_for_root(menu, item)

        menu.addMenu(self._folding_menu)

        #menu for all items (legacy API)!
        extra_menus = self.extra_menus.get('all', ())
        #menu for all items!
        for m in extra_menus:
            if isinstance(m, QMenu):
                menu.addSeparator()
                menu.addMenu(m)
        #menu for the Project Type(if present)
        if handler:
            for m in handler.get_context_menus():
                if isinstance(m, QMenu):
                    menu.addSeparator()
                    menu.addMenu(m)
        #show the menu!
        menu.exec_(QCursor.pos())
Exemplo n.º 4
0
 def add_project_pages(self, option='Python'):
     self.option = option
     pages = settings.get_project_type_handler(option).get_pages()
     listIds = self.pageIds()
     listIds.pop(listIds.index(0))
     for page in pages:
         self.addPage(page)
     #this page is always needed by a project!
     self.addPage(PageProjectProperties())
     for i in listIds:
         self.removePage(i)
Exemplo n.º 5
0
    def _project_menu_context_tree(self, menu, item):
        handler = None
        menu.addSeparator()
        actionRunProject = menu.addAction(QIcon(
            resources.IMAGES['play']), self.tr("Run Project"))
        self.connect(actionRunProject, SIGNAL("triggered()"),
            SIGNAL("runProject()"))
        actionMainProject = menu.addAction(self.tr("Set as Main Project"))
        self.connect(actionMainProject, SIGNAL("triggered()"),
            lambda: self.set_default_project(item))
        if item.addedToConsole:
            actionRemoveFromConsole = menu.addAction(
                self.tr("Remove this Project from the Python Console"))
            self.connect(actionRemoveFromConsole, SIGNAL("triggered()"),
                self._remove_project_from_console)
        else:
            actionAdd2Console = menu.addAction(
                self.tr("Add this Project to the Python Console"))
            self.connect(actionAdd2Console, SIGNAL("triggered()"),
                self._add_project_to_console)
        actionProperties = menu.addAction(QIcon(resources.IMAGES['pref']),
            self.tr("Project Properties"))
        self.connect(actionProperties, SIGNAL("triggered()"),
            self.open_project_properties)
        #get the extra context menu for this projectType
        handler = settings.get_project_type_handler(item.projectType)

        menu.addSeparator()
        action_refresh = menu.addAction(
            self.style().standardIcon(QStyle.SP_BrowserReload),
            self.tr("Refresh Project"))
        self.connect(action_refresh, SIGNAL("triggered()"),
            self._refresh_project)
        action_close = menu.addAction(
            self.style().standardIcon(QStyle.SP_DialogCloseButton),
            self.tr("Close Project"))
        self.connect(action_close, SIGNAL("triggered()"),
            self._close_project)
        #menu for the Project Type(if present)
        if handler:
            for m in handler.get_context_menus():
                menu.addSeparator()
                menu.addMenu(m)
        for handler in settings.get_context_menu_handlers('project'):
            handler.feed_menu(menu, item)
Exemplo n.º 6
0
    def _menu_context_tree(self, point):
        index = self.indexAt(point)
        if not index.isValid():
            return

        item = self.itemAt(point)
        handler = None
        menu = QMenu(self)
        if item.isFolder or item.parent() is None:
            action_add_file = menu.addAction(QIcon(resources.IMAGES['new']),
                self.tr("Add New File"))
            self.connect(action_add_file, SIGNAL("triggered()"),
                self._add_new_file)
            action_add_folder = menu.addAction(QIcon(
                resources.IMAGES['openProj']), self.tr("Add New Folder"))
            self.connect(action_add_folder, SIGNAL("triggered()"),
                self._add_new_folder)
            action_create_init = menu.addAction(
                self.tr("Create '__init__' Complete"))
            self.connect(action_create_init, SIGNAL("triggered()"),
                self._create_init)
            if item.isFolder and (item.parent() != None):
                action_remove_folder = menu.addAction(self.tr("Remove Folder"))
                self.connect(action_remove_folder, SIGNAL("triggered()"),
                    self._delete_folder)
        elif not item.isFolder:
            action_rename_file = menu.addAction(self.tr("Rename File"))
            action_move_file = menu.addAction(self.tr("Move File"))
            action_copy_file = menu.addAction(self.tr("Copy File"))
            action_remove_file = menu.addAction(
                self.style().standardIcon(QStyle.SP_DialogCloseButton),
                self.tr("Delete File"))
            self.connect(action_remove_file, SIGNAL("triggered()"),
                self._delete_file)
            self.connect(action_rename_file, SIGNAL("triggered()"),
                self._rename_file)
            self.connect(action_copy_file, SIGNAL("triggered()"),
                self._copy_file)
            self.connect(action_move_file, SIGNAL("triggered()"),
                self._move_file)
            #menu per file language!
            for m in self.EXTRA_MENUS.get(item.lang(), ()):
                menu.addSeparator()
                menu.addMenu(m)
        if item.parent() is None:
            menu.addSeparator()
            actionRunProject = menu.addAction(QIcon(
                resources.IMAGES['play']), self.tr("Run Project"))
            self.connect(actionRunProject, SIGNAL("triggered()"),
                SIGNAL("runProject()"))
            actionMainProject = menu.addAction(self.tr("Set as Main Project"))
            self.connect(actionMainProject, SIGNAL("triggered()"),
                lambda: self.set_default_project(item))
            if item.addedToConsole:
                actionRemoveFromConsole = menu.addAction(
                    self.tr("Remove this Project from the Python Console"))
                self.connect(actionRemoveFromConsole, SIGNAL("triggered()"),
                    self._remove_project_from_console)
            else:
                actionAdd2Console = menu.addAction(
                    self.tr("Add this Project to the Python Console"))
                self.connect(actionAdd2Console, SIGNAL("triggered()"),
                    self._add_project_to_console)
            actionProperties = menu.addAction(QIcon(resources.IMAGES['pref']),
                self.tr("Project Properties"))
            self.connect(actionProperties, SIGNAL("triggered()"),
                self.open_project_properties)
            #get the extra context menu for this projectType
            handler = settings.get_project_type_handler(item.projectType)
#            if handler:
#                for m in handler.get_context_menus():
#                    menu.addSeparator()
#                    menu.addMenu(m)

            menu.addSeparator()
            action_refresh = menu.addAction(
                self.style().standardIcon(QStyle.SP_BrowserReload),
                self.tr("Refresh Project"))
            self.connect(action_refresh, SIGNAL("triggered()"),
                self._refresh_project)
            action_close = menu.addAction(
                self.style().standardIcon(QStyle.SP_DialogCloseButton),
                self.tr("Close Project"))
            self.connect(action_close, SIGNAL("triggered()"),
                self._close_project)

        #menu for all items!
        for m in self.EXTRA_MENUS.get('all', ()):
            menu.addSeparator()
            menu.addMenu(m)

        #menu for the Project Type(if present)
        if handler:
            for m in handler.get_context_menus():
                menu.addSeparator()
                menu.addMenu(m)
        #show the menu!
        menu.exec_(QCursor.pos())