diff --git a/locales.cpp b/locales.cpp index 28f2d6b..8455834 100644 --- a/locales.cpp +++ b/locales.cpp @@ -40,9 +40,16 @@ bool Locales::setLocalePrivate(const QLocale &locale) { } emit sigTranslationChanged(); + _currentLocate = locale; + return _translations.size(); } +const QLocale &Locales::currentLocate() { + auto obj = instance(); + return obj->currentLocatePrivate(); +} + bool Locales::setLocale(const QLocale &locale) { auto obj = instance(); return obj->setLocalePrivate(locale); @@ -78,12 +85,17 @@ void Locales::removeOldTranslation() { QCoreApplication::removeTranslator(tr); delete tr; } + _translations.clear(); } void Locales::addLocationPrivate(const QString &location) { _locations += location; } +const QLocale &Locales::currentLocatePrivate() const { + return _currentLocate; + +} void Locales::addLocation(const QString &location) { auto obj = instance(); obj->addLocationPrivate(location); diff --git a/locales.h b/locales.h index 6d8ead3..820471a 100644 --- a/locales.h +++ b/locales.h @@ -66,6 +66,12 @@ public: */ static Locales *instance(); + /** + * @brief currentLocate This method return current locate of applicatuon. + * @return current or last sets locate of applciation. + */ + static const QLocale ¤tLocate(); + signals: /** * @brief sigTranslationChanged Emited when set new locale for application. @@ -82,6 +88,9 @@ private: void removeOldTranslation(); void addLocationPrivate(const QString& location); + const QLocale ¤tLocatePrivate() const; + + QLocale _currentLocate; QSet<QString> _locations; QList<QTranslator *> _translations;