aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-04-17 01:38:07 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-04-17 01:38:07 +0200
commit74a7ea3732853f954fcab7088acaa2413fc3e7c1 (patch)
tree02ca9dd6f0dd4ea1b18346d4c6004c74c504d04f /src/mainwindow
parentMultiple subwindows interface (diff)
downloadsmolbote-74a7ea3732853f954fcab7088acaa2413fc3e7c1.tar.xz
Enabled address bar suggestions
Also fixed occasional bug when showing the completer.
Diffstat (limited to 'src/mainwindow')
-rw-r--r--src/mainwindow/mainwindow.cpp16
-rw-r--r--src/mainwindow/mainwindow.h7
-rw-r--r--src/mainwindow/widgets/navigationbar.cpp12
-rw-r--r--src/mainwindow/widgets/navigationbar.h2
4 files changed, 22 insertions, 15 deletions
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index c039c8e..6af530a 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -23,6 +23,7 @@
#include <QUrl>
#include <about/aboutdialog.h>
#include <configuration/configuration.h>
+#include "addressbar/urllineedit.h"
MainWindow::MainWindow(std::shared_ptr<Configuration> &config, QWidget *parent)
: QMainWindow(parent)
@@ -41,16 +42,28 @@ MainWindow::MainWindow(std::shared_ptr<Configuration> &config, QWidget *parent)
show();
createMenuBar();
+
auto *navigationToolBar = new NavigationBar(config->section("navigation"), this);
navigationToolBar->setMovable(config->value<bool>("navigation.movable").value());
addToolBar(Qt::TopToolBarArea, navigationToolBar);
navigationToolBar->connectWebView(nullptr);
+ QHash<QString, QString> a;
+ addressBar = new UrlLineEdit(a, this);
+ navigationToolBar->addWidget(addressBar);
+
+ auto *focusShortcut = new QShortcut(QKeySequence("F4"), this);
+ connect(focusShortcut, &QShortcut::activated, this, [this]() {
+ addressBar->setFocus();
+ addressBar->selectAll();
+ });
+
setCentralWidget(mdiArea);
mdiArea->setFocus();
connect(mdiArea, &QMdiArea::subWindowActivated, this, [this, navigationToolBar](QMdiSubWindow *window) {
disconnect(titleChangedConnection);
+ disconnect(addressBarConnection);
disconnect(navigationBarConnection);
auto *w = qobject_cast<Window *>(window);
@@ -60,6 +73,8 @@ MainWindow::MainWindow(std::shared_ptr<Configuration> &config, QWidget *parent)
this->setWindowTitle(title + titleSuffix);
});
+ addressBar->connectWebView(w->currentView());
+ addressBarConnection = connect(w, &Window::currentViewChanged, addressBar, &UrlLineEdit::connectWebView);
navigationToolBar->connectWebView(w->currentView());
navigationBarConnection = connect(w, &Window::currentViewChanged, navigationToolBar, &NavigationBar::connectWebView);
}
@@ -74,6 +89,7 @@ MainWindow::MainWindow(std::shared_ptr<Configuration> &config, QWidget *parent)
MainWindow::~MainWindow()
{
disconnect(titleChangedConnection);
+ disconnect(addressBarConnection);
disconnect(navigationBarConnection);
}
diff --git a/src/mainwindow/mainwindow.h b/src/mainwindow/mainwindow.h
index 1817fdd..ad879c3 100644
--- a/src/mainwindow/mainwindow.h
+++ b/src/mainwindow/mainwindow.h
@@ -12,11 +12,15 @@
#include <QMainWindow>
#include <memory>
+class Browser;
class QMdiArea;
class Configuration;
class Window;
+class UrlLineEdit;
class MainWindow : public QMainWindow
{
+ friend class Browser;
+
Q_OBJECT
public:
@@ -43,12 +47,13 @@ protected:
private:
QString titleSuffix;
QMenu *toolsMenu = nullptr;
+ UrlLineEdit *addressBar;
QMdiArea *mdiArea;
std::shared_ptr<Configuration> m_config;
QMetaObject::Connection titleChangedConnection;
- QMetaObject::Connection navigationBarConnection;
+ QMetaObject::Connection addressBarConnection, navigationBarConnection;
};
#endif // SMOLBOTE_MAINWINDOW_H
diff --git a/src/mainwindow/widgets/navigationbar.cpp b/src/mainwindow/widgets/navigationbar.cpp
index e2c714e..98a7932 100644
--- a/src/mainwindow/widgets/navigationbar.cpp
+++ b/src/mainwindow/widgets/navigationbar.cpp
@@ -77,16 +77,6 @@ NavigationBar::NavigationBar(const QHash<QString, QString> &conf, QWidget *paren
connect(homeAction, &QAction::triggered, this, [this]() {
m_view->triggerViewAction(WebView::GoHome);
});
-
- QHash<QString, QString> a;
- addressBar = new UrlLineEdit(a, this);
- addWidget(addressBar);
-
- auto *focusShortcut = new QShortcut(QKeySequence("F4"), this);
- connect(focusShortcut, &QShortcut::activated, this, [this]() {
- addressBar->setFocus();
- addressBar->selectAll();
- });
}
void NavigationBar::connectWebView(WebView *view)
@@ -115,8 +105,6 @@ void NavigationBar::connectWebView(WebView *view)
loadFinishedConnection = connect(view, &WebView::loaded, this, &NavigationBar::update_loadFinished);
stopReloadAction->setEnabled(true);
homeAction->setEnabled(true);
-
- addressBar->connectWebView(view);
}
void NavigationBar::update_loadStarted()
diff --git a/src/mainwindow/widgets/navigationbar.h b/src/mainwindow/widgets/navigationbar.h
index 1b4cc05..f2c7e61 100644
--- a/src/mainwindow/widgets/navigationbar.h
+++ b/src/mainwindow/widgets/navigationbar.h
@@ -11,7 +11,6 @@
#include <QToolBar>
-class UrlLineEdit;
class WebView;
class NavigationBar : public QToolBar
{
@@ -34,7 +33,6 @@ private:
QAction *backAction, *forwardAction;
QAction *stopReloadAction;
QAction *homeAction;
- UrlLineEdit *addressBar;
QMetaObject::Connection loadStartedConnection, loadFinishedConnection;
};