Changeset View
Changeset View
Standalone View
Standalone View
src/filewidgets/knewfilemenu.cpp
Show First 20 Lines • Show All 454 Lines • ▼ Show 20 Line(s) | 416 | for (; it != m_popupFiles.constEnd(); ++it) { | |||
---|---|---|---|---|---|
455 | dlg->show(); | 455 | dlg->show(); | ||
456 | } | 456 | } | ||
457 | // We don't set m_src here -> there will be no copy, we are done. | 457 | // We don't set m_src here -> there will be no copy, we are done. | ||
458 | } | 458 | } | ||
459 | 459 | | |||
460 | void KNewFileMenuPrivate::executeRealFileOrDir(const KNewFileMenuSingleton::Entry &entry) | 460 | void KNewFileMenuPrivate::executeRealFileOrDir(const KNewFileMenuSingleton::Entry &entry) | ||
461 | { | 461 | { | ||
462 | // The template is not a desktop file | 462 | // The template is not a desktop file | ||
463 | // Show the small dialog for getting the destination filename | 463 | // Prompt the user to set the destination filename | ||
464 | QString text = entry.text; | 464 | QString text = entry.text; | ||
465 | text.remove(QStringLiteral("...")); // the ... is fine for the menu item but not for the default filename | 465 | text.remove(QStringLiteral("...")); // the ... is fine for the menu item but not for the default filename | ||
466 | text = text.trimmed(); // In some languages, there is a space in front of "...", see bug 268895 | 466 | text = text.trimmed(); // In some languages, there is a space in front of "...", see bug 268895 | ||
467 | // add the extension (from the templatePath), should work with .txt, .html and with ".tar.gz"... etc | ||||
dfaure: typo: extenstion -> extension | |||||
"use the translation" is done before that comment, so it's a bit of a confusing place for it. dfaure: "use the translation" is done before that comment, so it's a bit of a confusing place for it. | |||||
468 | const QString fileName = entry.templatePath.mid(entry.templatePath.lastIndexOf(QLatin1Char('/'))); | ||||
469 | const int dotIndex = fileName.indexOf(QLatin1Char('.')); | ||||
The old code was using a translated string as suggested file name. How about appending the extension from templatePath to the translated text? dfaure: The old code was using a translated string as suggested file name.
You're using a filename that… | |||||
470 | text += dotIndex > 0 ? fileName.midRef(dotIndex) : QStringRef(); | ||||
text += fileName.midRef(....); This also assumes all those files always have an extension.... mid(-1) returns the whole string. dfaure: text += fileName.midRef(....);
This also assumes all those files always have an extension.... | |||||
471 | | ||||
467 | m_copyData.m_src = entry.templatePath; | 472 | m_copyData.m_src = entry.templatePath; | ||
468 | 473 | | |||
469 | const QUrl directory = mostLocalUrl(m_popupFiles.first()); | 474 | const QUrl directory = mostLocalUrl(m_popupFiles.first()); | ||
470 | const QUrl defaultFile = QUrl::fromLocalFile(directory.toLocalFile() + QLatin1Char('/') + KIO::encodeFileName(text)); | 475 | const QUrl defaultFile = QUrl::fromLocalFile(directory.toLocalFile() + QLatin1Char('/') + KIO::encodeFileName(text)); | ||
471 | if (defaultFile.isLocalFile() && QFile::exists(defaultFile.toLocalFile())) { | 476 | if (defaultFile.isLocalFile() && QFile::exists(defaultFile.toLocalFile())) { | ||
472 | text = KFileUtils::suggestName(directory, text); | 477 | text = KFileUtils::suggestName(directory, text); | ||
473 | } | 478 | } | ||
474 | 479 | | |||
▲ Show 20 Lines • Show All 934 Lines • Show Last 20 Lines |
typo: extenstion -> extension