X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blobdiff_plain;f=src%2Fmainview.cpp;h=a1e018b400734422350bbf1b8cf3c46d5ef88685;hp=844f930971428834cd1bd747df6d028a5624b204;hb=f3047a42fa756bb36d4840f40ab7acf83e751b48;hpb=255215b082091aaadd5ef24cfc0880cd81e42272 diff --git a/src/mainview.cpp b/src/mainview.cpp index 844f930..a1e018b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -21,17 +21,44 @@ #include "mainview.h" #include "settings.h" +// KDE Framework headers. +#include + // Qt framework headers. #include MainView::MainView(QWidget *parent) : QWidget(parent) { + // Instantiate the mainview UI. + Ui::MainView mainViewUi; + // Setup the UI. mainViewUi.setupUi(this); - // Get a handle for the web engine view. - QWebEngineView *webEngineViewPointer = mainViewUi.webEngineView; + // Get handles for the views. + urlLineEditPointer = mainViewUi.urlLineEdit; + webEngineViewPointer = mainViewUi.webEngineView; + + // 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(updateUrlLineEdit())); + connect(webEngineViewPointer, SIGNAL(loadProgress(int)), this, SLOT(updateUrlLineEdit())); + connect(webEngineViewPointer, SIGNAL(loadFinished(bool)), this, SLOT(updateUrlLineEdit())); // Load a website. webEngineViewPointer->setUrl(QUrl(QStringLiteral("https://www.stoutner.com/"))); } + +void MainView::loadUrl(const QString &urlFromUser) +{ + // Load the URL, adding standard protocol sections if needed. TODO. Replace this with logic that prefers HTTPS. + webEngineViewPointer->setUrl(QUrl::fromUserInput(urlFromUser)); +} + +void MainView::updateUrlLineEdit() +{ + // Update the URL line edit. + urlLineEditPointer->setText(webEngineViewPointer->url().toString()); +}