int SelectLocalesDialog::exec() { accepted = false; ui->listWidgetLanguage->clear(); ui->listWidgetTerritory->clear(); ui->comboBoxLocale->clear(); ui->comboBoxLocale->hide(); // Block signals ui->listWidgetLanguage->setEnabled(false); ui->listWidgetLanguage->blockSignals(true); ui->listWidgetTerritory->blockSignals(true); ui->comboBoxLocale->blockSignals(true); // Setup locales locales = Global::getAllLocales(); QStringList keys = locales.keys(); keys.sort(); for (int i = 0; i < keys.size(); ++i) { ui->listWidgetLanguage->addItem(keys.at(i)); } // Enable signals ui->listWidgetLanguage->setEnabled(true); ui->listWidgetLanguage->blockSignals(false); ui->listWidgetTerritory->blockSignals(false); ui->comboBoxLocale->blockSignals(false); updateApplyEnabledState(); return QDialog::exec(); }
int SelectLocalesDialog::exec() { m_accepted = false; m_supportedLocalesModel = new SupportedLocalesModel(); m_languageSortProxy = new QSortFilterProxyModel(); m_languageSortProxy->setSourceModel( m_supportedLocalesModel ); m_languageSortProxy->setSortLocaleAware( true ); m_languageSortProxy->sort( 0, Qt::AscendingOrder ); ui->languageListView->setModel( m_languageSortProxy ); m_languageSelectionProxy = new KSelectionProxyModel( ui->languageListView->selectionModel(), this ); m_languageSelectionProxy->setSourceModel( m_supportedLocalesModel ); m_languageSelectionProxy->setFilterBehavior( KSelectionProxyModel::ChildrenOfExactSelection ); m_countrySortProxy = new QSortFilterProxyModel(); m_countrySortProxy->setSourceModel( m_languageSelectionProxy ); m_countrySortProxy->setSortLocaleAware( true ); m_countrySortProxy->sort( 0, Qt::AscendingOrder ); ui->countryListView->setModel( m_countrySortProxy ); m_countrySelectionProxy = new KSelectionProxyModel( ui->countryListView->selectionModel(), this ); m_countrySelectionProxy->setSourceModel( m_supportedLocalesModel ); m_countrySelectionProxy->setFilterBehavior( KSelectionProxyModel::ChildrenOfExactSelection ); ui->localeComboBox->setModel( m_countrySelectionProxy ); ui->localeComboBox->hide(); updateApplyEnabledState(); return QDialog::exec(); }
void SelectLocalesDialog::listWidgetLanguageItemChanged(QListWidgetItem *current, QListWidgetItem*) { // Block signals ui->comboBoxLocale->blockSignals(true); ui->listWidgetTerritory->blockSignals(true); // Clear fields first ui->listWidgetTerritory->clear(); ui->labelDescription->clear(); ui->comboBoxLocale->clear(); ui->comboBoxLocale->hide(); currentTerritories.clear(); if (!locales.contains(current->text())) return; currentTerritories = locales.value(current->text()); QStringList keys = currentTerritories.keys(); keys.sort(); for (int i = 0; i < keys.size(); ++i) { ui->listWidgetTerritory->addItem(keys.at(i)); } // Enable signals ui->listWidgetTerritory->blockSignals(false); ui->comboBoxLocale->blockSignals(false); updateApplyEnabledState(); }
void SelectLocalesDialog::hideLocaleComboBox( const QModelIndex& index ) { if ( index.isValid() ) { ui->localeComboBox->hide(); updateApplyEnabledState(); } }
void Page_Keyboard::listVariant_currentItemChanged(QListWidgetItem * current, QListWidgetItem *) { LayoutItem *layoutItem = dynamic_cast<LayoutItem*>(ui->listLayout->currentItem()); LayoutItem *variantItem = dynamic_cast<LayoutItem*>(current); if (!layoutItem || !variantItem) return; keyboardPreview.setLayout(layoutItem->data); keyboardPreview.setVariant(variantItem->data); updateApplyEnabledState(); }
void SelectLocalesDialog::comboBoxLocaleIndexChanged(const QString &text) { // Clear fields first ui->labelDescription->clear(); // Set right description for (int i = 0; i < currentLocales.size(); ++i) { if (currentLocales.at(i).locale != text) continue; ui->labelDescription->setText(currentLocales.at(i).description); break; } updateApplyEnabledState(); }
void SelectLocalesDialog::listWidgetTerritoryItemChanged(QListWidgetItem *current, QListWidgetItem*) { // Block signals ui->comboBoxLocale->blockSignals(true); QString currentText = current->text(); // Clear fields first ui->labelDescription->clear(); ui->comboBoxLocale->clear(); ui->comboBoxLocale->show(); currentLocales.clear(); if (!currentTerritories.contains(currentText)) return; currentLocales = currentTerritories.value(currentText); // Find item and set text int index = -1; for (int i = 0; i < currentLocales.size(); ++i) { QString locale = currentLocales.at(i).locale; ui->comboBoxLocale->addItem(locale); if (locale.toLower().endsWith(".utf8") || locale.toLower().endsWith(".utf-8")) index = ui->comboBoxLocale->count() - 1; } // Set description if (index >= 0) ui->comboBoxLocale->setCurrentIndex(index); comboBoxLocaleIndexChanged(ui->comboBoxLocale->currentText()); // Enable signals ui->comboBoxLocale->blockSignals(false); updateApplyEnabledState(); }
void SelectLocalesDialog::showLocaleComboBox( const QModelIndex& index ) { if ( index.isValid() ) { /* Select locale with UTF-8 encoding by default */ QAbstractItemModel* model = ui->localeComboBox->model(); QModelIndexList localeIndexList = model->match( model->index( 0,0 ), SupportedLocalesModel::ValueRole, "UTF-8", -1, Qt::MatchContains ); if ( localeIndexList.size() > 0 ) { QModelIndex modelIndex = localeIndexList.first(); ui->localeComboBox->setCurrentIndex( modelIndex.row() ); } ui->localeComboBox->show(); updateApplyEnabledState(); } }
void Page_Keyboard::listLayout_currentItemChanged(QListWidgetItem * current, QListWidgetItem *) { LayoutItem *item = dynamic_cast<LayoutItem*>(current); if (!item) return; // Block signals ui->listVariant->blockSignals(true); QMap< QString, QString > variants = item->info.variants; QMapIterator<QString, QString> li(variants); LayoutItem *defaultItem = NULL; ui->listVariant->clear(); while (li.hasNext()) { li.next(); item = new LayoutItem(ui->listVariant); item->setText(li.key()); item->data = li.value(); if (li.value() == "") defaultItem = item; } // Set to default value if (defaultItem) ui->listVariant->setCurrentItem(defaultItem); // Trigger signals listVariant_currentItemChanged(ui->listVariant->currentItem(), ui->listVariant->currentItem()); // Unblock signals ui->listVariant->blockSignals(false); updateApplyEnabledState(); }