Commit ead92e20fa2f011edefd88edca8a323f88ffbf4c
- Diff rendering mode:
- inline
- side by side
|   | |||
| 57 | 57 | containerPolicy = new DuiLinearLayoutPolicy(containerLayout, Qt::Vertical); | |
| 58 | 58 | containerLayout->setPolicy(containerPolicy); | |
| 59 | 59 | ||
| 60 | DuiLocale locale; | ||
| 60 | 61 | QStringList list; | |
| 61 | 62 | for (int i = 0; i < 10000; ++i) { | |
| 62 | list << QString::number(10000 + i); | ||
| 63 | list << locale.formatNumber(10000 + i); | ||
| 63 | 64 | } | |
| 64 | 65 | ||
| 65 | 66 | comboBox1 = new DuiComboBox; |
|   | |||
| 105 | 105 | if (currentLanguage == model->item(i, 1)->text()) | |
| 106 | 106 | comboBox->setCurrentIndex(i); | |
| 107 | 107 | } | |
| 108 | DuiLocale locale; | ||
| 108 | 109 | //% "Please select language" | |
| 109 | comboBox->setTitle(qtTrId("xx_language_combobox_title")); | ||
| 110 | comboBox->setTitle(qtTrId("xx_language_combobox_title") + " " + locale.formatNumber(1234567890)); | ||
| 110 | 111 | ||
| 111 | 112 | connect(comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeLanguage(int))); | |
| 112 | 113 | } |
src/i18n/duilocale.cpp
(36 / 18)
|   | |||
| 62 | 62 | const QString SettingsCountry("/Dui/i18n/Country"); | |
| 63 | 63 | const QString SettingsScript("/Dui/i18n/Script"); | |
| 64 | 64 | const QString SettingsVariant("/Dui/i18n/Variant"); | |
| 65 | const QString SettingsLcNumeric("/Dui/i18n/LcNumeric"); | ||
| 65 | 66 | } | |
| 66 | 67 | ||
| 67 | 68 | /// Helper | |
| … | … | ||
| 315 | 315 | , currentLanguageItem(SettingsLanguage), | |
| 316 | 316 | currentCountryItem(SettingsCountry), | |
| 317 | 317 | currentScriptItem(SettingsScript), | |
| 318 | currentVariantItem(SettingsVariant) | ||
| 318 | currentVariantItem(SettingsVariant), | ||
| 319 | currentLcNumericItem(SettingsLcNumeric) | ||
| 319 | 320 | #endif | |
| 320 | 321 | { | |
| 321 | 322 | } | |
| … | … | ||
| 343 | 343 | , currentLanguageItem(SettingsLanguage), | |
| 344 | 344 | currentCountryItem(SettingsCountry), | |
| 345 | 345 | currentScriptItem(SettingsScript), | |
| 346 | currentVariantItem(SettingsVariant) | ||
| 346 | currentVariantItem(SettingsVariant), | ||
| 347 | currentLcNumericItem(SettingsLcNumeric) | ||
| 347 | 348 | #endif | |
| 348 | 349 | { | |
| 349 | 350 | #ifdef HAVE_ICU | |
| … | … | ||
| 637 | 637 | DuiGConfItem countryItem(SettingsCountry); | |
| 638 | 638 | DuiGConfItem scriptItem(SettingsScript); | |
| 639 | 639 | DuiGConfItem variantItem(SettingsVariant); | |
| 640 | DuiGConfItem lcNumericItem(SettingsLcNumeric); | ||
| 640 | 641 | ||
| 641 | 642 | QString language = languageItem.value().toString(); | |
| 642 | 643 | QString country = countryItem.value().toString(); | |
| 643 | 644 | QString script = scriptItem.value().toString(); | |
| 644 | 645 | QString variant = variantItem.value().toString(); | |
| 646 | QString lcNumeric = lcNumericItem.value().toString(); | ||
| 645 | 647 | ||
| 646 | 648 | DuiLocale *systemLocale; | |
| 647 | 649 | ||
| … | … | ||
| 664 | 664 | QString(variant))); | |
| 665 | 665 | } | |
| 666 | 666 | ||
| 667 | if (!lcNumeric.isEmpty()) | ||
| 668 | systemLocale->setCategoryLocale(DuiLocale::DuiLcNumeric, lcNumeric); | ||
| 669 | |||
| 667 | 670 | return systemLocale; | |
| 668 | 671 | #else | |
| 669 | 672 | QString language = qgetenv("LANG"); | |
| … | … | ||
| 678 | 678 | #endif | |
| 679 | 679 | } | |
| 680 | 680 | ||
| 681 | |||
| 682 | 681 | //! creates a "C" locale | |
| 683 | 682 | DuiLocale DuiLocale::createCLocale() | |
| 684 | 683 | { | |
| … | … | ||
| 692 | 692 | ||
| 693 | 693 | QObject::connect(&d->currentLanguageItem, SIGNAL(valueChanged()), | |
| 694 | 694 | this, SLOT(refreshSettings())); | |
| 695 | |||
| 696 | 695 | QObject::connect(&d->currentCountryItem, SIGNAL(valueChanged()), | |
| 697 | 696 | this, SLOT(refreshSettings())); | |
| 698 | |||
| 699 | 697 | QObject::connect(&d->currentScriptItem, SIGNAL(valueChanged()), | |
| 700 | 698 | this, SLOT(refreshSettings())); | |
| 701 | |||
| 702 | 699 | QObject::connect(&d->currentVariantItem, SIGNAL(valueChanged()), | |
| 703 | 700 | this, SLOT(refreshSettings())); | |
| 701 | QObject::connect(&d->currentLcNumericItem, SIGNAL(valueChanged()), | ||
| 702 | this, SLOT(refreshSettings())); | ||
| 704 | 703 | #endif | |
| 705 | 704 | } | |
| 706 | 705 | ||
| … | … | ||
| 711 | 711 | ||
| 712 | 712 | QObject::disconnect(&d->currentLanguageItem, SIGNAL(valueChanged()), | |
| 713 | 713 | this, SLOT(refreshSettings())); | |
| 714 | |||
| 715 | 714 | QObject::disconnect(&d->currentCountryItem, SIGNAL(valueChanged()), | |
| 716 | 715 | this, SLOT(refreshSettings())); | |
| 717 | |||
| 718 | 716 | QObject::disconnect(&d->currentScriptItem, SIGNAL(valueChanged()), | |
| 719 | 717 | this, SLOT(refreshSettings())); | |
| 720 | |||
| 721 | 718 | QObject::disconnect(&d->currentVariantItem, SIGNAL(valueChanged()), | |
| 722 | 719 | this, SLOT(refreshSettings())); | |
| 720 | QObject::disconnect(&d->currentLcNumericItem, SIGNAL(valueChanged()), | ||
| 721 | this, SLOT(refreshSettings())); | ||
| 723 | 722 | #endif | |
| 724 | 723 | } | |
| 725 | 724 | ||
| … | … | ||
| 838 | 838 | ||
| 839 | 839 | // Setting the default QLocale is needed to get localized number | |
| 840 | 840 | // support in translations via %Ln, %L1, %L2, ...: | |
| 841 | QLocale qlocale(locale.language() + '_' + locale.country()); | ||
| 841 | QLocale qlocale(locale.categoryLanguage(DuiLcNumeric) | ||
| 842 | + '_' | ||
| 843 | + locale.categoryCountry(DuiLcNumeric)); | ||
| 842 | 844 | QLocale::setDefault(qlocale); | |
| 843 | 845 | // sends QEvent::LanguageChange to qApp: | |
| 844 | 846 | (s_systemDefault->d_ptr)->insertTrToQCoreApp(); | |
| … | … | ||
| 2064 | 2064 | { | |
| 2065 | 2065 | #ifdef HAVE_GCONF | |
| 2066 | 2066 | Q_D(DuiLocale); | |
| 2067 | bool settingsHaveReallyChanged = false; | ||
| 2067 | 2068 | QString language = d->currentLanguageItem.value().toString(); | |
| 2068 | 2069 | QString country = d->currentCountryItem.value().toString(); | |
| 2069 | 2070 | QString script = d->currentScriptItem.value().toString(); | |
| 2070 | 2071 | QString variant = d->currentVariantItem.value().toString(); | |
| 2071 | 2072 | QString localeName = d->createLocaleString(language, country, script, variant); | |
| 2073 | QString lcNumeric = d->currentLcNumericItem.value().toString(); | ||
| 2072 | 2074 | ||
| 2075 | qDebug() << __PRETTY_FUNCTION__ << "***mike start refreshSettings()" << "_defaultLocale=" << d->_defaultLocale << "_messageLocale=" << d->_messageLocale << categoryName(DuiLcMessages) << "_numericLocale=" << d->_numericLocale << categoryName(DuiLcNumeric) << "_collationLocale=" << d->_collationLocale << categoryName(DuiLcCollate) << "_calendarLocale=" << d->_calendarLocale << categoryName(DuiLcTime) << "_monetaryLocale=" << d->_monetaryLocale << categoryName(DuiLcMonetary) << "_nameLocale=" << d->_nameLocale << categoryName(DuiLcName); | ||
| 2076 | |||
| 2073 | 2077 | if (localeName != d->_defaultLocale) { | |
| 2078 | settingsHaveReallyChanged = true; | ||
| 2074 | 2079 | d->_defaultLocale = localeName; | |
| 2075 | setCategoryLocale(DuiLcMessages, localeName); | ||
| 2076 | setCategoryLocale(DuiLcTime, localeName); | ||
| 2077 | setCategoryLocale(DuiLcNumeric, localeName); | ||
| 2078 | setCategoryLocale(DuiLcCollate, localeName); | ||
| 2079 | setCategoryLocale(DuiLcMonetary, localeName); | ||
| 2080 | setCategoryLocale(DuiLcName, localeName); | ||
| 2081 | |||
| 2080 | } | ||
| 2081 | if (lcNumeric != d->_numericLocale) { | ||
| 2082 | settingsHaveReallyChanged = true; | ||
| 2083 | setCategoryLocale(DuiLcNumeric, lcNumeric); | ||
| 2084 | } | ||
| 2085 | if (settingsHaveReallyChanged) { | ||
| 2082 | 2086 | if (this == s_systemDefault) { | |
| 2087 | qDebug () << __PRETTY_FUNCTION__ << "***mike is s_systemDefault"; | ||
| 2083 | 2088 | // Setting the default QLocale is needed to get localized number | |
| 2084 | 2089 | // support in translations via %Ln, %L1, %L2, ...: | |
| 2085 | QLocale qlocale(this->language() + '_' + this->country()); | ||
| 2090 | QLocale qlocale(this->categoryLanguage(DuiLcNumeric) | ||
| 2091 | + '_' | ||
| 2092 | + this->categoryCountry(DuiLcNumeric)); | ||
| 2086 | 2093 | QLocale::setDefault(qlocale); | |
| 2087 | 2094 | d->removeTrFromQCoreApp(); | |
| 2088 | 2095 | d->loadTrCatalogs(); | |
| … | … | ||
| 2101 | 2101 | else { | |
| 2102 | 2102 | d->loadTrCatalogs(); | |
| 2103 | 2103 | } | |
| 2104 | qDebug () << __PRETTY_FUNCTION__ << "***mike emit settingsChanged()"; | ||
| 2104 | 2105 | emit settingsChanged(); | |
| 2105 | 2106 | } | |
| 2107 | |||
| 2108 | qDebug() << __PRETTY_FUNCTION__ << "***mike end refreshSettings()" << "_defaultLocale=" << d->_defaultLocale << "_messageLocale=" << d->_messageLocale << categoryName(DuiLcMessages) << "_numericLocale=" << d->_numericLocale << categoryName(DuiLcNumeric) << "_collationLocale=" << d->_collationLocale << categoryName(DuiLcCollate) << "_calendarLocale=" << d->_calendarLocale << categoryName(DuiLcTime) << "_monetaryLocale=" << d->_monetaryLocale << categoryName(DuiLcMonetary) << "_nameLocale=" << d->_nameLocale << categoryName(DuiLcName); | ||
| 2109 | |||
| 2106 | 2110 | #endif | |
| 2107 | 2111 | } |
src/i18n/duilocale_p.h
(1 / 0)
|   | |||
| 134 | 134 | DuiGConfItem currentCountryItem; | |
| 135 | 135 | DuiGConfItem currentScriptItem; | |
| 136 | 136 | DuiGConfItem currentVariantItem; | |
| 137 | DuiGConfItem currentLcNumericItem; | ||
| 137 | 138 | #endif | |
| 138 | 139 | ||
| 139 | 140 | DuiLocale *q_ptr; |
src/widgets/duiwindow.cpp
(1 / 0)
|   | |||
| 722 | 722 | foreach(QGraphicsItem *item, items) | |
| 723 | 723 | if(!item->parentItem()) itemsWithoutParents << item; | |
| 724 | 724 | foreach(QGraphicsItem * item, itemsWithoutParents) { | |
| 725 | qDebug() << __PRETTY_FUNCTION__ << "***mike QEvent::LanguageChange handler"; | ||
| 725 | 726 | d->handleLanguageChangeEvent(item); | |
| 726 | 727 | } | |
| 727 | 728 | } |

