Add a 'language_without_region' as this is not specific to networkremotesettingpage

This commit is contained in:
Arnaud Bienner 2013-07-27 19:23:55 +02:00
parent 9bf5690671
commit fc1880161c
3 changed files with 12 additions and 6 deletions

View File

@ -157,6 +157,14 @@ void Application::AddError(const QString& message) {
emit ErrorAdded(message); emit ErrorAdded(message);
} }
QString Application::language_without_region() const {
const int underscore = language_name_.indexOf('_');
if (underscore != -1) {
return language_name_.left(underscore);
}
return language_name_;
}
LibraryBackend* Application::library_backend() const { LibraryBackend* Application::library_backend() const {
return library()->backend(); return library()->backend();
} }

View File

@ -55,7 +55,9 @@ public:
Application(QObject* parent = NULL); Application(QObject* parent = NULL);
~Application(); ~Application();
QString language_name() const { return language_name_; } const QString& language_name() const { return language_name_; }
// Same as language_name, but remove the region code at the end if there is one
QString language_without_region() const;
void set_language_name(const QString& name) { language_name_ = name; } void set_language_name(const QString& name) { language_name_ = name; }
TagReaderClient* tag_reader_client() const { return tag_reader_client_; } TagReaderClient* tag_reader_client() const { return tag_reader_client_; }

View File

@ -89,11 +89,7 @@ void NetworkRemoteSettingsPage::Load() {
ui_->ip_address->setText(ip_addresses); ui_->ip_address->setText(ip_addresses);
// Get the right play store badge for this language. // Get the right play store badge for this language.
QString language = dialog()->app()->language_name(); QString language = dialog()->app()->language_without_region();
const int underscore = language.indexOf('_');
if (underscore != -1) {
language = language.left(underscore);
}
QString badge_filename = ":/playstore/" + language + "_generic_rgb_wo_45.png"; QString badge_filename = ":/playstore/" + language + "_generic_rgb_wo_45.png";
if (!QFile::exists(badge_filename)) { if (!QFile::exists(badge_filename)) {