diff options
author | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-06-24 10:15:16 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-06-24 09:22:42 +0000 |
commit | 1e589e37a991b29076e9a661f92dfa178421c208 (patch) | |
tree | ccdae70edb75b1bc17f0efc61086e16554e3f4eb /src/libs | |
parent | 65a5d4d33c7dcb27ce99ce59535733a28991c544 (diff) |
Unify translated error messages
* Enclose file paths in ""
* Localize file paths with QDir::toNativeSeparators.
* Make sure sentences end with a '.'
* Append error details always by ':', e.g.
tr("Failed to copy file '%1': %2").(...)
* Use 'directory' instead of 'folder' everywhere
Change-Id: Ie045f429f72ad5045c96537465c5fb9d2e99d250
Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
Diffstat (limited to 'src/libs')
52 files changed, 419 insertions, 342 deletions
diff --git a/src/libs/installer/adminauthorization_win.cpp b/src/libs/installer/adminauthorization_win.cpp index 56d912ae7..3f2155d35 100644 --- a/src/libs/installer/adminauthorization_win.cpp +++ b/src/libs/installer/adminauthorization_win.cpp @@ -112,14 +112,14 @@ bool AdminAuthorization::execute(QWidget *, const QString &program, const QStrin shellExecuteInfo.lpParameters = (wchar_t *)args.utf16(); shellExecuteInfo.fMask = SEE_MASK_NOASYNC; - qDebug() << QString::fromLatin1("Starting elevated process %1 with arguments: %2.").arg(file, args); + qDebug() << QString::fromLatin1("Starting elevated process \"%1\" with arguments \"%2\".").arg(file, args); if (ShellExecuteExW(&shellExecuteInfo)) { qDebug() << "Finished starting elevated process."; return true; } else { - qWarning() << QString::fromLatin1("Error while starting elevated process: %1, " - "Error: %2").arg(program, QInstaller::windowsErrorString(GetLastError())); + qWarning() << QString::fromLatin1("Error while starting elevated process %1: %2").arg( + program, QInstaller::windowsErrorString(GetLastError())); } return false; } diff --git a/src/libs/installer/binarycontent.cpp b/src/libs/installer/binarycontent.cpp index 0aa3de84b..dc8753e43 100644 --- a/src/libs/installer/binarycontent.cpp +++ b/src/libs/installer/binarycontent.cpp @@ -119,7 +119,7 @@ BinaryLayout BinaryContent::binaryLayout(QFile *file, quint64 magicCookie) const qint64 posOfMetaDataCount = layout.endOfBinaryContent - (4 * sizeof(qint64)); if (!file->seek(posOfMetaDataCount)) { throw QInstaller::Error(QCoreApplication::translate("BinaryLayout", - "Could not seek to %1 to read the embedded meta data count.").arg(posOfMetaDataCount)); + "Cannot seek to %1 to read the embedded meta data count.").arg(posOfMetaDataCount)); } // read the meta resources count @@ -130,7 +130,7 @@ BinaryLayout BinaryContent::binaryLayout(QFile *file, quint64 magicCookie) + (8 * sizeof(qint64))); // meta count, offset/length collection index, marker, cookie... if (!file->seek(posOfResourceCollectionsSegment)) { throw Error(QCoreApplication::translate("BinaryLayout", - "Could not seek to %1 to read the resource collection segment.") + "Cannot seek to %1 to read the resource collection segment.") .arg(posOfResourceCollectionsSegment)); } @@ -205,7 +205,7 @@ void BinaryContent::readBinaryContent(QFile *file, QList<OperationBlob> *operati const qint64 posOfOperationsBlock = layout.operationsSegment.start(); if (!file->seek(posOfOperationsBlock)) { throw Error(QCoreApplication::translate("BinaryContent", - "Could not seek to %1 to read the operation data.").arg(posOfOperationsBlock)); + "Cannot seek to %1 to read the operation data.").arg(posOfOperationsBlock)); } // read the operations count qint64 operationsCount = QInstaller::retrieveInt64(file); @@ -222,7 +222,7 @@ void BinaryContent::readBinaryContent(QFile *file, QList<OperationBlob> *operati if (manager) { // read the collection index and data const qint64 posOfResourceCollectionBlock = layout.resourceCollectionsSegment.start(); if (!file->seek(posOfResourceCollectionBlock)) { - throw Error(QCoreApplication::translate("BinaryContent", "Could not seek to %1 to " + throw Error(QCoreApplication::translate("BinaryContent", "Cannot seek to %1 to " "read the resource collection block.").arg(posOfResourceCollectionBlock)); } manager->read(file, layout.endOfExectuable); @@ -261,7 +261,7 @@ void BinaryContent::writeBinaryContent(QFile *out, const QList<OperationBlob> &o const bool isOpen = resource->isOpen(); if ((!isOpen) && (!resource->open())) { throw Error(QCoreApplication::translate("BinaryContent", - "Could not open meta resource. Error: %1").arg(resource->errorString())); + "Cannot open meta resource %1.").arg(resource->errorString())); } resource->seek(0); diff --git a/src/libs/installer/binaryformat.cpp b/src/libs/installer/binaryformat.cpp index 425767954..998f937ea 100644 --- a/src/libs/installer/binaryformat.cpp +++ b/src/libs/installer/binaryformat.cpp @@ -170,7 +170,7 @@ bool Resource::open() } if (!QIODevice::open(QIODevice::ReadOnly)) { - setErrorString(tr("Could not open Resource '%1' read-only.").arg(QString::fromUtf8(m_name))); + setErrorString(tr("Cannot open resource %1 for reading.").arg(QString::fromUtf8(m_name))); return false; } return true; @@ -398,7 +398,7 @@ Range<qint64> ResourceCollectionManager::write(QFileDevice *out, qint64 offset) foreach (const QSharedPointer<Resource> &resource, collection.resources()) { if (!resource->open()) { - throw QInstaller::Error(tr("Could not open resource %1: %2") + throw QInstaller::Error(tr("Cannot open resource %1: %2") .arg(QString::fromUtf8(resource->name()), resource->errorString())); } resource->copyData(out); diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index 02a8b2c5f..9b8c2a430 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -565,8 +565,8 @@ void Component::loadUserInterfaces(const QDir &directory, const QStringList &uis while (it.hasNext()) { QFile file(it.next()); if (!file.open(QIODevice::ReadOnly)) { - throw Error(tr("Could not open the requested UI file '%1'. Error: %2").arg(it.fileName(), - file.errorString())); + throw Error(tr("Cannot open the requested UI file \"%1\": %2").arg( + it.fileName(), file.errorString())); } static QUiLoader loader; @@ -574,8 +574,8 @@ void Component::loadUserInterfaces(const QDir &directory, const QStringList &uis loader.setLanguageChangeEnabled(true); QWidget *const widget = loader.load(&file, 0); if (!widget) { - throw Error(tr("Could not load the requested UI file '%1'. Error: %2").arg(it.fileName(), - loader.errorString())); + throw Error(tr("Cannot load the requested UI file \"%1\": %2").arg( + it.fileName(), loader.errorString())); } d->scriptEngine()->newQObject(widget); d->m_userInterfaces.insert(widget->objectName(), widget); @@ -609,8 +609,8 @@ void Component::loadLicenses(const QString &directory, const QHash<QString, QVar << ". Using untranslated fallback."; file.setFileName(directory + fileName); if (!file.open(QIODevice::ReadOnly)) { - throw Error(tr("Could not open the requested license file '%1'. Error: %2").arg(fileName, - file.errorString())); + throw Error(tr("Cannot open the requested license file \"%1\": %2").arg( + fileName, file.errorString())); } } QTextStream stream(&file); @@ -974,7 +974,7 @@ Operation *Component::createOperation(const QString &operationName, const QStrin if (operation == 0) { const QMessageBox::StandardButton button = MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("OperationDoesNotExistError"), tr("Error"), tr("Error: Operation %1 does not exist") + QLatin1String("OperationDoesNotExistError"), tr("Error"), tr("Error: Operation %1 does not exist.") .arg(operationName), QMessageBox::Abort | QMessageBox::Ignore); if (button == QMessageBox::Abort) d->m_operationsCreatedSuccessfully = false; diff --git a/src/libs/installer/consumeoutputoperation.cpp b/src/libs/installer/consumeoutputoperation.cpp index bf9e6c143..f665a4c44 100644 --- a/src/libs/installer/consumeoutputoperation.cpp +++ b/src/libs/installer/consumeoutputoperation.cpp @@ -74,8 +74,8 @@ bool ConsumeOutputOperation::performOperation() const QString installerKeyName = arguments().at(0); if (installerKeyName.isEmpty()) { setError(UserDefinedError); - setErrorString(tr("Can not save the output of %1 to an empty installer key value.").arg( - arguments().at(1))); + setErrorString(tr("Cannot save the output of \"%1\" to an empty installer key value.").arg( + QDir::toNativeSeparators(arguments().at(1)))); return false; } @@ -88,7 +88,7 @@ bool ConsumeOutputOperation::performOperation() if (!executable.exists() || !executable.isExecutable()) { setError(UserDefinedError); - setErrorString(tr("File '%1' does not exist or is not an executable binary.").arg( + setErrorString(tr("File \"%1\" does not exist or is not an executable binary.").arg( QDir::toNativeSeparators(executable.absoluteFilePath()))); return false; } @@ -109,7 +109,7 @@ bool ConsumeOutputOperation::performOperation() << "standard output: " << process.readAllStandardOutput() << "error output: " << process.readAllStandardError(); setError(UserDefinedError); - setErrorString(tr("Running '%1' resulted in a crash.").arg( + setErrorString(tr("Running \"%1\" resulted in a crash.").arg( QDir::toNativeSeparators(executable.absoluteFilePath()))); return false; } @@ -127,7 +127,7 @@ bool ConsumeOutputOperation::performOperation() } if (executableOutput.isEmpty()) { - qWarning() << QString::fromLatin1("Cannot get any query output from executable: '%1'").arg( + qWarning() << QString::fromLatin1("Cannot get any query output from executable \"%1\".").arg( executable.absoluteFilePath()); } core->setValue(installerKeyName, QString::fromLocal8Bit(executableOutput)); diff --git a/src/libs/installer/copydirectoryoperation.cpp b/src/libs/installer/copydirectoryoperation.cpp index 06c952993..a25e00930 100644 --- a/src/libs/installer/copydirectoryoperation.cpp +++ b/src/libs/installer/copydirectoryoperation.cpp @@ -78,18 +78,21 @@ bool CopyDirectoryOperation::performOperation() } else { setError(InvalidArguments); setErrorString(tr("Invalid argument in %1: Third argument needs to be forceOverwrite, " - "if specified").arg(name())); + "if specified.").arg(name())); return false; } } const QFileInfo sourceInfo(sourcePath); const QFileInfo targetInfo(targetPath); - if (!sourceInfo.exists() || !sourceInfo.isDir() || !targetInfo.exists() || !targetInfo.isDir()) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %1: Directories are invalid: %2 %3").arg(name()) - .arg(sourcePath).arg(targetPath)); - return false; + + foreach (const QFileInfo &dir, QList<QFileInfo>() << sourceInfo << targetInfo) { + if (!dir.exists() || !dir.isDir()) { + setError(InvalidArguments); + setErrorString(tr("Invalid argument in %1: Directory \"%2\" is invalid.").arg(name()) + .arg(QDir::toNativeSeparators(sourcePath))); + return false; + } } const QDir sourceDir = sourceInfo.absoluteDir(); @@ -120,22 +123,24 @@ bool CopyDirectoryOperation::performOperation() } else if (itemInfo.isDir()) { if (!targetDir.mkpath(targetDir.absoluteFilePath(relativePath))) { setError(InvalidArguments); - setErrorString(tr("Could not create %1").arg(targetDir.absoluteFilePath(relativePath))); + setErrorString(tr("Cannot create directory \"%1\".").arg( + QDir::toNativeSeparators(targetDir.absoluteFilePath(relativePath)))); return false; } } else { const QString absolutePath = targetDir.absoluteFilePath(relativePath); if (overwrite && QFile::exists(absolutePath) && !deleteFileNowOrLater(absolutePath)) { setError(UserDefinedError); - setErrorString(tr("Failed to overwrite %1").arg(absolutePath)); + setErrorString(tr("Failed to overwrite \"%1\".").arg(QDir::toNativeSeparators(absolutePath))); return false; } QFile file(sourceDir.absoluteFilePath(itemName)); if (!file.copy(absolutePath)) { setError(UserDefinedError); - setErrorString(tr("Could not copy %1 to %2, error was: %3").arg(sourceDir.absoluteFilePath(itemName), - targetDir.absoluteFilePath(relativePath), - file.errorString())); + setErrorString(tr("Cannot copy file \"%1\" to \"%2\": %3").arg( + QDir::toNativeSeparators(sourceDir.absoluteFilePath(itemName)), + QDir::toNativeSeparators(targetDir.absoluteFilePath(relativePath)), + file.errorString())); return false; } autoPush.m_files.prepend(targetDir.absoluteFilePath(relativePath)); @@ -154,7 +159,7 @@ bool CopyDirectoryOperation::undoOperation() foreach (const QString &file, files) { if (!QFile::remove(file)) { setError(InvalidArguments); - setErrorString(tr("Could not remove %1").arg(file)); + setErrorString(tr("Cannot remove file \"%1\".").arg(QDir::toNativeSeparators(file))); return false; } dir.rmpath(QFileInfo(file).absolutePath()); diff --git a/src/libs/installer/copyfiletask.cpp b/src/libs/installer/copyfiletask.cpp index 0ec9c6d27..58d232939 100644 --- a/src/libs/installer/copyfiletask.cpp +++ b/src/libs/installer/copyfiletask.cpp @@ -34,6 +34,7 @@ #include "copyfiletask.h" #include "observer.h" +#include <QDir> #include <QFileInfo> #include <QTemporaryFile> @@ -69,8 +70,8 @@ void CopyFileTask::doTask(QFutureInterface<FileTaskResult> &fi) QFile source(item.source()); if (!source.open(QIODevice::ReadOnly)) { - fi.reportException(TaskException(tr("Could not open source '%1' for read. Error: %2.") - .arg(source.fileName(), source.errorString()))); + fi.reportException(TaskException(tr("Cannot open file \"%1\" for reading: %2") + .arg(QDir::toNativeSeparators(source.fileName()), source.errorString()))); fi.reportFinished(); return; // error } observer.setBytesToTransfer(source.size()); @@ -85,8 +86,8 @@ void CopyFileTask::doTask(QFutureInterface<FileTaskResult> &fi) file.reset(new QFile(target)); } if (!file->open(QIODevice::WriteOnly | QIODevice::Truncate)) { - fi.reportException(TaskException(tr("Could not open target '%1' for write. Error: %2.") - .arg(file->fileName(), file->errorString()))); + fi.reportException(TaskException(tr("Cannot open file \"%1\" for writing: %2") + .arg(QDir::toNativeSeparators(file->fileName()), file->errorString()))); fi.reportFinished(); return; // error } @@ -102,8 +103,8 @@ void CopyFileTask::doTask(QFutureInterface<FileTaskResult> &fi) while (written < read) { const qint64 toWrite = file->write(buffer.constData() + written, read - written); if (toWrite < 0) { - fi.reportException(TaskException(tr("Writing to target '%1' failed. Error: %2.") - .arg(file->fileName(), file->errorString()))); + fi.reportException(TaskException(tr("Writing to file \"%1\" failed: %2") + .arg(QDir::toNativeSeparators(file->fileName()), file->errorString()))); } written += toWrite; } diff --git a/src/libs/installer/createdesktopentryoperation.cpp b/src/libs/installer/createdesktopentryoperation.cpp index 8d71c2c07..ec98e7fc8 100644 --- a/src/libs/installer/createdesktopentryoperation.cpp +++ b/src/libs/installer/createdesktopentryoperation.cpp @@ -122,7 +122,7 @@ void CreateDesktopEntryOperation::backup() } if (!file.copy(value(QLatin1String("backupOfExistingDesktopEntry")).toString())) - setErrorString(tr("Could not backup file %1: %2").arg(filename, file.errorString())); + setErrorString(tr("Cannot backup file \"%1\": %2").arg(QDir::toNativeSeparators(filename), file.errorString())); } bool CreateDesktopEntryOperation::performOperation() @@ -136,13 +136,13 @@ bool CreateDesktopEntryOperation::performOperation() QFile file(filename); if (file.exists() && !file.remove()) { setError(UserDefinedError); - setErrorString(tr("Failed to overwrite %1").arg(filename)); + setErrorString(tr("Failed to overwrite file \"%1\".").arg(QDir::toNativeSeparators(filename))); return false; } if(!file.open(QIODevice::WriteOnly)) { setError(UserDefinedError); - setErrorString(tr("Could not write Desktop Entry at %1").arg(filename)); + setErrorString(tr("Cannot write desktop entry to \"%1\".").arg(QDir::toNativeSeparators(filename))); return false; } @@ -168,7 +168,7 @@ bool CreateDesktopEntryOperation::undoOperation() // first remove the link QFile file(filename); if (file.exists() && !file.remove()) { - qWarning() << "Could not delete file" << filename << file.errorString(); + qWarning() << "Cannot delete file" << filename << ":" << file.errorString(); return true; } @@ -178,13 +178,13 @@ bool CreateDesktopEntryOperation::undoOperation() QFile backupFile(value(QLatin1String("backupOfExistingDesktopEntry")).toString()); if (!backupFile.exists()) { // do not treat this as a real error: The backup file might have been just nuked by the user. - qWarning() << "Could not restore original desktop entry at" << filename + qWarning() << "Cannot restore original desktop entry at" << filename << ": Backup file" << backupFile.fileName() << "does not exist anymore."; return true; } if (!backupFile.rename(filename)) - qWarning() << "Could not restore the file" << filename << ":" << backupFile.errorString(); + qWarning() << "Cannot restore the file" << filename << ":" << backupFile.errorString(); return true; } diff --git a/src/libs/installer/createlinkoperation.cpp b/src/libs/installer/createlinkoperation.cpp index fc0950870..aa98c54a5 100644 --- a/src/libs/installer/createlinkoperation.cpp +++ b/src/libs/installer/createlinkoperation.cpp @@ -35,6 +35,7 @@ #include "link.h" +#include <QDir> #include <QFileInfo> using namespace QInstaller; @@ -60,7 +61,8 @@ bool CreateLinkOperation::performOperation() if (!link.exists()) { setError(UserDefinedError); - setErrorString(tr("Could not create link from %1 to %2.").arg(linkPath, targetPath)); + setErrorString(tr("Cannot create link from \"%1\" to \"%2\".").arg( + QDir::toNativeSeparators(linkPath), QDir::toNativeSeparators(targetPath))); return false; } @@ -80,7 +82,8 @@ bool CreateLinkOperation::undoOperation() } if (!link.remove()) { setError(UserDefinedError); - setErrorString(tr("Could not remove link from %1 to %2.").arg(linkPath, targetPath)); + setErrorString(tr("Cannot remove link from \"%1\" to \"%2\".").arg( + QDir::toNativeSeparators(linkPath), QDir::toNativeSeparators(targetPath))); return false; } diff --git a/src/libs/installer/createlocalrepositoryoperation.cpp b/src/libs/installer/createlocalrepositoryoperation.cpp index 51e209df7..a58570917 100644 --- a/src/libs/installer/createlocalrepositoryoperation.cpp +++ b/src/libs/installer/createlocalrepositoryoperation.cpp @@ -89,8 +89,8 @@ static void fixPermissions(const QString &repoPath) if (!QFile::setPermissions(it.filePath(), QFile::ReadOwner | QFile::WriteOwner | QFile::ReadUser | QFile::WriteUser | QFile::ReadGroup | QFile::ReadOther)) { - throw Error(CreateLocalRepositoryOperation::tr("Could not set file permissions %1!") - .arg(it.filePath())); + throw Error(CreateLocalRepositoryOperation::tr("Cannot set permissions for file \"%1\".") + .arg(QDir::toNativeSeparators(it.filePath()))); } } } @@ -110,8 +110,8 @@ static void removeFiles(const QString &path, AutoHelper *const helper) if (fi.isSymLink() || fi.isFile()) { QFile f(fi.filePath()); if (!f.remove()) { - throw Error(CreateLocalRepositoryOperation::tr("Could not remove file %1: %2") - .arg(f.fileName(), f.errorString())); + throw Error(CreateLocalRepositoryOperation::tr("Cannot remove file \"%1\": %2") + .arg(QDir::toNativeSeparators(f.fileName()), f.errorString())); } helper->m_files.removeAll(f.fileName()); } @@ -128,8 +128,9 @@ static QString createArchive(const QString repoPath, const QString &sourceDir, c Lib7z::createArchive(&archive, QStringList() << sourceDir); removeFiles(sourceDir, helper); // cleanup the files we compressed if (!archive.rename(sourceDir + fileName)) { - throw Error(CreateLocalRepositoryOperation::tr("Could not move file %1 to %2. Error: %3") - .arg(archive.fileName(), sourceDir + fileName, archive.errorString())); + throw Error(CreateLocalRepositoryOperation::tr("Cannot move file \"%1\" to \"%2\": %3") + .arg(QDir::toNativeSeparators(archive.fileName()), + QDir::toNativeSeparators(sourceDir + fileName), archive.errorString())); } return archive.fileName(); } @@ -166,7 +167,7 @@ bool CreateLocalRepositoryOperation::performOperation() // check if this is an offline version, otherwise there will be no binary data PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); if (core && !core->isOfflineOnly()) { - throw QInstaller::Error(tr("Installer needs to be an offline version: %1.") + throw QInstaller::Error(tr("Installer at \"%1\" needs to be an offline one.") .arg(QDir::toNativeSeparators(binaryPath))); } @@ -210,13 +211,15 @@ bool CreateLocalRepositoryOperation::performOperation() // open the updates xml file we previously copied QFile updatesXml(repoPath + QLatin1String("Updates.xml")); if (!updatesXml.exists() || !updatesXml.open(QIODevice::ReadOnly)) - throw QInstaller::Error(tr("Could not open file: %1").arg(updatesXml.fileName())); + throw QInstaller::Error(tr("Cannot open file \"%1\" for reading.").arg( + QDir::toNativeSeparators(updatesXml.fileName()))); // read the content of the updates xml QString error; QDomDocument doc; if (!doc.setContent(&updatesXml, &error)) - throw QInstaller::Error(tr("Could not read: %1. Error: %2").arg(updatesXml.fileName(), error)); + throw QInstaller::Error(tr("Cannot read file \"%1\": %2").arg( + QDir::toNativeSeparators(updatesXml.fileName()), error)); // build for each available package a name - version mapping QHash<QString, QString> nameVersionHash; @@ -246,8 +249,9 @@ bool CreateLocalRepositoryOperation::performOperation() QFile file(binaryPath); if (!file.open(QIODevice::ReadOnly)) { - throw QInstaller::Error(tr("Could not open file: %1. Error: %2").arg(file.fileName(), - file.errorString())); + throw QInstaller::Error(tr("Cannot open file \"%1\" for reading: %2").arg( + QDir::toNativeSeparators(file.fileName()), + file.errorString())); } // start to read the binary layout @@ -264,8 +268,8 @@ bool CreateLocalRepositoryOperation::performOperation() for (int i = 0; i < names.count(); ++i) { const QString name = names.at(i); if (!repo.mkpath(name)) { - throw QInstaller::Error(tr("Could not create target dir: %1.") - .arg(repo.filePath(name))); + throw QInstaller::Error(tr("Cannot create target directory: \"%1\".") + .arg(QDir::toNativeSeparators(repo.filePath(name)))); } // zip the meta files that come with the offline installer helper.m_files.prepend(Static::createArchive(repoPath, @@ -333,10 +337,10 @@ bool CreateLocalRepositoryOperation::undoOperation() QDir dir; const QStringList files = value(QLatin1String("files")).toStringList(); foreach (const QString &file, files) { - emit outputTextChanged(tr("Removing file: %1").arg(file)); + emit outputTextChanged(tr("Removing file \"%1\".").arg(QDir::toNativeSeparators(file))); if (!QFile::remove(file)) { setError(InvalidArguments); - setErrorString(tr("Could not remove %1.").arg(file)); + setErrorString(tr("Cannot remove file \"%1\".").arg(QDir::toNativeSeparators(file))); return false; } dir.rmpath(QFileInfo(file).absolutePath()); @@ -355,12 +359,12 @@ bool CreateLocalRepositoryOperation::undoOperation() #if defined(Q_OS_WIN) && !defined(Q_CC_MINGW) char msg[128]; if (strerror_s(msg, sizeof msg, errno) != 0) { - setError(UserDefinedError, tr("Cannot remove directory %1: %2").arg(createdDir.path(), - QString::fromLocal8Bit(msg))); + setError(UserDefinedError, tr("Cannot remove directory \"%1\": %2").arg( + QDir::toNativeSeparators(createdDir.path()), QString::fromLocal8Bit(msg))); } #else - setError(UserDefinedError, tr("Cannot remove directory %1: %2").arg(createdDir.path(), - QString::fromLocal8Bit(strerror(errno)))); + setError(UserDefinedError, tr("Cannot remove directory \"%1\": %2").arg( + QDir::toNativeSeparators(createdDir.path()), QString::fromLocal8Bit(strerror(errno)))); #endif } setValue(QLatin1String("files"), QStringList()); diff --git a/src/libs/installer/createshortcutoperation.cpp b/src/libs/installer/createshortcutoperation.cpp index 110698413..4bd5ca453 100644 --- a/src/libs/installer/createshortcutoperation.cpp +++ b/src/libs/installer/createshortcutoperation.cpp @@ -219,11 +219,11 @@ bool CreateShortcutOperation::performOperation() #if defined(Q_OS_WIN) && !defined(Q_CC_MINGW) char msg[128]; if (strerror_s(msg, sizeof msg, errno) != 0) { - setErrorString(tr("Could not create folder %1: %2.").arg(QDir::toNativeSeparators(linkPath), + setErrorString(tr("Cannot create directory \"%1\": %2").arg(QDir::toNativeSeparators(linkPath), QString::fromLocal8Bit(msg))); } #else - setErrorString(tr("Could not create folder %1: %2.").arg(QDir::toNativeSeparators(linkPath), + setErrorString(tr("Cannot create directory \"%1\": %2").arg(QDir::toNativeSeparators(linkPath), QString::fromLocal8Bit(strerror(errno)))); #endif return false; @@ -233,7 +233,7 @@ bool CreateShortcutOperation::performOperation() QString errorString; if (QFile::exists(linkLocation) && !deleteFileNowOrLater(linkLocation, &errorString)) { setError(UserDefinedError); - setErrorString(tr("Failed to overwrite %1: %2").arg(QDir::toNativeSeparators(linkLocation), + setErrorString(tr("Failed to overwrite \"%1\": %2").arg(QDir::toNativeSeparators(linkLocation), errorString)); return false; } @@ -241,7 +241,7 @@ bool CreateShortcutOperation::performOperation() const bool linked = createLink(linkTarget, linkLocation, m_workingDir, targetArguments, m_iconPath, m_iconId); if (!linked) { setError(UserDefinedError); - setErrorString(tr("Could not create link %1: %2").arg(QDir::toNativeSeparators(linkLocation), + setErrorString(tr("Cannot create link \"%1\": %2").arg(QDir::toNativeSeparators(linkLocation), qt_error_string())); return false; } diff --git a/src/libs/installer/downloadarchivesjob.cpp b/src/libs/installer/downloadarchivesjob.cpp index c3cfb4abd..828e7f99a 100644 --- a/src/libs/installer/downloadarchivesjob.cpp +++ b/src/libs/installer/downloadarchivesjob.cpp @@ -222,7 +222,7 @@ void DownloadArchivesJob::registerFile() QMessageBox::Retry | QMessageBox::Cancel, QMessageBox::Cancel); if (res == QMessageBox::Cancel) { - finishWithError(tr("Could not verify Hash")); + finishWithError(tr("Cannot verify Hash")); return; } } else { @@ -252,7 +252,7 @@ void DownloadArchivesJob::downloadFailed(const QString &error) const QMessageBox::StandardButton b = MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("archiveDownloadError"), tr("Download Error"), tr("Could not download archive: %1 : %2") + QLatin1String("archiveDownloadError"), tr("Download Error"), tr("Cannot download archive %1: %2") .arg(m_archivesToDownload.first().second, error), QMessageBox::Retry | QMessageBox::Cancel); if (b == QMessageBox::Retry) @@ -264,7 +264,7 @@ void DownloadArchivesJob::downloadFailed(const QString &error) void DownloadArchivesJob::finishWithError(const QString &error) { const FileDownloader *const dl = qobject_cast<const FileDownloader*> (sender()); - const QString msg = tr("Could not fetch archives: %1\nError while loading %2"); + const QString msg = tr("Cannot fetch archives: %1\nError while loading %2"); if (dl != 0) emitFinishedWithError(QInstaller::DownloadError, msg.arg(error, dl->url().toString())); else @@ -303,14 +303,13 @@ KDUpdater::FileDownloader *DownloadArchivesJob::setupDownloader(const QString &s + component->name() + QLatin1Char('/') + fi.fileName() + suffix); } - emit outputTextChanged(tr("Downloading archive '%1' for component: %2") + emit outputTextChanged(tr("Downloading archive \"%1\" for component %2.") .arg(fi.fileName() + suffix, component->displayName())); } else { - emit outputTextChanged(tr("Scheme not supported: %1 (%2)").arg(scheme, url.toString())); + emit outputTextChanged(tr("Scheme %1 not supported (URL: %2).").arg(scheme, url.toString())); } } else { - emit outputTextChanged(tr("Could not find component for: %1.").arg(QFileInfo(fi.path()) - .fileName())); + emit outputTextChanged(tr("Cannot find component for %1.").arg(QFileInfo(fi.path()).fileName())); } return downloader; } diff --git a/src/libs/installer/downloadfiletask.cpp b/src/libs/installer/downloadfiletask.cpp index dde85795c..6bc1a1c8f 100644 --- a/src/libs/installer/downloadfiletask.cpp +++ b/src/libs/installer/downloadfiletask.cpp @@ -37,6 +37,7 @@ #include "downloadfiletask_p.h" #include <QCoreApplication> +#include <QDir> #include <QEventLoop> #include <QFileInfo> #include <QNetworkProxyFactory> @@ -126,15 +127,17 @@ void Downloader::onReadyRead() } if (file->exists() && (!QFileInfo(file->fileName()).isFile())) { - m_futureInterface->reportException(TaskException(tr("Target file '%1' already exists " + m_futureInterface->reportException(TaskException(tr("Target file \"%1\" already exists " "but is not a file.").arg(file->fileName()))); return; } if (!file->open(QIODevice::WriteOnly | QIODevice::Truncate)) { //: %2 is a sentence describing the error - m_futureInterface->reportException(TaskException(tr("Could not open target '%1' for " - "write. Error: %2.").arg(file->fileName(), file->errorString()))); + m_futureInterface->reportException( + TaskException(tr("Cannot open file \"%1\" for writing: %2").arg( + QDir::toNativeSeparators(file->fileName()), + file->errorString()))); return; } data.file = std::move(file); @@ -143,8 +146,9 @@ void Downloader::onReadyRead() if (!data.file->isOpen()) { //: %2 is a sentence describing the error. m_futureInterface->reportException( - TaskException(tr("Target '%1' not open for write. Error: %2.").arg( - data.file->fileName(), data.file->errorString()))); + TaskException(tr("File \"%1\" not open for writing: %2").arg( + QDir::toNativeSeparators(data.file->fileName()), + data.file->errorString()))); return; } @@ -162,8 +166,9 @@ void Downloader::onReadyRead() if (toWrite < 0) { //: %2 is a sentence describing the error. m_futureInterface->reportException( - TaskException(tr("Writing to target '%1' failed. Error: %2.").arg( - data.file->fileName(), data.file->errorString()))); + TaskException(tr("Writing to file \"%1\" failed: %2").arg( + QDir::toNativeSeparators(data.file->fileName()), + data.file->errorString()))); return; } written += toWrite; @@ -209,7 +214,7 @@ void Downloader::onFinished(QNetworkReply *reply) reply->deleteLater(); return; } else { - m_futureInterface->reportException(TaskException(tr("Redirect loop detected '%1'.") + m_futureInterface->reportException(TaskException(tr("Redirect loop detected for \"%1\".") .arg(url.toString()))); return; } @@ -226,7 +231,7 @@ void Downloader::onFinished(QNetworkReply *reply) const QByteArray expectedCheckSum = data.taskItem.value(TaskRole::Checksum).toByteArray(); if (!expectedCheckSum.isEmpty()) { if (expectedCheckSum != data.observer->checkSum().toHex()) { - m_futureInterface->reportException(TaskException(tr("Checksum mismatch detected '%1'.") + m_futureInterface->reportException(TaskException(tr("Checksum mismatch detected for \"%1\".") .arg(reply->url().toString()))); } } @@ -256,12 +261,12 @@ void Downloader::onError(QNetworkReply::NetworkError error) const Data &data = *m_downloads[reply]; //: %2 is a sentence describing the error m_futureInterface->reportException( - TaskException(tr("Network error while downloading '%1': %2.").arg( + TaskException(tr("Network error while downloading \"%1\": %2").arg( data.taskItem.source(), reply->errorString()))); } else { //: %1 is a sentence describing the error m_futureInterface->reportException( - TaskException(tr("Unknown network error while downloading: %1.").arg(error))); + TaskException(tr("Unknown network error while downloading \"%1\".").arg(error))); } } @@ -271,7 +276,7 @@ void Downloader::onSslErrors(const QList<QSslError> &sslErrors) Q_UNUSED(sslErrors); #else foreach (const QSslError &error, sslErrors) - qDebug() << QString::fromLatin1("SSL error: %s").arg(error.errorString()); + qDebug() << QString::fromLatin1("SSL error: %1").arg(error.errorString()); #endif } @@ -336,7 +341,7 @@ QNetworkReply *Downloader::startDownload(const FileTaskItem &item) QUrl const source = item.source(); if (!source.isValid()) { //: %2 is a sentence describing the error - m_futureInterface->reportException(TaskException(tr("Invalid source '%1'. Error: %2.") + m_futureInterface->reportException(TaskException(tr("Invalid source URL \"%1\": %2") .arg(source.toString(), source.errorString()))); return 0; } diff --git a/src/libs/installer/elevatedexecuteoperation.cpp b/src/libs/installer/elevatedexecuteoperation.cpp index 9fe20a103..640ae7c1a 100644 --- a/src/libs/installer/elevatedexecuteoperation.cpp +++ b/src/libs/installer/elevatedexecuteoperation.cpp @@ -142,7 +142,7 @@ bool ElevatedExecuteOperation::Private::run(const QStringList &arguments) const bool success = QProcessWrapper::startDetached(args.front(), args.mid(1)); if (!success) { q->setError(UserDefinedError); - q->setErrorString(tr("Execution failed: Could not start detached: \"%1\"").arg(callstr)); + q->setErrorString(tr("Cannot start detached: \"%1\"").arg(callstr)); } return success; } @@ -194,7 +194,7 @@ bool ElevatedExecuteOperation::Private::run(const QStringList &arguments) if (!success) { q->setError(UserDefinedError); //TODO: pass errorString() through the wrapper */ - q->setErrorString(tr("Execution failed: Could not start: \"%1\"(%2)").arg(callstr, + q->setErrorString(tr("Cannot start: \"%1\": %2").arg(callstr, process->errorString())); returnValue = false; } @@ -210,7 +210,7 @@ bool ElevatedExecuteOperation::Private::run(const QStringList &arguments) if (process->exitStatus() == QProcessWrapper::CrashExit) { q->setError(UserDefinedError); - q->setErrorString(tr("Execution failed (Crash): \"%1\"").arg(callstr)); + q->setErrorString(tr("Program crashed: \"%1\"").arg(callstr)); returnValue = false; } diff --git a/src/libs/installer/environmentvariablesoperation.cpp b/src/libs/installer/environmentvariablesoperation.cpp index 55332f540..b3ac9c268 100644 --- a/src/libs/installer/environmentvariablesoperation.cpp +++ b/src/libs/installer/environmentvariablesoperation.cpp @@ -80,7 +80,7 @@ UpdateOperation::Error writeSetting(const QString ®Path, oldValue->clear(); SettingsType registry(regPath, QSettingsWrapper::NativeFormat); if (!registry.isWritable()) { - *errorString = UpdateOperation::tr("Registry path %1 is not writable").arg(regPath); + *errorString = UpdateOperation::tr("Registry path %1 is not writable.").arg(regPath); return UpdateOperation::UserDefinedError; } @@ -92,7 +92,7 @@ UpdateOperation::Error writeSetting(const QString ®Path, registry.sync(); if (registry.status() != QSettingsWrapper::NoError) { - *errorString = UpdateOperation::tr("Could not write to registry path %1").arg(regPath); + *errorString = UpdateOperation::tr("Cannot write to registry path %1.").arg(regPath); return UpdateOperation::UserDefinedError; } diff --git a/src/libs/installer/extractarchiveoperation_p.h b/src/libs/installer/extractarchiveoperation_p.h index 4476228cd..6154a8cb4 100644 --- a/src/libs/installer/extractarchiveoperation_p.h +++ b/src/libs/installer/extractarchiveoperation_p.h @@ -154,7 +154,7 @@ protected: QFile f(filename); const bool renamed = f.rename(backup); if (f.exists() && !renamed) { - qCritical("Could not rename %s to %s: %s", qPrintable(filename), qPrintable(backup), + qCritical("Cannot rename %s to %s: %s", qPrintable(filename), qPrintable(backup), qPrintable(f.errorString())); return false; } @@ -185,8 +185,7 @@ public: { QFile archive(archivePath); if (!archive.open(QIODevice::ReadOnly)) { - - emit finished(false, tr("Could not open %1 for reading: %2.").arg(archivePath, archive.errorString())); + emit finished(false, tr("Cannot open archive \"%1\" for reading: %2").arg(archivePath, archive.errorString())); return; } @@ -194,9 +193,9 @@ public: Lib7z::extractArchive(&archive, targetDir, callback); emit finished(true, QString()); } catch (const Lib7z::SevenZipException& e) { - emit finished(false, tr("Error while extracting '%1': %2").arg(archivePath, e.message())); + emit finished(false, tr("Error while extracting archive \"%1\": %2").arg(archivePath, e.message())); } catch (...) { - emit finished(false, tr("Unknown exception caught while extracting %1.").arg(archivePath)); + emit finished(false, tr("Unknown exception caught while extracting \"%1\".").arg(archivePath)); } } diff --git a/src/libs/installer/fakestopprocessforupdateoperation.cpp b/src/libs/installer/fakestopprocessforupdateoperation.cpp index 562816bfc..5b99641ec 100644 --- a/src/libs/installer/fakestopprocessforupdateoperation.cpp +++ b/src/libs/installer/fakestopprocessforupdateoperation.cpp @@ -62,7 +62,7 @@ bool FakeStopProcessForUpdateOperation::undoOperation() PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); if (!core) { - setError(KDUpdater::UpdateOperation::UserDefinedError, tr("Could not get package manager " + setError(KDUpdater::UpdateOperation::UserDefinedError, tr("Cannot get package manager " "core.")); return false; } diff --git a/src/libs/installer/fileio.cpp b/src/libs/installer/fileio.cpp index 70f2be147..d014449e5 100644 --- a/src/libs/installer/fileio.cpp +++ b/src/libs/installer/fileio.cpp @@ -39,6 +39,7 @@ #include <QCoreApplication> #include <QByteArray> +#include <QDir> #include <QFileDevice> #include <QString> @@ -108,7 +109,8 @@ void QInstaller::openForRead(QFileDevice *dev) Q_ASSERT(dev); if (!dev->open(QIODevice::ReadOnly)) { throw Error(QCoreApplication::translate("QInstaller", - "Cannot open file %1 for reading: %2").arg(dev->fileName(), dev->errorString())); + "Cannot open file \"%1\" for reading: %2").arg( + QDir::toNativeSeparators(dev->fileName()), dev->errorString())); } } @@ -117,7 +119,8 @@ void QInstaller::openForWrite(QFileDevice *dev) Q_ASSERT(dev); if (!dev->open(QIODevice::WriteOnly)) { throw Error(QCoreApplication::translate("QInstaller", - "Cannot open file %1 for writing: %2").arg(dev->fileName(), dev->errorString())); + "Cannot open file \"%1\" for writing: %2").arg( + QDir::toNativeSeparators(dev->fileName()), dev->errorString())); } } @@ -126,7 +129,8 @@ void QInstaller::openForAppend(QFileDevice *dev) Q_ASSERT(dev); if (!dev->open(QIODevice::WriteOnly | QIODevice::Append)) { throw Error(QCoreApplication::translate("QInstaller", - "Cannot open file %1 for writing: %2").arg(dev->fileName(), dev->errorString())); + "Cannot open file \"%1\" for writing: %2").arg( + QDir::toNativeSeparators(dev->fileName()), dev->errorString())); } } @@ -160,7 +164,7 @@ qint64 QInstaller::blockingCopy(QFileDevice *in, QFileDevice *out, qint64 size) size -= actual; actual = qMin(blockSize, size); } catch (const Error &error) { - throw Error(QCoreApplication::translate("QInstaller", "Copy failed. Error: %1") + throw Error(QCoreApplication::translate("QInstaller", "Copy failed: %1") .arg(error.message())); } } diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp index a44db1126..00c289ffa 100644 --- a/src/libs/installer/fileutils.cpp +++ b/src/libs/installer/fileutils.cpp @@ -182,7 +182,8 @@ void QInstaller::removeFiles(const QString &path, bool ignoreErrors) QFile f(fi.filePath()); if (!f.remove()) { const QString errorMessage = QCoreApplication::translate("QInstaller", - "Could not remove file %1: %2").arg(f.fileName(), f.errorString()); + "Cannot remove file \"%1\": %2").arg( + QDir::toNativeSeparators(f.fileName()), f.errorString()); if (!ignoreErrors) throw Error(errorMessage); qWarning() << errorMessage; @@ -223,7 +224,8 @@ void QInstaller::removeDirectory(const QString &path, bool ignoreErrors) errno = 0; if (d.exists(path) && !d.rmdir(dir)) { const QString errorMessage = QCoreApplication::translate("QInstaller", - "Could not remove folder %1: %2").arg(dir, errnoToQString(errno)); + "Cannot remove directory \"%1\": %2").arg(QDir::toNativeSeparators(dir), + errnoToQString(errno)); if (!ignoreErrors) throw Error(errorMessage); qWarning() << errorMessage; @@ -293,8 +295,8 @@ void QInstaller::copyDirectoryContents(const QString &sourceDir, const QString & Q_ASSERT(QFileInfo(sourceDir).isDir()); Q_ASSERT(!QFileInfo(targetDir).exists() || QFileInfo(targetDir).isDir()); if (!QDir().mkpath(targetDir)) { - throw Error(QCoreApplication::translate("QInstaller", "Could not create folder %1") - .arg(targetDir)); + throw Error(QCoreApplication::translate("QInstaller", "Cannot create directory \"%1\".") + .arg(QDir::toNativeSeparators(targetDir))); } QDirIterator it(sourceDir, QDir::NoDotAndDotDot | QDir::AllEntries); while (it.hasNext()) { @@ -307,8 +309,10 @@ void QInstaller::copyDirectoryContents(const QString &sourceDir, const QString & const QString target = QDir(targetDir).absoluteFilePath(i.fileName()); if (!f.copy(target)) { throw Error(QCoreApplication::translate("QInstaller", - "Could not copy file from %1 to %2: %3").arg(f.fileName(), target, - f.errorString())); + "Cannot copy file from \"%1\" to \"%2\": %3").arg( + QDir::toNativeSeparators(f.fileName()), + QDir::toNativeSeparators(target), + f.errorString())); } } } @@ -319,8 +323,8 @@ void QInstaller::moveDirectoryContents(const QString &sourceDir, const QString & Q_ASSERT(QFileInfo(sourceDir).isDir()); Q_ASSERT(!QFileInfo(targetDir).exists() || QFileInfo(targetDir).isDir()); if (!QDir().mkpath(targetDir)) { - throw Error(QCoreApplication::translate("QInstaller", "Could not create folder %1") - .arg(targetDir)); + throw Error(QCoreApplication::translate("QInstaller", "Cannot create directory \"%1\".") + .arg(QDir::toNativeSeparators(targetDir))); } QDirIterator it(sourceDir, QDir::NoDotAndDotDot | QDir::AllEntries); while (it.hasNext()) { @@ -336,8 +340,10 @@ void QInstaller::moveDirectoryContents(const QString &sourceDir, const QString & const QString target = QDir(targetDir).absoluteFilePath(i.fileName()); if (!f.rename(target)) { throw Error(QCoreApplication::translate("QInstaller", - "Could not move file from %1 to %2: %3").arg(f.fileName(), target, - f.errorString())); + "Cannot move file from \"%1\" to \"%2\": %3").arg( + QDir::toNativeSeparators(f.fileName()), + QDir::toNativeSeparators(target), + f.errorString())); } } } @@ -347,8 +353,8 @@ void QInstaller::mkdir(const QString &path) { errno = 0; if (!QDir().mkdir(QFileInfo(path).absoluteFilePath())) { - throw Error(QCoreApplication::translate("QInstaller", "Could not create folder %1: %2") - .arg(path, errnoToQString(errno))); + throw Error(QCoreApplication::translate("QInstaller", "Cannot create directory \"%1\": %2") + .arg(QDir::toNativeSeparators(path), errnoToQString(errno))); } } @@ -356,8 +362,8 @@ void QInstaller::mkpath(const QString &path) { errno = 0; if (!QDir().mkpath(QFileInfo(path).absoluteFilePath())) { - throw Error(QCoreApplication::translate("QInstaller", "Could not create folder %1: %2") - .arg(path, errnoToQString(errno))); + throw Error(QCoreApplication::translate("QInstaller", "Cannot create directory \"%1\": %2") + .arg(QDir::toNativeSeparators(path), errnoToQString(errno))); } } @@ -367,7 +373,7 @@ QString QInstaller::generateTemporaryFileName(const QString &templ) QTemporaryFile f; if (!f.open()) { throw Error(QCoreApplication::translate("QInstaller", - "Could not open temporary file: %1").arg(f.errorString())); + "Cannot open temporary file: %1").arg(f.errorString())); } return f.fileName(); } @@ -386,7 +392,7 @@ QString QInstaller::generateTemporaryFileName(const QString &templ) QFile f(tmp.arg(templ, suffix).arg(count)); if (!f.open(QIODevice::WriteOnly)) { throw Error(QCoreApplication::translate("QInstaller", - "Could not open temporary file for template %1: %2").arg(templ, f.errorString())); + "Cannot open temporary file for template %1: %2").arg(templ, f.errorString())); } f.remove(); return f.fileName(); @@ -487,13 +493,13 @@ void QInstaller::setApplicationIcon(const QString &application, const QString &i { QFile iconFile(icon); if (!iconFile.open(QIODevice::ReadOnly)) { - qWarning() << QString::fromLatin1("Could not use '%1' as application icon: %2.") + qWarning() << QString::fromLatin1("Cannot use \"%1\" as application icon: %2") .arg(icon, iconFile.errorString()); return; } if (QImageReader::imageFormat(icon) != "ico") { - qWarning() << QString::fromLatin1("Could not use '%1' as application icon, unsupported format %2.") + qWarning() << QString::fromLatin1("Cannot use \"%1\" as application icon, unsupported format %2.") .arg(icon, QLatin1String(QImageReader::imageFormat(icon))); return; } diff --git a/src/libs/installer/globalsettingsoperation.cpp b/src/libs/installer/globalsettingsoperation.cpp index f8d5ee439..3ddf8f05b 100644 --- a/src/libs/installer/globalsettingsoperation.cpp +++ b/src/libs/installer/globalsettingsoperation.cpp @@ -55,7 +55,7 @@ bool GlobalSettingsOperation::performOperation() if (!settings->isWritable()) { setError(UserDefinedError); - setErrorString(tr("Settings are not writable")); + setErrorString(tr("Settings are not writable.")); return false; } @@ -65,7 +65,7 @@ bool GlobalSettingsOperation::performOperation() if (settings->status() != QSettingsWrapper::NoError) { setError(UserDefinedError); - setErrorString(tr("Failed to write settings")); + setErrorString(tr("Failed to write settings.")); return false; } diff --git a/src/libs/installer/installercalculator.cpp b/src/libs/installer/installercalculator.cpp index 79c085c55..a03d11fc2 100644 --- a/src/libs/installer/installercalculator.cpp +++ b/src/libs/installer/installercalculator.cpp @@ -77,7 +77,7 @@ QString InstallerCalculator::installReason(Component *component) const "Components added as automatic dependencies:"); case Dependent: return QCoreApplication::translate("InstallerCalculator", "Components added as " - "dependency for '%1':").arg(installReasonReferencedComponent(component)); + "dependency for \"%1\":").arg(installReasonReferencedComponent(component)); case Resolved: return QCoreApplication::translate("InstallerCalculator", "Components that have resolved dependencies:"); @@ -108,8 +108,8 @@ void InstallerCalculator::realAppendToInstallComponents(Component *component) QString InstallerCalculator::recursionError(Component *component) { - return QCoreApplication::translate("InstallerCalculator", "Recursion detected, component '%1' " - "already added with reason: '%2'").arg(component->name(), installReason(component)); + return QCoreApplication::translate("InstallerCalculator", "Recursion detected, component \"%1\" " + "already added with reason: \"%2\"").arg(component->name(), installReason(component)); } bool InstallerCalculator::appendComponentsToInstall(const QList<Component *> &components) @@ -171,7 +171,7 @@ bool InstallerCalculator::appendComponentToInstall(Component *component) PackageManagerCore::componentByName(dependencyComponentName, m_allComponents); if (!dependencyComponent) { const QString errorMessage = QCoreApplication::translate("InstallerCalculator", - "Cannot find missing dependency '%1' for '%2'.").arg(dependencyComponentName, + "Cannot find missing dependency \"%1\" for \"%2\".").arg(dependencyComponentName, component->name()); qWarning() << errorMessage; m_componentsToInstallError.append(errorMessage); diff --git a/src/libs/installer/installiconsoperation.cpp b/src/libs/installer/installiconsoperation.cpp index f9a9096f5..b6613cd5d 100644 --- a/src/libs/installer/installiconsoperation.cpp +++ b/src/libs/installer/installiconsoperation.cpp @@ -118,7 +118,7 @@ bool InstallIconsOperation::performOperation() if (source.isEmpty()) { setError(InvalidArguments); - setErrorString(tr("Invalid Argument: source folder must not be empty.")); + setErrorString(tr("Invalid Argument: source directory must not be empty.")); return false; } @@ -167,7 +167,8 @@ bool InstallIconsOperation::performOperation() QFile bf(target); if (!bf.copy(backup)) { setError(UserDefinedError); - setErrorString(tr("Could not backup file %1: %2").arg(target, bf.errorString())); + setErrorString(tr("Cannot backup file \"%1\": %2").arg( + QDir::toNativeSeparators(target), bf.errorString())); undoOperation(); return false; } @@ -180,7 +181,8 @@ bool InstallIconsOperation::performOperation() QString errStr; if (!deleteFileNowOrLater(target, &errStr)) { setError(UserDefinedError); - setErrorString(tr("Failed to overwrite %1: %2").arg(target, errStr)); + setErrorString(tr("Failed to overwrite \"%1\": %2").arg( + QDir::toNativeSeparators(target), errStr)); undoOperation(); return false; } @@ -191,7 +193,8 @@ bool InstallIconsOperation::performOperation() QFile cf(source); if (!cf.copy(target)) { setError(UserDefinedError); - setErrorString(tr("Failed to copy file %1: %2").arg(target, cf.errorString())); + setErrorString(tr("Failed to copy file \"%1\": %2").arg( + QDir::toNativeSeparators(target), cf.errorString())); undoOperation(); return false; } @@ -201,7 +204,8 @@ bool InstallIconsOperation::performOperation() setValue(QLatin1String("files"), files); } else if (fi.isDir() && !QDir(target).exists()) { if (!QDir().mkpath(target)) { - setErrorString(tr("Could not create folder at %1: %2").arg(target, qt_error_string())); + setErrorString(tr("Cannot create directory \"%1\": %2").arg( + QDir::toNativeSeparators(target), qt_error_string())); undoOperation(); return false; } @@ -233,7 +237,7 @@ bool InstallIconsOperation::undoOperation() QFile installedTarget(target); if (installedTarget.exists() && !(installedTarget.copy(source) && installedTarget.remove())) { - warningMessages << QString::fromLatin1("Could not move file from '%1' to '%2', error: %3)").arg( + warningMessages << QString::fromLatin1("Cannot move file from \"%1\" to \"%2\": %3)").arg( target, source, installedTarget.errorString()); } } @@ -249,13 +253,13 @@ bool InstallIconsOperation::undoOperation() deleteFileNowOrLater(target); // then copy the backup onto the target if (!QFile::copy(backup, target)) { - warningMessages << QString::fromLatin1("Could not restore the backup '%1' to '%2'").arg( + warningMessages << QString::fromLatin1("Cannot restore the backup \"%1\" to \"%2\".").arg( backup, target); } // finally remove the backp if (!deleteFileNowOrLater(backup)) - warningMessages << QString::fromLatin1("Could not remove the backup '%1'").arg(backup); + warningMessages << QString::fromLatin1("Cannot remove the backup \"%1\".").arg(backup); } @@ -265,11 +269,11 @@ bool InstallIconsOperation::undoOperation() const QDir dir(*it); removeSystemGeneratedFiles(dir.absolutePath()); if (dir.exists() && !QDir::root().rmdir(dir.path())) - warningMessages << QString::fromLatin1("Could not remove directory '%1'").arg(dir.path()); + warningMessages << QString::fromLatin1("Cannot remove directory \"%1\".").arg(dir.path()); } if (!warningMessages.isEmpty()) { - qWarning() << QString::fromLatin1("Undo of operation '%1' with arguments '%2' had some problems.").arg( + qWarning() << QString::fromLatin1("Undo of operation %1 with arguments \"%2\" had some problems.").arg( name(), arguments().join(QLatin1String(", "))); foreach (const QString &message, warningMessages) { qWarning() << message; diff --git a/src/libs/installer/lib7z_facade.cpp b/src/libs/installer/lib7z_facade.cpp index 41bce1eb1..e68064204 100644 --- a/src/libs/installer/lib7z_facade.cpp +++ b/src/libs/installer/lib7z_facade.cpp @@ -222,7 +222,7 @@ struct DirectoryGuard return; QDir dir(m_path); if (!dir.rmdir(m_path)) - qWarning() << "Could not delete directory " << m_path; + qWarning() << "Cannot delete directory " << m_path; } /*! @@ -239,7 +239,7 @@ struct DirectoryGuard return QStringList(); if (fi.exists() && !fi.isDir()) { throw SevenZipException(QCoreApplication::translate("DirectoryGuard", - "Path exists but is not a folder: %1").arg(m_path)); + "Path \"%1\" exists but is not a directory.").arg(QDir::toNativeSeparators(m_path))); } QStringList created; @@ -255,7 +255,7 @@ struct DirectoryGuard m_created = dir.mkpath(m_path); if (!m_created) { throw SevenZipException(QCoreApplication::translate("DirectoryGuard", - "Could not create folder: %1").arg(m_path)); + "Cannot create directory \"%1\".").arg(QDir::toNativeSeparators(m_path))); } return created; } @@ -285,7 +285,7 @@ static NCOM::CPropVariant readProperty(IInArchive *archive, int index, int propI NCOM::CPropVariant prop; if (archive->GetProperty(index, propId, &prop) != S_OK) { throw SevenZipException(QCoreApplication::translate("Lib7z", - "Could not retrieve property %1 for item %2").arg(QString::number(propId), + "Cannot retrieve property %1 for item %2.").arg(QString::number(propId), QString::number(index))); } return prop; @@ -317,13 +317,13 @@ static bool getDateTimeProperty(IInArchive *arc, int index, int id, QDateTime *v FILETIME ft; if (!FileTimeToLocalFileTime(&ft7z, &ft)) { throw SevenZipException(QCoreApplication::translate("Lib7z", - "Could not convert 7z stored file time to local time.")); + "Cannot convert file time to local time.")); } SYSTEMTIME st; if (!BOOLToBool(FileTimeToSystemTime(&ft, &st))) { throw SevenZipException(QCoreApplication::translate("Lib7z", - "Could not convert local file time to system time.")); + "Cannot convert local file time to system time.")); } *value = QDateTime(QDate(st.wYear, st.wMonth, st.wDay), QTime(st.wHour, st.wMinute, st.wSecond)); @@ -489,7 +489,7 @@ QVector<File> listArchive(QFileDevice *archive) try { CCodecs codecs; if (codecs.Load() != S_OK) - throw SevenZipException(QCoreApplication::translate("Lib7z", "Could not load codecs.")); + throw SevenZipException(QCoreApplication::translate("Lib7z", "Cannot load codecs.")); COpenOptions op; op.codecs = &codecs; @@ -509,7 +509,7 @@ QVector<File> listArchive(QFileDevice *archive) CArchiveLink archiveLink; if (archiveLink.Open2(op, nullptr) != S_OK) { throw SevenZipException(QCoreApplication::translate("Lib7z", - "Could not open archive '%1'.").arg(archive->fileName())); + "Cannot open archive \"%1\".").arg(archive->fileName())); } QVector<File> flat; @@ -518,14 +518,14 @@ QVector<File> listArchive(QFileDevice *archive) UInt32 numItems = 0; if (arch->GetNumberOfItems(&numItems) != S_OK) { throw SevenZipException(QCoreApplication::translate("Lib7z", - "Could not retrieve number of items in archive.")); + "Cannot retrieve number of items in archive.")); } flat.reserve(flat.size() + numItems); for (uint item = 0; item < numItems; ++item) { UString s; if (archiveLink.Arcs[i].GetItemPath(item, s) != S_OK) { throw SevenZipException(QCoreApplication::translate("Lib7z", - "Could not retrieve path of archive item '%1'.").arg(item)); + "Cannot retrieve path of archive item \"%1\".").arg(item)); } File f; f.archiveIndex.setX(i); @@ -585,7 +585,7 @@ STDMETHODIMP ExtractCallback::GetStream(UInt32 index, ISequentialOutStream **out UString s; if (arc->GetItemPath(index, s) != S_OK) { setLastError(QCoreApplication::translate("ExtractCallbackImpl", - "Could not retrieve path of archive item %1").arg(index)); + "Cannot retrieve path of archive item %1.").arg(index)); return E_FAIL; } @@ -613,14 +613,15 @@ STDMETHODIMP ExtractCallback::GetStream(UInt32 index, ISequentialOutStream **out // do not follow symlinks, so we need to remove an existing one if (fi.isSymLink() && (!QFile::remove(fi.absoluteFilePath()))) { setLastError(QCoreApplication::translate("ExtractCallbackImpl", - "Could not remove already existing symlink %1.").arg(fi.absoluteFilePath())); + "Cannot remove already existing symlink %1.").arg(fi.absoluteFilePath())); return E_FAIL; } #endif std::unique_ptr<QFile> file(new QFile(fi.absoluteFilePath())); if (!file->open(QIODevice::WriteOnly)) { - setLastError(QCoreApplication::translate("ExtractCallbackImpl", "Could not open " - "file '%1': %2").arg(fi.absoluteFilePath(), file->errorString())); + setLastError(QCoreApplication::translate("ExtractCallbackImpl", + "Cannot open file \"%1\" for writing: %2").arg( + QDir::toNativeSeparators(fi.absoluteFilePath()), file->errorString())); return E_FAIL; } CMyComPtr<ISequentialOutStream> stream = @@ -645,7 +646,7 @@ STDMETHODIMP ExtractCallback::SetOperationResult(Int32 /*resultEOperationResult* UString s; if (arc->GetItemPath(currentIndex, s) != S_OK) { setLastError(QCoreApplication::translate("ExtractCallbackImpl", - "Could not retrieve path of archive item %1.").arg(currentIndex)); + "Cannot retrieve path of archive item %1.").arg(currentIndex)); return E_FAIL; } @@ -669,14 +670,14 @@ STDMETHODIMP ExtractCallback::SetOperationResult(Int32 /*resultEOperationResult* QFileInfo symlinkPlaceHolderFileInfo(absFilePath); if (symlinkPlaceHolderFileInfo.isSymLink()) { setLastError(QCoreApplication::translate("ExtractCallbackImpl", - "Could not create symlink at '%1'. Another one is already existing.") + "Cannot create symlink at \"%1\". Another one is already existing.") .arg(absFilePath)); return E_FAIL; } QFile symlinkPlaceHolderFile(absFilePath); if (!symlinkPlaceHolderFile.open(QIODevice::ReadOnly)) { setLastError(QCoreApplication::translate("ExtractCallbackImpl", - "Could not read symlink target from file '%1'.").arg(absFilePath)); + "Cannot read symlink target from file \"%1\".").arg(absFilePath)); return E_FAIL; } @@ -686,7 +687,7 @@ STDMETHODIMP ExtractCallback::SetOperationResult(Int32 /*resultEOperationResult* QFile targetFile(QString::fromLatin1(symlinkTarget)); if (!targetFile.link(absFilePath)) { setLastError(QCoreApplication::translate("ExtractCallbackImpl", - "Could not create symlink at %1: %2.").arg(absFilePath, + "Cannot create symlink at %1: %2").arg(absFilePath, targetFile.errorString())); return E_FAIL; } @@ -838,8 +839,8 @@ static QString createTmp7z() { QTemporaryFile file; if (!file.open()) { - throw SevenZipException(QCoreApplication::translate("Lib7z", "Could not create " - "temporary file. Error: %1").arg(file.errorString())); + throw SevenZipException(QCoreApplication::translate("Lib7z", "Cannot create " + "temporary file: %1").arg(file.errorString())); } file.write(QByteArray::fromHex("377A.BCAF.271C" // Signature. @@ -923,7 +924,7 @@ void createArchive(const QString &archive, const QStringList &sources, QTmpFile CCodecs codecs; if (codecs.Load() != S_OK) - throw SevenZipException(QCoreApplication::translate("Lib7z", "Could not load codecs.")); + throw SevenZipException(QCoreApplication::translate("Lib7z", "Cannot load codecs.")); CObjectVector<COpenType> types; if (!ParseOpenTypes(codecs, options.ArcType, types)) @@ -936,22 +937,26 @@ void createArchive(const QString &archive, const QStringList &sources, QTmpFile const QFile tempFile(UString2QString(options.ArchiveName)); if (res != S_OK || !tempFile.exists()) { - throw SevenZipException(QCoreApplication::translate("Lib7z", "Could not create " - "archive '%1'. %2").arg(tempFile.fileName(), errorMessageFrom7zResult(res))); + throw SevenZipException(QCoreApplication::translate("Lib7z", "Cannot create " + "archive \"%1\": %2").arg(QDir::toNativeSeparators(tempFile.fileName()), + errorMessageFrom7zResult(res))); } if (mode == QTmpFile::Yes) { QFile org(archive); if (org.exists() && !org.remove()) { - throw SevenZipException(QCoreApplication::translate("Lib7z", "Could not remove " - "old archive '%1'. Error: %2").arg(org.fileName(), org.errorString())); + throw SevenZipException(QCoreApplication::translate("Lib7z", "Cannot remove " + "old archive \"%1\": %2").arg(QDir::toNativeSeparators(org.fileName()), + org.errorString())); } QFile arc(UString2QString(options.ArchiveName)); if(!arc.rename(archive)) { - throw SevenZipException(QCoreApplication::translate("Lib7z", "Could not rename " - "temporary archive '%1' to '%2'. Error: %3").arg(arc.fileName(), archive, - arc.errorString())); + throw SevenZipException(QCoreApplication::translate("Lib7z", "Cannot rename " + "temporary archive \"%1\" to \"%2\": %3").arg( + QDir::toNativeSeparators(arc.fileName()), + QDir::toNativeSeparators(archive), + arc.errorString())); } } } catch (const char *err) { @@ -992,7 +997,7 @@ void extractArchive(QFileDevice *archive, const QString &directory, ExtractCallb CCodecs codecs; if (codecs.Load() != S_OK) - throw SevenZipException(QCoreApplication::translate("Lib7z", "Could not load codecs.")); + throw SevenZipException(QCoreApplication::translate("Lib7z", "Cannot load codecs.")); COpenOptions op; op.codecs = &codecs; @@ -1012,7 +1017,7 @@ void extractArchive(QFileDevice *archive, const QString &directory, ExtractCallb CArchiveLink archiveLink; if (archiveLink.Open2(op, nullptr) != S_OK) { throw SevenZipException(QCoreApplication::translate("Lib7z", - "Could not open archive '%1'.").arg(archive->fileName())); + "Cannot open archive \"%1\".").arg(archive->fileName())); } callback->setTarget(directory); @@ -1049,7 +1054,7 @@ bool isSupportedArchive(QFileDevice *archive) try { CCodecs codecs; if (codecs.Load() != S_OK) - throw SevenZipException(QCoreApplication::translate("Lib7z", "Could not load codecs.")); + throw SevenZipException(QCoreApplication::translate("Lib7z", "Cannot load codecs.")); COpenOptions op; op.codecs = &codecs; diff --git a/src/libs/installer/licenseoperation.cpp b/src/libs/installer/licenseoperation.cpp index af5d29d98..4721a6108 100644 --- a/src/libs/installer/licenseoperation.cpp +++ b/src/libs/installer/licenseoperation.cpp @@ -76,11 +76,10 @@ bool LicenseOperation::performOperation() setArguments(QStringList(targetDir)); for (QVariantMap::const_iterator it = licenses.constBegin(); it != licenses.constEnd(); ++it) { - QFile file(targetDir + QDir::separator() + it.key()); + QFile file(targetDir + QLatin1Char('/') + it.key()); if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { setError(UserDefinedError); - setErrorString(tr("Can not write license file: %1.").arg(targetDir + QDir::separator() - + it.key())); + setErrorString(tr("Can not write license file \"%1\".").arg(QDir::toNativeSeparators(file.fileName()))); return false; } diff --git a/src/libs/installer/linereplaceoperation.cpp b/src/libs/installer/linereplaceoperation.cpp index c84d1922c..11168b10e 100644 --- a/src/libs/installer/linereplaceoperation.cpp +++ b/src/libs/installer/linereplaceoperation.cpp @@ -66,7 +66,8 @@ bool LineReplaceOperation::performOperation() QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { setError(UserDefinedError); - setErrorString(tr("Failed to open '%1' for reading.").arg(fileName)); + setErrorString(tr("Cannot open file \"%1\" for reading: %2").arg( + QDir::toNativeSeparators(fileName), file.errorString())); return false; } @@ -83,7 +84,8 @@ bool LineReplaceOperation::performOperation() if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { setError(UserDefinedError); - setErrorString(tr("Failed to open '%1' for writing.").arg(fileName)); + setErrorString(tr("Cannot open file \"%1\" for writing: %2").arg( + QDir::toNativeSeparators(fileName), file.errorString())); return false; } diff --git a/src/libs/installer/link.cpp b/src/libs/installer/link.cpp index 9462f5358..f90a6d3c1 100644 --- a/src/libs/installer/link.cpp +++ b/src/libs/installer/link.cpp @@ -94,7 +94,7 @@ public: OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, 0); if (m_dirHandle == INVALID_HANDLE_VALUE) { - qWarning() << QString::fromLatin1("Could not open: '%1'; error: %2\n").arg(path) + qWarning() << QString::fromLatin1("Cannot open: \"%1\": %2\n").arg(path) .arg(QInstaller::windowsErrorString(GetLastError())); } } @@ -144,13 +144,13 @@ QString readWindowsSymLink(const QString &path) Link createJunction(const QString &linkPath, const QString &targetPath) { if (!QDir().mkpath(linkPath)) { - qWarning() << QString::fromLatin1("Could not create the mount directory: %1").arg( + qWarning() << QString::fromLatin1("Cannot create the mount directory: %1").arg( linkPath); return Link(linkPath); } FileHandleWrapper dirHandle(linkPath); if (dirHandle.handle() == INVALID_HANDLE_VALUE) { - qWarning() << QString::fromLatin1("Could not open: '%1'; error: %2\n").arg(linkPath) + qWarning() << QString::fromLatin1("Cannot open: \"%1\": %2\n").arg(linkPath) .arg(QInstaller::windowsErrorString(GetLastError())); return Link(linkPath); } @@ -181,7 +181,7 @@ Link createJunction(const QString &linkPath, const QString &targetPath) if (!::DeviceIoControl(dirHandle.handle(), FSCTL_SET_REPARSE_POINT, reparseStructData, reparseStructData->ReparseDataLength + REPARSE_DATA_BUFFER_HEADER_SIZE, 0, 0, &bytesReturned, 0)) { - qWarning() << QString::fromLatin1("Could not set the reparse point: for '%1' to %2; error: %3" + qWarning() << QString::fromLatin1("Cannot set the reparse point for \"%1\" to %2: %3" ).arg(linkPath, targetPath).arg(QInstaller::windowsErrorString(GetLastError())); } return Link(linkPath); @@ -203,7 +203,7 @@ bool removeJunction(const QString &path) REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, 0, 0, &bytesReturned, 0)) { - qWarning() << QString::fromLatin1("Could not remove the reparse point: '%1'; error: %3" + qWarning() << QString::fromLatin1("Cannot remove the reparse point \"'%1\": %3" ).arg(path).arg(QInstaller::windowsErrorString(GetLastError())); return false; } @@ -217,7 +217,7 @@ Link createLnSymlink(const QString &linkPath, const QString &targetPath) int linkedError = symlink(QFileInfo(targetPath).absoluteFilePath().toUtf8(), QFileInfo(linkPath).absoluteFilePath().toUtf8()); if (linkedError != 0) { - qWarning() << QString::fromLatin1("Could not create a symlink: from '%1' to %2; error: %3" + qWarning() << QString::fromLatin1("Cannot create a symlink from \"%1\" to \"%2\": %3" ).arg(linkPath, targetPath).arg(linkedError); } @@ -245,7 +245,7 @@ Link Link::create(const QString &link, const QString &targetPath) if (!linkPathExists) linkPathExists = QDir().mkpath(linkPath); if (!linkPathExists) { - qWarning() << QString::fromLatin1("Could not create the needed directories: %1").arg( + qWarning() << QString::fromLatin1("Cannot create the needed directories: %1").arg( link); return Link(link); } diff --git a/src/libs/installer/messageboxhandler.cpp b/src/libs/installer/messageboxhandler.cpp index a33810938..368a68e01 100644 --- a/src/libs/installer/messageboxhandler.cpp +++ b/src/libs/installer/messageboxhandler.cpp @@ -407,8 +407,8 @@ QMessageBox::StandardButton MessageBoxHandler::showMessageBox(MessageType messag messageTypeHash.insert(warningType, QLatin1String("warning")); }; - qDebug() << QString::fromLatin1("created %1 message box %2: '%3', %4").arg(messageTypeHash - .value(messageType),identifier, title, text); + qDebug() << QString::fromLatin1("Created %1 message box %2: \"%3\", %4").arg(messageTypeHash + .value(messageType), identifier, title, text); if (qobject_cast<QApplication*> (qApp) == 0) return defaultButton; diff --git a/src/libs/installer/metadatajob.cpp b/src/libs/installer/metadatajob.cpp index fa3168e8f..9082c0367 100644 --- a/src/libs/installer/metadatajob.cpp +++ b/src/libs/installer/metadatajob.cpp @@ -297,7 +297,7 @@ MetadataJob::Status MetadataJob::parseUpdatesXml(const QList<FileTaskResult> &re Metadata metadata; QTemporaryDir tmp(QDir::tempPath() + QLatin1String("/remoterepo-XXXXXX")); if (!tmp.isValid()) { - qDebug() << "Could not create unique temporary directory."; + qDebug() << "Cannot create unique temporary directory."; return XmlDownloadFailure; } @@ -307,20 +307,20 @@ MetadataJob::Status MetadataJob::parseUpdatesXml(const QList<FileTaskResult> &re QFile file(result.target()); if (!file.rename(metadata.directory + QLatin1String("/Updates.xml"))) { - qDebug() << "Could not rename target to Updates.xml. Error:" << file.errorString(); + qDebug() << "Cannot rename target to Updates.xml:" << file.errorString(); return XmlDownloadFailure; } if (!file.open(QIODevice::ReadOnly)) { - qDebug() << "Could not open Updates.xml for reading. Error:" << file.errorString(); + qDebug() << "Cannot open Updates.xml for reading:" << file.errorString(); return XmlDownloadFailure; } QString error; QDomDocument doc; if (!doc.setContent(&file, &error)) { - qDebug() << QString::fromLatin1("Could not fetch a valid version of Updates.xml from " - "repository: %1. Error: %2").arg(metadata.repository.displayname(), error); + qDebug() << QString::fromLatin1("Cannot fetch a valid version of Updates.xml from " + "repository %1: %2").arg(metadata.repository.displayname(), error); return XmlDownloadFailure; } file.close(); diff --git a/src/libs/installer/metadatajob_p.h b/src/libs/installer/metadatajob_p.h index 6e9796712..0e2cbf3b6 100644 --- a/src/libs/installer/metadatajob_p.h +++ b/src/libs/installer/metadatajob_p.h @@ -39,6 +39,7 @@ #include "lib7z_facade.h" #include "metadatajob.h" +#include <QDir> #include <QFile> namespace QInstaller{ @@ -86,14 +87,14 @@ public: Lib7z::extractArchive(&archive, m_targetDir); } catch (const Lib7z::SevenZipException& e) { fi.reportException(UnzipArchiveException(MetadataJob::tr("Error while extracting " - "'%1': %2").arg(m_archive, e.message()))); + "archive \"%1\": %2").arg(QDir::toNativeSeparators(m_archive), e.message()))); } catch (...) { fi.reportException(UnzipArchiveException(MetadataJob::tr("Unknown exception " - "caught while extracting %1.").arg(m_archive))); + "caught while extracting archive \"%1\".").arg(QDir::toNativeSeparators(m_archive)))); } } else { - fi.reportException(UnzipArchiveException(MetadataJob::tr("Could not open %1 for " - "reading. Error: %2").arg(m_archive, archive.errorString()))); + fi.reportException(UnzipArchiveException(MetadataJob::tr("Cannot open file \"%1\" for " + "reading: %2").arg(QDir::toNativeSeparators(m_archive), archive.errorString()))); } fi.reportFinished(); diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 9efee0465..1bb800b4a 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -657,7 +657,7 @@ int PackageManagerCore::downloadNeededArchives(double partProgressSize) throw Error(archivesJob.errorString()); if (d->statusCanceledOrFailed()) - throw Error(tr("Installation canceled by user")); + throw Error(tr("Installation canceled by user.")); ProgressCoordinator::instance()->emitDownloadStatus(tr("All downloads finished.")); @@ -749,7 +749,7 @@ void PackageManagerCore::rollBackInstallation() } catch (const Error &e) { MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), QLatin1String("ElevationError"), tr("Authentication Error"), tr("Some components " - "could not be removed completely because admin rights could not be acquired: %1.") + "could not be removed completely because administrative rights could not be acquired: %1.") .arg(e.message())); } catch (...) { MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), QLatin1String("unknown"), @@ -966,7 +966,7 @@ bool PackageManagerCore::fetchLocalPackagesTree() d->setStatus(Running); if (!isPackageManager()) { - d->setStatus(Failure, tr("Application not running in Package Manager mode!")); + d->setStatus(Failure, tr("Application not running in Package Manager mode.")); return false; } @@ -988,7 +988,7 @@ bool PackageManagerCore::fetchLocalPackagesTree() component->loadDataFromPackage(installedPackages.value(key)); const QString &name = component->name(); if (components.contains(name)) { - qCritical("Could not register component! Component with identifier %s already registered.", + qCritical("Cannot register component! Component with identifier %s already registered.", qPrintable(name)); continue; } @@ -1074,7 +1074,7 @@ bool PackageManagerCore::fetchRemotePackagesTree() d->setStatus(Running); if (isUninstaller()) { - d->setStatus(Failure, tr("Application running in Uninstaller mode!")); + d->setStatus(Failure, tr("Application running in Uninstaller mode.")); return false; } @@ -2330,7 +2330,7 @@ bool PackageManagerCore::updateComponentData(struct Data &data, Component *compo // check if we already added the component to the available components list const QString name = data.package->data(scName).toString(); if (data.components->contains(name)) { - qCritical("Could not register component! Component with identifier %s already registered.", + qCritical("Cannot register component! Component with identifier %s already registered.", qPrintable(name)); return false; } diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index ceb1e2f60..84eb057c2 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -753,7 +753,7 @@ void PackageManagerCorePrivate::writeMaintenanceConfigFiles() if (cfg.status() != QSettingsWrapper::NoError) { const QString reason = cfg.status() == QSettingsWrapper::AccessError ? tr("Access error") : tr("Format error"); - throw Error(tr("Could not write installer configuration to %1: %2").arg(iniPath, reason)); + throw Error(tr("Cannot write installer configuration to %1: %2").arg(iniPath, reason)); } QFile file(targetDir() + QLatin1Char('/') + QLatin1String("network.xml")); @@ -1009,13 +1009,13 @@ void PackageManagerCorePrivate::writeMaintenanceToolBinary(QFile *const input, q { QFile dummy(resourcePath.filePath(QLatin1String("installer.dat"))); if (dummy.exists() && !dummy.remove()) { - throw Error(tr("Could not remove data file '%1': %2").arg(dummy.fileName(), + throw Error(tr("Cannot remove data file \"%1\": %2").arg(dummy.fileName(), dummy.errorString())); } } if (!dataOut.rename(resourcePath.filePath(QLatin1String("installer.dat")))) { - throw Error(tr("Could not write maintenance tool data to %1: %2").arg(out.fileName(), + throw Error(tr("Cannot write maintenance tool data to %1: %2").arg(out.fileName(), out.errorString())); } dataOut.setAutoRemove(false); @@ -1034,13 +1034,13 @@ void PackageManagerCorePrivate::writeMaintenanceToolBinary(QFile *const input, q { QFile dummy(maintenanceToolRenamedName); if (dummy.exists() && !dummy.remove()) { - throw Error(tr("Could not remove data file '%1': %2").arg(dummy.fileName(), + throw Error(tr("Cannot remove data file \"%1\": %2").arg(dummy.fileName(), dummy.errorString())); } } if (!out.copy(maintenanceToolRenamedName)) { - throw Error(tr("Could not write maintenance tool to %1: %2").arg(maintenanceToolRenamedName, + throw Error(tr("Cannot write maintenance tool to \"%1\": %2").arg(maintenanceToolRenamedName, out.errorString())); } @@ -1072,8 +1072,8 @@ void PackageManagerCorePrivate::writeMaintenanceToolBinaryData(QFileDevice *outp file.remove(); // clear all possible leftovers m_core->setValue(QString::fromLatin1("DefaultResourceReplacement"), QString()); } else { - qWarning() << QString::fromLatin1("Could not replace default resource with '%1'.") - .arg(newDefaultResource); + qWarning() << QString::fromLatin1("Cannot replace default resource with \"%1\".") + .arg(QDir::toNativeSeparators(newDefaultResource)); } } @@ -1261,17 +1261,17 @@ void PackageManagerCorePrivate::writeMaintenanceTool(OperationList performedOper if (!replacementBinary.remove()) { // Is there anything more sensible we can do with this error? I think not. It's not serious // enough for throwing / aborting the process. - qDebug() << QString::fromLatin1("Could not remove installer base binary '%1' after updating " + qDebug() << QString::fromLatin1("Cannot remove installer base binary \"%1\" after updating " "the maintenance tool: %2").arg(installerBaseBinary, replacementBinary.errorString()); } else { - qDebug() << QString::fromLatin1("Removed installer base binary '%1' after updating the " + qDebug() << QString::fromLatin1("Removed installer base binary \"%1\" after updating the " "maintenance tool.").arg(installerBaseBinary); } m_installerBaseBinaryUnreplaced.clear(); } else if (!installerBaseBinary.isEmpty() && !QFileInfo(installerBaseBinary).exists()) { qWarning() << QString::fromLatin1("The current maintenance tool could not be " - "updated. '%1' does not exist. Please fix the 'setInstallerBaseBinary(<temp_installer_base_" - "binary_path>)' call in your script.").arg(installerBaseBinary); + "updated. \"%1\" does not exist. Please fix the \"setInstallerBaseBinary(<temp_installer_base_" + "binary_path>)\" call in your script.").arg(installerBaseBinary); } QFile input; @@ -1281,7 +1281,7 @@ void PackageManagerCorePrivate::writeMaintenanceTool(OperationList performedOper try { if (isInstaller()) { if (QFile::exists(dataFile)) { - qWarning() << QString::fromLatin1("Found binary data file '%1' but " + qWarning() << QString::fromLatin1("Found binary data file \"%1\" but " "deliberately not used. Running as installer requires to read the " "resources from the application binary.").arg(dataFile); } @@ -1332,12 +1332,12 @@ void PackageManagerCorePrivate::writeMaintenanceTool(OperationList performedOper QFile dummy(dataFile + QLatin1String(".new")); if (dummy.exists() && !dummy.remove()) { - throw Error(tr("Could not remove data file '%1': %2").arg(dummy.fileName(), + throw Error(tr("Cannot remove data file \"%1\": %2").arg(dummy.fileName(), dummy.errorString())); } if (!file.rename(dataFile + QLatin1String(".new"))) { - throw Error(tr("Could not write maintenance tool binary data to %1: %2") + throw Error(tr("Cannot write maintenance tool binary data to %1: %2") .arg(file.fileName(), file.errorString())); } file.setAutoRemove(false); @@ -1864,7 +1864,7 @@ void PackageManagerCorePrivate::installComponent(Component *component, double pr bool ignoreError = false; bool ok = performOperationThreaded(operation); while (!ok && !ignoreError && m_core->status() != PackageManagerCore::Canceled) { - qDebug() << QString::fromLatin1("Operation '%1' with arguments: '%2' failed: %3") + qDebug() << QString::fromLatin1("Operation \"%1\" with arguments \"%2\" failed: %3") .arg(operation->name(), operation->arguments().join(QLatin1String("; ")), operation->errorString()); const QMessageBox::StandardButton button = @@ -2111,7 +2111,7 @@ PackagesList PackageManagerCorePrivate::remotePackages() m_updateFinder->run(); if (m_updateFinder->updates().isEmpty()) { - setStatus(PackageManagerCore::Failure, tr("Could not retrieve remote tree: %1.") + setStatus(PackageManagerCore::Failure, tr("Cannot retrieve remote tree %1.") .arg(m_updateFinder->errorString())); return PackagesList(); } @@ -2144,7 +2144,7 @@ LocalPackagesHash PackageManagerCorePrivate::localInstalledPackages() } if (m_localPackageHub->error() != LocalPackageHub::NoError) { - setStatus(PackageManagerCore::Failure, tr("Failure to read packages from: %1.") + setStatus(PackageManagerCore::Failure, tr("Failure to read packages from %1.") .arg(componentsXmlPath())); } @@ -2170,7 +2170,7 @@ bool PackageManagerCorePrivate::fetchMetaInformationFromRepositories() m_metadataJob.start(); m_metadataJob.waitForFinished(); } catch (Error &error) { - setStatus(PackageManagerCore::Failure, tr("Could not retrieve meta information: %1") + setStatus(PackageManagerCore::Failure, tr("Cannot retrieve meta information: %1") .arg(error.message())); return m_repoFetched; } @@ -2221,7 +2221,7 @@ bool PackageManagerCorePrivate::addUpdateResourcesFromRepositories(bool parseChe QInstaller::openForRead(&updatesFile); } catch(const Error &e) { qDebug() << "Error opening Updates.xml:" << e.message(); - setStatus(PackageManagerCore::Failure, tr("Could not add temporary update source information.")); + setStatus(PackageManagerCore::Failure, tr("Cannot add temporary update source information.")); return false; } @@ -2232,7 +2232,7 @@ bool PackageManagerCorePrivate::addUpdateResourcesFromRepositories(bool parseChe if (!doc.setContent(&updatesFile, &error, &line, &column)) { qDebug() << QString::fromLatin1("Parse error in file %4: %1 at line %2 col %3").arg(error, QString::number(line), QString::number(column), updatesFile.fileName()); - setStatus(PackageManagerCore::Failure, tr("Could not add temporary update source information.")); + setStatus(PackageManagerCore::Failure, tr("Cannot add temporary update source information.")); return false; } @@ -2245,7 +2245,7 @@ bool PackageManagerCorePrivate::addUpdateResourcesFromRepositories(bool parseChe } if (m_packageSources.count() == 0) { - setStatus(PackageManagerCore::Failure, tr("Could not find any update source information.")); + setStatus(PackageManagerCore::Failure, tr("Cannot find any update source information.")); return false; } @@ -2310,7 +2310,7 @@ OperationList PackageManagerCorePrivate::sortOperationsBasedOnComponentDependenc const QStringList resolvedComponents = componentGraph.sort(); if (componentGraph.hasCycle()) { - throw Error(tr("Dependency cycle between components detected: '%1' and '%2'.") + throw Error(tr("Dependency cycle between components \"%1\" and \"%2\" detected.") .arg(componentGraph.cycle().first, componentGraph.cycle().second)); } foreach (const QString &componentName, resolvedComponents) @@ -2335,7 +2335,7 @@ void PackageManagerCorePrivate::processFilesForDelayedDeletion() foreach (const QString &i, filesForDelayedDeletion) { QFile file(i); //TODO: this should happen asnyc and report errors, I guess if (file.exists() && !file.remove()) { - qWarning("Could not delete file %s: %s", qPrintable(i), + qWarning("Cannot delete file %s: %s", qPrintable(i), qPrintable(file.errorString())); m_filesForDelayedDeletion << i; // try again next time } diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp index a180f3a7a..d25e9f486 100644 --- a/src/libs/installer/packagemanagergui.cpp +++ b/src/libs/installer/packagemanagergui.cpp @@ -2159,7 +2159,7 @@ TargetDirectoryPage::TargetDirectoryPage(PackageManagerCore *core) QLabel *msgLabel = new QLabel(this); msgLabel->setWordWrap(true); msgLabel->setObjectName(QLatin1String("MessageLabel")); - msgLabel->setText(tr("Please specify the folder where %1 will be installed.").arg(productName())); + msgLabel->setText(tr("Please specify the directory where %1 will be installed.").arg(productName())); layout->addWidget(msgLabel); QHBoxLayout *hlayout = new QHBoxLayout; @@ -2267,14 +2267,14 @@ bool TargetDirectoryPage::validatePage() QFileInfo fi2(targetDir + QDir::separator() + fileName); if (fi2.exists()) { - return failWithError(QLatin1String("TargetDirectoryInUse"), tr("The folder you selected already " + return failWithError(QLatin1String("TargetDirectoryInUse"), tr("The directory you selected already " "exists and contains an installation. Choose a different target for installation.")); } return askQuestion(QLatin1String("OverwriteTargetDirectory"), - tr("You have selected an existing, non-empty folder for installation.\nNote that it will be " + tr("You have selected an existing, non-empty directory for installation.\nNote that it will be " "completely wiped on uninstallation of this application.\nIt is not advisable to install into " - "this folder as installation might fail.\nDo you want to continue?")); + "this directory as installation might fail.\nDo you want to continue?")); } else if (fi.isFile() || fi.isSymLink()) { return failWithError(QLatin1String("WrongTargetDirectory"), tr("You have selected an existing file " "or symlink, please choose a different target for installation.")); @@ -2329,7 +2329,7 @@ bool TargetDirectoryPage::isComplete() const QString TargetDirectoryPage::targetDirWarning() const { if (targetDir().isEmpty()) - return tr("The installation path cannot be empty, please specify a valid folder."); + return tr("The installation path cannot be empty, please specify a valid directory."); QDir target(targetDir()); if (target.isRelative()) @@ -2392,7 +2392,7 @@ QString TargetDirectoryPage::targetDirWarning() const } if (nativeTargetDir.endsWith(QLatin1Char('.'))) - return tr("The installation path must not end with '.', please specify a valid folder."); + return tr("The installation path must not end with '.', please specify a valid directory."); QString ambiguousChars = QLatin1String("[\"~<>|?*!@#$%^&:,; ]" "|(\\\\CON)|(\\\\PRN)|(\\\\AUX)|(\\\\NUL)|(\\\\COM\\d)|(\\\\LPT\\d)"); @@ -2407,8 +2407,8 @@ QString TargetDirectoryPage::targetDirWarning() const // check if there are not allowed characters in the target path QRegularExpressionMatch match = ambCharRegEx.match(nativeTargetDir); if (match.hasMatch()) { - return tr("The installation path must not contain '%1', " - "please specify a valid folder.").arg(match.captured(0)); + return tr("The installation path must not contain \"%1\", " + "please specify a valid directory.").arg(match.captured(0)); } return QString(); @@ -2453,7 +2453,7 @@ StartMenuDirectoryPage::StartMenuDirectoryPage(PackageManagerCore *core) setObjectName(QLatin1String("StartMenuDirectoryPage")); setColoredTitle(tr("Start Menu shortcuts")); setColoredSubTitle(tr("Select the Start Menu in which you would like to create the program's " - "shortcuts. You can also enter a name to create a new folder.")); + "shortcuts. You can also enter a name to create a new directory.")); m_lineEdit = new QLineEdit(this); m_lineEdit->setText(core->value(scStartMenuDir, productName())); @@ -2610,7 +2610,7 @@ void ReadyForInstallationPage::entering() // at the moment there is no better way to check this if (targetVolume.size() == 0 && installVolumeAvailableSize == 0) { - qDebug() << QString::fromLatin1("Could not determine available space on device. Volume " + qDebug() << QString::fromLatin1("Cannot determine available space on device. Volume " "descriptor: %1, Mount path: %2. Continue silently.").arg(targetVolume .volumeDescriptor(), targetVolume.mountPath()); return; // TODO: Shouldn't this also disable the "Next" button? @@ -2618,11 +2618,11 @@ void ReadyForInstallationPage::entering() const bool tempOnSameVolume = (targetVolume == tempVolume); if (tempOnSameVolume) { - qDebug() << "Tmp and install folder are on the same volume. Volume mount point:" + qDebug() << "Tmp and install directories are on the same volume. Volume mount point:" << targetVolume.mountPath() << "Free space available:" << humanReadableSize(installVolumeAvailableSize); } else { - qDebug() << "Tmp is on a different volume than the install folder. Tmp volume mount point:" + qDebug() << "Tmp is on a different volume than the installation directory. Tmp volume mount point:" << tempVolume.mountPath() << "Free space available:" << humanReadableSize(tempVolumeAvailableSize) << "Install volume mount point:" << targetVolume.mountPath() << "Free space available:" @@ -2654,7 +2654,7 @@ void ReadyForInstallationPage::entering() if (tempOnSameVolume && (installVolumeAvailableSize <= (required + tempRequired))) { m_msgLabel->setText(tr("Not enough disk space to store temporary files and the " - "installation! Available space: %1, at least required %2.") + "installation. %1 are available, while %2 are at least required.") .arg(humanReadableSize(installVolumeAvailableSize), humanReadableSize(required + tempRequired))); setComplete(false); @@ -2662,16 +2662,16 @@ void ReadyForInstallationPage::entering() } if (installVolumeAvailableSize < required) { - m_msgLabel->setText(tr("Not enough disk space to store all selected components! Available " - "space: %1, at least required: %2.").arg(humanReadableSize(installVolumeAvailableSize), + m_msgLabel->setText(tr("Not enough disk space to store all selected components! %1 are available " + "while %2 are at least required.").arg(humanReadableSize(installVolumeAvailableSize), humanReadableSize(required))); setComplete(false); return; } if (tempVolumeAvailableSize < tempRequired) { - m_msgLabel->setText(tr("Not enough disk space to store temporary files! Available space: " - "%1, at least required: %2.").arg(humanReadableSize(tempVolumeAvailableSize), + m_msgLabel->setText(tr("Not enough disk space to store temporary files! %1 are available " + "while %2 are at least required.").arg(humanReadableSize(tempVolumeAvailableSize), humanReadableSize(tempRequired))); setComplete(false); return; diff --git a/src/libs/installer/qtpatch.cpp b/src/libs/installer/qtpatch.cpp index 963865c7b..88020fddb 100644 --- a/src/libs/installer/qtpatch.cpp +++ b/src/libs/installer/qtpatch.cpp @@ -174,7 +174,7 @@ bool QtPatch::patchTextFile(const QString &fileName, QFile file(fileName); if (!file.open(QFile::ReadOnly)) { - qDebug() << QString::fromLatin1("qpatch: warning: Open the file '%1' stopped: %2").arg( + qDebug() << QString::fromLatin1("Cannot open file \"%1\" for patching: %2").arg( fileName, file.errorString()); return false; } @@ -189,7 +189,7 @@ bool QtPatch::patchTextFile(const QString &fileName, } if (!file.open(QFile::WriteOnly | QFile::Truncate)) { - qDebug() << QString::fromLatin1("qpatch: error: file '%1' not writable").arg(fileName); + qDebug() << QString::fromLatin1("File \"%1\" not writable.").arg(fileName); return false; } @@ -209,7 +209,7 @@ bool QtPatch::openFileForPatching(QFile *file) } return file->openMode() == QFile::ReadWrite; } - qDebug() << QString::fromLatin1("qpatch: error: File '%1 is open, so it cannot be opened again.").arg( + qDebug() << QString::fromLatin1("File \"%1\" is open, so it cannot be opened again.").arg( file->fileName()); return false; } diff --git a/src/libs/installer/remoteclient_p.h b/src/libs/installer/remoteclient_p.h index 9baef7aa9..9762de3a3 100644 --- a/src/libs/installer/remoteclient_p.h +++ b/src/libs/installer/remoteclient_p.h @@ -132,8 +132,8 @@ public: const QMessageBox::Button res = MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), QLatin1String("AuthorizationError"), - QCoreApplication::translate("RemoteClient", "Could not get authorization."), - QCoreApplication::translate("RemoteClient", "Could not get authorization that " + QCoreApplication::translate("RemoteClient", "Cannot get authorization."), + QCoreApplication::translate("RemoteClient", "Cannot get authorization that " "is needed for continuing the installation.\n Either abort the " "installation or use the fallback solution by running\n\n%1\n\nas root " "and then clicking OK.").arg(fallback), diff --git a/src/libs/installer/remoteobject.h b/src/libs/installer/remoteobject.h index 18cd1ccbb..8db843177 100644 --- a/src/libs/installer/remoteobject.h +++ b/src/libs/installer/remoteobject.h @@ -97,7 +97,7 @@ public: QByteArray data; while (!receivePacket(m_socket, &command, &data)) { if (!m_socket->waitForReadyRead(-1)) { - throw Error(tr("Could not read all data after sending command: %1. " + throw Error(tr("Cannot read all data after sending command: %1. " "Bytes expected: %2, Bytes received: %3. Error: %4").arg(name).arg(0) .arg(m_socket->bytesAvailable()).arg(m_socket->errorString())); } diff --git a/src/libs/installer/replaceoperation.cpp b/src/libs/installer/replaceoperation.cpp index 98a0e7bc9..8911534bb 100644 --- a/src/libs/installer/replaceoperation.cpp +++ b/src/libs/installer/replaceoperation.cpp @@ -66,7 +66,8 @@ bool ReplaceOperation::performOperation() QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { setError(UserDefinedError); - setErrorString(tr("Failed to open %1 for reading").arg(fileName)); + setErrorString(tr("Cannot open file \"%1\" for reading: %2").arg( + QDir::toNativeSeparators(fileName), file.errorString())); return false; } @@ -76,7 +77,8 @@ bool ReplaceOperation::performOperation() if (!file.open(QIODevice::WriteOnly)) { setError(UserDefinedError); - setErrorString(tr("Failed to open %1 for writing").arg(fileName)); + setErrorString(tr("Cannot open file \"%1\" for writing: %2").arg( + QDir::toNativeSeparators(fileName), file.errorString())); return false; } diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp index e3f82194c..eebfdf214 100644 --- a/src/libs/installer/scriptengine.cpp +++ b/src/libs/installer/scriptengine.cpp @@ -372,7 +372,7 @@ QJSValue ScriptEngine::loadInContext(const QString &context, const QString &file { QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { - throw Error(tr("Could not open the requested script file at %1: %2.") + throw Error(tr("Cannot open script file at %1: %2") .arg(fileName, file.errorString())); } @@ -390,9 +390,10 @@ QJSValue ScriptEngine::loadInContext(const QString &context, const QString &file QJSValue scriptContext = evaluate(scriptContent, fileName); scriptContext.setProperty(QLatin1String("Uuid"), QUuid::createUuid().toString()); if (scriptContext.isError()) { - throw Error(tr("Exception while loading the component script '%1'. (%2)").arg( - QFileInfo(file).absoluteFilePath(), scriptContext.toString().isEmpty() ? - QString::fromLatin1("Unknown error.") : scriptContext.toString())); + throw Error(tr("Exception while loading the component script \"%1\": %2").arg( + QDir::toNativeSeparators(QFileInfo(file).absoluteFilePath()), + scriptContext.toString().isEmpty() ? + tr("Unknown error.") : scriptContext.toString())); } return scriptContext; } diff --git a/src/libs/installer/selfrestartoperation.cpp b/src/libs/installer/selfrestartoperation.cpp index 8b1f6b0e8..54df7aa9e 100644 --- a/src/libs/installer/selfrestartoperation.cpp +++ b/src/libs/installer/selfrestartoperation.cpp @@ -54,7 +54,7 @@ bool SelfRestartOperation::performOperation() PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); if (!core) { setError(UserDefinedError); - setErrorString(tr("Installer object needed in '%1' operation is empty.").arg(name())); + setErrorString(tr("Installer object needed in operation %1 is empty.").arg(name())); return false; } diff --git a/src/libs/installer/settings.cpp b/src/libs/installer/settings.cpp index bf13a22d8..f46388d2d 100644 --- a/src/libs/installer/settings.cpp +++ b/src/libs/installer/settings.cpp @@ -104,7 +104,7 @@ static QStringList readArgumentAttributes(QXmlStreamReader &reader, Settings::Pa switch (token) { case QXmlStreamReader::StartElement: { if (!reader.attributes().isEmpty()) { - raiseError(reader, QString::fromLatin1("Unexpected attribute for element '%1'.") + raiseError(reader, QString::fromLatin1("Unexpected attribute for element \"%1\".") .arg(reader.name().toString()), parseMode); return arguments; } else { @@ -112,7 +112,7 @@ static QStringList readArgumentAttributes(QXmlStreamReader &reader, Settings::Pa (lc) ? arguments.append(reader.readElementText().toLower()) : arguments.append(reader.readElementText()); } else { - raiseError(reader, QString::fromLatin1("Unexpected element '%1'.").arg(reader.name() + raiseError(reader, QString::fromLatin1("Unexpected element \"%1\".").arg(reader.name() .toString()), parseMode); return arguments; } @@ -154,23 +154,23 @@ static QSet<Repository> readRepositories(QXmlStreamReader &reader, bool isDefaul } else if (reader.name() == QLatin1String("Enabled")) { repo.setEnabled(bool(reader.readElementText().toInt())); } else { - raiseError(reader, QString::fromLatin1("Unexpected element '%1'.").arg(reader.name() + raiseError(reader, QString::fromLatin1("Unexpected element \"%1\".").arg(reader.name() .toString()), parseMode); } if (!reader.attributes().isEmpty()) { - raiseError(reader, QString::fromLatin1("Unexpected attribute for element '%1'.") + raiseError(reader, QString::fromLatin1("Unexpected attribute for element \"%1\".") .arg(reader.name().toString()), parseMode); } } set.insert(repo); } else { - raiseError(reader, QString::fromLatin1("Unexpected element '%1'.").arg(reader.name().toString()), + raiseError(reader, QString::fromLatin1("Unexpected element \"%1\".").arg(reader.name().toString()), parseMode); } if (!reader.attributes().isEmpty()) { - raiseError(reader, QString::fromLatin1("Unexpected attribute for element '%1'.").arg(reader + raiseError(reader, QString::fromLatin1("Unexpected attribute for element \"%1\".").arg(reader .name().toString()), parseMode); } } @@ -237,12 +237,12 @@ Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix, file.setFileName(overrideConfig.fileName()); if (!file.open(QIODevice::ReadOnly)) - throw Error(tr("Could not open settings file %1 for reading: %2").arg(path, file.errorString())); + throw Error(tr("Cannot open settings file %1 for reading: %2").arg(path, file.errorString())); QXmlStreamReader reader(&file); if (reader.readNextStartElement()) { if (reader.name() != QLatin1String("Installer")) { - reader.raiseError(QString::fromLatin1("Unexpected element '%1' as root element.").arg(reader + reader.raiseError(QString::fromLatin1("Unexpected element \"%1\" as root element.").arg(reader .name().toString())); } } @@ -265,15 +265,15 @@ Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix, while (reader.readNextStartElement()) { const QString name = reader.name().toString(); if (!elementList.contains(name)) - raiseError(reader, QString::fromLatin1("Unexpected element '%1'.").arg(name), parseMode); + raiseError(reader, QString::fromLatin1("Unexpected element \"%1\".").arg(name), parseMode); if (!reader.attributes().isEmpty()) { - raiseError(reader, QString::fromLatin1("Unexpected attribute for element '%1'.").arg(name), + raiseError(reader, QString::fromLatin1("Unexpected attribute for element \"%1\".").arg(name), parseMode); } if (s.d->m_data.contains(name)) - reader.raiseError(QString::fromLatin1("Element '%1' has been defined before.").arg(name)); + reader.raiseError(QString::fromLatin1("Element \"%1\" has been defined before.").arg(name)); if (name == scTranslations) { s.setTranslations(readArgumentAttributes(reader, parseMode, QLatin1String("Translation"), true)); diff --git a/src/libs/installer/settingsoperation.cpp b/src/libs/installer/settingsoperation.cpp index 9a9d7c471..2cb36bf48 100644 --- a/src/libs/installer/settingsoperation.cpp +++ b/src/libs/installer/settingsoperation.cpp @@ -69,7 +69,7 @@ bool SettingsOperation::checkArguments() if (!missingArguments.isEmpty()) { setError(InvalidArguments); - setErrorString(tr("Missing argument(s) '%1' calling '%2' with arguments '%3'.").arg( + setErrorString(tr("Missing argument(s) \"%1\" calling %2 with arguments \"%3\".").arg( missingArguments.join(QLatin1String("; ")), name(), arguments().join(QLatin1String("; ")))); return false; } @@ -79,7 +79,7 @@ bool SettingsOperation::checkArguments() if (!possibleMethodValues.contains(method)) { setError(InvalidArguments); - setErrorString(tr("Current method argument calling '%1' with arguments '%2' is not " + setErrorString(tr("Current method argument calling \"%1\" with arguments \"%2\" is not " "supported. Please use set, remove, add_array_value or remove_array_value.").arg(name(), arguments().join(QLatin1String("; ")))); return false; diff --git a/src/libs/installer/simplemovefileoperation.cpp b/src/libs/installer/simplemovefileoperation.cpp index 54a5583ee..ce643020d 100644 --- a/src/libs/installer/simplemovefileoperation.cpp +++ b/src/libs/installer/simplemovefileoperation.cpp @@ -34,6 +34,7 @@ #include "simplemovefileoperation.h" +#include <QDir> #include <QtCore/QFileInfo> namespace QInstaller { @@ -58,8 +59,8 @@ bool SimpleMoveFileOperation::performOperation() if (source.isEmpty() || target.isEmpty()) { setError(UserDefinedError); - setErrorString(tr("None of the arguments can be empty: source '%1', target '%2'.") - .arg(source, target)); + setErrorString(tr("None of the arguments can be empty: source \"%1\", target \"%2\".") + .arg(QDir::toNativeSeparators(source), QDir::toNativeSeparators(target))); return false; } @@ -69,8 +70,8 @@ bool SimpleMoveFileOperation::performOperation() if (file.exists()) { if (!file.remove()) { setError(UserDefinedError); - setErrorString(tr("Cannot move source '%1' to target '%2', because target exists and is " - "not removable.").arg(source, target)); + setErrorString(tr("Cannot move file from \"%1\" to \"%2\", because the target path exists and is " + "not removable.").arg(QDir::toNativeSeparators(source), QDir::toNativeSeparators(target))); return false; } } @@ -78,12 +79,14 @@ bool SimpleMoveFileOperation::performOperation() file.setFileName(source); if (!file.rename(target)) { setError(UserDefinedError); - setErrorString(tr("Cannot move source '%1' to target '%2': %3").arg(source, target, - file.errorString())); + setErrorString(tr("Cannot move file \"%1\" to \"%2\": %3").arg( + QDir::toNativeSeparators(source), QDir::toNativeSeparators(target), + file.errorString())); return false; } - emit outputTextChanged(tr("Move '%1' to '%2'.").arg(source, target)); + emit outputTextChanged(tr("Moving file \"%1\" to \"%2\".").arg(QDir::toNativeSeparators(source), + QDir::toNativeSeparators(target))); return true; } @@ -93,7 +96,8 @@ bool SimpleMoveFileOperation::undoOperation() const QString target = arguments().at(1); QFile(target).rename(source); - emit outputTextChanged(tr("Move '%1' to '%2'.").arg(target, source)); + emit outputTextChanged(tr("Moving file \"%1\" to \"%2\".").arg(QDir::toNativeSeparators(target), + QDir::toNativeSeparators(source))); return true; } diff --git a/src/libs/installer/testrepository.cpp b/src/libs/installer/testrepository.cpp index 1dcba41ae..10e2673e4 100644 --- a/src/libs/installer/testrepository.cpp +++ b/src/libs/installer/testrepository.cpp @@ -110,7 +110,7 @@ void TestRepository::doCancel() if (m_downloader) { QString errorString = m_downloader->errorString(); if (errorString.isEmpty()) - errorString = tr("Got a timeout while testing: '%1'").arg(m_repository.displayname()); + errorString = tr("Got a timeout while testing \"%1\".").arg(m_repository.displayname()); // at the moment the download sends downloadCompleted() if we cancel it, so just disconnect(m_downloader, 0, this, 0); m_downloader->cancelDownload(); @@ -130,15 +130,15 @@ void TestRepository::downloadCompleted() QString errorMsg; if (!doc.setContent(&file, &errorMsg)) { error = InvalidUpdatesXml; - errorMsg = tr("Could not parse Updates.xml! Error: %1.").arg(errorMsg); + errorMsg = tr("Cannot parse Updates.xml: %1").arg(errorMsg); } else { error = NoError; } } else { - errorMsg = tr("Updates.xml could not be opened for reading!"); + errorMsg = tr("Updates.xml could not be opened for reading."); } } else { - errorMsg = tr("Updates.xml could not be found on server!"); + errorMsg = tr("Updates.xml could not be found on server."); } if (error > NoError) diff --git a/src/libs/kdtools/kdlockfile_unix.cpp b/src/libs/kdtools/kdlockfile_unix.cpp index 938961ac2..d763c7c14 100644 --- a/src/libs/kdtools/kdlockfile_unix.cpp +++ b/src/libs/kdtools/kdlockfile_unix.cpp @@ -36,6 +36,7 @@ #include "kdlockfile_p.h" #include <QCoreApplication> +#include <QDir> #include <cerrno> #include <sys/file.h> @@ -50,8 +51,8 @@ bool KDLockFile::Private::lock() errno = 0; handle = open(filename.toLatin1().constData(), O_CREAT | O_RDWR | O_NONBLOCK, 0600); if (handle == -1) { - errorString = QCoreApplication::translate("KDLockFile", "Could not create lock file '%1': " - "%2").arg(filename, QString::fromLocal8Bit(strerror(errno))); + errorString = QCoreApplication::translate("KDLockFile", "Cannot create lock file \"%1\": " + "%2").arg(QDir::toNativeSeparators(filename), QString::fromLocal8Bit(strerror(errno))); return false; } const QString pid = QString::number(qApp->applicationPid()); @@ -61,8 +62,8 @@ bool KDLockFile::Private::lock() while (written < data.size()) { const qint64 n = write(handle, data.constData() + written, data.size() - written); if (n < 0) { - errorString = QCoreApplication::translate("KDLockFile", "Could not write PID to lock " - "file '%1': %2").arg(filename, QString::fromLocal8Bit(strerror(errno))); + errorString = QCoreApplication::translate("KDLockFile", "Cannot write PID to lock " + "file \"%1\": %2").arg(QDir::toNativeSeparators(filename), QString::fromLocal8Bit(strerror(errno))); return false; } written += n; @@ -70,8 +71,8 @@ bool KDLockFile::Private::lock() errno = 0; locked = flock(handle, LOCK_NB | LOCK_EX) != -1; if (!locked) { - errorString = QCoreApplication::translate("KDLockFile", "Could not obtain the lock for " - "file '%1': %2").arg(filename, QString::fromLocal8Bit(strerror(errno))); + errorString = QCoreApplication::translate("KDLockFile", "Cannot obtain the lock for " + "file \"%1\": %2").arg(QDir::toNativeSeparators(filename), QString::fromLocal8Bit(strerror(errno))); } return locked; } @@ -85,8 +86,8 @@ bool KDLockFile::Private::unlock() errno = 0; locked = flock(handle, LOCK_UN | LOCK_NB) == -1; if (locked) { - errorString = QCoreApplication::translate("KDLockFile", "Could not release the lock for " - "file '%1': %2").arg(filename, QString::fromLocal8Bit(strerror(errno))); + errorString = QCoreApplication::translate("KDLockFile", "Cannot release the lock for " + "file \"%1\": %2").arg(QDir::toNativeSeparators(filename), QString::fromLocal8Bit(strerror(errno))); } else { unlink(filename.toLatin1()); } diff --git a/src/libs/kdtools/kdlockfile_win.cpp b/src/libs/kdtools/kdlockfile_win.cpp index 963ba682f..b3241b003 100644 --- a/src/libs/kdtools/kdlockfile_win.cpp +++ b/src/libs/kdtools/kdlockfile_win.cpp @@ -39,6 +39,7 @@ #include <utils.h> #include <QCoreApplication> +#include <QDir> #include <QFileInfo> bool KDLockFile::Private::lock() @@ -52,23 +53,23 @@ bool KDLockFile::Private::lock() FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, NULL); if (handle == INVALID_HANDLE_VALUE) { - errorString = QCoreApplication::translate("KDLockFile", "Could not create lock file '%1': " - "%2").arg(filename, QInstaller::windowsErrorString(GetLastError())); + errorString = QCoreApplication::translate("KDLockFile", "Cannot create lock file \"%1\": " + "%2").arg(QDir::toNativeSeparators(filename), QInstaller::windowsErrorString(GetLastError())); return false; } DWORD bytesWritten; const QByteArray pid = QString::number(QCoreApplication::applicationPid()).toLatin1(); if (!WriteFile(handle, pid.data(), pid.size(), &bytesWritten, NULL)) { - errorString = QCoreApplication::translate("KDLockFile", "Could not write PID to lock file " - "'%1': %2").arg(filename, QInstaller::windowsErrorString(GetLastError())); + errorString = QCoreApplication::translate("KDLockFile", "Cannot write PID to lock file " + "\"%1\": %2").arg(QDir::toNativeSeparators(filename), QInstaller::windowsErrorString(GetLastError())); return false; } FlushFileBuffers(handle); if (!LockFile(handle, 0, 0, QFileInfo(filename).size(), 0)) { - errorString = QCoreApplication::translate("KDLockFile", "Could not obtain the lock for " - "file '%1': %2").arg(filename, QInstaller::windowsErrorString(GetLastError())); + errorString = QCoreApplication::translate("KDLockFile", "Cannot obtain the lock for " + "file \"%1\": %2").arg(QDir::toNativeSeparators(filename), QInstaller::windowsErrorString(GetLastError())); } else { locked = true; } @@ -82,8 +83,8 @@ bool KDLockFile::Private::unlock() return true; if (!UnlockFile(handle, 0, 0, QFileInfo(filename).size(), 0)) { - errorString = QCoreApplication::translate("KDLockFile", "Could not release the lock for " - "file '%1': %2").arg(filename, QInstaller::windowsErrorString(GetLastError())); + errorString = QCoreApplication::translate("KDLockFile", "Cannot release the lock for " + "file \"%1\": %2").arg(QDir::toNativeSeparators(filename), QInstaller::windowsErrorString(GetLastError())); } else { locked = false; CloseHandle(handle); diff --git a/src/libs/kdtools/kdsysinfo_x11.cpp b/src/libs/kdtools/kdsysinfo_x11.cpp index 1e0a109b7..41575f775 100644 --- a/src/libs/kdtools/kdsysinfo_x11.cpp +++ b/src/libs/kdtools/kdsysinfo_x11.cpp @@ -76,7 +76,7 @@ QList<VolumeInfo> mountedVolumes() QFile f(QLatin1String("/etc/mtab")); if (!f.open(QIODevice::ReadOnly)) { - qCritical("%s: Could not open %s: %s", Q_FUNC_INFO, qPrintable(f.fileName()), qPrintable(f.errorString())); + qCritical("%s: Cannot open %s: %s", Q_FUNC_INFO, qPrintable(f.fileName()), qPrintable(f.errorString())); return result; //better error-handling? } diff --git a/src/libs/kdtools/kdupdaterfiledownloader.cpp b/src/libs/kdtools/kdupdaterfiledownloader.cpp index 98234920c..919a0a20e 100644 --- a/src/libs/kdtools/kdupdaterfiledownloader.cpp +++ b/src/libs/kdtools/kdupdaterfiledownloader.cpp @@ -39,6 +39,7 @@ #include <fileutils.h> #include <QDialog> +#include <QDir> #include <QFile> #include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkProxyFactory> @@ -696,8 +697,8 @@ void KDUpdater::LocalFileDownloader::doDownload() d->source = new QFile(localFile, this); if (!d->source->open(QFile::ReadOnly)) { onError(); - setDownloadAborted(tr("Cannot open source file '%1' for reading.").arg(QFileInfo(localFile) - .fileName())); + setDownloadAborted(tr("Cannot open file \"%1\" for reading: %2").arg(QFileInfo(localFile) + .fileName(), d->source->errorString())); return; } @@ -712,8 +713,8 @@ void KDUpdater::LocalFileDownloader::doDownload() if (!d->destination->isOpen()) { onError(); - setDownloadAborted(tr("Cannot open destination file '%1' for writing.") - .arg(QFileInfo(d->destination->fileName()).fileName())); + setDownloadAborted(tr("Cannot open file \"%1\" for writing: %2") + .arg(QFileInfo(d->destination->fileName()).fileName(), d->destination->errorString())); return; } @@ -785,8 +786,9 @@ void KDUpdater::LocalFileDownloader::timerEvent(QTimerEvent *event) killTimer(d->timerId); d->timerId = -1; onError(); - setDownloadAborted(tr("Writing to %1 failed: %2").arg(d->destination->fileName(), - d->destination->errorString())); + setDownloadAborted(tr("Writing to file \"%1\" failed: %2").arg( + QDir::toNativeSeparators(d->destination->fileName()), + d->destination->errorString())); return; } toWrite -= numWritten; @@ -975,7 +977,7 @@ void KDUpdater::ResourceFileDownloader::timerEvent(QTimerEvent *event) onError(); killTimer(d->timerId); emit downloadProgress(1); - setDownloadAborted(tr("Could not read resource file \"%1\". Reason:").arg(downloadedFileName(), + setDownloadAborted(tr("Cannot read resource file \"%1\": %2").arg(downloadedFileName(), d->destFile.errorString())); return; } @@ -1163,7 +1165,7 @@ void KDUpdater::HttpDownloader::httpReadyRead() const QString error = d->destination->errorString(); const QString fileName = d->destination->fileName(); d->shutDown(); - setDownloadAborted(tr("Cannot download %1: Writing to file '%2' failed: %3") + setDownloadAborted(tr("Cannot download %1. Writing to file \"%2\" failed: %3") .arg(url().toString(), fileName, error)); return; } @@ -1313,7 +1315,7 @@ void KDUpdater::HttpDownloader::startDownload(const QUrl &url) const QString error = d->destination->errorString(); const QString fileName = d->destination->fileName(); d->shutDown(); - setDownloadAborted(tr("Cannot download %1: Could not create %2: %3").arg( + setDownloadAborted(tr("Cannot download %1. Cannot create file \"%2\": %3").arg( url.toString(), fileName, error)); } } diff --git a/src/libs/kdtools/kdupdaterfiledownloaderfactory.cpp b/src/libs/kdtools/kdupdaterfiledownloaderfactory.cpp index fad1023d1..2321e7667 100644 --- a/src/libs/kdtools/kdupdaterfiledownloaderfactory.cpp +++ b/src/libs/kdtools/kdupdaterfiledownloaderfactory.cpp @@ -74,7 +74,7 @@ FileDownloaderFactory::FileDownloaderFactory() if (QSslSocket::supportsSsl()) registerFileDownloader<HttpDownloader>(QLatin1String("https")); else - qWarning() << "Could not register file downloader for https protocol: QSslSocket::supportsSsl() returns false"; + qWarning() << "Cannot register file downloader for https protocol: QSslSocket::supportsSsl() returns false"; #endif d->m_followRedirects = false; diff --git a/src/libs/kdtools/kdupdaterupdatefinder.cpp b/src/libs/kdtools/kdupdaterupdatefinder.cpp index 7c12213a7..987ad6335 100644 --- a/src/libs/kdtools/kdupdaterupdatefinder.cpp +++ b/src/libs/kdtools/kdupdaterupdatefinder.cpp @@ -180,7 +180,7 @@ void UpdateFinder::Private::computeUpdates() // First do some quick sanity checks on the packages info std::shared_ptr<LocalPackageHub> packages = m_localPackageHub.lock(); if (!packages) { - q->reportError(tr("Could not access the package information of this application.")); + q->reportError(tr("Cannot access the package information of this application.")); return; } @@ -294,7 +294,7 @@ bool UpdateFinder::Private::downloadUpdateXMLFiles() const Data data = m_updatesInfoList.value(updatesInfo); if (data.downloader) { if (!data.downloader->isDownloaded()) { - q->reportError(tr("Could not download package source %1 from ('%2')").arg(data + q->reportError(tr("Cannot download package source %1 from \"%2\".").arg(data .downloader->url().fileName(), data.info.url.toString())); } else { updatesInfo->setFileName(data.downloader->downloadedFileName()); diff --git a/src/libs/kdtools/kdupdaterupdateoperation.cpp b/src/libs/kdtools/kdupdaterupdateoperation.cpp index 8ecf6d3a5..8940609e1 100644 --- a/src/libs/kdtools/kdupdaterupdateoperation.cpp +++ b/src/libs/kdtools/kdupdaterupdateoperation.cpp @@ -250,7 +250,7 @@ QString UpdateOperation::argumentKeyValue(const QString &key, const QString &def it = std::find_if(++it, tArguments.end(), StartsWith(keySeparater)); if (it != tArguments.end()) { qWarning() << QString::fromLatin1("There are multiple keys in the arguments calling" - " '%1'. Only the first found '%2' is used: '%3'").arg(name(), key, arguments().join( + " \"%1\". Only the first found \"%2\" is used: \"%3\"").arg(name(), key, arguments().join( QLatin1String("; "))); } return value; @@ -340,7 +340,8 @@ bool UpdateOperation::deleteFileNowOrLater(const QString &file, QString *errorSt QFile f(file); if (!f.rename(backup)) { if (errorString) - *errorString = tr("Renaming %1 into %2 failed with %3.").arg(file, backup, f.errorString()); + *errorString = tr("Renaming file \"%1\" to \"%2\" failed: %3").arg( + QDir::toNativeSeparators(file), QDir::toNativeSeparators(backup), f.errorString()); return false; } registerForDelayedDeletion(QStringList(backup)); diff --git a/src/libs/kdtools/kdupdaterupdateoperations.cpp b/src/libs/kdtools/kdupdaterupdateoperations.cpp index 90dbc7d60..944679070 100644 --- a/src/libs/kdtools/kdupdaterupdateoperations.cpp +++ b/src/libs/kdtools/kdupdaterupdateoperations.cpp @@ -139,7 +139,7 @@ void CopyOperation::backup() // race condition: The backup file could get created by another process right now. But this is the same // in QFile::copy... if (!QFile::rename(destination, value(QLatin1String("backupOfExistingDestination")).toString())) - setError(UserDefinedError, tr("Could not backup file %1.").arg(destination)); + setError(UserDefinedError, tr("Cannot backup file \"%1\".").arg(QDir::toNativeSeparators(destination))); } bool CopyOperation::performOperation() @@ -155,7 +155,7 @@ bool CopyOperation::performOperation() QFile sourceFile(source); if (!sourceFile.exists()) { setError(UserDefinedError); - setErrorString(tr("Could not copy a non-existent file: %1").arg(source)); + setErrorString(tr("Cannot copy a non-existent file: %1").arg(QDir::toNativeSeparators(source))); return false; } // If destination file exists, we cannot use QFile::copy() because it does not overwrite an existing @@ -164,7 +164,8 @@ bool CopyOperation::performOperation() if (destinationFile.exists()) { if (!destinationFile.remove()) { setError(UserDefinedError); - setErrorString(tr("Could not remove destination file %1: %2").arg(destination, destinationFile.errorString())); + setErrorString(tr("Cannot remove file \"%1\": %2").arg( + QDir::toNativeSeparators(destination), destinationFile.errorString())); return false; } } @@ -172,7 +173,9 @@ bool CopyOperation::performOperation() const bool copied = sourceFile.copy(destination); if (!copied) { setError(UserDefinedError); - setErrorString(tr("Could not copy %1 to %2: %3").arg(source, destination, sourceFile.errorString())); + setErrorString(tr("Cannot copy file \"%1\" to \"%2\": %3").arg( + QDir::toNativeSeparators(source), QDir::toNativeSeparators(destination), + sourceFile.errorString())); } return copied; } @@ -189,7 +192,8 @@ bool CopyOperation::undoOperation() QFile destFile(destination); // first remove the dest if (destFile.exists() && !destFile.remove()) { - setError(UserDefinedError, tr("Could not delete file %1: %2").arg(destination, destFile.errorString())); + setError(UserDefinedError, tr("Cannot delete file \"%1\": %2").arg( + QDir::toNativeSeparators(destination), destFile.errorString())); return false; } @@ -202,7 +206,8 @@ bool CopyOperation::undoOperation() // otherwise we have to copy the backup back: const bool success = backupFile.rename(destination); if (!success) - setError(UserDefinedError, tr("Could not restore backup file into %1: %2").arg(destination, backupFile.errorString())); + setError(UserDefinedError, tr("Cannot restore backup file into \"%1\": %2").arg( + QDir::toNativeSeparators(destination), backupFile.errorString())); return success; } @@ -263,7 +268,7 @@ void MoveOperation::backup() // race condition: The backup file could get created by another process right now. But this is the same // in QFile::copy... if (!QFile::rename(dest, value(QLatin1String("backupOfExistingDestination")).toString())) - setError(UserDefinedError, tr("Could not backup file %1.").arg(dest)); + setError(UserDefinedError, tr("Cannot backup file \"%1\".").arg(QDir::toNativeSeparators(dest))); } bool MoveOperation::performOperation() @@ -281,7 +286,8 @@ bool MoveOperation::performOperation() QFile file(dest); if (!file.remove(dest)) { setError(UserDefinedError); - setErrorString(tr("Could not remove destination file %1: %2").arg(dest, file.errorString())); + setErrorString(tr("Cannot remove file \"%1\": %2").arg( + QDir::toNativeSeparators(dest), file.errorString())); return false; } } @@ -290,7 +296,8 @@ bool MoveOperation::performOperation() QFile file(args.at(0)); if (!file.copy(dest)) { setError(UserDefinedError); - setErrorString(tr("Could not copy %1 to %2: %3").arg(file.fileName(), dest, file.errorString())); + setErrorString(tr("Cannot copy file \"%1\" to \"%2\": %3").arg(QDir::toNativeSeparators(file.fileName()), + QDir::toNativeSeparators(dest), file.errorString())); return false; } return deleteFileNowOrLater(file.fileName()); @@ -303,13 +310,14 @@ bool MoveOperation::undoOperation() // first: copy back the destination to source QFile destF(dest); if (!destF.copy(args.first())) { - setError(UserDefinedError, tr("Cannot copy %1 to %2: %3").arg(dest, args.first(), destF.errorString())); + setError(UserDefinedError, tr("Cannot copy file \"%1\" to \"%2\": %3").arg( + QDir::toNativeSeparators(dest), QDir::toNativeSeparators(args.first()), destF.errorString())); return false; } // second: delete the move destination if (!deleteFileNowOrLater(dest)) { - setError(UserDefinedError, tr("Cannot remove file %1.")); + setError(UserDefinedError, tr("Cannot remove file \"%1\".").arg(QDir::toNativeSeparators(dest))); return false; } @@ -322,7 +330,8 @@ bool MoveOperation::undoOperation() QFile backupF(value(QLatin1String("backupOfExistingDestination")).toString()); const bool success = backupF.rename(dest); if (!success) - setError(UserDefinedError, tr("Cannot restore backup file for %1: %2").arg(dest, backupF.errorString())); + setError(UserDefinedError, tr("Cannot restore backup file for \"%1\": %2").arg( + QDir::toNativeSeparators(dest), backupF.errorString())); return success; } @@ -360,7 +369,8 @@ void DeleteOperation::backup() QFile file(fileName); if (!file.copy(value(QLatin1String("backupOfExistingFile")).toString())) - setError(UserDefinedError, tr("Cannot create backup of %1: %2").arg(fileName, file.errorString())); + setError(UserDefinedError, tr("Cannot create backup of file \"%1\": %2").arg( + QDir::toNativeSeparators(fileName), file.errorString())); } bool DeleteOperation::performOperation() @@ -381,7 +391,8 @@ bool DeleteOperation::undoOperation() QFile backupF(value(QLatin1String("backupOfExistingFile")).toString()); const bool success = backupF.copy(fileName) && deleteFileNowOrLater(backupF.fileName()); if (!success) - setError(UserDefinedError, tr("Cannot restore backup file for %1: %2").arg(fileName, backupF.errorString())); + setError(UserDefinedError, tr("Cannot restore backup file for \"%1\": %2").arg( + QDir::toNativeSeparators(fileName), backupF.errorString())); return success; } @@ -457,7 +468,8 @@ bool MkdirOperation::performOperation() const bool created = QDir::root().mkpath(dirName); if (!created) { setError(UserDefinedError); - setErrorString(tr("Could not create folder %1: Unknown error.").arg(dirName)); + setErrorString(tr("Cannot create directory \"%1\": %2").arg( + QDir::toNativeSeparators(dirName), tr("Unknown error."))); } return created; } @@ -489,9 +501,11 @@ bool MkdirOperation::undoOperation() if (!result) { if (errorString.isEmpty()) - setError(UserDefinedError, tr("Cannot remove directory %1: %2").arg(createdDir.path(), errorString)); + setError(UserDefinedError, tr("Cannot remove directory \"%1\": %2").arg( + QDir::toNativeSeparators(createdDir.path()), errorString)); else - setError(UserDefinedError, tr("Cannot remove directory %1: %2").arg(createdDir.path(), errnoToQString(errno))); + setError(UserDefinedError, tr("Cannot remove directory \"%1\": %2").arg( + QDir::toNativeSeparators(createdDir.path()), errnoToQString(errno))); } return result; } @@ -532,7 +546,8 @@ bool RmdirOperation::performOperation() QDir dir(firstArg); if (!dir.exists()) { setError(UserDefinedError); - setErrorString(tr("Could not remove folder %1: The folder does not exist.").arg(firstArg)); + setErrorString(tr("Cannot remove directory \"%1\": %2").arg( + QDir::toNativeSeparators(firstArg), tr("The directory does not exist."))); return false; } @@ -541,7 +556,8 @@ bool RmdirOperation::performOperation() setValue(QLatin1String("removed"), removed); if (!removed) { setError(UserDefinedError); - setErrorString(tr("Could not remove folder %1: %2").arg(firstArg, errnoToQString(errno))); + setErrorString(tr("Cannot remove directory \"%1\": %2").arg( + QDir::toNativeSeparators(firstArg), errnoToQString(errno))); } return removed; } @@ -555,7 +571,8 @@ bool RmdirOperation::undoOperation() const QFileInfo fi(arguments().first()); const bool success = fi.dir().mkdir(fi.fileName()); if( !success) - setError(UserDefinedError, tr("Cannot recreate directory %1: %2").arg(fi.fileName(), errnoToQString(errno))); + setError(UserDefinedError, tr("Cannot recreate directory \"%1\": %2").arg( + QDir::toNativeSeparators(fi.fileName()), errnoToQString(errno))); return success; } @@ -591,7 +608,8 @@ void AppendFileOperation::backup() setValue(QLatin1String("backupOfFile"), backupFileName(filename)); if (!file.copy(value(QLatin1String("backupOfFile")).toString())) { - setError(UserDefinedError, tr("Cannot backup file %1: %2").arg(filename, file.errorString())); + setError(UserDefinedError, tr("Cannot backup file \"%1\": %2").arg( + QDir::toNativeSeparators(filename), file.errorString())); clearValue(QLatin1String("backupOfFile")); } } @@ -626,7 +644,8 @@ bool AppendFileOperation::performOperation() if (error) { setError(UserDefinedError); - setErrorString(tr("Could not open file '%1' for writing: %2").arg(file.fileName(), file.errorString())); + setErrorString(tr("Cannot open file \"%1\" for writing: %2").arg( + QDir::toNativeSeparators(file.fileName()), file.errorString())); return false; } deleteFileNowOrLater(newName); @@ -645,13 +664,15 @@ bool AppendFileOperation::undoOperation() const QString filename = arguments().first(); const QString backupOfFile = value(QLatin1String("backupOfFile")).toString(); if (!backupOfFile.isEmpty() && !QFile::exists(backupOfFile)) { - setError(UserDefinedError, tr("Cannot find backup file for %1.").arg(filename)); + setError(UserDefinedError, tr("Cannot find backup file for \"%1\".").arg( + QDir::toNativeSeparators(filename))); return false; } const bool removed = deleteFileNowOrLater(filename); if (!removed) { - setError(UserDefinedError, tr("Could not restore backup file for %1.").arg(filename)); + setError(UserDefinedError, tr("Cannot restore backup file for \"%1\".").arg( + QDir::toNativeSeparators(filename))); return false; } @@ -662,7 +683,8 @@ bool AppendFileOperation::undoOperation() QFile backupFile(backupOfFile); const bool success = backupFile.rename(filename); if (!success) - setError(UserDefinedError, tr("Could not restore backup file for %1: %2").arg(filename, backupFile.errorString())); + setError(UserDefinedError, tr("Cannot restore backup file for \"%1\": %2").arg( + QDir::toNativeSeparators(filename), backupFile.errorString())); return success; } @@ -697,7 +719,8 @@ void PrependFileOperation::backup() setValue(QLatin1String("backupOfFile"), backupFileName(filename)); if (!file.copy(value(QLatin1String("backupOfFile")).toString())) { - setError(UserDefinedError, tr("Cannot backup file %1: %2").arg(filename, file.errorString())); + setError(UserDefinedError, tr("Cannot backup file \"%1\": %2").arg( + QDir::toNativeSeparators(filename), file.errorString())); clearValue(QLatin1String("backupOfFile")); } } @@ -716,7 +739,8 @@ bool PrependFileOperation::performOperation() QFile file(fName); if (!file.open(QFile::ReadOnly)) { setError(UserDefinedError); - setErrorString(tr("Could not open file %1 for reading: %2").arg(file.fileName(), file.errorString())); + setErrorString(tr("Cannot open file \"%1\" for reading: %2").arg( + QDir::toNativeSeparators(file.fileName()), file.errorString())); return false; } @@ -734,7 +758,8 @@ bool PrependFileOperation::performOperation() if (!QFile::rename(fName, newName) && QFile::copy(newName, fName) && file.open(QFile::WriteOnly)) { QFile::rename(newName, fName); setError(UserDefinedError); - setErrorString(tr("Could not open file %1 for writing: %2").arg(file.fileName(), file.errorString())); + setErrorString(tr("Cannot open file \"%1\" for writing: %2").arg( + QDir::toNativeSeparators(file.fileName()), file.errorString())); return false; } deleteFileNowOrLater(newName); @@ -752,12 +777,14 @@ bool PrependFileOperation::undoOperation() const QString filename = arguments().first(); const QString backupOfFile = value(QLatin1String("backupOfFile")).toString(); if (!backupOfFile.isEmpty() && !QFile::exists(backupOfFile)) { - setError(UserDefinedError, tr("Cannot find backup file for %1.").arg(filename)); + setError(UserDefinedError, + tr("Cannot find backup file for \"%1\".").arg(QDir::toNativeSeparators(filename))); return false; } if (!deleteFileNowOrLater(filename)) { - setError(UserDefinedError, tr("Cannot restore backup file for %1.").arg(filename)); + setError(UserDefinedError, + tr("Cannot restore backup file for \"%1\".").arg(QDir::toNativeSeparators(filename))); return false; } @@ -768,7 +795,8 @@ bool PrependFileOperation::undoOperation() QFile backupF(backupOfFile); const bool success = backupF.rename(filename); if (!success) - setError(UserDefinedError, tr("Cannot restore backup file for %1: %2").arg(filename, backupF.errorString())); + setError(UserDefinedError, tr("Cannot restore backup file for \"%1\": %2").arg( + QDir::toNativeSeparators(filename), backupF.errorString())); return success; } diff --git a/src/libs/kdtools/kdupdaterupdatesinfo.cpp b/src/libs/kdtools/kdupdaterupdatesinfo.cpp index a5b1b0a86..48003279b 100644 --- a/src/libs/kdtools/kdupdaterupdatesinfo.cpp +++ b/src/libs/kdtools/kdupdaterupdatesinfo.cpp @@ -61,7 +61,7 @@ void UpdatesInfoData::parseFile(const QString &updateXmlFile) QFile file(updateXmlFile); if (!file.open(QFile::ReadOnly)) { error = UpdatesInfo::CouldNotReadUpdateInfoFileError; - errorMessage = tr("Could not read \"%1\"").arg(updateXmlFile); + errorMessage = tr("Cannot read \"%1\"").arg(updateXmlFile); return; } diff --git a/src/libs/kdtools/localpackagehub.cpp b/src/libs/kdtools/localpackagehub.cpp index 02bb8cb64..6172de853 100644 --- a/src/libs/kdtools/localpackagehub.cpp +++ b/src/libs/kdtools/localpackagehub.cpp @@ -258,7 +258,7 @@ void LocalPackageHub::refresh() // Open Packages.xml if (!file.open(QFile::ReadOnly)) { d->error = CouldNotReadPackageFileError; - d->errorMessage = tr("Could not open %1.").arg(d->fileName); + d->errorMessage = tr("Cannot open %1.").arg(d->fileName); return; } |