void AppSettings::getLangs(){ QString themeDir=""; #ifdef RELEASE #ifdef _OS_DARWIN_ themeDir = QDir::currentPath(); themeDir.append("/"); themeDir.append(APP_SHORT_NAME); themeDir.append(".app/Contents"); #else themeDir = APP_PREF; themeDir.append("/share/"); themeDir.append(APP_SHORT_NAME); #endif #else themeDir = QString::fromUtf8(APP_BUILD); #endif themeDir.append("/l10n"); QDir tmp(themeDir); tmp.setFilter(QDir::Files | QDir::NoSymLinks); QFileInfoList list = tmp.entryInfoList(); for (int i = 0; i < list.size(); ++i) { QFileInfo fileInfo = list.at(i); if (fileInfo.fileName().right(2)=="qm"){ QString lName = fileInfo.fileName().replace("q4wine_", ""); QLocale lObj = QLocale(lName); QString lNameNative = lObj.nativeLanguageName(); lng_hash[lNameNative] = lObj.name(); comboLangs->addItem(lNameNative); } } return; }
QString Speller::nameForLanguage(const QString &code) const { QLocale loc = QLocale(code); QString name = QLocale::languageToString(loc.language()); if (loc.country() != QLocale::AnyCountry) { name.append(" / " + loc.nativeLanguageName()); } return name; }
void InfoWidget::localeChanged(QLocale locale) { setLocale(locale); name->setText(locale.name()); bcp47Name->setText(locale.bcp47Name()); languageName->setText(QLocale::languageToString(locale.language())); nativeLanguageName->setText(locale.nativeLanguageName()); scriptName->setText(QLocale::scriptToString(locale.script())); countryName->setText(QLocale::countryToString(locale.country())); nativeCountryName->setText(locale.nativeCountryName()); }
void KnownDictsManager::rebuildDictsModel () { auto candidates = GetSystemPaths (); candidates.prepend (LocalPath_); Lang2Path_.clear (); for (const auto& dir : candidates) { if (!QFile::exists (dir)) continue; for (auto file : QDir (dir).entryList ({ "*.dic" })) { if (file.startsWith ("hyph_")) continue; file.chop (4); if (Lang2Path_.contains (file)) continue; Lang2Path_ [file] = dir; } } Model_->clear (); Model_->setHorizontalHeaderLabels ({ tr ("Locale"), tr ("Language"), tr ("Country") }); for (auto i = Lang2Path_.begin (); i != Lang2Path_.end (); ++i) { auto item = new QStandardItem (i.key ()); item->setCheckable (true); item->setCheckState (Languages_.contains (i.key ()) ? Qt::Checked : Qt::Unchecked); const QLocale loc (i.key ()); QList<QStandardItem*> row { item }; row << new QStandardItem (loc.nativeLanguageName ()); row << new QStandardItem (loc.nativeCountryName ()); for (auto item : row) item->setEditable (false); Model_->appendRow (row); } }
AcceptLanguageDialog::AcceptLanguageDialog(const QString &languages, QWidget *parent) : Dialog(parent), m_ui(new Ui::AcceptLanguageDialog) { m_ui->setupUi(this); m_model = new QStandardItemModel(this); m_model->setHorizontalHeaderLabels(QStringList({tr("Name"), tr("Code")})); m_ui->languagesViewWidget->setModel(m_model); QStringList chosenLanguages(languages.split(QLatin1Char(','), QString::SkipEmptyParts)); for (int i = 0; i < chosenLanguages.count(); ++i) { addLanguage(chosenLanguages.at(i).section(QLatin1Char(';'), 0, 0)); } const QList<QLocale> locales(QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry)); QVector<QPair<QString, QString> > entries; for (int i = 0; i < locales.count(); ++i) { const QLocale locale(locales.at(i)); if (locale != QLocale::c()) { if (locale.nativeCountryName().isEmpty() || locale.nativeLanguageName().isEmpty()) { entries.append({tr("Unknown [%1]").arg(locale.bcp47Name()), locale.bcp47Name()}); } else { entries.append({QStringLiteral("%1 - %2 [%3]").arg(locale.nativeLanguageName()).arg(locale.nativeCountryName()).arg(locale.bcp47Name()), locale.bcp47Name()}); } } } QCollator collator; collator.setCaseSensitivity(Qt::CaseInsensitive); qSort(entries.begin(), entries.end(), [&](const QPair<QString, QString> &first, const QPair<QString, QString> &second) { return (collator.compare(first.first, second.first) < 0); }); entries.prepend(QPair<QString, QString>(tr("Any other"), QLatin1String("*"))); entries.prepend(QPair<QString, QString>(tr("System language (%1 - %2)").arg(QLocale::system().nativeLanguageName()).arg(QLocale::system().nativeCountryName()), QString("system"))); for (int i = 0; i < entries.count(); ++i) { m_ui->languagesComboBox->addItem(entries.at(i).first, entries.at(i).second); } m_ui->moveDownButton->setIcon(ThemesManager::createIcon(QLatin1String("arrow-down"))); m_ui->moveUpButton->setIcon(ThemesManager::createIcon(QLatin1String("arrow-up"))); m_ui->languagesComboBox->installEventFilter(this); connect(m_ui->moveDownButton, &QToolButton::clicked, m_ui->languagesViewWidget, &ItemViewWidget::moveDownRow); connect(m_ui->moveUpButton, &QToolButton::clicked, m_ui->languagesViewWidget, &ItemViewWidget::moveUpRow); connect(m_ui->removeButton, &QToolButton::clicked, m_ui->languagesViewWidget, &ItemViewWidget::removeRow); connect(m_ui->addButton, &QToolButton::clicked, this, &AcceptLanguageDialog::addNewLanguage); connect(m_ui->languagesViewWidget, &ItemViewWidget::canMoveDownChanged, m_ui->moveDownButton, &QToolButton::setEnabled); connect(m_ui->languagesViewWidget, &ItemViewWidget::canMoveUpChanged, m_ui->moveUpButton, &QToolButton::setEnabled); connect(m_ui->languagesViewWidget, &ItemViewWidget::needsActionsUpdate, this, &AcceptLanguageDialog::updateActions); }
LookConfig::LookConfig(Settings &st) : ConfigWidget(st) { setupUi(this); #ifndef Q_OS_MAC if (! QSystemTrayIcon::isSystemTrayAvailable()) #endif qgbTray->hide(); qcbLanguage->addItem(tr("System default")); QDir d(QLatin1String(":"),QLatin1String("mumble_*.qm"),QDir::Name,QDir::Files); foreach(const QString &key, d.entryList()) { QString cc = key.mid(7,key.indexOf(QLatin1Char('.'))-7); QLocale tmpLocale = QLocale(cc); //If there is no native language name, use the locale QString displayName = cc; if(!tmpLocale.nativeLanguageName().isEmpty()) { displayName = QString(QLatin1String("%1 (%2)")) .arg(tmpLocale.nativeLanguageName()) .arg(cc); } else if (cc == QLatin1String("eo")){ // Can't initialize QLocale for a countryless language (QTBUG-8452, QTBUG-14592). // We only have one so special case it. displayName = QLatin1String("Esperanto (eo)"); } qcbLanguage->addItem(displayName, QVariant(cc)); } qcbExpand->addItem(tr("None"), Settings::NoChannels); qcbExpand->addItem(tr("Only with users"), Settings::ChannelsWithUsers); qcbExpand->addItem(tr("All"), Settings::AllChannels); qcbChannelDrag->insertItem(Settings::Ask, tr("Ask"), Settings::Ask); qcbChannelDrag->insertItem(Settings::DoNothing, tr("Do Nothing"), Settings::DoNothing); qcbChannelDrag->insertItem(Settings::Move, tr("Move"), Settings::Move); qcbUserDrag->insertItem(Settings::Ask, tr("Ask"), Settings::Ask); qcbUserDrag->insertItem(Settings::DoNothing, tr("Do Nothing"), Settings::DoNothing); qcbUserDrag->insertItem(Settings::Move, tr("Move"), Settings::Move); connect(qrbLCustom,SIGNAL(toggled(bool)),qcbLockLayout,SLOT(setEnabled(bool))); QDir userThemeDirectory = Themes::getUserThemesDirectory(); if (userThemeDirectory.exists()) { m_themeDirectoryWatcher = new QFileSystemWatcher(this); // Use a timer to cut down floods of directory changes. We only want // to trigger a refresh after nothing has happened for 200ms in the // watched directory. m_themeDirectoryDebouncer = new QTimer(this); m_themeDirectoryDebouncer->setSingleShot(true); m_themeDirectoryDebouncer->setInterval(200); m_themeDirectoryDebouncer->connect(m_themeDirectoryWatcher, SIGNAL(directoryChanged(QString)), SLOT(start())); connect(m_themeDirectoryDebouncer, SIGNAL(timeout()), SLOT(themeDirectoryChanged())); m_themeDirectoryWatcher->addPath(userThemeDirectory.path()); QUrl userThemeDirectoryUrl = QUrl::fromLocalFile(userThemeDirectory.path()); //: This link is located next to the theme heading in the ui config and opens the user theme directory qlThemesDirectory->setText(tr("<a href=\"%1\">Browse</a>").arg(userThemeDirectoryUrl.toString())); qlThemesDirectory->setOpenExternalLinks(true); } }