def on_btn_beautify_clicked(self): try: try: from css_html_prettify import css_prettify except: _t = QMessageBox.question(self, "Can't beautify", "Python package \"css_html_prettify\" could not be loaded.\nDo you want to try installing it now?", QMessageBox.Yes, QMessageBox.No) if _t == QMessageBox.Yes: from devtools import PluginInstaller PluginInstaller().installPackages(['css_html_prettify']) self.on_btn_beautify_clicked() return #import traceback; QMessageBox.Critical("Can't minify", traceback.format_exc()).exec_() index = self.tabWidget.currentIndex _old = "" if index == 0: _old = self.qssEditor.toPlainText() elif index == 1: _old = self.chatEditor.toPlainText() _beautified = css_prettify(_old) if index == 0: QApplication.instance().styleSheet = _beautified self.qssEditor.setPlainText(_beautified) elif index == 1: self.chatEditor.setPlainText(_beautified);return if QMessageBox(QMessageBox.Warning, "Use minified QSS?", "Your minified QSS code has been applied.\n\nIf you encounter any issues with the minified code you should click on cancel.", QMessageBox.Ok | QMessageBox.Cancel).exec_() == QMessageBox.Cancel: QApplication.instance().styleSheet = _old self.qssEditor.setPlainText(_old) except: try: from traceback import format_exc QMessageBox(QMessageBox.Critical, "Can't beautify", format_exc()).exec_() except: print(format_exc())
def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL and menuItemID == 0: error, ownid = ts3lib.getClientID(schid) if not error == ts3defines.ERROR_ok: _t = QMessageBox( QMessageBox.Critical, "Error #%s" % error, "Unable to get own client ID in Tab #%s!" % schid) _t.show() return error, ownchan = ts3lib.getChannelOfClient(schid, ownid) if not error == ts3defines.ERROR_ok: _t = QMessageBox( QMessageBox.Critical, "Error #%s" % error, "Unable to get own channel ID in Tab #%s!" % schid) _t.show() return self.sendMessage( schid, ts3defines.TextMessageTargetMode.TextMessageTarget_CHANNEL, ownchan) elif atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT and menuItemID == 0: self.sendMessage( schid, ts3defines.TextMessageTargetMode.TextMessageTarget_CLIENT, selectedItemID) elif atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL and menuItemID == 0: self.sendMessage( schid, ts3defines.TextMessageTargetMode.TextMessageTarget_CHANNEL, selectedItemID)
def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype == PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL: if menuItemID == 0: error, ownid = ts3.getClientID(schid) if error == ERROR_ok: error, meta = ts3.getClientVariableAsString(schid, ownid, ClientProperties.CLIENT_META_DATA) if error == ERROR_ok: x = QWidget() _meta = QInputDialog.getMultiLineText(x, "Change own Meta Data", "Meta Data:", meta) if _meta == meta: return error = ts3.setClientSelfVariableAsString(schid, ClientProperties.CLIENT_META_DATA, _meta) if not error == ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error #%s"%error, "Unable to set own meta data!");_t.show() elif menuItemID == 1: error, ownid = ts3.getClientID(schid) if error == ERROR_ok: error, flag = ts3.getClientVariableAsString(schid, ownid, ClientPropertiesRare.CLIENT_FLAG_AVATAR) ts3.printMessageToCurrentTab("Your current avatar flag is: %s"%flag) if error == ERROR_ok: x = QWidget() _flag = QInputDialog.getText(x, "Change own Avatar Flag", "Avatar File MD5:") if _flag == "x" or _flag.strip() == flag.strip(): return error = ts3.setClientSelfVariableAsString(schid, ClientPropertiesRare.CLIENT_FLAG_AVATAR, _flag) error2 = ts3.flushClientSelfUpdates(schid) if not error == ERROR_ok or not error2 == ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error", "Unable to set own avatar flag!");_t.show()
def sendMessage(self, schid, targetMode, toID): x = QWidget() clipboard = QApplication.clipboard().text(); _message = QInputDialog.getMultiLineText(x, "Enter long text here", "", clipboard) message = [_message[i:i + self.maxsize] for i in range(0, len(_message), self.maxsize)] if targetMode == ts3defines.TextMessageTargetMode.TextMessageTarget_CHANNEL: for msg in message: error = ts3lib.requestSendChannelTextMsg(schid, "\n"+msg, toID) if not error == ts3defines.ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error #%s"%error,"Unable to send message to #%s!"%toID);_t.show();return elif targetMode == ts3defines.TextMessageTargetMode.TextMessageTarget_CLIENT: for msg in message: error = ts3lib.requestSendPrivateTextMsg(schid, "\n"+msg, toID) if not error == ts3defines.ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error #%s"%error,"Unable to send message to #%s!"%toID);_t.show();return
def on_btn_beautify_clicked(self): try: try: from bs4 import BeautifulSoup except Exception: from traceback import format_exc print("Error: {0}".format(format_exc())) _t = QMessageBox.question( self, "Can't beautify", "Python package \"beautifulsoup4\" could not be loaded.\nDo you want to try installing it now?", QMessageBox.Yes, QMessageBox.No) if _t == QMessageBox.Yes: from devtools import PluginInstaller PluginInstaller().installPackages(['beautifulsoup4']) self.on_btn_beautify_clicked() return #import traceback; QMessageBox.Critical("Can't minify", traceback.format_exc()).exec_() index = self.tabWidget.currentIndex _old = "" if index == 0: _old = self.qssEditor.toPlainText() elif index == 1: _old = self.chatEditor.toPlainText() elif index == 2: _old = self.tplEditor.toPlainText() elif index == 3: _old = self.chatEditor_html.toPlainText() _beautified = BeautifulSoup(_old) _beautified = _beautified.prettify() if index == 0: QApplication.instance().styleSheet = _beautified self.qssEditor.setPlainText(_beautified) elif index == 1: self.chatEditor.setPlainText(_beautified) return elif index == 2: self.tplEditor.setPlainText(_beautified) return elif index == 3: self.chatEditor_html.setPlainText(_beautified) return if QMessageBox( QMessageBox.Warning, "Use beautified code?", "Your beautified code has been applied.\n\nIf you encounter any issues with the beautified code you should click on cancel.", QMessageBox.Ok | QMessageBox.Cancel).exec_() == QMessageBox.Cancel: QApplication.instance().styleSheet = _old self.qssEditor.setPlainText(_old) except: try: from traceback import format_exc QMessageBox(QMessageBox.Critical, "Can't beautify", format_exc()).exec_() except: print(format_exc())
def onRemoveButtonClicked(self, pluginname): if pluginname in self.host.plugins: if self.cfg.getboolean("general", "uninstallQuestion"): def cbox_state_changed(state): if state == Qt.Checked: self.cfg.set("general", "uninstallQuestion", "False") else: self.cfg.set("general", "uninstallQuestion", "True") cbox = QCheckBox(self._tr("Don't ask me again")) cbox.connect("stateChanged(int)", cbox_state_changed) msgbox = QMessageBox(self) msgbox.setInformativeText(self._tr("Do you really want to " "delete plugin {name}?\n" "This will erase all " "script data of the " "plugin from disk."). format(name=pluginname)) msgbox.setIcon(4) # QMessageBox::Icon::Question = 4 msgbox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) msgbox.setDefaultButton(QMessageBox.Cancel) msgbox.setCheckBox(cbox) if msgbox.exec_() != QMessageBox.Ok: return if pluginname in self.host.active: self.host.deactivate(pluginname) devtools.PluginInstaller.removePlugin(pluginname) self.host.reload() self.host.start() self.setupList()
def on_btn_reset_clicked(self): if QMessageBox( QMessageBox.Warning, "Reset QSS?", "This will reset your changes to the initial Stylesheet! Continue?", QMessageBox.Ok | QMessageBox.Cancel).exec_() == QMessageBox.Ok: QApplication.instance().styleSheet = self.stylesheet self.qssEditor.setPlainText(self.stylesheet)
def msgBox(text, icon=QMessageBox.Information, title=""): """ :param text: :param icon: :param title: """ x = QMessageBox() if title: x.setWindowTitle(title) x.setText(text) x.setIcon(icon) x.exec()
def onDelChannelEvent(self, schid, channel, invokerID, invokerName, invokerUniqueIdentifier): if self.schid == schid and self.channel == channel: msgBox = QMessageBox() msgBox.setText( "Channel \"{0}\" got deleted by \"{1}\"\n\nStopping Queue!". format(self.cname, invokerName)) msgBox.setIcon(QMessageBox.Warning) msgBox.exec() self.schid = 0 self.channel = 0 self.password = "" self.name = ""
def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL: if menuItemID == 0: schid = ts3.getCurrentServerConnectionHandlerID() error, ownid = ts3.getClientID(schid) if error == ts3defines.ERROR_ok: error, meta = ts3.getClientVariableAsString( schid, ownid, ts3defines.ClientProperties.CLIENT_META_DATA) if error == ts3defines.ERROR_ok: x = QWidget() meta = QInputDialog.getMultiLineText( x, "Change own Meta Data", "Meta Data:", meta) error = ts3.setClientSelfVariableAsString( schid, ts3defines.ClientProperties.CLIENT_META_DATA, meta) if not error == ts3defines.ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error", "Unable to set own meta data!") t.show()
def msgBox(text, icon=QMessageBox.Information): x = QMessageBox() x.setText(text) x.setIcon(icon) x.exec()