diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/AboutDialog.cpp | 30 | ||||
-rw-r--r-- | src/ui/KeyServerImportDialog.cpp | 88 | ||||
-rw-r--r-- | src/ui/KeyUploadDialog.cpp | 125 | ||||
-rw-r--r-- | src/ui/keypair_details/KeyPairDetailTab.cpp | 63 | ||||
-rw-r--r-- | src/ui/keypair_details/KeySetExpireDateDialog.cpp | 6 | ||||
-rw-r--r-- | src/ui/widgets/KeyList.cpp | 103 |
6 files changed, 279 insertions, 136 deletions
diff --git a/src/ui/AboutDialog.cpp b/src/ui/AboutDialog.cpp index 652bb956..e51f225d 100644 --- a/src/ui/AboutDialog.cpp +++ b/src/ui/AboutDialog.cpp @@ -50,21 +50,19 @@ InfoTab::InfoTab(QWidget *parent) : QWidget(parent) { auto *pixmap = new QPixmap(":gpgfrontend-logo.png"); auto *text = new QString("<center><h2>" + qApp->applicationName() + "</h2></center>" - + "<center><b>" + qApp->applicationVersion() + "</b></center>" - + "<center>" + GIT_VERSION + "</center>" - + tr("<br><center>GPGFrontend is a modern, easy-to-use, compact, <br>" - "cross-platform, and installation-free gpg front-end tool.<br>" - "It visualizes most of the common operations of gpg commands.<br>" - "It's licensed under the GPL v3<br><br>" - "<b>Developer:</b><br>" - "Saturneric<br><br>" - "If you have any questions or suggestions have a look<br/>" - "at my <a href=\"https://bktus.com/%e8%81%94%e7%b3%bb%e4%b8%8e%e9%aa%8c%e8%af%81\">" - "contact page</a> or send a mail to my<br/> mailing list at" - " <a href=\"mailto:[email protected]\">[email protected]</a>.") + - tr("<br><br> Built with Qt ") + qVersion() - + tr(" and GPGME ") + GpgME::GpgContext::getGpgmeVersion() + - tr("<br>Built at ") + BUILD_TIMESTAMP + "</center>"); + + "<center><b>" + qApp->applicationVersion() + "</b></center>" + + "<center>" + GIT_VERSION + "</center>" + + tr("<br><center>GPGFrontend is an easy-to-use, compact, <br>" + "cross-platform, and installation-free gpg front-end tool.<br>" + "It visualizes most of the common operations of gpg commands.<br>" + "It's licensed under the GPL v3<br><br>" + "<b>Developer:</b><br>" + "Saturneric<br><br>" + "If you have any questions or suggestions, raise an issue<br/>" + "at <a href=\"https://github.com/saturneric/GpgFrontend\">GitHub</a> or send a mail to my mailing list at <a href=\"mailto:[email protected]\">[email protected]</a>.") + + tr("<br><br> Built with Qt ") + qVersion() + + tr(" and GPGME ") + GpgME::GpgContext::getGpgmeVersion() + + tr("<br>Built at ") + BUILD_TIMESTAMP + "</center>"); auto *layout = new QGridLayout(); auto *pixmapLabel = new QLabel(); @@ -83,7 +81,7 @@ InfoTab::InfoTab(QWidget *parent) TranslatorsTab::TranslatorsTab(QWidget *parent) : QWidget(parent) { QFile translatorsFile; - translatorsFile.setFileName(qApp->applicationDirPath() + "/TRANSLATORS"); + translatorsFile.setFileName(qApp->applicationDirPath() + "/About"); translatorsFile.open(QIODevice::ReadOnly); QByteArray inBuffer = translatorsFile.readAll(); diff --git a/src/ui/KeyServerImportDialog.cpp b/src/ui/KeyServerImportDialog.cpp index 00ff4165..bfa53cce 100644 --- a/src/ui/KeyServerImportDialog.cpp +++ b/src/ui/KeyServerImportDialog.cpp @@ -61,7 +61,7 @@ KeyServerImportDialog::KeyServerImportDialog(GpgME::GpgContext *ctx, KeyList *ke waitingBar->setVisible(false); waitingBar->setRange(0, 0); waitingBar->setFixedHeight(24); - waitingBar->setFixedWidth(260); + waitingBar->setFixedWidth(200); // Layout for messagebox auto *messageLayout = new QHBoxLayout; @@ -82,7 +82,6 @@ KeyServerImportDialog::KeyServerImportDialog(GpgME::GpgContext *ctx, KeyList *ke // 自动化调用界面布局 if(automatic) { mainLayout->addLayout(messageLayout, 0, 0, 1, 3); - mainLayout->addLayout(buttonsLayout, 1, 0, 1, 3); } else { mainLayout->addWidget(searchLabel, 1, 0); mainLayout->addWidget(searchLineEdit, 1, 1); @@ -95,10 +94,13 @@ KeyServerImportDialog::KeyServerImportDialog(GpgME::GpgContext *ctx, KeyList *ke } this->setLayout(mainLayout); - this->setWindowTitle(tr("Import Keys from Keyserver")); + if(automatic) + this->setWindowTitle(tr("Update Keys from Keyserver")); + else + this->setWindowTitle(tr("Import Keys from Keyserver")); if(automatic) { - this->setMinimumHeight(80); + this->setFixedSize(200, 42); } else { // Restore window size & location if (this->settings.value("ImportKeyFromServer/setWindowSize").toBool()) { @@ -206,12 +208,25 @@ void KeyServerImportDialog::slotSearchFinished() { keysTable->setRowCount(0); QString firstLine = QString(reply->readLine(1024)); - QVariant redirectionTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); - if (reply->error()) { - setMessage(tr("<h4>Couldn't contact keyserver!</h4>"), true); - qDebug() << reply->error(); + auto error = reply->error(); + if (error != QNetworkReply::NoError) { + qDebug() << "Error From Reply" << reply->errorString(); + switch (error) { + case QNetworkReply::ContentNotFoundError : + setMessage(tr("Not Key Found"), true); + break; + case QNetworkReply::TimeoutError : + setMessage(tr("Timeout"), true); + break; + case QNetworkReply::HostNotFoundError : + setMessage(tr("Key Server Not Found"), true); + break; + default: + setMessage(tr("Connection Error"), true); + } return; } + if (firstLine.contains("Error")) { QString text = QString(reply->readLine(1024)); if (text.contains("Too many responses")) { @@ -322,6 +337,16 @@ void KeyServerImportDialog::slotImport(const QStringList& keyIds) { slotImport(keyIds, QUrl(keyserver)); } +void KeyServerImportDialog::slotImportKey(const QVector<GpgKey>& keys) { + QString keyserver = settings.value("keyserver/defaultKeyServer").toString(); + qDebug() << "Select Key Server" << keyserver; + auto keyIds = QStringList(); + for(const auto &key : keys) { + keyIds.append(key.id); + } + slotImport(keyIds, QUrl(keyserver)); +} + void KeyServerImportDialog::slotImport(const QStringList& keyIds, const QUrl &keyServerUrl) { for (const auto &keyId : keyIds) { @@ -329,9 +354,9 @@ void KeyServerImportDialog::slotImport(const QStringList& keyIds, const QUrl &ke keyServerUrl.scheme() + "://" + keyServerUrl.host() + "/pks/lookup?op=get&search=0x" + keyId + "&options=mr"); qDebug() << "slotImport reqUrl" << reqUrl; - qnam = new QNetworkAccessManager(this); + auto pManager = new QNetworkAccessManager(this); - QNetworkReply *reply = qnam->get(QNetworkRequest(reqUrl)); + QNetworkReply *reply = pManager->get(QNetworkRequest(reqUrl)); connect(reply, SIGNAL(finished()), this, SLOT(slotImportFinished())); @@ -369,6 +394,9 @@ void KeyServerImportDialog::slotImportFinished() { default: setMessage(tr("Connection Error"), true); } + if(mAutomatic) { + setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint); + } return; } @@ -393,7 +421,7 @@ void KeyServerImportDialog::slotImportFinished() { void KeyServerImportDialog::importKeys(QByteArray inBuffer) { GpgImportInformation result = mCtx->importKey(std::move(inBuffer)); if(mAutomatic) { - new KeyImportDetailDialog(mCtx, result, false, nullptr); + new KeyImportDetailDialog(mCtx, result, false, this); this->accept(); } else { new KeyImportDetailDialog(mCtx, result, false, this); @@ -411,3 +439,41 @@ void KeyServerImportDialog::setLoading(bool status) { message->setVisible(true); } } + +KeyServerImportDialog::KeyServerImportDialog(GpgME::GpgContext *ctx, QWidget *parent) + : QDialog(parent), appPath(qApp->applicationDirPath()), + settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat), + mCtx(ctx), mAutomatic(true) { + + setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint); + + message = new QLabel; + message->setFixedHeight(24); + icon = new QLabel; + icon->setFixedHeight(24); + + // Network Waiting + waitingBar = new QProgressBar(); + waitingBar->setVisible(false); + waitingBar->setRange(0, 0); + waitingBar->setFixedHeight(24); + waitingBar->setFixedWidth(200); + + // Layout for messagebox + auto *messageLayout = new QHBoxLayout; + messageLayout->addWidget(icon); + messageLayout->addWidget(message); + messageLayout->addWidget(waitingBar); + messageLayout->addStretch(); + + keyServerComboBox = createComboBox(); + + auto *mainLayout = new QGridLayout; + + mainLayout->addLayout(messageLayout, 0, 0, 1, 3); + + this->setLayout(mainLayout); + this->setWindowTitle(tr("Upload Keys from Keyserver")); + this->setFixedSize(200, 42); + this->setModal(true); +} diff --git a/src/ui/KeyUploadDialog.cpp b/src/ui/KeyUploadDialog.cpp new file mode 100644 index 00000000..a81ed7a4 --- /dev/null +++ b/src/ui/KeyUploadDialog.cpp @@ -0,0 +1,125 @@ +/** + * This file is part of GPGFrontend. + * + * GPGFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Foobar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from gpg4usb-team. + * Their source code version also complies with GNU General Public License. + * + * The source code version of this software was modified and released + * by Saturneric<[email protected]> starting on May 12, 2021. + * + */ + +#include "ui/KeyUploadDialog.h" + +#include <utility> + +KeyUploadDialog::KeyUploadDialog(GpgME::GpgContext *ctx, const QVector<GpgKey> &keys, QWidget *parent) +: appPath(qApp->applicationDirPath()), +settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat), +QDialog(parent) { + ctx->exportKeys(keys, mKeyData); + uploadKeyToServer(mKeyData); +} + +void KeyUploadDialog::uploadKeyToServer(QByteArray &keys) { + + // set default keyserver + QString keyserver = settings.value("keyserver/defaultKeyServer").toString(); + + QUrl reqUrl(keyserver + "/pks/add"); + auto qnam = new QNetworkAccessManager(this); + + // Building Post Data + QByteArray postData; + + keys.replace("\n", "%0A") + .replace("\r", "%0D") + .replace("(", "%28") + .replace(")", "%29") + .replace("/", "%2F") + .replace(":", "%3A") + .replace("+", "%2B") + .replace('=', "%3D") + .replace(' ', '+'); + + QNetworkRequest request(reqUrl); + request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); + + postData.append("keytext").append("=").append(keys); + + // Send Post Data + QNetworkReply *reply = qnam->post(request, postData); + connect(reply, SIGNAL(finished()), + this, SLOT(slotUploadFinished())); + + + // A Waiting Dialog + auto *dialog = new QDialog(this, Qt::CustomizeWindowHint | Qt::WindowTitleHint); + dialog->setModal(true); + dialog->setWindowTitle(tr("Uploading Public Key")); + dialog->setFixedSize(200, 42); + + auto *pb = new QProgressBar(); + pb->setRange(0, 0); + pb->setFixedSize(200, 24); + + auto *layout = new QVBoxLayout(dialog); + layout->addWidget(pb); + dialog->setLayout(layout); + + dialog->show(); + + // Keep Waiting + while(reply->isRunning()) { + QApplication::processEvents(); + } + + // Done + dialog->hide(); + dialog->close(); +} + +void KeyUploadDialog::slotUploadFinished() { + auto *reply = qobject_cast<QNetworkReply *>(sender()); + + QByteArray response = reply->readAll(); + qDebug() << "Response: " << response.data(); + + auto error = reply->error(); + if (error != QNetworkReply::NoError) { + qDebug() << "Error From Reply" << reply->errorString(); + QString message; + switch (error) { + case QNetworkReply::ContentNotFoundError : + message = tr("Key Not Found"); + break; + case QNetworkReply::TimeoutError : + message = tr("Timeout"); + break; + case QNetworkReply::HostNotFoundError : + message = tr("Key Server Not Found"); + break; + default: + message = tr("Connection Error"); + } + QMessageBox::critical(this, "Upload Failed", message); + return; + } else { + QMessageBox::information(this, "Upload Success", "Upload Public Key Successfully"); + qDebug() << "Success while contacting keyserver!"; + } + reply->deleteLater(); +} diff --git a/src/ui/keypair_details/KeyPairDetailTab.cpp b/src/ui/keypair_details/KeyPairDetailTab.cpp index 97b9cf87..c72a7685 100644 --- a/src/ui/keypair_details/KeyPairDetailTab.cpp +++ b/src/ui/keypair_details/KeyPairDetailTab.cpp @@ -135,9 +135,19 @@ KeyPairDetailTab::KeyPairDetailTab(GpgME::GpgContext *ctx, const GpgKey &mKey, Q vboxPK->addWidget(exportButton); connect(exportButton, SIGNAL(clicked()), this, SLOT(slotExportPrivateKey())); - auto *editExpiresButton = new QPushButton(tr("Modify Expiration Datetime")); - vboxPK->addWidget(editExpiresButton); - connect(editExpiresButton, SIGNAL(clicked()), this, SLOT(slotModifyEditDatetime())); + if(mKey.has_master_key) { + auto *editExpiresButton = new QPushButton(tr("Modify Expiration Datetime")); + vboxPK->addWidget(editExpiresButton); + connect(editExpiresButton, SIGNAL(clicked()), this, SLOT(slotModifyEditDatetime())); + + auto *keyServerOperaButton = new QPushButton(tr("Key Server Operation")); + vboxPK->addWidget(keyServerOperaButton); + connect(keyServerOperaButton, SIGNAL(clicked()), this, SLOT(slotModifyEditDatetime())); + + // Set Menu + createKeyServerOperaMenu(); + keyServerOperaButton->setMenu(keyServerOperaMenu); + } privKeyBox->setLayout(vboxPK); mvbox->addWidget(privKeyBox); @@ -147,19 +157,18 @@ KeyPairDetailTab::KeyPairDetailTab(GpgME::GpgContext *ctx, const GpgKey &mKey, Q if ((mKey.expired) || (mKey.revoked)) { auto *expBox = new QHBoxLayout(); - QIcon icon = QIcon::fromTheme("dialog-warning"); - QPixmap pixmap = icon.pixmap(QSize(32, 32), QIcon::Normal, QIcon::On); + QPixmap pixmap(":warning.png"); auto *expLabel = new QLabel(); auto *iconLabel = new QLabel(); if (mKey.expired) { - expLabel->setText(tr("Warning: The master key of the key pair has expired.")); + expLabel->setText(tr("Warning: The Master Key has expired.")); } if (mKey.revoked) { - expLabel->setText(tr("Warning: The master key of the key pair has been revoked")); + expLabel->setText(tr("Warning: The Master Key has been revoked")); } - iconLabel->setPixmap(pixmap); + iconLabel->setPixmap(pixmap.scaled(24,24,Qt::KeepAspectRatio)); QFont font = expLabel->font(); font.setBold(true); expLabel->setFont(font); @@ -180,10 +189,9 @@ KeyPairDetailTab::KeyPairDetailTab(GpgME::GpgContext *ctx, const GpgKey &mKey, Q void KeyPairDetailTab::slotExportPrivateKey() { // Show a information box with explanation about private key int ret = QMessageBox::information(this, tr("Exporting private Key"), - tr("You are about to export your private key.\n" - "This is NOT your public key, so don't give it away.\n" - "Make sure you keep it save." - "Do you really want to export your private key?"), + tr("<h3>You are about to export your <font color=\"red\">PRIVATE KEY</font>!</h3>\n" + "This is NOT your Public Key, so DON'T give it away.<br />" + "Do you REALLY want to export your PRIVATE KEY?"), QMessageBox::Cancel | QMessageBox::Ok); // export key, if ok was clicked @@ -192,12 +200,12 @@ void KeyPairDetailTab::slotExportPrivateKey() { mCtx->exportSecretKey(*keyid, keyArray); auto &key = mCtx->getKeyById(*keyid); QString fileString = key.name + " " +key.email + "(" + - key.id + ")_pub_sec.asc"; + key.id + ")_secret.asc"; QString fileName = QFileDialog::getSaveFileName(this, tr("Export Key To File"), fileString, tr("Key Files") + " (*.asc *.txt);;All Files (*)"); QFile file(fileName); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { - QMessageBox::critical(nullptr, tr("Export error"), tr("Couldn't open %1 for writing").arg(fileName)); + QMessageBox::critical(nullptr, tr("Export Error"), tr("Couldn't open %1 for writing").arg(fileName)); return; } QTextStream stream(&file); @@ -284,3 +292,30 @@ void KeyPairDetailTab::slotRefreshKeyInfo() { } +void KeyPairDetailTab::createKeyServerOperaMenu() { + keyServerOperaMenu = new QMenu(this); + + auto *uploadKeyPair = new QAction(tr("Upload Key Pair"), this); + connect(uploadKeyPair, SIGNAL(triggered()), this, SLOT(slotUploadKeyToServer())); + auto *updateKeyPair = new QAction(tr("Update Key Pair"), this); + connect(updateKeyPair, SIGNAL(triggered()), this, SLOT(slotUpdateKeyToServer())); + + keyServerOperaMenu->addAction(uploadKeyPair); + // TODO Solve Refresh Problem +// keyServerOperaMenu->addAction(updateKeyPair); +} + +void KeyPairDetailTab::slotUploadKeyToServer() { + QVector<GpgKey> keys; + keys.append(mKey); + auto *dialog = new KeyUploadDialog(mCtx, keys); +} + +void KeyPairDetailTab::slotUpdateKeyToServer() { + QVector<GpgKey> keys; + keys.append(mKey); + auto *dialog = new KeyServerImportDialog(mCtx, this); + dialog->show(); + dialog->slotImportKey(keys); +} + diff --git a/src/ui/keypair_details/KeySetExpireDateDialog.cpp b/src/ui/keypair_details/KeySetExpireDateDialog.cpp index 67238685..f76fa3ab 100644 --- a/src/ui/keypair_details/KeySetExpireDateDialog.cpp +++ b/src/ui/keypair_details/KeySetExpireDateDialog.cpp @@ -37,9 +37,9 @@ QDialog(parent), mKey(key), mSubkey(subkey), mCtx(ctx) { auto *gridLayout = new QGridLayout(); gridLayout->addWidget(dateTimeEdit, 0, 0, 1, 2); - gridLayout->addWidget(nonExpiredCheck, 1, 0, 1, 1, Qt::AlignRight); - gridLayout->addWidget(new QLabel(tr("Never Expire"))); - gridLayout->addWidget(confirmButton, 2, 0); + gridLayout->addWidget(nonExpiredCheck, 0, 2, 1, 1, Qt::AlignRight); + gridLayout->addWidget(new QLabel(tr("Never Expire")), 0, 3); + gridLayout->addWidget(confirmButton, 1, 3); connect(nonExpiredCheck, SIGNAL(stateChanged(int)), this, SLOT(slotNonExpiredChecked(int))); connect(confirmButton, SIGNAL(clicked(bool)), this, SLOT(slotConfirm())); diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp index 4f0fe1c3..6982c3a2 100644 --- a/src/ui/widgets/KeyList.cpp +++ b/src/ui/widgets/KeyList.cpp @@ -305,14 +305,12 @@ void KeyList::addMenuAction(QAction *act) void KeyList::dropEvent(QDropEvent* event) { -// importKeyDialog(); - QSettings settings; auto *dialog = new QDialog(); dialog->setWindowTitle(tr("Import Keys")); QLabel *label; - label = new QLabel(tr("You've dropped something on the keylist.\n gpg4usb will now try to import key(s).")+"\n"); + label = new QLabel(tr("You've dropped something on the table.\n GpgFrontend will now try to import key(s).")+"\n"); // "always import keys"-CheckBox auto *checkBox = new QCheckBox(tr("Always import without bothering.")); @@ -346,7 +344,7 @@ void KeyList::dropEvent(QDropEvent* event) if (event->mimeData()->hasUrls()) { - foreach (QUrl tmp, event->mimeData()->urls()) + for (const QUrl& tmp : event->mimeData()->urls()) { QFile file; file.setFileName(tmp.toLocalFile()); @@ -384,94 +382,6 @@ void KeyList::importKeys(QByteArray inBuffer) new KeyImportDetailDialog(mCtx, result, false, this); } -void KeyList::uploadKeyToServer(QByteArray *keys) { - - // set default keyserver - QString keyserver = settings.value("keyserver/defaultKeyServer").toString(); - - QUrl reqUrl(keyserver + "/pks/add"); - qnam = new QNetworkAccessManager(this); - - // Building Post Data - QByteArray postData; - - keys->replace("\n", "%0A") - .replace("\r", "%0D") - .replace("(", "%28") - .replace(")", "%29") - .replace("/", "%2F") - .replace(":", "%3A") - .replace("+", "%2B") - .replace('=', "%3D") - .replace(' ', '+'); - - QNetworkRequest request(reqUrl); - request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); - - postData.append("keytext").append("=").append(*keys); - - // Send Post Data - QNetworkReply *reply = qnam->post(request, postData); - connect(reply, SIGNAL(finished()), - this, SLOT(uploadFinished())); - - - // A Waiting Dialog - auto *dialog = new QDialog(this, Qt::CustomizeWindowHint | Qt::WindowTitleHint); - dialog->setModal(true); - dialog->setWindowTitle(tr("Uploading Public Key...")); - - auto *pb = new QProgressBar(); - pb->setRange(0, 0); - pb->setFixedSize(260, 24); - - auto *layout = new QVBoxLayout(dialog); - layout->addWidget(pb); - dialog->setLayout(layout); - - dialog->show(); - - // Keep Waiting - while(reply->isRunning()) { - QApplication::processEvents(); - } - - // Done - dialog->hide(); - dialog->close(); -} -void KeyList::uploadFinished() { - auto *reply = qobject_cast<QNetworkReply *>(sender()); - - QByteArray response = reply->readAll(); - qDebug() << "Response: " << response.data(); - - auto error = reply->error(); - if (error != QNetworkReply::NoError) { - qDebug() << "Error From Reply" << reply->errorString(); - QString message; - switch (error) { - case QNetworkReply::ContentNotFoundError : - message = tr("Key Not Found"); - break; - case QNetworkReply::TimeoutError : - message = tr("Timeout"); - break; - case QNetworkReply::HostNotFoundError : - message = tr("Key Server Not Found"); - break; - default: - message = tr("Connection Error"); - } - QMessageBox::critical(nullptr, "Upload Failed", message); - return; - } else { - QMessageBox::information(nullptr, "Upload Success", "Upload Public Key Successfully"); - qDebug() << "Success while contacting keyserver!"; - } - reply->deleteLater(); -} - void KeyList::getCheckedKeys(QVector<GpgKey> &keys) { keys.clear(); for (int i = 0; i < mKeyList->rowCount(); i++) { @@ -512,3 +422,12 @@ void KeyList::getPrivateCheckedKeys(QVector<GpgKey> &keys) { } } } + +GpgKey KeyList::getSelectedKey() { + for (int i = 0; i < mKeyList->rowCount(); i++) { + if (mKeyList->item(i, 0)->isSelected() == 1) { + return buffered_keys[i]; + } + } + return GpgKey(); +} |