From a4a61bb3efac34a202c102f19b170ca705a6901e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Tue, 20 Mar 2012 08:47:57 +0100 Subject: QCoreApplication - add return type bool on install/remove translator This add a bool as return value on QCoreApplication::installTranslator and QCoreApplication::removeTranslator. It returns true on success. Before it was very clumsy to detected this. It was needed to react on the signal and mark a success - just to provide an error message on failure. This is 99.99% source compatible - only if someone grabs a function pointer to this - it will break the code - but it seems to be very theoretic. Change-Id: I947fcee1352f530e559bb177a90c10d84eed1aec Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll --- src/corelib/kernel/qcoreapplication.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/corelib/kernel/qcoreapplication.cpp') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 967ed447d5..c901bc142e 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1513,26 +1513,29 @@ void QCoreApplication::quit() generated by \l{Qt Designer} provide a \c retranslateUi() function that can be called. + The function returns true on success and false on failure. + \sa removeTranslator() translate() QTranslator::load() {Dynamic Translation} */ -void QCoreApplication::installTranslator(QTranslator *translationFile) +bool QCoreApplication::installTranslator(QTranslator *translationFile) { if (!translationFile) - return; + return false; if (!QCoreApplicationPrivate::checkInstance("installTranslator")) - return; + return false; QCoreApplicationPrivate *d = self->d_func(); d->translators.prepend(translationFile); #ifndef QT_NO_TRANSLATION_BUILDER if (translationFile->isEmpty()) - return; + return false; #endif QEvent ev(QEvent::LanguageChange); QCoreApplication::sendEvent(self, &ev); + return true; } /*! @@ -1540,20 +1543,24 @@ void QCoreApplication::installTranslator(QTranslator *translationFile) translation files used by this application. (It does not delete the translation file from the file system.) + The function returns true on success and false on failure. + \sa installTranslator() translate(), QObject::tr() */ -void QCoreApplication::removeTranslator(QTranslator *translationFile) +bool QCoreApplication::removeTranslator(QTranslator *translationFile) { if (!translationFile) - return; + return false; if (!QCoreApplicationPrivate::checkInstance("removeTranslator")) - return; + return false; QCoreApplicationPrivate *d = self->d_func(); if (d->translators.removeAll(translationFile) && !self->closingDown()) { QEvent ev(QEvent::LanguageChange); QCoreApplication::sendEvent(self, &ev); + return true; } + return false; } static void replacePercentN(QString *result, int n) -- cgit v1.2.3