aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow')
-rw-r--r--src/mainwindow/mainwindow.cpp43
-rw-r--r--src/mainwindow/mainwindow.h5
2 files changed, 43 insertions, 5 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);
diff --git a/src/mainwindow/mainwindow.h b/src/mainwindow/mainwindow.h
index af713fc..30d2178 100644
--- a/src/mainwindow/mainwindow.h
+++ b/src/mainwindow/mainwindow.h
@@ -56,15 +56,18 @@ protected:
private:
QAction *subWindowAction = nullptr;
QMenu *toolsMenu = nullptr;
+
NavigationBar *navigationToolBar = nullptr;
AddressBar *addressBar = nullptr;
SearchForm *searchBox = nullptr;
+
QMdiArea *mdiArea;
+ WebView *currentView = nullptr;
std::shared_ptr<Configuration> m_config;
QMetaObject::Connection viewChangedConnection;
- QMetaObject::Connection searchConnection, searchBoxConnection;
+ QMetaObject::Connection searchBoxConnection;
QMetaObject::Connection statusBarConnection;
};