aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-02-02 14:13:14 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-02-02 14:13:14 +0100
commitf875ad5313b86275c3fd48884063aefb8849235d (patch)
tree9c7933aacc895ab6a52045abc7fe8fb1dccb6c20 /src/mainwindow.cpp
parentAStyle pass (diff)
downloadsmolbote-f875ad5313b86275c3fd48884063aefb8849235d.tar.xz
Added loading bar to status bar
Hovered links now display in status bar
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index cc7003d..4cd8975 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -30,6 +30,7 @@
#include <QApplication>
#include <QInputDialog>
#include <QWebEngineDownloadItem>
+#include <QStatusBar>
MainWindow::MainWindow(Browser *instance, QUrl defaultUrl, QWidget *parent) :
QMainWindow(parent),
@@ -39,7 +40,8 @@ MainWindow::MainWindow(Browser *instance, QUrl defaultUrl, QWidget *parent) :
navigationToolBar(new QToolBar(tr("Navigation"), this)),
tabToolBar(new QToolBar(tr("Tab bar"), this)),
tabBar(new WebViewTabBar(this)),
- urlLineEdit(new UrlLineEdit(navigationToolBar))
+ urlLineEdit(new UrlLineEdit(navigationToolBar)),
+ progressBar(new LoadingBar(this))
{
browserInstance = instance;
Settings settings;
@@ -82,7 +84,9 @@ MainWindow::MainWindow(Browser *instance, QUrl defaultUrl, QWidget *parent) :
connect(urlLineEdit, SIGNAL(returnPressed()), this, SLOT(handleUrlChanged()));
tabToolBar->addWidget(tabBar);
- connect(tabBar, SIGNAL(currentTabChanged(QWebEngineView*)), this, SLOT(handleTabChanged(QWebEngineView*)));
+ connect(tabBar, SIGNAL(currentTabChanged(WebView*)), this, SLOT(handleTabChanged(WebView*)));
+
+ ui->statusBar->addPermanentWidget(progressBar);
if(!defaultUrl.isEmpty()) {
createNewTab(defaultUrl);
@@ -160,16 +164,27 @@ void MainWindow::handleNewWindow(const QUrl &url)
browserInstance->addWindow(new MainWindow(browserInstance, url));
}
-void MainWindow::handleTabChanged(QWebEngineView *view)
+void MainWindow::handleTabChanged(WebView *view)
{
+ // clear the parent of the central widget so it doesn't get deleted
centralWidget()->setParent(0);
+
+ // disconnect signals
disconnect(centralWidget());
+
+ // set new central widget
setCentralWidget(view);
+
+ // connect signals
connect(view, SIGNAL(urlChanged(QUrl)), urlLineEdit, SLOT(setUrl(QUrl)));
connect(view, SIGNAL(titleChanged(QString)), this, SLOT(handleTitleUpdated(QString)));
+ connect(view, SIGNAL(linkHovered(QString)), ui->statusBar, SLOT(showMessage(QString)));
+
+ progressBar->connectWebView(view);
+
+ // update UI
urlLineEdit->setUrl(view->url());
this->handleTitleUpdated(view->title());
-
centralWidget()->setFocus();
}