diff options
author | Mirian Margiani <mixosaurus+ichthyo@pm.me> | 2020-12-20 12:22:38 +0100 |
---|---|---|
committer | Mirian Margiani <mixosaurus+ichthyo@pm.me> | 2020-12-20 12:22:38 +0100 |
commit | 737a8c2f626740ccbbbe504fbc3fdc480fbc594f (patch) | |
tree | c42ff2c70c4689ba0b3da1aff399c3d4eb298cf8 | |
parent | 7f437890d366f1315a9ad81db68f6b9cec560d06 (diff) |
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.
-rw-r--r-- | src/mainwindow.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
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); |