From e3792543f6d8b8dd8b0af78194967cc70448873f Mon Sep 17 00:00:00 2001 From: Saturneric Date: Sun, 12 Dec 2021 17:36:08 +0800 Subject: Fixed & Modified & Added. 1. Fixed UTF-16 & UTF-8 filesystem path's bugs. 2. Added mkdir & create empty file. 3. Improve file browser. 4. Added Infoboard.ui. 5. Fixed Verify Bugs. --- src/ui/main_window/MainWindowFileSlotFunction.cpp | 40 +++++++++++++++-------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'src/ui/main_window/MainWindowFileSlotFunction.cpp') diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp index 19be9769..133a7820 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; -- cgit v1.2.3