示例#1
0
    def setupList(self):
        self.pluginsTable.clear()
        self.pluginsTable.setRowCount(len(self.host.plugins))

        try:
            ico = ts3client.IconPack.current()
            ico.open()
        except Exception as e:
            ico = None
            ts3print(self._tr("Error loading iconpack: {exception}").
                     format(exception=e), ts3defines.LogLevel.LogLevel_ERROR,
                     "pyTSon.ConfigurationDialog.setupList", 0)

        row = 0
        diffapi = self.cfg.getboolean("general", "differentApi",
                                      fallback=False)
        for key, p in self.host.plugins.items():
            if diffapi or p.apiVersion == pytson.getCurrentApiVersion():
                item = QTableWidgetItem(p.name)
                item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable |
                              Qt.ItemIsEnabled)
                item.setCheckState(Qt.Checked if key in self.host.active
                                   else Qt.Unchecked)
                item.setData(Qt.UserRole, key)
                self.pluginsTable.setItem(row, 0, item)

                if p.offersConfigure:
                    setbutton = QToolButton()
                    setbutton.connect("clicked()", lambda n=p.name:
                                      self.onSettingsButtonClicked(n))
                    setbutton.setToolTip(self._tr("Configure"))
                    if ico:
                        setbutton.setIcon(QIcon(ico.icon("SETTINGS")))
                    self.pluginsTable.setCellWidget(row, 1, setbutton)

                    if p.name not in self.host.active:
                        setbutton.setEnabled(False)

                rembutton = QToolButton()
                if ico:
                    rembutton.setIcon(QIcon(ico.icon("DELETE")))
                rembutton.connect("clicked()", lambda n=p.name:
                                  self.onRemoveButtonClicked(n))
                rembutton.setToolTip(self._tr("Remove"))
                self.pluginsTable.setCellWidget(row, 2, rembutton)

                row += 1

        if ico:
            ico.close()

        self.pluginsTable.setRowCount(row)
        self.pluginsTable.sortItems(0)
示例#2
0
    def reloadSite(self):
        self.siteTable.clearContents()

        self.sitepkgs = devtools.installedPackages()
        self.siteTable.setRowCount(len(self.sitepkgs))

        for i, pkg in enumerate(self.sitepkgs):
            item = QTableWidgetItem(pkg["name"])
            item.setData(Qt.UserRole, i)
            self.siteTable.setItem(i, 0, item)

            item = QTableWidgetItem(pkg["version"])
            item.setData(Qt.UserRole, i)
            self.siteTable.setItem(i, 1, item)

        self.siteTable.sortItems(0)