]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Use same logic for "no extension" case with Duplicate feature
authorNate Graham <nate@kde.org>
Mon, 23 Mar 2020 19:42:48 +0000 (13:42 -0600)
committerNate Graham <nate@kde.org>
Sun, 5 Apr 2020 22:48:51 +0000 (16:48 -0600)
Summary:
In the "no extension" case, we weren't separating out the path and the original filename,
breaking the feature for languages where the word "copy" would be at the beginning of the
filename, not after it (e.g. "copia de foo" in Spanish, and similar in other romance
languages). This patch fixes that by separating the original path and filename in the no
extension case as is done for the other case, which should solve the issue.

BUG: 419070
FIXED-IN: 20.04.0

Test Plan:
No changes in English; should fix the issue in Spanish once new translations are done
(see https://bugs.kde.org/show_bug.cgi?id=419070 for details)

Reviewers: #dolphin, elvisangelaccio, arojas, meven, pino, #localization

Reviewed By: #dolphin, elvisangelaccio

Subscribers: aacid, kfm-devel

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D28227

src/views/dolphinview.cpp

index 2f9f2a3869848e7ebcae80a811cf8d6c35e42776..d8f2aab937bc84f33f8e93a95fb5e1ffee80b892 100644 (file)
@@ -719,24 +719,25 @@ void DolphinView::duplicateSelectedItems()
     QList<QUrl> newSelection;
     for (const auto &item : itemList) {
         const QUrl originalURL  = item.url();
+        const QString originalDirectoryPath = originalURL.adjusted(QUrl::RemoveFilename).path();
         const QString originalFileName = item.name();
+
         QString extension = db.suffixForFileName(originalFileName);
 
         QUrl duplicateURL = originalURL;
 
         // No extension; new filename is "<oldfilename> copy"
         if (extension.isEmpty()) {
-            duplicateURL.setPath(i18nc("<file path> copy", "%1 copy", originalURL.path()));
+            duplicateURL.setPath(originalDirectoryPath + i18nc("<filename> copy", "%1 copy", originalFileName));
         // There's an extension; new filename is "<oldfilename> copy.<extension>"
         } else {
             // Need to add a dot since QMimeDatabase::suffixForFileName() doesn't include it
             extension = QLatin1String(".") + extension;
-            const QString directoryPath = originalURL.adjusted(QUrl::RemoveFilename).path();
             const QString originalFilenameWithoutExtension = originalFileName.chopped(extension.size());
             // Preserve file's original filename extension in case the casing differs
             // from what QMimeDatabase::suffixForFileName() returned
             const QString originalExtension = originalFileName.right(extension.size());
-            duplicateURL.setPath(i18nc("<file path><filename> copy.<extension>", "%1%2 copy%3", directoryPath, originalFilenameWithoutExtension, originalExtension));
+            duplicateURL.setPath(originalDirectoryPath + i18nc("<filename> copy", "%1 copy", originalFilenameWithoutExtension) + originalExtension);
         }
 
         KIO::CopyJob* job = KIO::copyAs(originalURL, duplicateURL, KIO::HideProgressInfo);