diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bf70710..3a2d71d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -38,6 +38,8 @@ #include <bookmarks/bookmarkswidget.h> #include <downloads/downloadswidget.h> +#include "browser.h" + MainWindow::MainWindow(std::shared_ptr<Configuration> config, QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), @@ -150,16 +152,7 @@ void MainWindow::addTabbedDock(Qt::DockWidgetArea area, QWidget *widget) // get all dock widgets QList<QDockWidget*> allDockWidgets = findChildren<QDockWidget*>(); - // check if the widget we're adding is there already - for(QDockWidget *w : allDockWidgets) { - if(w->widget() == widget) { - // widget is already shown --> return - w->show(); - return; - } - } - - // we haven't shown this widget, so let's make a list of widgets in the area we want + // make a list of widgets in the area we want QVector<QDockWidget*> areaDockWidgets; for(QDockWidget *w : allDockWidgets) { if(dockWidgetArea(w) == area) { @@ -168,8 +161,12 @@ void MainWindow::addTabbedDock(Qt::DockWidgetArea area, QWidget *widget) } // create a dock widget - // this dock widget will be destroyed with the MainWindow QDockWidget *dock = new QDockWidget(widget->windowTitle(), this); + + // release the held widget when deleted + connect(dock, &QDockWidget::destroyed, this, [dock]() { + dock->widget()->setParent(nullptr); + }); dock->setWidget(widget); if(areaDockWidgets.empty()) { @@ -190,6 +187,14 @@ void MainWindow::newTab(const QUrl &url) tabBar->addTab(url); } +void MainWindow::newWindow(const QUrl &url) +{ + Browser *instance = static_cast<Browser*>(qApp->instance()); + MainWindow *window = instance->createWindow(); + window->setProfile(tabBar->profile()); + window->newTab(url); +} + void MainWindow::focusAddress() { m_addressBar->setFocus(); @@ -251,13 +256,6 @@ void MainWindow::toggleFullscreen() } } -void MainWindow::newWindow(const QUrl &url) -{ - QHash<QString, QVariant> options; - options.insert("urls", url); - //browser->createWindow(options); -} - void MainWindow::handleTabChanged(WebView *view) { Q_ASSERT(view != nullptr); |