ui: Fix new tabs always showing the welcome page (fixes #851)

This commit is contained in:
Oleg Shparber 2018-01-06 15:47:26 +02:00
parent a406f8de5f
commit d0cdc200bb
4 changed files with 9 additions and 5 deletions

View File

@ -505,7 +505,7 @@ void MainWindow::moveTab(int from, int to) {
ui->webViewStack->insertWidget(to, w);
}
void MainWindow::createTab(int index)
WebViewTab *MainWindow::createTab(int index)
{
if (m_settings->openNewTabAfterActive)
index = m_tabBar->currentIndex() + 1;
@ -521,6 +521,8 @@ void MainWindow::createTab(int index)
m_tabBar->setCurrentIndex(index);
ui->lineEdit->setFocus();
return newState->widget;
}
void MainWindow::duplicateTab(int index)

View File

@ -65,7 +65,7 @@ public:
void search(const Zeal::Registry::SearchQuery &query);
void bringToFront();
void createTab(int index = -1);
WebViewTab *createTab(int index = -1);
public slots:
void toggleWindow();

View File

@ -23,6 +23,7 @@
#include "webview.h"
#include "webviewtab.h"
#include "../mainwindow.h"
#include <core/application.h>
@ -94,9 +95,8 @@ QWebView *WebView::createWindow(QWebPage::WebWindowType type)
{
Q_UNUSED(type)
MainWindow *mw = qobject_cast<MainWindow *>(qApp->activeWindow());
mw->createTab();
return this;
MainWindow *mainWindow = qobject_cast<MainWindow *>(qApp->activeWindow());
return mainWindow->createTab()->m_webView;
}
void WebView::mousePressEvent(QMouseEvent *event)

View File

@ -68,6 +68,8 @@ protected:
void keyPressEvent(QKeyEvent *event) override;
private:
friend class WebView;
WebView *m_webView = nullptr;
SearchToolBar *m_searchToolBar = nullptr;
};