Exemplo n.º 1
0
bool NotifyQt::askForPassword(const std::string& key_details, bool prev_is_bad, std::string& password,bool& cancelled)
{
	RsAutoUpdatePage::lockAllEvents() ;

	QInputDialog dialog;
	dialog.setWindowTitle(tr("PGP key passphrase"));
	dialog.setLabelText((prev_is_bad ? QString("%1\n\n").arg(tr("Wrong password !")) : QString()) + QString("%1:\n    %2").arg(tr("Please enter your PGP password for key"), QString::fromUtf8(key_details.c_str())));
	dialog.setTextEchoMode(QLineEdit::Password);
	dialog.setModal(true);

	int ret = dialog.exec();

    cancelled = false ;

	RsAutoUpdatePage::unlockAllEvents() ;

    if (ret == QDialog::Rejected) {
        password.clear() ;
        cancelled = true ;
        return true ;
    }

    if (ret == QDialog::Accepted) {
		 password = dialog.textValue().toUtf8().constData();
		 return true;
    }

	return false;
}
Exemplo n.º 2
0
bool NotifyQt::askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password,bool& cancelled)
{
	RsAutoUpdatePage::lockAllEvents() ;

	QInputDialog dialog;
	if (title == "") {
		dialog.setWindowTitle(tr("PGP key passphrase"));
	} else if (title == "AuthSSLimpl::SignX509ReqWithGPG()") {
		dialog.setWindowTitle(tr("You need to sign your node's certificate."));
	} else if (title == "p3IdService::service_CreateGroup()") {
		dialog.setWindowTitle(tr("You need to sign your forum/chatrooms identity."));
	} else {
		dialog.setWindowTitle(QString::fromStdString(title));
	}

	dialog.setLabelText((prev_is_bad ? QString("%1\n\n").arg(tr("Wrong password !")) : QString()) + QString("%1:\n    %2").arg(tr("Please enter your PGP password for key"), QString::fromUtf8(key_details.c_str())));
	dialog.setTextEchoMode(QLineEdit::Password);
	dialog.setModal(true);

	int ret = dialog.exec();

    cancelled = false ;

	RsAutoUpdatePage::unlockAllEvents() ;

    if (ret == QDialog::Rejected) {
        password.clear() ;
        cancelled = true ;
        return true ;
    }

    if (ret == QDialog::Accepted) {
		 password = dialog.textValue().toUtf8().constData();
		 return true;
    }

	return false;
}