X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blobdiff_plain;f=src%2FBrowserWindow.cpp;h=29fe4644feb31db29f80f92ea8bdd798e82d7862;hp=546a9519899b7ae5d472d124b667419e0d854a6d;hb=68167c0aba46c4bd4c859b176824873ffd14a3e7;hpb=05800bafb963a10f291d2a9604dc90cd7ac37c7b diff --git a/src/BrowserWindow.cpp b/src/BrowserWindow.cpp index 546a951..29fe464 100644 --- a/src/BrowserWindow.cpp +++ b/src/BrowserWindow.cpp @@ -22,6 +22,8 @@ #include "Settings.h" #include "ui_SettingsPrivacy.h" #include "ui_SettingsGeneral.h" +#include "helpers/SearchEngineHelper.h" +#include "helpers/UserAgentHelper.h" // KDE Frameworks headers. #include @@ -53,7 +55,7 @@ BrowserWindow::BrowserWindow() : KXmlGuiWindow() setupGUI(); } -void BrowserWindow::fileNew() +void BrowserWindow::fileNew() const { // Display a new instance of Privacy Browser. (new BrowserWindow)->show(); @@ -76,18 +78,19 @@ void BrowserWindow::settingsConfigure() privacySettingsUi.setupUi(privacySettingsWidgetPointer); generalSettingsUi.setupUi(generalSettingsWidgetPointer); - // Get handles for the user agent widgets. + // Get handles for the widgets. QComboBox *userAgentComboBoxPointer = privacySettingsUi.kcfg_userAgent; userAgentLabelPointer = privacySettingsUi.userAgentLabel; + QComboBox *searchEngineComboBoxPointer = generalSettingsUi.kcfg_searchEngine; + searchEngineLabelPointer = generalSettingsUi.searchEngineLabel; - // Instantiate the user agent helper. - userAgentHelperPointer = new UserAgentHelper(); - - // Display the initial user agent. + // Populate the combo box labels. updateUserAgentLabel(userAgentComboBoxPointer->currentText()); + updateSearchEngineLabel(searchEngineComboBoxPointer->currentText()); - // Update the user agent when the combo box changes. - connect(userAgentComboBoxPointer, SIGNAL(currentTextChanged(QString)), this, SLOT(updateUserAgentLabel(QString))); + // Update the labels when the combo boxs 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. KConfigDialog *configDialogPointer = new KConfigDialog(this, QStringLiteral("settings"), Settings::self()); @@ -111,14 +114,20 @@ void BrowserWindow::settingsConfigure() } } -void BrowserWindow::updateStatusBar(const QString &statusBarMessage) +void BrowserWindow::updateSearchEngineLabel(const QString &searchEngineString) const +{ + // Update the search engine label. + searchEngineLabelPointer->setText(SearchEngineHelper::getSearchUrl(searchEngineString)); +} + +void BrowserWindow::updateStatusBar(const QString &statusBarMessage) const { // Display the status bar message. statusBar()->showMessage(statusBarMessage); } -void BrowserWindow::updateUserAgentLabel(const QString &userAgentName) +void BrowserWindow::updateUserAgentLabel(const QString &userAgentName) const { // Update the user agent label. - userAgentLabelPointer->setText(userAgentHelperPointer->getUserAgent(userAgentName)); + userAgentLabelPointer->setText(UserAgentHelper::getUserAgent(userAgentName)); }