API Documentation
Loading...
Searching...
No Matches
TranslationCombo.h
Go to the documentation of this file.
1#pragma once
2#include <NDEVR/QCustomCombobox.h>
3#include <NDEVR/Translator.h>
4namespace NDEVR
5{
7 {
8 public:
9 TranslationCombo(QWidget* parent = nullptr)
10 : QCustomComboBox(parent)
11 {
14 if (id.size() == 0)
15 id = "en_US";
16 setValue(id);
17 setToolTip(_td("language_tooltip", "Select from the list of available language options. "
18 "If you would like to see additional language options in the list, please contact us to make a request."));
19 }
21 {
23 Buffer<TranslatedString> translation_names;
24 Buffer<String> translation_ids;
25 for (const auto& translator : m_translations)
26 {
27 translation_names.add(TranslatedString(translator.second.name()));
28 translation_ids.add(translator.first);
29 }
30 setup(_t("Language"), translation_ids, translation_names);
32 }
33 void setTranslation(const Translator& translator)
34 {
35 lib_assert(m_translations.hasKey(translator.id()), "Could not find translation");
36 setValue(translator.id());
37
38 }
40 {
41 String value = getAs<String>();
42 if (m_translations.hasKey(value))
43 return m_translations.get(value);
44 lib_assert(false, "Bad translation");
45 return Translator();
46 }
47 protected:
49 };
50}
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:68
#define _t(english_string)
Definition Translator.h:90
#define _td(def, english_string)
Definition Translator.h:94
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:59
void add(t_type &&object)
Definition Buffer.hpp:211
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:59
A compact way to present a list of options to the user.
Definition QCustomCombobox.h:53
void setValue(const t_type &t_value)
Definition QCustomCombobox.h:209
void sortAlphabetically(uint04 start=0, uint04 size=Constant< uint04 >::Invalid)
void setup(const TranslatedString &title, const Buffer< TranslatedString > &values)
void setToolTip(const TranslatedString &tooltip)
t_type getAs() const
Definition QCustomCombobox.h:197
The core String class for the software.
Definition String.h:47
Any text displayed to the user should be defined as a TranslatedString which allows the.
Definition TranslatedString.h:13
Definition TranslationCombo.h:7
void updateTranslationsFromDisk()
Definition TranslationCombo.h:20
Dictionary< String, Translator > m_translations
Definition TranslationCombo.h:48
Translator currentTranslation() const
Definition TranslationCombo.h:39
TranslationCombo(QWidget *parent=nullptr)
Definition TranslationCombo.h:9
void setTranslation(const Translator &translator)
Definition TranslationCombo.h:33
Contains logic for translating a string into a defined language.
Definition Translator.h:45
const String & id() const
Definition Translator.h:60
static Translator * MainTranslator()
static Dictionary< String, Translator > GetAvailableTranslations(File folder=File())
Definition ACIColor.h:37