# # # patch "src/view/dialogs/KeyManagement.cpp" # from [8f926ce4de668c7c928aca4eb69cc7af94397ec1] # to [10a95be196dda8d70292d8b71c199d31862320a3] # # patch "src/view/dialogs/KeyManagement.h" # from [f110b2cd75d8543287ccff9d17bd4e7f611276bb] # to [2661c45144f24e9241f4c73719c7e2ba9cc17f9b] # ============================================================ --- src/view/dialogs/KeyManagement.cpp 8f926ce4de668c7c928aca4eb69cc7af94397ec1 +++ src/view/dialogs/KeyManagement.cpp 10a95be196dda8d70292d8b71c199d31862320a3 @@ -67,6 +67,12 @@ KeyManagement::KeyManagement(QWidget * p act = new QAction(tr("Copy public key data to clipboard"), this); connect(act, SIGNAL(triggered()), this, SLOT(copyPubkeyDataToClipboard())); popupMenu->addAction(act); + + popupMenu->addSeparator(); + + act = new QAction(tr("Drop key"), this); + connect(act, SIGNAL(triggered()), this, SLOT(dropKey())); + popupMenu->addAction(act); } KeyManagement::~KeyManagement() @@ -130,7 +136,7 @@ void KeyManagement::copyLocalNameToClipb clipboard->setText(key->local_name); } -//! \todo should be converted to automate pubkey, if available +// TODO: should be converted to automate pubkey, if available void KeyManagement::copyPubkeyDataToClipboard() { Key * key = getKeyFromSelection(); @@ -158,3 +164,56 @@ void KeyManagement::copyPubkeyDataToClip clipboard->setText(QString::fromUtf8(output)); } +// TODO: should be converted to automate dropkey, if available +void KeyManagement::dropKey() +{ + Key * key = getKeyFromSelection(); + if (key == 0) + return; + + QMessageBox::StandardButton btn = QMessageBox::question( + this, + tr("Drop key?"), + tr("Do you really want to drop the key %1 (%2)?") + .arg(key->given_name) + .arg(key->hash), + QMessageBox::Yes | QMessageBox::No + ); + + if (btn == QMessageBox::No) return; + + // ask one more time for private keys + if (key->private_locations > 0) + { + QMessageBox::StandardButton btn = QMessageBox::question( + this, + tr("Drop private key?"), + tr("WARNING: If you do this and you have no backup of your keypair, " + "any particular trust setup (f.e. in a monotone server) " + "will no longer recognize you.\n\n" + "Do you really want to continue?"), + QMessageBox::Yes | QMessageBox::No + ); + + if (btn == QMessageBox::No) return; + } + + QStringList args; + args << "-d" << databaseFile << "dropkey" << key->hash; + + QByteArray output; + if (!MonotoneManager::singleRun(Settings::getMtnBinaryPath(), args, output)) + { + QMessageBox::critical( + this, + tr("Couldn't drop key"), + tr("Failed to drop key \"%1\": %2") + .arg(key->hash) + .arg(QString(output)), + QMessageBox::Ok + ); + return; + } + + model->readKeys(); +} ============================================================ --- src/view/dialogs/KeyManagement.h f110b2cd75d8543287ccff9d17bd4e7f611276bb +++ src/view/dialogs/KeyManagement.h 2661c45144f24e9241f4c73719c7e2ba9cc17f9b @@ -54,6 +54,7 @@ private slots: void copyGivenNameToClipboard(); void copyLocalNameToClipboard(); void copyPubkeyDataToClipboard(); + void dropKey(); }; #endif