aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/FileEncryptionDialog.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2021-06-05 20:57:30 +0000
committerSaturneric <[email protected]>2021-06-05 20:57:30 +0000
commit9c09b5de5180632746d9fc7f75a3ed7f07b06292 (patch)
tree89c1e21762f04b4e383ff7f2f45c280b2c5e67ce /src/ui/FileEncryptionDialog.cpp
parentUpdate the verification function. (diff)
downloadGpgFrontend-9c09b5de5180632746d9fc7f75a3ed7f07b06292.tar.gz
GpgFrontend-9c09b5de5180632746d9fc7f75a3ed7f07b06292.zip
Adjust and improve the detailed interface of the verification information result.
Check whether the key can be signed before signing operation. Check whether the key is qualified before encrypting and signing operations. Modify part of the text explanation on the key details tab. Adjust the length and width of the key pair management interface. Add the actual function column to the list on the file operation page. Adjust the file operation page. For the function that displays the actual possession of the key in the key list by default. Add the function of displaying the actual possession of the key in the key details page. Adjust the code structure. Convert the label prompt below into a message board prompt. Signed-off-by: Saturneric <[email protected]>
Diffstat (limited to '')
-rwxr-xr-xsrc/ui/FileEncryptionDialog.cpp59
1 files changed, 39 insertions, 20 deletions
diff --git a/src/ui/FileEncryptionDialog.cpp b/src/ui/FileEncryptionDialog.cpp
index 97e0d357..d4c0d6d1 100755
--- a/src/ui/FileEncryptionDialog.cpp
+++ b/src/ui/FileEncryptionDialog.cpp
@@ -26,21 +26,16 @@
FileEncryptionDialog::FileEncryptionDialog(GpgME::GpgContext *ctx, QStringList keyList, DialogAction action,
QWidget *parent)
- : QDialog(parent) {
- mAction = action;
- mCtx = ctx;
+ : QDialog(parent), mAction(action), mCtx(ctx){
+
if (mAction == Decrypt) {
setWindowTitle(tr("Decrypt File"));
- resize(500, 200);
} else if (mAction == Encrypt) {
setWindowTitle(tr("Encrypt File"));
- resize(500, 400);
} else if (mAction == Sign) {
setWindowTitle(tr("Sign File"));
- resize(500, 400);
} else if (mAction == Verify) {
setWindowTitle(tr("Verify File"));
- resize(500, 200);
}
setModal(true);
@@ -49,19 +44,19 @@ FileEncryptionDialog::FileEncryptionDialog(GpgME::GpgContext *ctx, QStringList k
connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotExecuteAction()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
- auto *groupBox1 = new QGroupBox(tr("File"));
+ auto *groupBox1 = new QGroupBox(tr("Input Parameters"));
/* Setup input & Outputfileselection*/
inputFileEdit = new QLineEdit();
- auto *fb1 = new QPushButton("...");
+ auto *fb1 = new QPushButton("Select");
connect(fb1, SIGNAL(clicked()), this, SLOT(slotSelectInputFile()));
- auto *fl1 = new QLabel(tr("Input"));
+ auto *fl1 = new QLabel(tr("Target File"));
fl1->setBuddy(inputFileEdit);
outputFileEdit = new QLineEdit();
- auto *fb2 = new QPushButton("...");
+ auto *fb2 = new QPushButton("Select");
connect(fb2, SIGNAL(clicked()), this, SLOT(slotSelectOutputFile()));
- auto *fl2 = new QLabel(tr("Output"));
+ auto *fl2 = new QLabel(tr("Output File"));
fl2->setBuddy(outputFileEdit);
auto *gLayout = new QGridLayout();
@@ -75,9 +70,9 @@ FileEncryptionDialog::FileEncryptionDialog(GpgME::GpgContext *ctx, QStringList k
gLayout->addWidget(outputFileEdit, 1, 1);
gLayout->addWidget(fb2, 1, 2);
} else {
- auto *sfb1 = new QPushButton("...");
+ auto *sfb1 = new QPushButton("Select");
connect(sfb1, SIGNAL(clicked()), this, SLOT(slotSelectSignFile()));
- auto *sfl1 = new QLabel(tr("Signature"));
+ auto *sfl1 = new QLabel(tr("Signature File(.sig) Path"));
sfl1->setBuddy(signFileEdit);
gLayout->addWidget(sfl1, 1, 0);
@@ -87,7 +82,30 @@ FileEncryptionDialog::FileEncryptionDialog(GpgME::GpgContext *ctx, QStringList k
groupBox1->setLayout(gLayout);
/*Setup KeyList*/
- mKeyList = new KeyList(mCtx, KeyListRow::ONLY_SECRET_KEY, KeyListColumn::NAME | KeyListColumn::EmailAddress);
+ mKeyList = new KeyList(mCtx, KeyListRow::ONLY_SECRET_KEY,
+ KeyListColumn::NAME | KeyListColumn::EmailAddress | KeyListColumn::Usage);
+ if(mAction == Verify)
+ mKeyList->setFilter([](const GpgKey &key) -> bool {
+ if(key.disabled || key.expired || key.revoked) return false;
+ else return true;
+ });
+
+ if(mAction == Encrypt)
+ mKeyList->setFilter([](const GpgKey &key) -> bool {
+ if(!GpgME::GpgContext::checkIfKeyCanEncr(key)) return false;
+ else return true;
+ });
+
+ if(mAction == Sign)
+ mKeyList->setFilter([](const GpgKey &key) -> bool {
+ if(!GpgME::GpgContext::checkIfKeyCanSign(key)) return false;
+ else return true;
+ });
+
+ if(mAction == Decrypt)
+ mKeyList->setDisabled(true);
+
+ mKeyList->slotRefresh();
mKeyList->setChecked(&keyList);
statusLabel = new QLabel();
@@ -101,11 +119,9 @@ FileEncryptionDialog::FileEncryptionDialog(GpgME::GpgContext *ctx, QStringList k
vbox2->addStretch(0);
setLayout(vbox2);
- if (action == Encrypt || action == Sign) {
- slotShowKeyList();
- }
+ this->setMinimumWidth(480);
+ this->show();
- exec();
}
void FileEncryptionDialog::slotSelectInputFile() {
@@ -192,7 +208,10 @@ void FileEncryptionDialog::slotExecuteAction() {
}
if (mAction == Sign) {
- if (!mCtx->sign(mKeyList->getChecked(), inBuffer, outBuffer, true)) return;
+ QVector<GpgKey> keys;
+ mKeyList->getCheckedKeys(keys);
+ if (!mCtx->sign(keys, inBuffer, outBuffer, true)) return;
+
}
if (mAction == Verify) {