Beispiel #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)
Beispiel #2
0
 def setupList(self, addons):
     try:
         self.tbl_addons.clear()
         self.tbl_addons.setRowCount(len(addons))
         row = 0
         for addon in addons:
             try:
                 if addon == None or addon.text == None: continue
                 _type = "Other";
                 try:
                     _type = addon.attrib["t"].title()
                 except: pass
                 item = QTableWidgetItem(_type)
                 item.setFlags(Qt.ItemIsEnabled | ~Qt.ItemIsEditable)
                 self.tbl_addons.setItem(row, 0, item)
                 item = QTableWidgetItem(addon.text)
                 if len(list(addon)):
                     font = QFont()
                     font.setBold(True)
                     item.setFont(font)
                     # item.setData(Qt.UserRole, addon.text)
                     if addon.text == "pyTSon": self.pytson = addon
                     elif addon.text == "Lua": self.lua = addon
                 item.setFlags(Qt.ItemIsEnabled | ~Qt.ItemIsEditable)
                 self.tbl_addons.setItem(row, 1, item)
                 if PluginHost.cfg.getboolean("general", "verbose"): ts3.printMessageToCurrentTab("%i [color=red]%s"%(row, xml.tostring(addon).decode("utf-8")))
                 try:
                     item = QTableWidgetItem(addon.attrib["v"])
                     item.setFlags(Qt.ItemIsEnabled | ~Qt.ItemIsEditable)
                     self.tbl_addons.setItem(row, 2, item)
                 except: ts3.logMessage("Addon %s does not have any version." % (addon.text), ts3defines.LogLevel.LogLevel_WARNING, "Addon List", 0)
                 try:
                     item = QTableWidgetItem(addon.attrib["a"])
                     item.setFlags(Qt.ItemIsEnabled | ~Qt.ItemIsEditable)
                     self.tbl_addons.setItem(row, 3, item)
                 except: ts3.logMessage("Addon %s does not have any author." % (addon.text), ts3defines.LogLevel.LogLevel_WARNING, "Addon List", 0)
                 row += 1
             except: from traceback import format_exc;ts3.logMessage("Error parsing addon %s:\n%s"%(addon.text,format_exc()), ts3defines.LogLevel.LogLevel_ERROR, "{c}.{f}".format(c=self.__class__,f=__name__), 0);continue
         self.tbl_addons.setRowCount(row)
         self.tbl_addons.sortItems(0)
         self.tbl_addons.setHorizontalHeaderLabels(["Type","Name","Version","Author","API"])
     except:
         try: from traceback import format_exc;ts3.logMessage("addonList: "+format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
         except:
             try: from traceback import format_exc;print("addonList: "+format_exc())
             except: print("addonList: Unknown Error")