aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 763d192..dea9f79 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -4,8 +4,9 @@
#include <QMenu>
#include <QCloseEvent>
#include <QMessageBox>
+#include "browser.h"
-MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
+MainWindow::MainWindow(Browser *instance, QUrl defaultUrl, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
navigationToolBar(new QToolBar(this)),
@@ -13,6 +14,7 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
tabBar(new WebViewTabBar(this)),
urlLineEdit(new QLineEdit(navigationToolBar))
{
+ browserInstance = instance;
Settings settings;
ui->setupUi(this);
@@ -21,8 +23,8 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
// Populate the menu bar
// Browser menu - with new window, new tab, open and quit
QMenu *browserMenu = new QMenu(qApp->applicationName(), ui->menuBar);
+ browserMenu->addAction(tr("New Window"), this, SLOT(handleNewWindow()), QKeySequence(tr("Ctrl+N")));
browserMenu->addAction(tr("New Tab"), this, SLOT(createNewTab()), QKeySequence(tr("Ctrl+T")));
- browserMenu->addAction(tr("New Window"));
browserMenu->addSeparator();
browserMenu->addAction(tr("Quit"), qApp, SLOT(quit()), QKeySequence(tr("Ctrl+Q")));
ui->menuBar->addMenu(browserMenu);
@@ -70,6 +72,11 @@ void MainWindow::closeEvent(QCloseEvent *event)
QMainWindow::closeEvent(event);
}
+void MainWindow::handleNewWindow(const QUrl &url)
+{
+ browserInstance->addWindow(new MainWindow(browserInstance, url));
+}
+
void MainWindow::handleTabChanged(QWebEngineView *view)
{
centralWidget()->setParent(0);