Beispiel #1
0
    def addItem(self,
                project_info: ProjectInfo,
                plugin_name=None,
                enabled=True):
        # don't add duplicates
        if self.findItems(project_info.name, Qt.MatchFixedString):
            if not plugin_name:
                return

        item = QListWidgetItem(project_info.name, parent=self)
        item.version = project_info.version
        super().addItem(item)

        widg = PluginListItem(
            *project_info,
            parent=self,
            plugin_name=plugin_name,
            enabled=enabled,
        )
        method = getattr(self.installer,
                         'uninstall' if plugin_name else 'install')
        widg.action_button.clicked.connect(lambda: method([project_info.name]))

        item.setSizeHint(widg.sizeHint())
        self.setItemWidget(item, widg)
    def addItem(self,
                project_info: ProjectInfo,
                plugin_name=None,
                enabled=True):
        # don't add duplicates
        if (self.findItems(project_info.name, Qt.MatchFixedString)
                and not plugin_name):
            return

        # including summary here for sake of filtering below.
        searchable_text = project_info.name + " " + project_info.summary
        item = QListWidgetItem(searchable_text, parent=self)
        item.version = project_info.version
        super().addItem(item)

        widg = PluginListItem(
            *project_info,
            parent=self,
            plugin_name=plugin_name,
            enabled=enabled,
        )
        method = getattr(self.installer,
                         'uninstall' if plugin_name else 'install')
        widg.action_button.clicked.connect(lambda: method([project_info.name]))

        item.setSizeHint(widg.sizeHint())
        self.setItemWidget(item, widg)
Beispiel #3
0
    def addItem(
        self,
        project_info: ProjectInfo,
        installed=False,
        plugin_name=None,
        enabled=True,
        npe_version=1,
    ):
        # don't add duplicates
        if (
            self.findItems(project_info.name, Qt.MatchFixedString)
            and not plugin_name
        ):
            return

        # including summary here for sake of filtering below.
        searchable_text = project_info.name + " " + project_info.summary
        item = QListWidgetItem(searchable_text, parent=self)
        item.version = project_info.version
        super().addItem(item)
        widg = PluginListItem(
            *project_info,
            parent=self,
            plugin_name=plugin_name,
            enabled=enabled,
            installed=installed,
            npe_version=npe_version,
        )
        item.widget = widg
        item.npe_version = npe_version
        action_name = 'uninstall' if installed else 'install'
        item.setSizeHint(widg.sizeHint())
        self.setItemWidget(item, widg)

        if project_info.url:
            import webbrowser

            widg.help_button.clicked.connect(
                lambda: webbrowser.open(project_info.url)
            )
        else:
            widg.help_button.setVisible(False)

        widg.action_button.clicked.connect(
            lambda: self.handle_action(item, project_info.name, action_name)
        )
        widg.update_btn.clicked.connect(
            lambda: self.handle_action(
                item, project_info.name, "install", update=True
            )
        )
        widg.cancel_btn.clicked.connect(
            lambda: self.handle_action(item, project_info.name, "cancel")
        )
        item.setSizeHint(widg.sizeHint())
        self.setItemWidget(item, widg)
Beispiel #4
0
    def addItem(
        self,
        project_info: PackageMetadata,
        installed=False,
        plugin_name=None,
        enabled=True,
        npe_version=1,
    ):
        pkg_name = project_info.name
        # don't add duplicates
        if self.findItems(pkg_name, Qt.MatchFixedString) and not plugin_name:
            return

        # including summary here for sake of filtering below.
        searchable_text = f"{pkg_name} {project_info.summary}"
        item = QListWidgetItem(searchable_text, self)
        item.version = project_info.version
        super().addItem(item)
        widg = PluginListItem(
            package_name=pkg_name,
            version=project_info.version,
            url=project_info.home_page,
            summary=project_info.summary,
            author=project_info.author,
            license=project_info.license,
            parent=self,
            plugin_name=plugin_name,
            enabled=enabled,
            installed=installed,
            npe_version=npe_version,
        )
        item.widget = widg
        item.npe_version = npe_version
        action_name = 'uninstall' if installed else 'install'
        item.setSizeHint(widg.sizeHint())
        self.setItemWidget(item, widg)

        if project_info.home_page:
            import webbrowser

            widg.help_button.clicked.connect(
                lambda: webbrowser.open(project_info.home_page))
        else:
            widg.help_button.setVisible(False)
        widg.action_button.clicked.connect(
            lambda: self.handle_action(item, pkg_name, action_name))
        widg.update_btn.clicked.connect(
            lambda: self.handle_action(item, pkg_name, "install", update=True))
        widg.cancel_btn.clicked.connect(
            lambda: self.handle_action(item, pkg_name, "cancel"))
        item.setSizeHint(widg.sizeHint())
        self.setItemWidget(item, widg)