diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2009-08-23 12:39:21 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2009-08-23 12:39:21 +0200 |
commit | c30a6e73d97530ed22cafa89b59cf25cf93e02d1 (patch) | |
tree | 1b9f9ed0bffc5fefa36f172f9585cc3a06a3c4c4 | |
parent | Merge commit 'megabigbug/Print' (diff) | |
download | rekonq-c30a6e73d97530ed22cafa89b59cf25cf93e02d1.tar.xz |
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..
-rw-r--r-- | src/application.cpp | 8 | ||||
-rw-r--r-- | src/mainview.cpp | 70 | ||||
-rw-r--r-- | src/mainview.h | 6 | ||||
-rw-r--r-- | src/webpage.cpp | 4 |
4 files changed, 69 insertions, 19 deletions
diff --git a/src/application.cpp b/src/application.cpp index 9263113e..81df7ffb 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -298,18 +298,20 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) switch(type) { case Rekonq::SettingOpenTab: - webView = m_mainWindow->mainView()->newTab(!ReKonfig::openTabsBack()); + webView = m_mainWindow->mainView()->newWebView(); if (!ReKonfig::openTabsBack()) { + m_mainWindow->mainView()->setCurrentWidget(webView); m_mainWindow->mainView()->urlBar()->setUrl(loadingUrl.prettyUrl()); } break; case Rekonq::NewCurrentTab: - webView = m_mainWindow->mainView()->newTab(true); + webView = m_mainWindow->mainView()->newWebView(); + m_mainWindow->mainView()->setCurrentWidget(webView); m_mainWindow->mainView()->urlBar()->setUrl(loadingUrl.prettyUrl()); break; case Rekonq::NewBackTab: - webView = m_mainWindow->mainView()->newTab(false); + webView = m_mainWindow->mainView()->newWebView(); break; case Rekonq::CurrentTab: webView = m_mainWindow->mainView()->currentWebView(); 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(); diff --git a/src/mainview.h b/src/mainview.h index 9a0b3412..de07e9a9 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -81,7 +81,8 @@ public: void showTabBar(); void clear(); - + WebView *newWebView(); + signals: // tab widget signals void tabsChanged(); @@ -100,9 +101,8 @@ public slots: * Core browser slot. This create a new tab with a WebView inside * for browsing. * - * @return a pointer to the new WebView */ - WebView *newTab(bool focused = true); + void newTab(); void slotCloneTab(int index = -1); void slotCloseTab(int index = -1); diff --git a/src/webpage.cpp b/src/webpage.cpp index 1968c751..14994746 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -127,7 +127,9 @@ WebPage *WebPage::newWindow(WebWindowType type) kDebug() << "Modal Dialog ---------------------------------------"; } - WebView *w = Application::instance()->mainWindow()->mainView()->newTab(!ReKonfig::openTabsBack()); + // FIXME: regression introduced. No more following rekonq setting about tab focus + // the FIX should be moving loadUrl code from Application to acceptNavigationRequest + WebView *w = Application::instance()->mainWindow()->mainView()->newWebView(); return w->page(); } |