aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/widgets/KeyList.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2021-06-23 08:14:31 +0000
committerSaturneric <[email protected]>2021-06-23 08:14:31 +0000
commitf96179e926ee8733ed3bd8c8b950cb24f57e46d5 (patch)
treeaae77ffa5d4a1636d0778c67c9d573a74bde220f /src/ui/widgets/KeyList.cpp
parentFix Problem in Project Configuration. (diff)
downloadGpgFrontend-f96179e926ee8733ed3bd8c8b950cb24f57e46d5.tar.gz
GpgFrontend-f96179e926ee8733ed3bd8c8b950cb24f57e46d5.zip
UI Improved.
Bugs Fixed.
Diffstat (limited to 'src/ui/widgets/KeyList.cpp')
-rw-r--r--src/ui/widgets/KeyList.cpp103
1 files changed, 11 insertions, 92 deletions
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();
+}