diff options
author | Saturn&Eric <[email protected]> | 2021-12-13 18:46:23 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-12-13 18:46:23 +0000 |
commit | 5d8e24b7ce4620164c3268b4f1de43a30df19a86 (patch) | |
tree | 6defd5d68468a95de980752ccf2c4ef8a0753617 /src/ui/main_window/MainWindowFileSlotFunction.cpp | |
parent | Create SECURITY.md (diff) | |
parent | Update Translations & README. (diff) | |
download | GpgFrontend-5d8e24b7ce4620164c3268b4f1de43a30df19a86.tar.gz GpgFrontend-5d8e24b7ce4620164c3268b4f1de43a30df19a86.zip |
Merge pull request #32 from saturneric/developv2.0.2
v2.0.2-beta.2
Diffstat (limited to 'src/ui/main_window/MainWindowFileSlotFunction.cpp')
-rw-r--r-- | src/ui/main_window/MainWindowFileSlotFunction.cpp | 60 |
1 files changed, 26 insertions, 34 deletions
diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp index 19be9769..535f47af 100644 --- a/src/ui/main_window/MainWindowFileSlotFunction.cpp +++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp @@ -245,14 +245,16 @@ void MainWindow::slotFileVerify() { signFilePath = path + ".sig"; } - bool ok; - QString text = - QInputDialog::getText(this, _("Origin file to verify"), _("Filepath"), - QLineEdit::Normal, dataFilePath, &ok); - if (ok && !text.isEmpty()) { - dataFilePath = text; - } else { - return; + if (fileInfo.suffix() != "gpg") { + bool ok; + QString text = + QInputDialog::getText(this, _("Origin file to verify"), _("Filepath"), + QLineEdit::Normal, dataFilePath, &ok); + if (ok && !text.isEmpty()) { + dataFilePath = text; + } else { + return; + } } QFileInfo dataFileInfo(dataFilePath), signFileInfo(signFilePath); @@ -395,13 +397,23 @@ void MainWindow::slotFileDecryptVerify() { if (!file_pre_check(this, path)) return; - QString outFileName, fileExtension = QFileInfo(path).suffix(); - - if (fileExtension == "asc" || fileExtension == "gpg") { - int pos = path.lastIndexOf(QChar('.')); - outFileName = path.left(pos); + boost::filesystem::path out_path(path.toStdString()); + if (out_path.extension() == ".asc" || out_path.extension() == ".gpg") { + out_path = out_path.parent_path() / out_path.filename(); } else { - outFileName = path + ".out"; + out_path = out_path.replace_extension(".out").string(); + } + LOG(INFO) << "out path" << out_path; + + if (QFile::exists(out_path.string().c_str())) { + auto ret = + QMessageBox::warning(this, _("Warning"), + QString(_("The output file %1 already exists, do " + "you need to overwrite it?")) + .arg(out_path.filename().string().c_str()), + QMessageBox::Ok | QMessageBox::Cancel); + + if (ret == QMessageBox::Cancel) return; } GpgDecrResult d_result = nullptr; @@ -438,24 +450,4 @@ void MainWindow::slotFileDecryptVerify() { } } -void MainWindow::slotFileEncryptCustom() { - new FileEncryptionDialog(mKeyList->getChecked(), - FileEncryptionDialog::Encrypt, this); -} - -void MainWindow::slotFileDecryptCustom() { - new FileEncryptionDialog(mKeyList->getChecked(), - FileEncryptionDialog::Decrypt, this); -} - -void MainWindow::slotFileSignCustom() { - new FileEncryptionDialog(mKeyList->getChecked(), FileEncryptionDialog::Sign, - this); -} - -void MainWindow::slotFileVerifyCustom() { - new FileEncryptionDialog(mKeyList->getChecked(), FileEncryptionDialog::Verify, - this); -} - } // namespace GpgFrontend::UI |