Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Public Member Functions | Private Member Functions | Private Attributes | List of all members
geometrize::dialog::LanguageSelectList::LanguageSelectListImpl Class Reference
Collaboration diagram for geometrize::dialog::LanguageSelectList::LanguageSelectListImpl:
Collaboration graph
[legend]

Public Member Functions

 LanguageSelectListImpl (LanguageSelectList *pQ)
 
LanguageSelectListImpl operator= (const LanguageSelectListImpl &)=delete
 
 LanguageSelectListImpl (const LanguageSelectListImpl &)=delete
 
 ~LanguageSelectListImpl ()
 
void onLanguageChange ()
 

Private Member Functions

void setupLanguageSelect ()
 
void addItemAtIndex (const int i, const QString &localeCode)
 

Private Attributes

LanguageSelectListq
 

Constructor & Destructor Documentation

geometrize::dialog::LanguageSelectList::LanguageSelectListImpl::LanguageSelectListImpl ( LanguageSelectList pQ)
inline
20  : q{pQ}
21  {
23 
24  q->connect(q, &QListWidget::currentItemChanged, [this](QListWidgetItem* current, QListWidgetItem* /*previous*/) {
25  if(current == nullptr) {
26  return;
27  }
28 
29  QString isoCode{current->data(Qt::UserRole).toString()};
30  if(isoCode == "pt") {
31  // NOTE hack - the default Portuguese translations are pt_PT not pt_BR, we make that explicit here
32  // This is because Qt defaults to Brazilian version, whereas we preferred to default to Portugal
33  isoCode = "pt_PT";
34  }
35 
37  prefs.setLanguageIsoCode(isoCode.toStdString());
38 
39  QLocale::setDefault(QLocale(isoCode));
40 
42  });
43  }
void setTranslatorsForLocale(const QString &locale)
installTranslatorsForLocale Installs translators for the application.
Definition: localization.cpp:74
The GlobalPreferences class models the preferences associated with the application as a whole...
Definition: globalpreferences.h:43
void setLanguageIsoCode(const std::string &languageIsoCode)
setLanguageIsoCode Sets the ISO 639-1 language preference for the application.
Definition: globalpreferences.cpp:643
LanguageSelectList * q
Definition: languageselectlist.cpp:84
geometrize::preferences::GlobalPreferences & getGlobalPreferences()
getGlobalPreferences Shorthand function that gets a reference to the shared global preferences object...
Definition: globalpreferences.cpp:32
void setupLanguageSelect()
Definition: languageselectlist.cpp:58
geometrize::dialog::LanguageSelectList::LanguageSelectListImpl::LanguageSelectListImpl ( const LanguageSelectListImpl )
delete
geometrize::dialog::LanguageSelectList::LanguageSelectListImpl::~LanguageSelectListImpl ( )
inline
48  {
49  }

Member Function Documentation

void geometrize::dialog::LanguageSelectList::LanguageSelectListImpl::addItemAtIndex ( const int  i,
const QString &  localeCode 
)
inlineprivate
73  {
74  const QLocale locale{localeCode};
75  const QLocale::Language language{locale.language()};
76  const QString languageName{locale.languageToString(language)};
77  const QIcon icon{geometrize::getFlagIconForLocaleCode(localeCode)};
78 
79  QListWidgetItem* const item{new QListWidgetItem(icon, languageName)};
80  item->setData(Qt::UserRole, localeCode);
81  q->insertItem(i, item);
82  }
LanguageSelectList * q
Definition: languageselectlist.cpp:84
QIcon getFlagIconForLocaleCode(const QString &localeCode)
getFlagIconForLocaleCode Gets a representative national flag for the given locale code...
Definition: localization.cpp:96

Here is the call graph for this function:

Here is the caller graph for this function:

void geometrize::dialog::LanguageSelectList::LanguageSelectListImpl::onLanguageChange ( )
inline
52  {
53  // Could iterate over items and translate the language labels
54  }
LanguageSelectListImpl geometrize::dialog::LanguageSelectList::LanguageSelectListImpl::operator= ( const LanguageSelectListImpl )
delete
void geometrize::dialog::LanguageSelectList::LanguageSelectListImpl::setupLanguageSelect ( )
inlineprivate
59  {
61  int idx = 0;
62  while (it.hasNext()) {
63  it.next();
64  QString fileName{it.fileName()};
65  const QString localeCode{fileName.remove("geometrize_").remove(geometrize::getBinaryTranslationFileExtension())};
66  addItemAtIndex(++idx, localeCode);
67  }
68 
69  q->sortItems(Qt::AscendingOrder);
70  }
LanguageSelectList * q
Definition: languageselectlist.cpp:84
QString getAppTranslationResourceDirectory()
getAppTranslationResourceDirectory Gets the resource path where translation files specific to the app...
Definition: localization.cpp:64
void addItemAtIndex(const int i, const QString &localeCode)
Definition: languageselectlist.cpp:72
QString getBinaryTranslationFileExtension()
getBinaryTranslationFileExtension Gets the file extension for Qt binary translation files...
Definition: localization.cpp:59

Here is the call graph for this function:

Member Data Documentation

LanguageSelectList* geometrize::dialog::LanguageSelectList::LanguageSelectListImpl::q
private

The documentation for this class was generated from the following file: