+#include "ui_mainview.h"
+
+MainView::MainView(QWidget *parent) : QWidget(parent)
+{
+ // Instantiate the mainview UI.
+ Ui::MainView mainViewUi;
+
+ // Setup the UI.
+ mainViewUi.setupUi(this);
+
+ // Get handles for the views.
+ backButtonPointer = mainViewUi.backButton;
+ forwardButtonPointer = mainViewUi.forwardButton;
+ QPushButton *homeButtonPointer = mainViewUi.homeButton;
+ urlLineEditPointer = mainViewUi.urlLineEdit;
+ javaScriptButtonPointer = mainViewUi.javaScript;
+ webEngineViewPointer = mainViewUi.webEngineView;
+
+ // Get handles for the aspects of the WebEngine.
+ QWebEnginePage *webEnginePagePointer = webEngineViewPointer->page();
+ webEngineHistoryPointer = webEnginePagePointer->history();
+ webEngineSettingsPointer = webEngineViewPointer->settings();
+
+ // Update the webengine view from the URL line edit.
+ connect(urlLineEditPointer, SIGNAL(returnKeyPressed(const QString)), this, SLOT(loadUrl(const QString)));
+
+ // Update the URL line edit form the webengine view.
+ connect(webEngineViewPointer, SIGNAL(loadStarted()), this, SLOT(updateInterface()));
+ connect(webEngineViewPointer, SIGNAL(loadProgress(int)), this, SLOT(updateInterface()));
+ connect(webEngineViewPointer, SIGNAL(loadFinished(bool)), this, SLOT(updateInterface()));
+
+ // Setup the URL bar buttons.
+ connect(backButtonPointer, SIGNAL(clicked()), webEngineViewPointer, SLOT(back()));
+ connect(forwardButtonPointer, SIGNAL(clicked()), webEngineViewPointer, SLOT(forward()));
+ connect(homeButtonPointer, SIGNAL(clicked()), this, SLOT(goHome()));
+ connect(javaScriptButtonPointer, SIGNAL(clicked()), this, SLOT(toggleJavaScript()));
+
+ // Instantiate the mouse event pointer.
+ MouseEventFilter *mouseEventFilterPointer = new MouseEventFilter(webEngineViewPointer);
+
+ // Install the mouse event filter.
+ qApp->installEventFilter(mouseEventFilterPointer);
+
+ // Listen for hovered link URLs.
+ connect(webEnginePagePointer, SIGNAL(linkHovered(QString)), this, SLOT(pageLinkHovered(QString)));
+
+ // Don't allow JavaScript to open windows.
+ webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, false);
+
+ // Set the zoom factor.
+ webEngineViewPointer->setZoomFactor(Settings::zoomFactor());
+
+ // Apply the application settings.
+ applyApplicationSettings();
+
+ // Apply the domain settings.
+ applyDomainSettings();