From 737a8c2f626740ccbbbe504fbc3fdc480fbc594f Mon Sep 17 00:00:00 2001 From: Mirian Margiani Date: Sun, 20 Dec 2020 12:22:38 +0100 Subject: Explicitly only remove ".gpg" when renaming files QFileInfo::baseName removes the path plus the complete suffix. The alternative QFileInfo::completeBaseName would only remove the last suffix (e.g. ".gz" in "foo.tar.gz") but we want to remove ".gpg" only. --- src/mainwindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5279610f..d792c6ed 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1018,7 +1018,10 @@ void MainWindow::renamePassword() { bool ok; QString file = getFile(ui->treeView->currentIndex(), false); QString filePath = QFileInfo(file).path(); - QString fileName = QFileInfo(file).baseName(); + QString fileName = QFileInfo(file).fileName(); + if (fileName.endsWith(".gpg", Qt::CaseInsensitive)) + fileName.chop(4); + QString newName = QInputDialog::getText(this, tr("Rename file"), tr("Rename File To: "), QLineEdit::Normal, fileName, &ok); -- cgit v1.2.3