def __kdeGetText(parent, title, label, mode = QLineEdit.Normal, text = QString(), f = Qt.WindowFlags(Qt.Widget)): """ Function to get some text from the user. @param parent parent widget of the dialog (QWidget) @param title window title of the dialog (QString) @param label text of the label for the line edit (QString) @param mode mode of the line edit (QLineEdit.EchoMode) @param text initial text of the line edit (QString) @param f window flags for the dialog (Qt.WindowFlags) @return tuple of (text, ok). text contains the text entered by the user, ok indicates a valid input. (QString, boolean) """ if mode == QLineEdit.Normal: return KInputDialog.getText(title, label, text, parent) else: dlg = KPasswordDialog(parent) dlg.setWindowTitle(title) dlg.setPrompt(label) if not text.isEmpty(): dlg.setPassword(text) if dlg.exec_() == KPasswordDialog.Accepted: ok = True password = dlg.password() else: ok = False password = QString() return password, ok
def __init__(self, parent, deviceName, maxTries=3, showKeepPassword=True): if showKeepPassword: flags = KPasswordDialog.ShowKeepPassword else: flags = KPasswordDialog.NoFlags KPasswordDialog.__init__(self, parent, flags) # Set UI self.setCaption(i18n("Enter PIN")) self.setPrompt("%s <b>%s</b>" % (i18n("Please Enter PIN Code for"), deviceName)) self.setPixmap(KIcon("preferences-desktop-notification").pixmap(64)) self.maxTries = maxTries