+ // Get lists of the actions' associated widgets.
+ QList<QWidget*> userAgentAssociatedWidgetsPointerList = userAgentPrivacyBrowserActionPointer->associatedWidgets();
+ QList<QWidget*> searchEngineAssociatedWidgetsPointerList = searchEngineMojeekActionPointer->associatedWidgets();
+
+ // Get the menu widget pointers. It is the second entry, after the main window.
+ QWidget *userAgentMenuWidgetPointer = userAgentAssociatedWidgetsPointerList[1];
+ QWidget *searchEngineMenuWidgetPointer = searchEngineAssociatedWidgetsPointerList[1];
+
+ // Get the menu pointers.
+ QMenu *userAgentMenuPointer = qobject_cast<QMenu*>(userAgentMenuWidgetPointer);
+ QMenu *searchEngineMenuPointer = qobject_cast<QMenu*>(searchEngineMenuWidgetPointer);
+
+ // Get the menu actions.
+ userAgentMenuActionPointer = userAgentMenuPointer->menuAction();
+ searchEngineMenuActionPointer = searchEngineMenuPointer->menuAction();
+
+ // Get handles for the toolbars.
+ navigationToolBarPointer = toolBar(QStringLiteral("navigation_toolbar"));
+ urlToolBarPointer = toolBar(QStringLiteral("url_toolbar"));
+
+ // Create a URL line edit.
+ urlLineEditPointer = new KLineEdit();
+
+ // Add an edit or add domain settings action to the URL line edit.
+ QAction *addOrEditDomainSettingsActionPointer = urlLineEditPointer->addAction(QIcon::fromTheme("settings-configure"), QLineEdit::TrailingPosition);
+
+ // Add or edit the current domain settings.
+ connect(addOrEditDomainSettingsActionPointer, SIGNAL(triggered()), this, SLOT(addOrEditDomainSettings()));
+
+ // Populate the URL toolbar.
+ urlToolBarPointer->insertWidget(javaScriptActionPointer, urlLineEditPointer);
+
+ // Load a new URL from the URL line edit.
+ connect(urlLineEditPointer, SIGNAL(returnKeyPressed(const QString)), this, SLOT(loadUrlFromLineEdit(const QString)));
+
+ // Update the URL line edit on page loads.
+ connect(tabWidgetPointer, SIGNAL(updateUrlLineEdit(QUrl)), this, SLOT(updateUrlLineEdit(QUrl)));
+
+ // Update the window title.
+ connect(tabWidgetPointer, SIGNAL(updateWindowTitle(const QString)), this, SLOT(updateWindowTitle(const QString)));
+
+ // Get a handle for the status bar.
+ QStatusBar *statusBarPointer = statusBar();
+
+ // Create a progress bar.
+ progressBarPointer = new QProgressBar();
+
+ // Add the progress bar to to the status bar.
+ statusBarPointer->addPermanentWidget(progressBarPointer);
+
+ // Update the status bar with the URL when a link is hovered.
+ connect(tabWidgetPointer, SIGNAL(linkHovered(QString)), statusBarPointer, SLOT(showMessage(QString)));
+
+ // Update the progress bar.
+ connect(tabWidgetPointer, SIGNAL(showProgressBar(const int)), this, SLOT(showProgressBar(const int)));
+ connect(tabWidgetPointer, SIGNAL(hideProgressBar()), progressBarPointer, SLOT(hide()));
+
+ // Update the URL line edit focus.
+ connect(tabWidgetPointer, SIGNAL(clearUrlLineEditFocus()), this, SLOT(clearUrlLineEditFocus()));
+
+ // Get the URL line edit palettes.
+ noDomainSettingsPalette = urlLineEditPointer->palette();
+ domainSettingsPalette = urlLineEditPointer->palette();
+
+ // Modify the domain settings palette.
+ domainSettingsPalette.setColor(QPalette::Base, QColor("#C8E6C9"));
+
+ // Update the applied palette.
+ connect(tabWidgetPointer, SIGNAL(updateDomainSettingsIndicator(const bool)), this, SLOT(updateDomainSettingsIndicator(const bool)));
+
+ // Process full screen requests.
+ connect(tabWidgetPointer, SIGNAL(fullScreenRequested(bool)), this, SLOT(fullScreenRequested(bool)));
+
+ // Create keyboard shortcuts.
+ QShortcut *ctrlTShortcutPointer = new QShortcut(QKeySequence(i18nc("The open new tab shortcut.", "Ctrl+t")), this);
+ QShortcut *f11ShortcutPointer = new QShortcut(QKeySequence(i18nc("The toggle full screen shortcut.", "F11")), this);
+ QShortcut *escapeShortcutPointer = new QShortcut(QKeySequence::Cancel, this);
+
+ // Connect the keyboard shortcuts to the actions.
+ connect(ctrlTShortcutPointer, SIGNAL(activated()), tabWidgetPointer, SLOT(addTab()));
+ connect(f11ShortcutPointer, SIGNAL(activated()), fullScreenActionPointer, SLOT(trigger()));
+ connect(escapeShortcutPointer, SIGNAL(activated()), this, SLOT(escape()));
+
+ // Load the initial website if this is the first window.
+ if (firstWindow)
+ tabWidgetPointer->loadInitialWebsite();
+}
+
+void BrowserWindow::addOrEditDomainSettings() const
+{
+ // Remove the focus from the URL line edit.
+ urlLineEditPointer->clearFocus();
+
+ // Create the domain settings dialog pointer.
+ DomainSettingsDialog *domainSettingsDialogPointer;
+
+ // Get the current domain settings name.
+ QString ¤tDomainSettingsName = tabWidgetPointer->getDomainSettingsName();
+
+ // Run the commands according to the current domain settings status.
+ if (currentDomainSettingsName == QStringLiteral("")) // Domain settings are not currently applied.
+ {
+ // Instruct the domain settings dialog to add a new domain.
+ domainSettingsDialogPointer = new DomainSettingsDialog(DomainSettingsDialog::ADD_DOMAIN, currentUrl.host());
+ }
+ else // Domain settings are currently applied.
+ {
+ // Instruct the domain settings dialog to edit the current domain.
+ domainSettingsDialogPointer = new DomainSettingsDialog(DomainSettingsDialog::EDIT_DOMAIN, currentDomainSettingsName);
+ }
+
+ // Set the dialog window title.
+ domainSettingsDialogPointer->setWindowTitle(i18nc("The domain settings dialog title", "Domain Settings"));
+
+ // Set the modality.
+ domainSettingsDialogPointer->setWindowModality(Qt::WindowModality::WindowModal);;
+
+ // Show the dialog.
+ domainSettingsDialogPointer->show();
+
+ // Reload the tabs when domain settings are updated.
+ connect(domainSettingsDialogPointer, SIGNAL(domainSettingsUpdated()), tabWidgetPointer, SLOT(applyDomainSettingsAndReload()));
+}
+
+void BrowserWindow::back() const
+{
+ // Remove the focus from the URL line edit.
+ urlLineEditPointer->clearFocus();
+
+ // Go back.
+ tabWidgetPointer->back();
+}
+
+void BrowserWindow::clearUrlLineEditFocus() const
+{
+ // Remove the focus from the URL line edit.
+ urlLineEditPointer->clearFocus();
+}
+
+void BrowserWindow::escape() const
+{
+ // Exit full screen browsing if it is enabled.
+ if (fullScreenActionPointer->isChecked())
+ fullScreenActionPointer->trigger();