- // Create the settings widgets.
- QWidget *privacySettingsWidgetPointer = new QWidget;
- QWidget *generalSettingsWidgetPointer = new QWidget;
- QWidget *spellCheckSettingsWidgetPointer = new QWidget;
-
- // Instantiate the settings UI.
- Ui::PrivacySettings privacySettingsUi;
- Ui::GeneralSettings generalSettingsUi;
- Ui::SpellCheckSettings spellCheckSettingsUi;
-
- // Setup the UI to display the settings widgets.
- privacySettingsUi.setupUi(privacySettingsWidgetPointer);
- generalSettingsUi.setupUi(generalSettingsWidgetPointer);
- spellCheckSettingsUi.setupUi(spellCheckSettingsWidgetPointer);
-
- // Get handles for the widgets.
- QComboBox *userAgentComboBoxPointer = privacySettingsUi.kcfg_userAgent;
- userAgentLabelPointer = privacySettingsUi.userAgentLabel;
- QComboBox *searchEngineComboBoxPointer = generalSettingsUi.kcfg_searchEngine;
- searchEngineLabelPointer = generalSettingsUi.searchEngineLabel;
- downloadLocationComboBoxPointer = generalSettingsUi.kcfg_downloadLocation;
- QPushButton *browseButtonPointer = generalSettingsUi.browseButton;
- QListWidget *spellCheckListWidgetPointer = spellCheckSettingsUi.spellCheckListWidget;
-
- // Populate the combo box labels.
- updateUserAgentLabel(userAgentComboBoxPointer->currentText());
- updateSearchEngineLabel(searchEngineComboBoxPointer->currentText());
-
- // Update the labels when the combo boxes change.
- connect(userAgentComboBoxPointer, SIGNAL(currentTextChanged(const QString)), this, SLOT(updateUserAgentLabel(const QString)));
- connect(searchEngineComboBoxPointer, SIGNAL(currentTextChanged(const QString)), this, SLOT(updateSearchEngineLabel(const QString)));
-
- // Connect the download location directory browse button.
- connect(browseButtonPointer, SIGNAL(clicked()), this, SLOT(showDownloadLocationBrowseDialog()));
-
- // Create a dictionaries QDir from the `QTWEBENGINE_DICTIONARIES_PATH` environment variable.
- QDir dictionariesDir = QDir(qEnvironmentVariable("QTWEBENGINE_DICTIONARIES_PATH"));
-
- // Get a dictionaries string list.
- QStringList dictionariesStringList = dictionariesDir.entryList(QStringList(QLatin1String("*.bdic")), QDir::Files | QDir::NoSymLinks);
-
- // Remove the `.bdic` file extensions from the dictionaries list.
- dictionariesStringList.replaceInStrings(QLatin1String(".bdic"), QLatin1String(""));
-
- // Get a list of the enabled spell check languages.
- QStringList enabledSpellCheckLanguagesList = Settings::spellCheckLanguages();
-
- // Add each dictionary to the spell check list widget.
- foreach(QString dictionaryString, dictionariesStringList)
- {
- // Create a new list widget item pointer.
- QListWidgetItem *listWidgetItemPointer = new QListWidgetItem();
-
- // Create a dictionary check box widget with the name of the dictionary string.
- QCheckBox *dictionaryCheckBoxWidget = new QCheckBox(dictionaryString);
-
- // Check the language if it is currently enabled.
- if (enabledSpellCheckLanguagesList.contains(dictionaryString))
- dictionaryCheckBoxWidget->setCheckState(Qt::Checked);
- else
- dictionaryCheckBoxWidget->setCheckState(Qt::Unchecked);
-
- // Add the list widget item to the spell check list widget.
- spellCheckListWidgetPointer->addItem(listWidgetItemPointer);
-
- // Set the list widget item check box widget.
- spellCheckListWidgetPointer->setItemWidget(listWidgetItemPointer, dictionaryCheckBoxWidget);
- }
-