- // Check to make sure the dialog box isn't already displayed.
- if (KConfigDialog::exists(QStringLiteral("settings")))
- {
- // Show the existing config dialog if it is hidden.
- configDialogPointer->show();
-
- // Raise the existing config dialog if it is below other windows.
- configDialogPointer->raise();
-
- // Restore the existing config dialog if it has been minimized.
- if (configDialogPointer->isMinimized()) {
- configDialogPointer->showNormal();
- }
-
- // Activate the existing config dialog, which brings its virtual desktop into focus.
- configDialogPointer->activateWindow();
- }
- else
- {
- // Create the settings widgets.
- QWidget *privacySettingsWidgetPointer = new QWidget;
- QWidget *generalSettingsWidgetPointer = new QWidget;
-
- // Instantiate the settings UI.
- Ui::PrivacySettings privacySettingsUi;
- Ui::GeneralSettings generalSettingsUi;
-
- // Setup the UI to display the settings widgets.
- privacySettingsUi.setupUi(privacySettingsWidgetPointer);
- generalSettingsUi.setupUi(generalSettingsWidgetPointer);
-
- // Get handles for the widgets.
- QComboBox *userAgentComboBoxPointer = privacySettingsUi.kcfg_userAgent;
- userAgentLabelPointer = privacySettingsUi.userAgentLabel;
- QComboBox *searchEngineComboBoxPointer = generalSettingsUi.kcfg_searchEngine;
- searchEngineLabelPointer = generalSettingsUi.searchEngineLabel;
-
- // 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)));
-
- // Instantiate a settings config dialog from the settings.kcfg file.
- configDialogPointer = new KConfigDialog(this, QStringLiteral("settings"), Settings::self());
-
- // Add the settings widgets as config dialog pages.
- configDialogPointer->addPage(privacySettingsWidgetPointer, i18nc("@title:tab", "Privacy"), QStringLiteral("privacy-browser"));
- configDialogPointer->addPage(generalSettingsWidgetPointer, i18nc("@title:tab", "General"), QStringLiteral("breeze-settings"));
-
- // Delete the config dialog when it is closed.
- configDialogPointer->setAttribute(Qt::WA_DeleteOnClose);
-
- // Make it so.
- configDialogPointer->show();
-
- // TODO. KConfigDialog does not respect expanding size policies. <https://redmine.stoutner.com/issues/823>
- //configDialogPointer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- //privacySettingsWidgetPointer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- //generalSettingsWidgetPointer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- //configDialogPointer->adjustSize();
-
- // Expand the config dialog.
- configDialogPointer->resize(1000, 500);
-
- // Apply the settings when they are updated.
- connect(configDialogPointer, SIGNAL(settingsChanged(QString)), browserViewPointer, SLOT(applyApplicationSettings()));
- connect(configDialogPointer, SIGNAL(settingsChanged(QString)), browserViewPointer, SLOT(applyDomainSettingsAndReload()));
- }