|
|
|
@ -22,6 +22,7 @@
|
|
|
|
|
|
|
|
|
|
#include <QLocale>
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
|
|
namespace CalamaresUtils
|
|
|
|
|
{
|
|
|
|
@ -35,8 +36,14 @@ namespace Locale
|
|
|
|
|
* translation system) into QLocales, and also into consistent
|
|
|
|
|
* human-readable text labels.
|
|
|
|
|
*/
|
|
|
|
|
class Label
|
|
|
|
|
class Label : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
Q_PROPERTY(QString label READ label NOTIFY labelChanged CONSTANT FINAL)
|
|
|
|
|
Q_PROPERTY(QString englishLabel READ englishLabel NOTIFY englishLabelChanged CONSTANT FINAL)
|
|
|
|
|
Q_PROPERTY(QString localeId MEMBER m_localeId NOTIFY localeIdChanged CONSTANT FINAL)
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
/** @brief Formatting option for label -- add (country) to label. */
|
|
|
|
|
enum class LabelFormat
|
|
|
|
@ -46,7 +53,7 @@ public:
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** @brief Empty locale. This uses the system-default locale. */
|
|
|
|
|
Label();
|
|
|
|
|
Label(QObject* parent = nullptr);
|
|
|
|
|
|
|
|
|
|
/** @brief Construct from a locale name.
|
|
|
|
|
*
|
|
|
|
@ -54,7 +61,7 @@ public:
|
|
|
|
|
* The @p format determines whether the country name is always present
|
|
|
|
|
* in the label (human-readable form) or only if needed for disambiguation.
|
|
|
|
|
*/
|
|
|
|
|
Label( const QString& localeName, LabelFormat format = LabelFormat::IfNeededWithCountry );
|
|
|
|
|
Label( const QString& localeName, LabelFormat format = LabelFormat::IfNeededWithCountry, QObject* parent = nullptr );
|
|
|
|
|
|
|
|
|
|
/** @brief Define a sorting order.
|
|
|
|
|
*
|
|
|
|
@ -100,6 +107,11 @@ protected:
|
|
|
|
|
QString m_localeId; // the locale identifier, e.g. "en_GB"
|
|
|
|
|
QString m_label; // the native name of the locale
|
|
|
|
|
QString m_englishLabel;
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void labelChanged( QString label );
|
|
|
|
|
void englishLabelChanged( QString englishLabel );
|
|
|
|
|
void localeIdChanged( QString localeIdChanged );
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Locale
|
|
|
|
|