diff options
author | Saturneric <[email protected]> | 2021-07-03 19:49:16 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2021-07-03 19:49:16 +0000 |
commit | f551c5b1958e15fc81ce44a7d2e3165854a2ddef (patch) | |
tree | 0d190388f68999dfae2bcbadc37e1fc26d0a6f02 /src/ui/main_window/MainWindowSlotFunction.cpp | |
parent | Continue to write new function. (diff) | |
download | GpgFrontend-f551c5b1958e15fc81ce44a7d2e3165854a2ddef.tar.gz GpgFrontend-f551c5b1958e15fc81ce44a7d2e3165854a2ddef.zip |
Improve UI; Improve File Opera;
Diffstat (limited to 'src/ui/main_window/MainWindowSlotFunction.cpp')
-rw-r--r-- | src/ui/main_window/MainWindowSlotFunction.cpp | 75 |
1 files changed, 34 insertions, 41 deletions
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp index 106c3cd1..dcc31527 100644 --- a/src/ui/main_window/MainWindowSlotFunction.cpp +++ b/src/ui/main_window/MainWindowSlotFunction.cpp @@ -257,49 +257,52 @@ void MainWindow::slotEncryptSign() { delete resultAnalyseEncr; delete resultAnalyseSign; } else if (edit->slotCurPageFileTreeView() != nullptr) { - this->slotFileVerify(); + this->slotFileEncryptSign(); } } void MainWindow::slotDecryptVerify() { - if (edit->tabCount() == 0 || edit->slotCurPageTextEdit() == nullptr) { - return; - } + if (edit->tabCount() == 0) return; - auto *decrypted = new QByteArray(); - QByteArray text = edit->curTextPage()->toPlainText().toUtf8(); - GpgME::GpgContext::preventNoDataErr(&text); + if (edit->slotCurPageTextEdit() != nullptr) { - gpgme_decrypt_result_t d_result = nullptr; - gpgme_verify_result_t v_result = nullptr; - // try decrypt, if fail do nothing, especially don't replace text - auto error = mCtx->decryptVerify(text, decrypted, &d_result, &v_result); - infoBoard->associateTextEdit(edit->curTextPage()); + auto *decrypted = new QByteArray(); + QByteArray text = edit->curTextPage()->toPlainText().toUtf8(); + GpgME::GpgContext::preventNoDataErr(&text); - if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) - edit->slotFillTextEditWithText(QString::fromUtf8(*decrypted)); + gpgme_decrypt_result_t d_result = nullptr; + gpgme_verify_result_t v_result = nullptr; + // try decrypt, if fail do nothing, especially don't replace text + auto error = mCtx->decryptVerify(text, decrypted, &d_result, &v_result); + infoBoard->associateTextEdit(edit->curTextPage()); - auto resultAnalyseDecrypt = new DecryptResultAnalyse(mCtx, error, d_result); - auto resultAnalyseVerify = new VerifyResultAnalyse(mCtx, error, v_result); + if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) + edit->slotFillTextEditWithText(QString::fromUtf8(*decrypted)); - int status = std::min(resultAnalyseDecrypt->getStatus(), resultAnalyseVerify->getStatus()); - auto &reportText = resultAnalyseDecrypt->getResultReport() + resultAnalyseVerify->getResultReport(); - if (status < 0) - infoBoard->slotRefresh(reportText, INFO_ERROR_CRITICAL); - else if (status > 0) - infoBoard->slotRefresh(reportText, INFO_ERROR_OK); - else - infoBoard->slotRefresh(reportText, INFO_ERROR_WARN); + auto resultAnalyseDecrypt = new DecryptResultAnalyse(mCtx, error, d_result); + auto resultAnalyseVerify = new VerifyResultAnalyse(mCtx, error, v_result); - if (resultAnalyseVerify->getStatus() >= 0) { - infoBoard->resetOptionActionsMenu(); - infoBoard->addOptionalAction("Show Verify Details", [this, error, v_result]() { - VerifyDetailsDialog(this, mCtx, mKeyList, error, v_result); - }); + int status = std::min(resultAnalyseDecrypt->getStatus(), resultAnalyseVerify->getStatus()); + auto &reportText = resultAnalyseDecrypt->getResultReport() + resultAnalyseVerify->getResultReport(); + if (status < 0) + infoBoard->slotRefresh(reportText, INFO_ERROR_CRITICAL); + else if (status > 0) + infoBoard->slotRefresh(reportText, INFO_ERROR_OK); + else + infoBoard->slotRefresh(reportText, INFO_ERROR_WARN); + + if (resultAnalyseVerify->getStatus() >= 0) { + infoBoard->resetOptionActionsMenu(); + infoBoard->addOptionalAction("Show Verify Details", [this, error, v_result]() { + VerifyDetailsDialog(this, mCtx, mKeyList, error, v_result); + }); + } + delete resultAnalyseDecrypt; + delete resultAnalyseVerify; + } else if (edit->slotCurPageFileTreeView() != nullptr) { + this->slotFileDecryptVerify(); } - delete resultAnalyseDecrypt; - delete resultAnalyseVerify; } /* @@ -747,16 +750,6 @@ void MainWindow::slotFileDecryptVerify() { outFileName = path + ".out"; } - if (QFile::exists(outFileName)) { - auto ret = QMessageBox::warning(this, - tr("Warning"), - tr("The target file already exists, do you need to overwrite it?"), - QMessageBox::Ok | QMessageBox::Cancel); - - if (ret == QMessageBox::Cancel) - return; - } - try { gpgme_decrypt_result_t d_result = nullptr; |