aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-01-12 11:11:34 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-01-12 11:11:34 +0100
commit835d23f1f3b8cc3ada5005ac87bdcfe7029c8732 (patch)
treedae8b4045bb9ac991a2cd8bb124b5f60e4171d24 /src/mainwindow.cpp
parentMinor changes (diff)
downloadsmolbote-835d23f1f3b8cc3ada5005ac87bdcfe7029c8732.tar.xz
New Window action now works
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);