From df2bce397c1b05c75afb175d340c3fa32614a3a9 Mon Sep 17 00:00:00 2001 From: nils Date: Wed, 29 Dec 2010 15:47:46 +0000 Subject: fixed behaviour in file encryption with existing and non-existing files git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@410 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- fileencryptiondialog.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'fileencryptiondialog.cpp') diff --git a/fileencryptiondialog.cpp b/fileencryptiondialog.cpp index 138a8b4..931aaa3 100755 --- a/fileencryptiondialog.cpp +++ b/fileencryptiondialog.cpp @@ -150,7 +150,6 @@ void FileEncryptionDialog::executeAction() } QByteArray inBuffer = infile.readAll(); - QByteArray *outBuffer = new QByteArray(); if (radioEnc->isChecked()) { @@ -162,6 +161,16 @@ void FileEncryptionDialog::executeAction() } QFile outfile(outputFileEdit->text()); + if (outfile.exists()){ + QMessageBox::StandardButton ret; + ret = QMessageBox::warning(this, tr("File"), + tr("File exists! Do you want to overwrite it?"), + QMessageBox::Ok|QMessageBox::Cancel); + if (ret == QMessageBox::Cancel){ + return; + } + } + if (!outfile.open(QFile::WriteOnly)) { QMessageBox::warning(this, tr("File"), tr("Cannot write file %1:\n%2.") @@ -172,15 +181,8 @@ void FileEncryptionDialog::executeAction() QDataStream out(&outfile); out.writeRawData(outBuffer->data(), outBuffer->length()); - - QMessageBox::StandardButton ret; - ret = QMessageBox::warning(this, tr("File"), - tr("File exists! Do you want to overwrite it?"), - QMessageBox::Ok|QMessageBox::Cancel); - if (ret == QMessageBox::Ok){ - accept(); - QMessageBox::information(0, "Done", "Output saved to " + outputFileEdit->text()); - } + QMessageBox::information(0, "Done", "Output saved to " + outputFileEdit->text()); + accept(); } void FileEncryptionDialog::showKeyList() -- cgit v1.2.3