def confirm(title, message): """ :param title: :param message: :return: """ x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) _x = QMessageBox.question(x, title, message, QMessageBox.Yes, QMessageBox.No) if _x == QMessageBox.Yes: return True if _x == QMessageBox.Yes else False
def inputBox(title, text, default=""): """ :param default: :param title: :param text: :return: """ x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) ok = BoolResult() # if default is None: default = QApplication.clipboard().text() text = QInputDialog.getText(x, title, text, QLineEdit.Normal, default, ok) # QDir.Home.dirName() if ok: return text else: return False
def inputInt(title="", label="", val=0, min=-2147483647, max=2147483647, step=1): """ :param title: :param label: :param val: :param min: :param max: :param step: :return: """ x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) ok = BoolResult() i = QInputDialog.getInt(x, title, label, val, min, max, step, ok) if ok: return i else: return False
def readChannels(self, file): if not file: file = QFileDialog.getOpenFileName( QDialog(), "", "", "All Files (*);;YaTQA Exported Channels (*.ts3_chans)") channels = [] with open(file) as fp: lines = fp.readlines() # i = 0 for line in lines: if not line.strip(): continue # Todo: Maybe trycatch instead? line = line.rstrip().split("|", 1) _channel = line.pop(0).split(" ") channel = {"flags": {}} for pair in _channel: pair = pair.split("=") key = pair.pop(0) (err, flag) = ts3lib.channelPropertyStringToFlag(key) if err != ERROR_ok or not len(pair): continue channel["flags"][flag] = escapeStr(pair.pop(0)) # ts3lib.printMessageToCurrentTab("{}: {} = {}".format(i, flag, value)) if len(line): perms = line.pop(0).split("|") channel["permissions"] = [] for perm in perms: permission = {} perm = perm.split(" ") for prop in perm: prop = prop.split("=") if prop[0] == "cid": continue permission[prop[0]] = prop[1] # print("{}: {} = {}".format(i, prop[0], prop[1])) channel["permissions"].append(permission) channels.append(channel) # i += 1 return channels
def inputBox(title, text): x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) (text, ok) = QInputDialog.getText(x, title, text) if ok: return text else: return False
def confirm(self, title, message): x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) _t = QMessageBox.question(x, title, message, QMessageBox.Yes, QMessageBox.No) if _t == QMessageBox.Yes: return True else: return False
def inputBox(title, text): x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) return QInputDialog.getText(x, title, text)
def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL: if menuItemID == 0: err, cname = ts3lib.getChannelVariable( schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME) self.channel = selectedItemID, cname ts3lib.printMessageToCurrentTab( '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now()) + " Set target channel to [color=yellow]" + str(self.channel) + "[/color]") elif menuItemID == 1: (e, cgid) = ts3lib.getServerVariableAsUInt64( schid, ts3defines.VirtualServerPropertiesRare. VIRTUALSERVER_DEFAULT_CHANNEL_GROUP) x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) dbid = QInputDialog.getInt(x, "Manually change channel group", "Enter DBID", QLineEdit.Normal) if self.channel == 0: (e, ownID) = ts3lib.getClientID(schid) (e, cid) = ts3lib.getChannelOfClient(schid, ownID) err, cname = ts3lib.getChannelVariable( schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME) self.channel = cid, cname name = "DBID: %s" % dbid if self.debug: ts3lib.printMessageToCurrentTab( "toggle: {0} | debug: {1} | channel: {2} | groups: {3} | dbid: {4} | name: {5}" .format(self.toggle, self.debug, self.channel, self.groups, dbid, name)) ts3lib.printMessageToCurrentTab( "schid: {0} | cgid: {1} | dbid: {2}".format( schid, cgid, dbid)) if not self.dlg: self.dlg = ChannelGroupDialog(schid, cgid, dbid, name, self.channel, self.groups) self.dlg.show() self.dlg.raise_() self.dlg.activateWindow() elif atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT: if menuItemID == 0: if self.channel == 0: (e, ownID) = ts3lib.getClientID(schid) (e, cid) = ts3lib.getChannelOfClient(schid, ownID) err, cname = ts3lib.getChannelVariable( schid, cid, ts3defines.ChannelProperties.CHANNEL_NAME) self.channel = cid, cname (e, dbid) = ts3lib.getClientVariableAsUInt64( schid, selectedItemID, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID) (e, cgid) = ts3lib.getClientVariableAsUInt64( schid, selectedItemID, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID) (e, name) = ts3lib.getClientVariableAsString( schid, selectedItemID, ts3defines.ClientProperties.CLIENT_NICKNAME) if self.debug: ts3lib.printMessageToCurrentTab( "toggle: {0} | debug: {1} | channel: {2} | groups: {3} | dbid: {4} | name: {5}" .format(self.toggle, self.debug, self.channel, self.groups, dbid, name)) if not self.dlg: self.dlg = ChannelGroupDialog(schid, cgid, dbid, name, self.channel, self.groups) self.dlg.show() self.dlg.raise_() self.dlg.activateWindow()