diff options
author | kh1 <karsten.heimrich@digia.com> | 2014-06-23 13:33:07 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2014-06-24 10:31:17 +0200 |
commit | 2ff4f0a8534f820131cc30392cb96b9c55fe7ab3 (patch) | |
tree | 891e49214d189b0619a53c96196d361067a68e74 /src | |
parent | 924ebcdbc9b9e590a5f0905941e2d05ac34d4be2 (diff) |
Don't use QObject::tr().
Change-Id: Icefbff9851a4e096a4b800adea7d17db756abe99
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/installer/binaryformat.cpp | 56 | ||||
-rw-r--r-- | src/libs/installer/createdesktopentryoperation.cpp | 11 | ||||
-rw-r--r-- | src/libs/installer/createlinkoperation.cpp | 4 | ||||
-rw-r--r-- | src/libs/installer/createlocalrepositoryoperation.cpp | 10 | ||||
-rw-r--r-- | src/libs/installer/createshortcutoperation.cpp | 2 | ||||
-rw-r--r-- | src/libs/installer/environmentvariablesoperation.cpp | 4 | ||||
-rw-r--r-- | src/libs/installer/fakestopprocessforupdateoperation.cpp | 8 | ||||
-rw-r--r-- | src/libs/installer/fileutils.cpp | 61 | ||||
-rw-r--r-- | src/libs/installer/installiconsoperation.cpp | 10 | ||||
-rw-r--r-- | src/libs/installer/lib7z_facade.cpp | 182 | ||||
-rw-r--r-- | src/libs/installer/linereplaceoperation.cpp | 4 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.cpp | 2 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 2 | ||||
-rw-r--r-- | src/libs/installer/registerfiletypeoperation.cpp | 4 | ||||
-rw-r--r-- | src/libs/installer/remoteclient_p.h | 9 | ||||
-rw-r--r-- | src/libs/installer/replaceoperation.cpp | 4 |
16 files changed, 210 insertions, 163 deletions
diff --git a/src/libs/installer/binaryformat.cpp b/src/libs/installer/binaryformat.cpp index 9e85ea61f..e31627a1c 100644 --- a/src/libs/installer/binaryformat.cpp +++ b/src/libs/installer/binaryformat.cpp @@ -96,7 +96,8 @@ qint64 QInstaller::findMagicCookie(QFile *in, quint64 magicCookie) return (fileSize - maxSearch) + searched; --searched; } - throw Error(QObject::tr("No marker found, stopped after %1.").arg(humanReadableSize(maxSearch))); + throw Error(QCoreApplication::translate("QInstaller", "No marker found, stopped after %1.") + .arg(humanReadableSize(maxSearch))); return -1; // never reached } @@ -264,8 +265,8 @@ qint64 Archive::size() const if (fi.isDir()) { if (m_inputFile.fileName().isEmpty() || !m_inputFile.exists()) { if (!const_cast< Archive* >(this)->createZippedFile()) { - throw Error(QObject::tr("Cannot create zipped file for path %1: %2").arg(m_path, - errorString())); + throw Error(QCoreApplication::translate("Archive", + "Cannot create zipped file for path %1: %2").arg(m_path, errorString())); } } Q_ASSERT(!m_inputFile.fileName().isEmpty()); @@ -525,18 +526,22 @@ static QByteArray addResourceFromBinary(QFile* file, const Range<qint64> &segmen return 0; if (!file->seek(segment.start())) { - throw Error(QObject::tr("Could not seek to in-binary resource. (offset: %1, length: %2)") + throw Error(QCoreApplication::translate("BinaryContent", + "Could not seek to in-binary resource. (offset: %1, length: %2)") .arg(QString::number(segment.start()), QString::number(segment.length()))); } QByteArray ba = QInstaller::retrieveData(file, segment.length()); - if (!QResource::registerResource((const uchar*)ba.constData(), QLatin1String(":/metadata"))) - throw Error(QObject::tr("Could not register in-binary resource.")); + if (!QResource::registerResource((const uchar*)ba.constData(), QLatin1String(":/metadata"))) { + throw Error(QCoreApplication::translate("BinaryContent", + "Could not register in-binary resource.")); + } return ba; } // -- BinaryContentPrivate + BinaryContentPrivate::BinaryContentPrivate() : m_magicMarker(Q_INT64_C(0)) , m_dataBlockStart(Q_INT64_C(0)) @@ -710,9 +715,10 @@ BinaryContent BinaryContent::readFromApplicationFile() BinaryContent BinaryContent::readFromBinary(const QString &path) { BinaryContent c(path); - if (!c.d->m_appBinary->open(QIODevice::ReadOnly)) - throw Error(QObject::tr("Could not open binary %1: %2").arg(path, c.d->m_appBinary->errorString())); - + if (!c.d->m_appBinary->open(QIODevice::ReadOnly)) { + throw Error(QCoreApplication::translate("BinaryContent", "Could not open binary %1: %2") + .arg(path, c.d->m_appBinary->errorString())); + } // check for supported binary, will throw if we can't find a marker const BinaryLayout layout = readBinaryLayout(c.d->m_appBinary.data(), findMagicCookie(c.d->m_appBinary.data(), QInstaller::MagicCookie)); @@ -755,8 +761,10 @@ BinaryContent BinaryContent::readFromBinary(const QString &path) BinaryLayout BinaryContent::readBinaryLayout(QFile *const file, qint64 cookiePos) { const qint64 indexSize = 5 * sizeof(qint64); - if (!file->seek(cookiePos - indexSize)) - throw Error(QObject::tr("Could not seek to binary layout section.")); + if (!file->seek(cookiePos - indexSize)) { + throw Error(QCoreApplication::translate("BinaryContent", + "Could not seek to binary layout section.")); + } BinaryLayout layout; layout.operationsStart = QInstaller::retrieveInt64(file); @@ -780,9 +788,12 @@ BinaryLayout BinaryContent::readBinaryLayout(QFile *const file, qint64 cookiePos const qint64 resourceOffsetAndLengtSize = 2 * sizeof(qint64); const qint64 dataBlockStart = layout.endOfData - layout.dataBlockSize; for (int i = 0; i < layout.resourceCount; ++i) { - if (!file->seek(layout.endOfData - layout.indexSize - resourceOffsetAndLengtSize * (i + 1))) - throw Error(QObject::tr("Could not seek to metadata index.")); - + const qint64 offset = layout.endOfData - layout.indexSize + - (resourceOffsetAndLengtSize * (i + 1)); + if (!file->seek(offset)) { + throw Error(QCoreApplication::translate("BinaryContent", + "Could not seek to metadata index.")); + } const qint64 metadataResourceOffset = QInstaller::retrieveInt64(file); const qint64 metadataResourceLength = QInstaller::retrieveInt64(file); layout.metadataResourceSegments.append(Range<qint64>::fromStartAndLength(metadataResourceOffset @@ -802,7 +813,7 @@ void BinaryContent::readBinaryData(BinaryContent &content, const QSharedPointer< const qint64 dataBlockStart = layout.endOfData - layout.dataBlockSize; const qint64 operationsStart = layout.operationsStart + dataBlockStart; if (!file->seek(operationsStart)) - throw Error(QObject::tr("Could not seek to operation list.")); + throw Error(QCoreApplication::translate("BinaryContent", "Could not seek to operation list.")); const qint64 operationsCount = QInstaller::retrieveInt64(file.data()); qDebug() << "Number of operations:" << operationsCount; @@ -816,12 +827,15 @@ void BinaryContent::readBinaryData(BinaryContent &content, const QSharedPointer< // seek to the position of the component index const qint64 resourceOffsetAndLengtSize = 2 * sizeof(qint64); const qint64 resourceSectionSize = resourceOffsetAndLengtSize * layout.resourceCount; - if (!file->seek(layout.endOfData - layout.indexSize - resourceSectionSize - resourceOffsetAndLengtSize)) - throw Error(QObject::tr("Could not seek to component index information.")); - + const qint64 offset = layout.endOfData - layout.indexSize - resourceSectionSize + - resourceOffsetAndLengtSize; + if (!file->seek(offset)) { + throw Error(QCoreApplication::translate("BinaryContent", + "Could not seek to component index information.")); + } const qint64 compIndexStart = QInstaller::retrieveInt64(file.data()) + dataBlockStart; if (!file->seek(compIndexStart)) - throw Error(QObject::tr("Could not seek to component index.")); + throw Error(QCoreApplication::translate("BinaryContent", "Could not seek to component index.")); content.d->m_componentIndex = QInstallerCreator::ComponentIndex::read(file, dataBlockStart); content.d->m_binaryFormatEngineHandler.setComponentIndex(content.d->m_componentIndex); @@ -900,8 +914,8 @@ int BinaryContent::registerEmbeddedQResources() const bool hasBinaryDataFile = !d->m_binaryDataFile.isNull(); QFile *const data = hasBinaryDataFile ? d->m_binaryDataFile.data() : d->m_appBinary.data(); if (data != 0 && !data->isOpen() && !data->open(QIODevice::ReadOnly)) { - throw Error(QObject::tr("Could not open binary %1: %2").arg(data->fileName(), - data->errorString())); + throw Error(QCoreApplication::translate("BinaryContent", "Could not open binary %1: %2") + .arg(data->fileName(), data->errorString())); } foreach (const Range<qint64> &i, d->m_metadataResourceSegments) diff --git a/src/libs/installer/createdesktopentryoperation.cpp b/src/libs/installer/createdesktopentryoperation.cpp index df94e9588..62c35cb0f 100644 --- a/src/libs/installer/createdesktopentryoperation.cpp +++ b/src/libs/installer/createdesktopentryoperation.cpp @@ -104,10 +104,6 @@ QString CreateDesktopEntryOperation::absoluteFileName() return QDir(directory).absoluteFilePath(filename); } -/* -TRANSLATOR QInstaller::CreateDesktopEntryOperation -*/ - CreateDesktopEntryOperation::CreateDesktopEntryOperation() { setName(QLatin1String("CreateDesktopEntry")); @@ -131,7 +127,7 @@ void CreateDesktopEntryOperation::backup() } if (!QFile::copy(filename, value(QLatin1String("backupOfExistingDesktopEntry")).toString())) - setErrorString(QObject::tr("Could not backup file %1").arg(filename)); + setErrorString(tr("Could not backup file %1").arg(filename)); } bool CreateDesktopEntryOperation::performOperation() @@ -181,7 +177,7 @@ bool CreateDesktopEntryOperation::undoOperation() // first remove the link if (!deleteFileNowOrLater(filename)) { - setErrorString(QObject::tr("Could not delete file %1").arg(filename)); + setErrorString(tr("Could not delete file %1").arg(filename)); return false; } @@ -192,8 +188,7 @@ bool CreateDesktopEntryOperation::undoOperation() const bool success = QFile::copy(backupOfExistingDesktopEntry, filename) && deleteFileNowOrLater(backupOfExistingDesktopEntry); if (!success) - setErrorString(QObject::tr("Could not restore backup file into %1").arg(filename)); - + setErrorString(tr("Could not restore backup file into %1").arg(filename)); return success; } diff --git a/src/libs/installer/createlinkoperation.cpp b/src/libs/installer/createlinkoperation.cpp index 02ff94df3..3cdc542ec 100644 --- a/src/libs/installer/createlinkoperation.cpp +++ b/src/libs/installer/createlinkoperation.cpp @@ -76,7 +76,7 @@ bool CreateLinkOperation::performOperation() if (!link.exists()) { setError(UserDefinedError); - setErrorString(QObject::tr("Could not create link from %1 to %2.").arg(linkPath, targetPath)); + setErrorString(tr("Could not create link from %1 to %2.").arg(linkPath, targetPath)); return false; } @@ -96,7 +96,7 @@ bool CreateLinkOperation::undoOperation() } if (!link.remove()) { setError(UserDefinedError); - setErrorString(QObject::tr("Could not remove link from %1 to %2.").arg(linkPath, targetPath)); + setErrorString(tr("Could not remove link from %1 to %2.").arg(linkPath, targetPath)); return false; } diff --git a/src/libs/installer/createlocalrepositoryoperation.cpp b/src/libs/installer/createlocalrepositoryoperation.cpp index d52729d72..671a96a35 100644 --- a/src/libs/installer/createlocalrepositoryoperation.cpp +++ b/src/libs/installer/createlocalrepositoryoperation.cpp @@ -112,8 +112,10 @@ static void removeFiles(const QString &path, AutoHelper *const helper) foreach (const QFileInfo &fi, entries) { if (fi.isSymLink() || fi.isFile()) { QFile f(fi.filePath()); - if (!f.remove()) - throw Error(QObject::tr("Could not remove file %1: %2").arg(f.fileName(), f.errorString())); + if (!f.remove()) { + throw Error(CreateLocalRepositoryOperation::tr("Could not remove file %1: %2") + .arg(f.fileName(), f.errorString())); + } helper->m_files.removeAll(f.fileName()); } } @@ -129,8 +131,8 @@ 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("Could not move file %1 to %2. Error: %3") + .arg(archive.fileName(), sourceDir + fileName, archive.errorString())); } return archive.fileName(); } diff --git a/src/libs/installer/createshortcutoperation.cpp b/src/libs/installer/createshortcutoperation.cpp index 8c5917852..7a35eba7a 100644 --- a/src/libs/installer/createshortcutoperation.cpp +++ b/src/libs/installer/createshortcutoperation.cpp @@ -226,7 +226,7 @@ bool CreateShortcutOperation::performOperation() QString errorString; if (QFile::exists(linkLocation) && !deleteFileNowOrLater(linkLocation, &errorString)) { setError(UserDefinedError); - setErrorString(QObject::tr("Failed to overwrite %1: %2").arg(QDir::toNativeSeparators(linkLocation), + setErrorString(tr("Failed to overwrite %1: %2").arg(QDir::toNativeSeparators(linkLocation), errorString)); return false; } diff --git a/src/libs/installer/environmentvariablesoperation.cpp b/src/libs/installer/environmentvariablesoperation.cpp index 4c423d94f..1ff4ab9be 100644 --- a/src/libs/installer/environmentvariablesoperation.cpp +++ b/src/libs/installer/environmentvariablesoperation.cpp @@ -91,7 +91,7 @@ UpdateOperation::Error writeSetting(const QString ®Path, oldValue->clear(); SettingsType registry(regPath, QSettingsWrapper::NativeFormat); if (!registry.isWritable()) { - *errorString = QObject::tr("Registry path %1 is not writable").arg(regPath); + *errorString = UpdateOperation::tr("Registry path %1 is not writable").arg(regPath); return UpdateOperation::UserDefinedError; } @@ -103,7 +103,7 @@ UpdateOperation::Error writeSetting(const QString ®Path, registry.sync(); if (registry.status() != QSettingsWrapper::NoError) { - *errorString = QObject::tr("Could not write to registry path %1").arg(regPath); + *errorString = UpdateOperation::tr("Could not write to registry path %1").arg(regPath); return UpdateOperation::UserDefinedError; } diff --git a/src/libs/installer/fakestopprocessforupdateoperation.cpp b/src/libs/installer/fakestopprocessforupdateoperation.cpp index ead887118..ba433d9ee 100644 --- a/src/libs/installer/fakestopprocessforupdateoperation.cpp +++ b/src/libs/installer/fakestopprocessforupdateoperation.cpp @@ -65,14 +65,14 @@ bool FakeStopProcessForUpdateOperation::undoOperation() { setError(KDUpdater::UpdateOperation::NoError); if (arguments().size() != 1) { - setError(KDUpdater::UpdateOperation::InvalidArguments, QObject::tr("Number of arguments does not " + setError(KDUpdater::UpdateOperation::InvalidArguments, tr("Number of arguments does not " "match: one is required")); return false; } PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); if (!core) { - setError(KDUpdater::UpdateOperation::UserDefinedError, QObject::tr("Could not get package manager " + setError(KDUpdater::UpdateOperation::UserDefinedError, tr("Could not get package manager " "core.")); return false; } @@ -87,11 +87,11 @@ bool FakeStopProcessForUpdateOperation::undoOperation() return true; if (processes.count() == 1) { - setError(UpdateOperation::UserDefinedError, QObject::tr("This process should be stopped before " + setError(UpdateOperation::UserDefinedError, tr("This process should be stopped before " "continuing: %1").arg(processes.first())); } else { const QString sep = QString::fromWCharArray(L"\n \u2022 "); // Unicode bullet - setError(UpdateOperation::UserDefinedError, QObject::tr("These processes should be stopped before " + setError(UpdateOperation::UserDefinedError, tr("These processes should be stopped before " "continuing: %1").arg(sep + processes.join(sep))); } return false; diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp index 76fae9d08..309c52180 100644 --- a/src/libs/installer/fileutils.cpp +++ b/src/libs/installer/fileutils.cpp @@ -188,11 +188,11 @@ void QInstaller::removeFiles(const QString &path, bool ignoreErrors) if (fi.isSymLink() || fi.isFile()) { QFile f(fi.filePath()); if (!f.remove()) { - QString errorMessage = QObject::tr("Could not remove file %1: %2").arg(f.fileName(), f.errorString()); - if (ignoreErrors) - qWarning() << errorMessage; - else + const QString errorMessage = QCoreApplication::translate("QInstaller", + "Could not remove file %1: %2").arg(f.fileName(), f.errorString()); + if (!ignoreErrors) throw Error(errorMessage); + qWarning() << errorMessage; } } } @@ -229,12 +229,11 @@ void QInstaller::removeDirectory(const QString &path, bool ignoreErrors) foreach (const QString &dir, dirs) { errno = 0; if (d.exists(path) && !d.rmdir(dir)) { - QString errorMessage = QObject::tr("Could not remove folder %1: %2").arg(dir, - errnoToQString(errno)); - if (ignoreErrors) - qWarning() << errorMessage; - else + const QString errorMessage = QCoreApplication::translate("QInstaller", + "Could not remove folder %1: %2").arg(dir, errnoToQString(errno)); + if (!ignoreErrors) throw Error(errorMessage); + qWarning() << errorMessage; } } } @@ -302,9 +301,10 @@ 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(QObject::tr("Could not create folder %1").arg(targetDir)); - + if (!QDir().mkpath(targetDir)) { + throw Error(QCoreApplication::translate("QInstaller", "Could not create folder %1") + .arg(targetDir)); + } QDirIterator it(sourceDir, QDir::NoDotAndDotDot | QDir::AllEntries); while (it.hasNext()) { const QFileInfo i(it.next()); @@ -315,7 +315,8 @@ void QInstaller::copyDirectoryContents(const QString &sourceDir, const QString & QFile f(i.filePath()); const QString target = QDir(targetDir).absoluteFilePath(i.fileName()); if (!f.copy(target)) { - throw Error(QObject::tr("Could not copy file from %1 to %2: %3").arg(f.fileName(), target, + throw Error(QCoreApplication::translate("QInstaller", + "Could not copy file from %1 to %2: %3").arg(f.fileName(), target, f.errorString())); } } @@ -326,9 +327,10 @@ 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(QObject::tr("Could not create folder %1").arg(targetDir)); - + if (!QDir().mkpath(targetDir)) { + throw Error(QCoreApplication::translate("QInstaller", "Could not create folder %1") + .arg(targetDir)); + } QDirIterator it(sourceDir, QDir::NoDotAndDotDot | QDir::AllEntries); while (it.hasNext()) { const QFileInfo i(it.next()); @@ -342,7 +344,8 @@ void QInstaller::moveDirectoryContents(const QString &sourceDir, const QString & QFile f(i.filePath()); const QString target = QDir(targetDir).absoluteFilePath(i.fileName()); if (!f.rename(target)) { - throw Error(QObject::tr("Could not move file from %1 to %2: %3").arg(f.fileName(), target, + throw Error(QCoreApplication::translate("QInstaller", + "Could not move file from %1 to %2: %3").arg(f.fileName(), target, f.errorString())); } } @@ -352,23 +355,29 @@ void QInstaller::moveDirectoryContents(const QString &sourceDir, const QString & void QInstaller::mkdir(const QString &path) { errno = 0; - if (!QDir().mkdir(QFileInfo(path).absoluteFilePath())) - throw Error(QObject::tr("Could not create folder %1: %2").arg(path, errnoToQString(errno))); + if (!QDir().mkdir(QFileInfo(path).absoluteFilePath())) { + throw Error(QCoreApplication::translate("QInstaller", "Could not create folder %1: %2") + .arg(path, errnoToQString(errno))); + } } void QInstaller::mkpath(const QString &path) { errno = 0; - if (!QDir().mkpath(QFileInfo(path).absoluteFilePath())) - throw Error(QObject::tr("Could not create folder %1: %2").arg(path, errnoToQString(errno))); + if (!QDir().mkpath(QFileInfo(path).absoluteFilePath())) { + throw Error(QCoreApplication::translate("QInstaller", "Could not create folder %1: %2") + .arg(path, errnoToQString(errno))); + } } QString QInstaller::generateTemporaryFileName(const QString &templ) { if (templ.isEmpty()) { QTemporaryFile f; - if (!f.open()) - throw Error(QObject::tr("Could not open temporary file: %1").arg(f.errorString())); + if (!f.open()) { + throw Error(QCoreApplication::translate("QInstaller", + "Could not open temporary file: %1").arg(f.errorString())); + } return f.fileName(); } @@ -384,8 +393,10 @@ QString QInstaller::generateTemporaryFileName(const QString &templ) ++count; QFile f(tmp.arg(templ, suffix).arg(count)); - if (!f.open(QIODevice::WriteOnly)) - throw Error(QObject::tr("Could not open temporary file for template %1: %2").arg(templ, f.errorString())); + if (!f.open(QIODevice::WriteOnly)) { + throw Error(QCoreApplication::translate("QInstaller", + "Could not open temporary file for template %1: %2").arg(templ, f.errorString())); + } f.remove(); return f.fileName(); } diff --git a/src/libs/installer/installiconsoperation.cpp b/src/libs/installer/installiconsoperation.cpp index 23787f312..45ab0a8b1 100644 --- a/src/libs/installer/installiconsoperation.cpp +++ b/src/libs/installer/installiconsoperation.cpp @@ -129,7 +129,7 @@ bool InstallIconsOperation::performOperation() if (source.isEmpty()) { setError(InvalidArguments); - setErrorString(QObject::tr("Invalid Argument: source folder must not be empty.")); + setErrorString(tr("Invalid Argument: source folder must not be empty.")); return false; } @@ -178,7 +178,7 @@ bool InstallIconsOperation::performOperation() QFile bf(target); if (!bf.copy(backup)) { setError(UserDefinedError); - setErrorString(QObject::tr("Could not backup file %1: %2").arg(target, bf.errorString())); + setErrorString(tr("Could not backup file %1: %2").arg(target, bf.errorString())); undoOperation(); return false; } @@ -191,7 +191,7 @@ bool InstallIconsOperation::performOperation() QString errStr; if (!deleteFileNowOrLater(target, &errStr)) { setError(UserDefinedError); - setErrorString(QObject::tr("Failed to overwrite %1: %2").arg(target, errStr)); + setErrorString(tr("Failed to overwrite %1: %2").arg(target, errStr)); undoOperation(); return false; } @@ -202,7 +202,7 @@ bool InstallIconsOperation::performOperation() QFile cf(source); if (!cf.copy(target)) { setError(UserDefinedError); - setErrorString(QObject::tr("Failed to copy file %1: %2").arg(target, cf.errorString())); + setErrorString(tr("Failed to copy file %1: %2").arg(target, cf.errorString())); undoOperation(); return false; } @@ -212,7 +212,7 @@ bool InstallIconsOperation::performOperation() setValue(QLatin1String("files"), files); } else if (fi.isDir() && !QDir(target).exists()) { if (!QDir().mkpath(target)) { - setErrorString(QObject::tr("Could not create folder at %1: %2").arg(target, qt_error_string())); + setErrorString(tr("Could not create folder at %1: %2").arg(target, qt_error_string())); undoOperation(); return false; } diff --git a/src/libs/installer/lib7z_facade.cpp b/src/libs/installer/lib7z_facade.cpp index e5c47eba6..e581647bc 100644 --- a/src/libs/installer/lib7z_facade.cpp +++ b/src/libs/installer/lib7z_facade.cpp @@ -167,9 +167,10 @@ struct DirectoryGuard { const QFileInfo fi(m_path); if (fi.exists() && fi.isDir()) return QStringList(); - if (fi.exists() && !fi.isDir()) - throw SevenZipException(QObject::tr("Path exists but is not a folder: %1").arg(m_path)); - + if (fi.exists() && !fi.isDir()) { + throw SevenZipException(QCoreApplication::translate("DirectoryGuard", + "Path exists but is not a folder: %1").arg(m_path)); + } QStringList created; QDir toCreate(m_path); @@ -183,9 +184,10 @@ struct DirectoryGuard { QDir dir(m_path); m_created = dir.mkpath(m_path); - if (!m_created) - throw SevenZipException(QObject::tr("Could not create folder: %1").arg(m_path)); - + if (!m_created) { + throw SevenZipException(QCoreApplication::translate("DirectoryGuard", + "Could not create folder: %1").arg(m_path)); + } return created; } @@ -212,8 +214,10 @@ static QString UString2QString(const UString& str) static QString generateTempFileName() { QTemporaryFile tmp; - if (!tmp.open()) - throw SevenZipException(QObject::tr("Could not create temporary file")); + if (!tmp.open()) { + throw SevenZipException(QCoreApplication::translate("QInstaller", + "Could not create temporary file")); + } return QDir::toNativeSeparators(tmp.fileName()); } @@ -231,8 +235,9 @@ static NCOM::CPropVariant readProperty(IInArchive* archive, int index, int propI { NCOM::CPropVariant prop; if (archive->GetProperty(index, propId, &prop) != S_OK) { - throw SevenZipException(QObject::tr("Could not retrieve property %1 for item %2") - .arg(QString::number(propId), QString::number(index))); + throw SevenZipException(QCoreApplication::translate("QInstaller", + "Could not retrieve property %1 for item %2").arg(QString::number(propId), + QString::number(index))); } return prop; } @@ -259,8 +264,9 @@ static bool getFileTimeFromProperty(IInArchive* archive, int index, int propId, { const NCOM::CPropVariant prop = readProperty(archive, index, propId); if (prop.vt != VT_FILETIME) { - throw SevenZipException(QObject::tr("Property %1 for item %2 not of type VT_FILETIME but %3") - .arg(QString::number(propId), QString::number(index), QString::number(prop.vt))); + throw SevenZipException(QCoreApplication::translate("QInstaller", + "Property %1 for item %2 not of type VT_FILETIME but %3").arg(QString::number(propId), + QString::number(index), QString::number(prop.vt))); } *fileTime = prop.filetime; @@ -277,13 +283,15 @@ QDateTime getDateTimeProperty(IInArchive* archive, int index, int propId, const return defaultValue; FILETIME localFileTime; - if (!FileTimeToLocalFileTime(&fileTime, &localFileTime)) - throw SevenZipException(QObject::tr("Could not convert file time to local time")); - + if (!FileTimeToLocalFileTime(&fileTime, &localFileTime)) { + throw SevenZipException(QCoreApplication::translate("QInstaller", + "Could not convert file time to local time")); + } SYSTEMTIME st; - if (!BOOLToBool(FileTimeToSystemTime(&localFileTime, &st))) - throw SevenZipException(QObject::tr("Could not convert local file time to system time")); - + if (!BOOLToBool(FileTimeToSystemTime(&localFileTime, &st))) { + throw SevenZipException(QCoreApplication::translate("QInstaller", + "Could not convert local file time to system time")); + } const QDate date(st.wYear, st.wMonth, st.wDay); const QTime time(st.wHour, st.wMinute, st.wSecond); QDateTime result(date, time); @@ -383,7 +391,8 @@ HRESULT QIODeviceSequentialOutStream::Write(const void* data, UInt32 size, UInt3 if (!m_device) { if (processedSize) *processedSize = 0; - m_errorString = QObject::tr("No device set for output stream"); + m_errorString = QCoreApplication::translate("QIODeviceSequentialOutStream", + "No device set for output stream"); return E_FAIL; } if (!m_device->isOpen()) { @@ -634,17 +643,21 @@ private: OpenArchiveInfo(QFileDevice* device) : codecs(new CCodecs) { - if (codecs->Load() != S_OK) - throw SevenZipException(QObject::tr("Could not load codecs")); - - if (!codecs->FindFormatForArchiveType(L"", formatIndices)) - throw SevenZipException(QObject::tr("Could not retrieve default format")); - + if (codecs->Load() != S_OK) { + throw SevenZipException(QCoreApplication::translate("OpenArchiveInfo", + "Could not load codecs")); + } + if (!codecs->FindFormatForArchiveType(L"", formatIndices)) { + throw SevenZipException(QCoreApplication::translate("OpenArchiveInfo", + "Could not retrieve default format")); + } stream = new QIODeviceInStream(device); - if (archiveLink.Open2(codecs.data(), formatIndices, false, stream, UString(), 0) != S_OK) - throw SevenZipException(QObject::tr("Could not open archive")); + if (archiveLink.Open2(codecs.data(), formatIndices, false, stream, UString(), 0) != S_OK) { + throw SevenZipException(QCoreApplication::translate("OpenArchiveInfo", + "Could not open archive")); + } if (archiveLink.Arcs.Size() == 0) - throw SevenZipException(QObject::tr("No CArc found")); + throw SevenZipException(QCoreApplication::translate("OpenArchiveInfo", "No CArc found")); m_cleaner = new OpenArchiveInfoCleaner(); m_cleaner->moveToThread(device->thread()); @@ -708,15 +721,16 @@ QVector<File> Lib7z::listArchive(QFileDevice* archive) IInArchive* const arch = arc.Archive; UInt32 numItems = 0; - if (arch->GetNumberOfItems(&numItems) != S_OK) - throw SevenZipException(QObject::tr("Could not retrieve number of items in archive")); - + if (arch->GetNumberOfItems(&numItems) != S_OK) { + throw SevenZipException(QCoreApplication::translate("Lib7z", + "Could not retrieve number of items in archive")); + } flat.reserve(flat.size() + numItems); for (uint item = 0; item < numItems; ++item) { UString s; if (arc.GetItemPath(item, s) != S_OK) { - throw SevenZipException(QObject::tr("Could not retrieve path of archive item %1") - .arg(item)); + throw SevenZipException(QCoreApplication::translate("Lib7z", + "Could not retrieve path of archive item %1").arg(item)); } File f; f.archiveIndex.setX(i); @@ -737,8 +751,8 @@ QVector<File> Lib7z::listArchive(QFileDevice* archive) } catch (const char *err) { throw SevenZipException(err); } catch (...) { - throw SevenZipException(QObject::tr("Unknown exception caught (%1)") - .arg(QString::fromLatin1(Q_FUNC_INFO))); + throw SevenZipException(QCoreApplication::translate("Lib7z", + "Unknown exception caught (%1)").arg(QString::fromLatin1(Q_FUNC_INFO))); } return QVector<File>(); // never reached } @@ -754,7 +768,7 @@ void ListArchiveJob::doStart() setErrorString(e.message()); } catch (...) { setError(Failed); - setErrorString(QObject::tr("Unknown exception caught (%1)").arg(QObject::tr("Failed"))); + setErrorString(tr("Unknown exception caught (%1)").arg(tr("Failed"))); } emitResult(); } @@ -806,7 +820,8 @@ public: UString s; if (arc->GetItemPath(index, s) != S_OK) { - Lib7z::setLastError(QObject::tr("Could not retrieve path of archive item %1").arg(index)); + Lib7z::setLastError(QCoreApplication::translate("ExtractCallbackImpl", + "Could not retrieve path of archive item %1").arg(index)); return E_FAIL; } @@ -834,16 +849,17 @@ public: #ifndef Q_OS_WIN // do not follow symlinks, so we need to remove an existing one if (fi.isSymLink() && (!QFile::remove(fi.absoluteFilePath()))) { - Lib7z::setLastError(QObject::tr("Could not remove already existing " - "symlink. %1").arg(fi.absoluteFilePath())); + Lib7z::setLastError(QCoreApplication::translate("ExtractCallbackImpl", + "Could not remove already existing symlink. %1").arg(fi.absoluteFilePath())); return E_FAIL; } #endif QIODeviceSequentialOutStream *qOutStream = new QIODeviceSequentialOutStream( new QFile(fi.absoluteFilePath()), QIODeviceSequentialOutStream::CloseAndDeleteDevice); if (!qOutStream->errorString().isEmpty()) { - Lib7z::setLastError(QObject::tr("Could not open file: %1 (%2)").arg( - fi.absoluteFilePath(), qOutStream->errorString())); + Lib7z::setLastError(QCoreApplication::translate("ExtractCallbackImpl", + "Could not open file: %1 (%2)").arg(fi.absoluteFilePath(), + qOutStream->errorString())); return E_FAIL; } CMyComPtr<ISequentialOutStream> stream = qOutStream; @@ -873,8 +889,8 @@ public: UString s; if (arc->GetItemPath(currentIndex, s) != S_OK) { - Lib7z::setLastError(QObject::tr("Could not retrieve path of archive item %1") - .arg(currentIndex)); + Lib7z::setLastError(QCoreApplication::translate("ExtractCallbackImpl", + "Could not retrieve path of archive item %1").arg(currentIndex)); return E_FAIL; } const QString path = UString2QString(s).replace(QLatin1Char('\\'), QLatin1Char('/')); @@ -896,14 +912,15 @@ public: #else QFileInfo symlinkPlaceHolderFileInfo(absFilePath); if (symlinkPlaceHolderFileInfo.isSymLink()) { - Lib7z::setLastError(QObject::tr("Could not create symlink at '%1'. " - "Another one is already existing.").arg(absFilePath)); + Lib7z::setLastError(QCoreApplication::translate("ExtractCallbackImpl", + "Could not create symlink at '%1'. Another one is already existing.") + .arg(absFilePath)); return E_FAIL; } QFile symlinkPlaceHolderFile(absFilePath); if (!symlinkPlaceHolderFile.open(QIODevice::ReadOnly)) { - Lib7z::setLastError(QObject::tr("Could not read symlink target from file '%1'." - ).arg(absFilePath)); + Lib7z::setLastError(QCoreApplication::translate("ExtractCallbackImpl", + "Could not read symlink target from file '%1'.").arg(absFilePath)); return E_FAIL; } @@ -912,8 +929,9 @@ public: symlinkPlaceHolderFile.remove(); QFile targetFile(QString::fromLatin1(symlinkTarget)); if (!targetFile.link(absFilePath)) { - Lib7z::setLastError(QObject::tr("Could not create symlink at %1. %2").arg( - absFilePath, targetFile.errorString())); + Lib7z::setLastError(QCoreApplication::translate("ExtractCallbackImpl", + "Could not create symlink at %1. %2").arg(absFilePath, + targetFile.errorString())); return E_FAIL; } return S_OK; @@ -1279,7 +1297,7 @@ namespace{ if (!Lib7z::lastError().isEmpty()) return Lib7z::lastError(); - QString errorMessage = QObject::tr("internal code: %1"); + QString errorMessage = QCoreApplication::translate("Lib7z", "internal code: %1"); switch (extractResult) { case S_OK: qFatal("S_OK value is not a valid error code."); @@ -1300,13 +1318,13 @@ namespace{ errorMessage = errorMessage.arg(QLatin1String("STG_E_INVALIDFUNCTION")); break; case E_OUTOFMEMORY: - errorMessage = QObject::tr("not enough memory"); + errorMessage = QCoreApplication::translate("Lib7z", "not enough memory"); break; case E_INVALIDARG: errorMessage = errorMessage.arg(QLatin1String("E_INVALIDARG")); break; default: - errorMessage = QObject::tr("Error: %1").arg(extractResult); + errorMessage = QCoreApplication::translate("Lib7z", "Error: %1").arg(extractResult); break; } return errorMessage; @@ -1326,12 +1344,14 @@ void Lib7z::createArchive(QFileDevice* archive, const QStringList &sourcePaths, QScopedPointer<CCodecs> codecs(new CCodecs); if (codecs->Load() != S_OK) - throw SevenZipException(QObject::tr("Could not load codecs")); + throw SevenZipException(QCoreApplication::translate("Lib7z", "Could not load codecs")); CIntVector formatIndices; - if (!codecs.data()->FindFormatForArchiveType(L"", formatIndices)) - throw SevenZipException(QObject::tr("Could not retrieve default format")); + if (!codecs.data()->FindFormatForArchiveType(L"", formatIndices)) { + throw SevenZipException(QCoreApplication::translate("Lib7z", + "Could not retrieve default format")); + } // yes this is crap, but there seems to be no streaming solution to this... @@ -1374,9 +1394,10 @@ void Lib7z::createArchive(QFileDevice* archive, const QStringList &sourcePaths, CUpdateErrorInfo errorInfo; const HRESULT res = UpdateArchive(codecs.data(), censor, options, errorInfo, 0, callback->impl()); - if (res != S_OK || !QFile::exists(tempFile)) - throw SevenZipException(QObject::tr("Could not create archive %1. %2").arg( - tempFile, errorMessageFrom7zResult(res))); + if (res != S_OK || !QFile::exists(tempFile)) { + throw SevenZipException(QCoreApplication::translate("Lib7z", + "Could not create archive %1. %2").arg(tempFile, errorMessageFrom7zResult(res))); + } { //TODO remove temp file even if one the following throws @@ -1396,7 +1417,7 @@ void Lib7z::createArchive(QFileDevice* archive, const QStringList &sourcePaths, } catch (const QInstaller::Error &err) { throw SevenZipException(err.message()); } catch (...) { - throw SevenZipException(QObject::tr("Unknown exception caught (%1)") + throw SevenZipException(QCoreApplication::translate("Lib7z", "Unknown exception caught (%1)") .arg(QString::fromLatin1(Q_FUNC_INFO))); } } @@ -1416,26 +1437,29 @@ void Lib7z::extractFileFromArchive(QFileDevice* archive, const File& item, QFile const int arcIdx = item.archiveIndex.x(); if (arcIdx < 0 || arcIdx >= openArchive->archiveLink.Arcs.Size()) { - throw SevenZipException(QObject::tr("CArc index %1 out of bounds [0, %2]") - .arg(openArchive->archiveLink.Arcs.Size() - 1)); + throw SevenZipException(QCoreApplication::translate("Lib7z", + "CArc index %1 out of bounds [0, %2]").arg(openArchive->archiveLink.Arcs.Size() - 1)); } const CArc& arc = openArchive->archiveLink.Arcs[arcIdx]; IInArchive* const parchive = arc.Archive; const UInt32 itemIdx = item.archiveIndex.y(); UInt32 numItems = 0; - if (parchive->GetNumberOfItems(&numItems) != S_OK) - throw SevenZipException(QObject::tr("Could not retrieve number of items in archive")); + if (parchive->GetNumberOfItems(&numItems) != S_OK) { + throw SevenZipException(QCoreApplication::translate("Lib7z", + "Could not retrieve number of items in archive")); + } if (itemIdx >= numItems) { - throw SevenZipException(QObject::tr("Item index %1 out of bounds [0, %2]").arg(itemIdx) - .arg(numItems - 1)); + throw SevenZipException(QCoreApplication::translate("Lib7z", + "Item index %1 out of bounds [0, %2]").arg(itemIdx).arg(numItems - 1)); } UString s; - if (arc.GetItemPath(itemIdx, s) != S_OK) - throw SevenZipException(QObject::tr("Could not retrieve path of archive item %1").arg(itemIdx)); - + if (arc.GetItemPath(itemIdx, s) != S_OK) { + throw SevenZipException(QCoreApplication::translate("Lib7z", + "Could not retrieve path of archive item %1").arg(itemIdx)); + } assert(item.path == UString2QString(s).replace(QLatin1Char('\\'), QLatin1Char('/'))); callback->setTarget(target); @@ -1449,7 +1473,7 @@ void Lib7z::extractFileFromArchive(QFileDevice* archive, const File& item, QFile } catch (const Lib7z::SevenZipException& e) { throw e; } catch (...) { - throw SevenZipException(QObject::tr("Unknown exception caught (%1)") + throw SevenZipException(QCoreApplication::translate("Lib7z", "Unknown exception caught (%1)") .arg(QString::fromLatin1(Q_FUNC_INFO))); } } @@ -1468,8 +1492,8 @@ void Lib7z::extractFileFromArchive(QFileDevice* archive, const File& item, outDir.tryCreate(); QFile out(fi.absoluteFilePath()); if (!out.open(QIODevice::WriteOnly)) { //TODO use tmp file - throw SevenZipException(QObject::tr("Could not create output file for writing: %1") - .arg(fi.absoluteFilePath())); + throw SevenZipException(QCoreApplication::translate("Lib7z", + "Could not create output file for writing: %1").arg(fi.absoluteFilePath())); } callback->setTarget(&out); extractFileFromArchive(archive, item, &out, callback); @@ -1526,13 +1550,14 @@ bool Lib7z::isSupportedArchive(QFileDevice* archive) try { QScopedPointer<CCodecs> codecs(new CCodecs); if (codecs->Load() != S_OK) - throw SevenZipException(QObject::tr("Could not load codecs")); + throw SevenZipException(QCoreApplication::translate("Lib7z", "Could not load codecs")); CIntVector formatIndices; - if (!codecs->FindFormatForArchiveType(L"", formatIndices)) - throw SevenZipException(QObject::tr("Could not retrieve default format")); - + if (!codecs->FindFormatForArchiveType(L"", formatIndices)) { + throw SevenZipException(QCoreApplication::translate("Lib7z", + "Could not retrieve default format")); + } CArchiveLink archiveLink; //CMyComPtr is needed, otherwise it crashes in OpenStream() const CMyComPtr<IInStream> stream = new QIODeviceInStream(archive); @@ -1550,7 +1575,7 @@ bool Lib7z::isSupportedArchive(QFileDevice* archive) throw SevenZipException(err); } catch (...) { archive->seek(initialPos); - throw SevenZipException(QObject::tr("Unknown exception caught (%1)") + throw SevenZipException(QCoreApplication::translate("Lib7z", "Unknown exception caught (%1)") .arg(QString::fromLatin1(Q_FUNC_INFO))); } return false; // never reached @@ -1569,11 +1594,10 @@ void ExtractItemJob::doStart() extractArchive(d->archive, d->targetDirectory, d->callback); } catch (const SevenZipException& e) { setError(Failed); - setErrorString(QObject::tr("Error while extracting '%1': %2").arg( - d->item.path, e.message())); + setErrorString(tr("Error while extracting '%1': %2").arg(d->item.path, e.message())); } catch (...) { setError(Failed); - setErrorString(QObject::tr("Unknown exception caught (%1)").arg(QObject::tr("Failed"))); + setErrorString(tr("Unknown exception caught (%1)").arg(tr("Failed"))); } emitResult(); } diff --git a/src/libs/installer/linereplaceoperation.cpp b/src/libs/installer/linereplaceoperation.cpp index 6c13f1716..ee4d931fc 100644 --- a/src/libs/installer/linereplaceoperation.cpp +++ b/src/libs/installer/linereplaceoperation.cpp @@ -77,7 +77,7 @@ bool LineReplaceOperation::performOperation() QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { setError(UserDefinedError); - setErrorString(QObject::tr("Failed to open '%1' for reading.").arg(fileName)); + setErrorString(tr("Failed to open '%1' for reading.").arg(fileName)); return false; } @@ -94,7 +94,7 @@ bool LineReplaceOperation::performOperation() if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { setError(UserDefinedError); - setErrorString(QObject::tr("Failed to open '%1' for writing.").arg(fileName)); + setErrorString(tr("Failed to open '%1' for writing.").arg(fileName)); return false; } diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 8cf7bc6ca..76eeaa373 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -1448,7 +1448,7 @@ bool PackageManagerCore::gainAdminRights() RemoteClient::instance().setActive(true); if (!RemoteClient::instance().isActive()) - throw Error(QObject::tr("Error while elevating access rights.")); + throw Error(tr("Error while elevating access rights.")); return true; } diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 051bf8103..97916a9b2 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -1044,7 +1044,7 @@ void PackageManagerCorePrivate::writeUninstallerBinary(QFile *const input, qint6 QInstaller::openForWrite(&out); // throws an exception in case of error if (!input->seek(0)) - throw Error(QObject::tr("Failed to seek in file %1: %2").arg(input->fileName(), input->errorString())); + throw Error(tr("Failed to seek in file %1: %2").arg(input->fileName(), input->errorString())); QInstaller::appendData(&out, input, size); if (writeBinaryLayout) { diff --git a/src/libs/installer/registerfiletypeoperation.cpp b/src/libs/installer/registerfiletypeoperation.cpp index 7fecde2cb..52efcb0ed 100644 --- a/src/libs/installer/registerfiletypeoperation.cpp +++ b/src/libs/installer/registerfiletypeoperation.cpp @@ -156,7 +156,7 @@ bool RegisterFileTypeOperation::performOperation() return true; #else setError(UserDefinedError); - setErrorString(QObject::tr("Registering file types is only supported on Windows.")); + setErrorString(tr("Registering file types is only supported on Windows.")); return false; #endif } @@ -219,7 +219,7 @@ bool RegisterFileTypeOperation::undoOperation() return true; #else - setErrorString(QObject::tr("Registering file types is only supported on Windows.")); + setErrorString(tr("Registering file types is only supported on Windows.")); return false; #endif } diff --git a/src/libs/installer/remoteclient_p.h b/src/libs/installer/remoteclient_p.h index d2aebdb5d..615694890 100644 --- a/src/libs/installer/remoteclient_p.h +++ b/src/libs/installer/remoteclient_p.h @@ -171,10 +171,11 @@ public: const QMessageBox::Button res = MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), - QObject::tr("Authorization Error"), QObject::tr("Could not get authorization."), - QObject::tr("Could not get authorization that is needed for continuing the " - "installation.\n Either abort the installation or use the fallback " - "solution by running\n%1\nas root and then clicking ok.").arg(fallback), + RemoteClient::tr("Authorization Error"), + RemoteClient::tr("Could not get authorization."), + RemoteClient::tr("Could not get authorization that is needed for continuing " + "the installation.\n Either abort the installation or use the fallback " + "solution by running\n%1\nas root and then clicking OK.").arg(fallback), QMessageBox::Abort | QMessageBox::Ok, QMessageBox::Ok); if (res == QMessageBox::Ok) diff --git a/src/libs/installer/replaceoperation.cpp b/src/libs/installer/replaceoperation.cpp index c172a2661..8a9cd8702 100644 --- a/src/libs/installer/replaceoperation.cpp +++ b/src/libs/installer/replaceoperation.cpp @@ -77,7 +77,7 @@ bool ReplaceOperation::performOperation() QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { setError(UserDefinedError); - setErrorString(QObject::tr("Failed to open %1 for reading").arg(fileName)); + setErrorString(tr("Failed to open %1 for reading").arg(fileName)); return false; } @@ -87,7 +87,7 @@ bool ReplaceOperation::performOperation() if (!file.open(QIODevice::WriteOnly)) { setError(UserDefinedError); - setErrorString(QObject::tr("Failed to open %1 for writing").arg(fileName)); + setErrorString(tr("Failed to open %1 for writing").arg(fileName)); return false; } |