Ejemplo n.º 1
0
void KLanguageButton::loadAllLanguages()
{
    QStringList langlist;
    const QStringList localeDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString("locale"), QStandardPaths::LocateDirectory);
    Q_FOREACH(const QString& localeDir, localeDirs) {
        const QStringList entries = QDir(localeDir).entryList(QDir::Dirs);
        Q_FOREACH(const QString& d, entries) {
            const QString entryFile = localeDir + '/' + d + "/entry.desktop";
            if (QFile::exists(entryFile)) {
                langlist.append(entryFile);
            }
        }
    }
    langlist.sort();
  for (int i = 0, count = langlist.count(); i < count; ++i)
  {
    QString fpath = langlist[i].left(langlist[i].length() - 14);
    QString code = fpath.mid(fpath.lastIndexOf('/') + 1);
    KConfig entry(langlist[i], KConfig::SimpleConfig);
    KConfigGroup group(&entry, "KCM Locale");
    QString name = group.readEntry("Name", i18n("without name"));
    insertLanguage(code, name);
  }

  setCurrentItem(d->locale);
}
Ejemplo n.º 2
0
void KLanguageButton::loadAllLanguages()
{
  QStringList langlist = KGlobal::dirs()->findAllResources("locale",
                                  QString::fromLatin1("*/entry.desktop"));
  langlist.sort();
  for (int i = 0, count = langlist.count(); i < count; ++i)
  {
    QString fpath = langlist[i].left(langlist[i].length() - 14);
    QString code = fpath.mid(fpath.lastIndexOf('/') + 1);
    KConfig entry(langlist[i], KConfig::SimpleConfig);
    KConfigGroup group(&entry, "KCM Locale");
    QString name = group.readEntry("Name", i18n("without name"));
    insertLanguage(code, name);
  }

  const KLocale *locale = d->locale ? d->locale : KGlobal::locale();
  setCurrentItem(locale ? locale->language() : KLocale::defaultLanguage());
}