From c30a6e73d97530ed22cafa89b59cf25cf93e02d1 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 23 Aug 2009 12:39:21 +0200 Subject: Modified newTab function and splitted into two parts. There are still some regressions to be fixed: - open link in new tab is always without focus - urlbar is empty on new tab loading - mics.. --- src/mainview.cpp | 70 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 12 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 5f0afa5c..3eca7929 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -307,7 +307,8 @@ WebView *MainView::webView(int index) const // 1. the slot void newTab() to create a "new empty focused tab" // 2. the public method WebView *newWebView() to just create a new webview // without working with the focus and loading an url -WebView *MainView::newTab(bool focused) + +WebView *MainView::newWebView() { WebView *webView = new WebView; // should be deleted on tab close? @@ -328,27 +329,72 @@ WebView *MainView::newTab(bool focused) addTab(webView, i18n("(Untitled)")); urlBar()->setUrl(KUrl("")); - - if (focused) - { - setCurrentWidget(webView); - urlBar()->setFocus(); - } - + emit tabsChanged(); showTabBar(); addTabButtonPosition(); + return webView; +} + + +void MainView::newTab() +{ + WebView *w = newWebView(); + + setCurrentWidget(w); + urlBar()->setFocus(); + if (ReKonfig::newTabsOpenHomePage()) { - webView->load(QUrl(ReKonfig::homePage())); + w->load(QUrl(ReKonfig::homePage())); } - - return webView; } +// WebView *MainView::newTab(bool focused) +// { +// WebView *webView = new WebView; // should be deleted on tab close? +// +// // connecting webview with mainview +// connect(webView, SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted())); +// connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewLoadFinished(bool))); +// connect(webView, SIGNAL(iconChanged()), this, SLOT(webViewIconChanged())); +// connect(webView, SIGNAL(titleChanged(const QString &)), this, SLOT(webViewTitleChanged(const QString &))); +// connect(webView, SIGNAL(urlChanged(const QUrl &)), this, SLOT(webViewUrlChanged(const QUrl &))); +// +// connect(webView, SIGNAL(ctrlTabPressed()), this, SLOT(nextTab())); +// connect(webView, SIGNAL(shiftCtrlTabPressed()), this, SLOT(previousTab())); +// +// // connecting webPage signals with mainview +// connect(webView->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); +// connect(webView->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *))); +// +// addTab(webView, i18n("(Untitled)")); +// +// urlBar()->setUrl(KUrl("")); +// +// if (focused) +// { +// setCurrentWidget(webView); +// urlBar()->setFocus(); +// } +// +// emit tabsChanged(); +// +// showTabBar(); +// addTabButtonPosition(); +// +// if (ReKonfig::newTabsOpenHomePage()) +// { +// webView->load(QUrl(ReKonfig::homePage())); +// } +// +// return webView; +// } + + void MainView::slotReloadAllTabs() { for (int i = 0; i < count(); ++i) @@ -413,7 +459,7 @@ void MainView::slotCloneTab(int index) index = currentIndex(); if (index < 0 || index >= count()) return; - WebView *tab = newTab(); + WebView *tab = newWebView(); tab->setUrl(webView(index)->url()); showTabBar(); -- cgit v1.2.1