mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Language Settings Wrapper
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
15fece7da2
commit
c3137cf07c
4 changed files with 143 additions and 2 deletions
|
@ -32,6 +32,11 @@ typedef struct {
|
|||
enum taxonomy_category category[3];
|
||||
} geocoding_prefs_t;
|
||||
|
||||
typedef struct {
|
||||
const char *language;
|
||||
bool use_system_language;
|
||||
} locale_prefs_t;
|
||||
|
||||
enum deco_mode {
|
||||
BUEHLMANN,
|
||||
RECREATIONAL,
|
||||
|
@ -126,6 +131,7 @@ struct preferences {
|
|||
int time_threshold;
|
||||
int distance_threshold;
|
||||
bool git_local_only;
|
||||
locale_prefs_t locale; //: TODO: move the rest of locale based info here.
|
||||
};
|
||||
enum unit_system_values {
|
||||
METRIC,
|
||||
|
|
|
@ -1273,6 +1273,7 @@ void loadPreferences()
|
|||
QSettings s;
|
||||
QVariant v;
|
||||
|
||||
uiLanguage(NULL);
|
||||
s.beginGroup("Units");
|
||||
if (s.value("unit_system").toString() == "metric") {
|
||||
prefs.unit_system = METRIC;
|
||||
|
|
|
@ -1389,3 +1389,100 @@ void DisplaySettingsObjectWrapper::setDisplayInvalidDives(short value)
|
|||
prefs.display_invalid_dives = value.;
|
||||
emit displayInvalidDivesChanged(value);
|
||||
}
|
||||
|
||||
LanguageSettingsObjectWrapper::LanguageSettingsObjectWrapper(QObject *parent) :
|
||||
QObject(parent),
|
||||
group("Language")
|
||||
{
|
||||
}
|
||||
|
||||
QString LanguageSettingsObjectWrapper::language() const
|
||||
{
|
||||
return prefs.locale.language;
|
||||
}
|
||||
|
||||
QString LanguageSettingsObjectWrapper::timeFormat() const
|
||||
{
|
||||
return prefs.time_format;
|
||||
}
|
||||
|
||||
QString LanguageSettingsObjectWrapper::dateFormat() const
|
||||
{
|
||||
return prefs.date_format;
|
||||
}
|
||||
|
||||
QString LanguageSettingsObjectWrapper::dateFormatShort() const
|
||||
{
|
||||
return prefs.date_format_short;
|
||||
}
|
||||
|
||||
bool LanguageSettingsObjectWrapper::timeFormatOverride() const
|
||||
{
|
||||
return prefs.time_format_override;
|
||||
}
|
||||
|
||||
bool LanguageSettingsObjectWrapper::dateFormatOverride() const
|
||||
{
|
||||
return prefs.date_format_override;
|
||||
}
|
||||
|
||||
bool LanguageSettingsObjectWrapper::useSystemLanguage() const
|
||||
{
|
||||
return prefs.locale.use_system_language;
|
||||
}
|
||||
|
||||
void LanguageSettingsObjectWrapper::setUseSystemLanguage(bool value)
|
||||
{
|
||||
QSettings s;
|
||||
s.setValue("UseSystemLanguage", value);
|
||||
prefs.locale.use_system_language = copy_string(qPrintable(value));
|
||||
emit useSystemLanguageChanged(value);
|
||||
}
|
||||
|
||||
void LanguageSettingsObjectWrapper::setLanguage(const QString& value)
|
||||
{
|
||||
QSettings s;
|
||||
s.setValue("UiLanguage", value);
|
||||
prefs.locale.language = copy_string(qPrintable(value));
|
||||
emit languageChanged(value);
|
||||
}
|
||||
|
||||
void LanguageSettingsObjectWrapper::setTimeFormat(const QString& value)
|
||||
{
|
||||
QSettings s;
|
||||
s.setValue("time_format", value);
|
||||
prefs.time_format = copy_string(qPrintable(value));;
|
||||
emit timeFormatChanged(value);
|
||||
}
|
||||
|
||||
void LanguageSettingsObjectWrapper::setDateFormat(const QString& value)
|
||||
{
|
||||
QSettings s;
|
||||
s.setValue("date_format", value);
|
||||
prefs.date_format = copy_string(qPrintable(value));;
|
||||
emit dateFormatChanged(value);
|
||||
}
|
||||
|
||||
void LanguageSettingsObjectWrapper::setDateFormatShort(const QString& value)
|
||||
{
|
||||
QSettings s;
|
||||
s.setValue("date_format_short", value);
|
||||
prefs.date_format_short = copy_string(qPrintable(value));;
|
||||
emit dateFormatShortChanged(value);
|
||||
}
|
||||
|
||||
void LanguageSettingsObjectWrapper::setTimeFormatOverride(bool value)
|
||||
{
|
||||
QSettings s;
|
||||
s.setValue("time_format_override", value);
|
||||
prefs.time_format_override = value.;
|
||||
emit timeFormatOverrideChanged(value);
|
||||
}
|
||||
|
||||
void LanguageSettingsObjectWrapper::setDateFormatOverride(bool value)
|
||||
{
|
||||
QSettings s;
|
||||
s.setValue("date_format_override", value);
|
||||
prefs.date_format_override = value.;
|
||||
emit dateFormatOverrideChanged(value);
|
||||
}
|
||||
|
|
|
@ -513,13 +513,50 @@ private:
|
|||
QString group;
|
||||
};
|
||||
|
||||
class SettingsObjectWrapper : public QObject {
|
||||
class LanguageSettingsObjectWrapper : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY languageChanged)
|
||||
Q_PROPERTY(QString time_format READ timeFormat WRITE setTimeFormat NOTIFY timeFormatChanged)
|
||||
Q_PROPERTY(QString date_format READ dateFormat WRITE setDateFormat NOTIFY dateFormatChanged)
|
||||
Q_PROPERTY(QString date_format_short READ dateFormatShort WRITE setDateFormatShort NOTIFY dateFormatShortChanged)
|
||||
Q_PROPERTY(bool time_format_override READ timeFormatOverride WRITE setTimeFormatOverride NOTIFY timeFormatOverrideChanged)
|
||||
Q_PROPERTY(bool date_format_override READ dateFormatOverride WRITE setDateFormatOverride NOTIFY dateFormatOverrideChanged)
|
||||
Q_PROPERTY(bool use_system_language READ useSystemLanguage WRITE setUseSystemLanguage NOTIFY useSystemLanguageChanged)
|
||||
|
||||
public:
|
||||
LanguageSettingsObjectWrapper(QObject *parent);
|
||||
QString language() const;
|
||||
QString timeFormat() const;
|
||||
QString dateFormat() const;
|
||||
QString dateFormatShort() const;
|
||||
bool timeFormatOverride() const;
|
||||
bool dateFormatOverride() const;
|
||||
bool useSystemLanguage() const;
|
||||
|
||||
public slots:
|
||||
void setLanguage (const QString& value);
|
||||
void setTimeFormat (const QString& value);
|
||||
void setDateFormat (const QString& value);
|
||||
void setDateFormatShort (const QString& value);
|
||||
void setTimeFormatOverride (bool value);
|
||||
void setDateFormatOverride (bool value);
|
||||
void setUseSystemLanguage (bool value);
|
||||
signals:
|
||||
void languageChanged(const QString& value);
|
||||
void timeFormatChanged(const QString& value);
|
||||
void dateFormatChanged(const QString& value);
|
||||
void dateFormatShortChanged(const QString& value);
|
||||
void timeFormatOverrideChanged(bool value);
|
||||
void dateFormatOverrideChanged(bool value);
|
||||
void useSystemLanguageChanged(bool value);
|
||||
|
||||
private:
|
||||
QString group;
|
||||
};
|
||||
|
||||
class SettingsObjectWrapper : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(int animation_speed READ animationSpeed WRITE setAnimationSpeed NOTIFY animationSpeedChanged)
|
||||
Q_PROPERTY(short unit_system READ unitSystem WRITE setUnitSystem NOTIFY uintSystemChanged)
|
||||
Q_PROPERTY(bool coordinates_traditional READ coordinatesTraditional WRITE setCoordinatesTraditional NOTIFY coordinatesTraditionalChanged)
|
||||
|
|
Loading…
Add table
Reference in a new issue