aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow/mainwindow.cpp')
-rw-r--r--src/mainwindow/mainwindow.cpp43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index b2c79cc..48c9e9e 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -93,6 +93,28 @@ MainWindow::MainWindow(std::shared_ptr<Configuration> &config, QWidget *parent)
}
});
+ // address bar
+ connect(addressBar, &AddressBar::search, this, [this](const QString &term) {
+ if(this->currentView) {
+ currentView->search(term);
+ currentView->setFocus();
+ }
+ });
+ connect(addressBar, &AddressBar::load, this, [this](const QUrl &url) {
+ if(this->currentView) {
+ currentView->load(url);
+ currentView->setFocus();
+ }
+ });
+
+ connect(addressBar, &AddressBar::giveFocus, this, [this]() {
+ if(this->currentView) {
+ currentView->setFocus();
+ }
+ });
+
+
+ // search box
auto *searchShortcut = new QShortcut(QKeySequence(config->value<std::string>("mainwindow.shortcuts.search").value().c_str()), this);
connect(searchShortcut, &QShortcut::activated, this, [=]() {
/* QTBUG-18665
@@ -112,9 +134,10 @@ MainWindow::MainWindow(std::shared_ptr<Configuration> &config, QWidget *parent)
MainWindow::~MainWindow()
{
disconnect(viewChangedConnection);
- disconnect(searchConnection);
disconnect(searchBoxConnection);
disconnect(statusBarConnection);
+
+ disconnect(addressBar);
}
void MainWindow::createMenuBar()
@@ -231,16 +254,28 @@ SubWindow *MainWindow::createSubWindow(const QString &url)
void MainWindow::setView(WebView *view)
{
- disconnect(searchConnection);
+ if(currentView) {
+ // disconnect old view
+ disconnect(currentView, 0, addressBar, 0);
+ }
+ currentView = view;
- addressBar->setView(view);
if(view) {
addressBar->setPageMenu(view->pageMenu());
addressBar->setToolsMenu(view->toolsMenu());
- searchConnection = connect(addressBar, &AddressBar::search, view, &WebView::search);
+
+ connect(view, &WebView::urlChanged, addressBar, &AddressBar::setUrl);
+ addressBar->setUrl(view->url());
+
+ connect(view, &WebView::loadProgress, addressBar, &AddressBar::setProgress);
+ addressBar->setProgress(100);
+
} else {
addressBar->setPageMenu(nullptr);
addressBar->setToolsMenu(nullptr);
+
+ addressBar->setUrl(QUrl());
+ addressBar->setProgress(100);
}
navigationToolBar->connectWebView(view);