// Application headers
#include "browserwindow.h"
#include "mainview.h"
+#include "mouseeventfilter.h"
#include "settings.h"
// KDE Framework headers.
#include <KLineEdit>
-// Qt framework headers.
+// Qt headers.
#include <QWebEngineHistory>
#include <QWebEngineView>
// Get handles for the views.
backButtonPointer = mainViewUi.backButton;
forwardButtonPointer = mainViewUi.forwardButton;
+ QPushButton *homeButtonPointer = mainViewUi.homeButton;
urlLineEditPointer = mainViewUi.urlLineEdit;
webEngineViewPointer = mainViewUi.webEngineView;
connect(webEngineViewPointer, SIGNAL(loadProgress(int)), this, SLOT(updateInterface()));
connect(webEngineViewPointer, SIGNAL(loadFinished(bool)), this, SLOT(updateInterface()));
- // Setup the forward and back buttons.
+ // 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()));
+
+ // 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)));
// Set the focus on the WebEngine view.
webEngineViewPointer->setFocus();
+ // Load the homepage.
+ goHome();
+}
+
+void MainView::goHome()
+{
// Load the homepage. TODO. Consider sanitizing the homepage input and adding things like protocols if they are missing.
webEngineViewPointer->setUrl(Settings::homepage());
}
urlLineEditPointer->setUrl(webEngineViewPointer->url().toString());
}
+ // Update the status of the forward and back buttons.
backButtonPointer->setEnabled(webEngineHistoryPointer->canGoBack());
forwardButtonPointer->setEnabled(webEngineHistoryPointer->canGoForward());