aboutsummaryrefslogtreecommitdiffstats
path: root/fileencryptiondialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fileencryptiondialog.cpp')
-rwxr-xr-xfileencryptiondialog.cpp65
1 files changed, 59 insertions, 6 deletions
diff --git a/fileencryptiondialog.cpp b/fileencryptiondialog.cpp
index b4eb6da..d81d3fd 100755
--- a/fileencryptiondialog.cpp
+++ b/fileencryptiondialog.cpp
@@ -29,14 +29,16 @@ FileEncryptionDialog::FileEncryptionDialog(GpgME::GpgContext *ctx, QStringList k
mCtx = ctx;
if (mAction == Decrypt) {
setWindowTitle(tr("Decrypt File"));
+ resize(500, 200);
} else if (mAction == Encrypt) {
setWindowTitle(tr("Encrypt File"));
- resize(500, 300);
+ resize(500, 400);
} else if (mAction == Sign) {
setWindowTitle(tr("Sign File"));
- resize(500, 300);
+ resize(500, 400);
} else if (mAction == Verify) {
setWindowTitle(tr("Verify File"));
+ resize(500, 200);
}
setModal(true);
@@ -64,11 +66,21 @@ FileEncryptionDialog::FileEncryptionDialog(GpgME::GpgContext *ctx, QStringList k
gLayout->addWidget(fl1, 0, 0);
gLayout->addWidget(inputFileEdit, 0, 1);
gLayout->addWidget(fb1, 0, 2);
- // verify does not need outfile
+ // verify does not need outfile, but signature file
if(mAction != Verify) {
gLayout->addWidget(fl2, 1, 0);
gLayout->addWidget(outputFileEdit, 1, 1);
gLayout->addWidget(fb2, 1, 2);
+ } else {
+ signFileEdit = new QLineEdit();
+ QPushButton *sfb1 = new QPushButton("...");
+ connect(sfb1, SIGNAL(clicked()), this, SLOT(slotSelectSignFile()));
+ QLabel *sfl1 = new QLabel(tr("Signature"));
+ sfl1->setBuddy(signFileEdit);
+
+ gLayout->addWidget(sfl1, 1, 0);
+ gLayout->addWidget(signFileEdit, 1, 1);
+ gLayout->addWidget(sfb1, 1, 2);
}
groupBox1->setLayout(gLayout);
@@ -79,9 +91,13 @@ FileEncryptionDialog::FileEncryptionDialog(GpgME::GpgContext *ctx, QStringList k
mKeyList->setColumnWidth(3, 150);
mKeyList->setChecked(&keyList);
+ statusLabel = new QLabel();
+ statusLabel->setStyleSheet("QLabel {color: red;}");
+
QVBoxLayout *vbox2 = new QVBoxLayout();
vbox2->addWidget(groupBox1);
vbox2->addWidget(mKeyList);
+ vbox2->addWidget(statusLabel);
vbox2->addWidget(buttonBox);
vbox2->addStretch(0);
setLayout(vbox2);
@@ -105,11 +121,15 @@ void FileEncryptionDialog::slotSelectInputFile()
inputFileEdit->setText(infileName);
// try to find a matching output-filename, if not yet done
- if (infileName > 0 && outputFileEdit->text().size() == 0) {
+ if (infileName > 0
+ && outputFileEdit->text().size() == 0
+ && signFileEdit->text().size() == 0) {
if (mAction == Encrypt) {
outputFileEdit->setText(infileName + ".asc");
} else if (mAction == Sign) {
outputFileEdit->setText(infileName + ".sig");
+ } else if (mAction == Verify) {
+ signFileEdit->setText(infileName + ".sig");
} else {
if (infileName.endsWith(".asc", Qt::CaseInsensitive)) {
QString ofn = infileName;
@@ -134,13 +154,33 @@ void FileEncryptionDialog::slotSelectOutputFile()
}
+void FileEncryptionDialog::slotSelectSignFile()
+{
+ QString path = "";
+ if (signFileEdit->text().size() > 0) {
+ path = QFileInfo(signFileEdit->text()).absolutePath();
+ }
+
+ QString signfileName = QFileDialog::getSaveFileName(this, tr("Open File"),path, NULL ,NULL ,QFileDialog::DontConfirmOverwrite);
+ signFileEdit->setText(signfileName);
+
+ if (inputFileEdit->text().size() == 0 && signfileName.endsWith(".sig", Qt::CaseInsensitive)) {
+ QString sfn = signfileName;
+ sfn.chop(4);
+ inputFileEdit->setText(sfn);
+ }
+
+}
+
void FileEncryptionDialog::slotExecuteAction()
{
QFile infile;
infile.setFileName(inputFileEdit->text());
if (!infile.open(QIODevice::ReadOnly)) {
- qDebug() << tr("Couldn't Open file: ") + inputFileEdit->text();
+ statusLabel->setText( tr("Couldn't open file"));
+ inputFileEdit->setStyleSheet("QLineEdit { background: yellow }");
+ return;
}
QByteArray inBuffer = infile.readAll();
@@ -155,7 +195,20 @@ void FileEncryptionDialog::slotExecuteAction()
}
if( mAction == Sign ) {
- mCtx->sign(mKeyList->getChecked(), inBuffer, outBuffer, true);
+ if(! mCtx->sign(mKeyList->getChecked(), inBuffer, outBuffer, true)) return;
+ }
+
+ if( mAction == Verify ) {
+ QFile signfile;
+ signfile.setFileName(signFileEdit->text());
+ if (!signfile.open(QIODevice::ReadOnly)) {
+ statusLabel->setText( tr("Couldn't open file"));
+ signFileEdit->setStyleSheet("QLineEdit { background: yellow }");
+ return;
+ }
+ QByteArray signBuffer = signfile.readAll();
+ new VerifyDetailsDialog(this, mCtx, mKeyList, &inBuffer, &signBuffer);
+ return;
}
QFile outfile(outputFileEdit->text());