fixed a locale display bug

master
Qiaoyong Zhong 11 years ago
parent 194054e6fd
commit 557d2597ec

@ -31,7 +31,7 @@ HEADERS += \
TRANSLATIONS = ts/2048-qt_zh_CN.ts
VERSION = 0.1.1
VERSION = 0.1.2
VERSTR = '\\"$${VERSION}\\"'
DEFINES += VER=\"$${VERSTR}\"

@ -13,7 +13,13 @@ int main(int argc, char *argv[])
settings.setVersion(QString(VER));
// Localization
QString locale = settings.value("language", QLocale::system().name()).toString();
QString locale;
if (settings.contains("language")) {
locale = settings.value("language").toString();
} else {
locale = QLocale::system().name();
settings.setValue("language", locale);
}
QString tsFile = "2048-qt_" + locale;
QTranslator translator;

@ -93,9 +93,9 @@ ApplicationWindow {
text: qsTr("English")
checkable: true
exclusiveGroup: languageSettingsGroup
checked: settings.value("language", "en_US") === "en_US" ? true : false
checked: settings.value("language") === "en_US" ? true : false
onTriggered: {
if (settings.value("language", "en_US") !== "en_US") {
if (settings.value("language") !== "en_US") {
settings.setValue("language", "en_US");
changeLanguageDialog.open();
}
@ -105,9 +105,9 @@ ApplicationWindow {
text: qsTr("Simplified Chinese")
checkable: true
exclusiveGroup: languageSettingsGroup
checked: settings.value("language", "en_US") === "zh_CN" ? true : false
checked: settings.value("language") === "zh_CN" ? true : false
onTriggered: {
if (settings.value("language", "en_US") !== "zh_CN") {
if (settings.value("language") !== "zh_CN") {
settings.setValue("language", "zh_CN");
changeLanguageDialog.open();
}

@ -8,6 +8,10 @@ Settings::~Settings() {
delete settings_;
}
bool Settings::contains(const QString & key) const {
return settings_->contains(key);
}
void Settings::setValue(const QString &key, const QVariant &value) {
settings_->setValue(key, value);
}

@ -16,6 +16,7 @@ public:
Q_INVOKABLE QString getVersion();
void setVersion(const QString version);
bool contains(const QString & key) const;
signals:

Loading…
Cancel
Save