From 55816b45e681f10c9b45675dba65575d01d9efe3 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 1 May 2009 03:20:42 +0200 Subject: Managing user tab open settings. Step 2 --- src/application.cpp | 4 ++-- src/application.h | 17 ++++++++++++++++- src/mainview.cpp | 19 +++++++++++++++---- src/mainview.h | 3 ++- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index 03c0f442..ec24691e 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -141,9 +141,9 @@ MainWindow *Application::mainWindow() } -WebView *Application::newWebView(bool makeCurrent) +WebView *Application::newWebView(Rekonq::OpenType type) { - return m_mainWindow->mainView()->newWebView(makeCurrent); + return m_mainWindow->mainView()->newWebView(type); } diff --git a/src/application.h b/src/application.h index 10f18545..61f4af81 100644 --- a/src/application.h +++ b/src/application.h @@ -48,6 +48,21 @@ class NetworkAccessManager; class WebView; +namespace Rekonq +{ + /** + * @short Open link options + * Different modes of opening new tab + */ + enum OpenType + { + Default, ///< open url according to users settings + New, ///< open url in new tab and make it current + Background ///< open url in new tab in background + }; +} + + /** * */ @@ -62,7 +77,7 @@ public: static Application *instance(); MainWindow *mainWindow(); - WebView* newWebView(bool makeCurrent = true); + WebView* newWebView(Rekonq::OpenType type = Rekonq::Default); KIcon icon(const KUrl &url) const; diff --git a/src/mainview.cpp b/src/mainview.cpp index d8375ab8..9dbf800b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -296,7 +296,7 @@ WebView *MainView::webView(int index) const } -WebView *MainView::newWebView(bool makeCurrent) +WebView *MainView::newWebView(Rekonq::OpenType type) { // line edit UrlBar *urlBar = new UrlBar; // Ownership of widget is passed on to the QStackedWidget (addWidget method). @@ -338,11 +338,22 @@ WebView *MainView::newWebView(bool makeCurrent) addTab(webView, i18n("(Untitled)")); - if (makeCurrent) + switch(type) { + case Rekonq::Default: + if (makeTabCurrent) + { + setCurrentWidget(webView); // this method does NOT take ownership of webView + urlBar->setFocus(); + } + break; + case Rekonq::New: setCurrentWidget(webView); // this method does NOT take ownership of webView urlBar->setFocus(); - } + break; + case Rekonq::Background: + break; + }; emit tabsChanged(); @@ -698,7 +709,7 @@ void MainView::mouseDoubleClickEvent(QMouseEvent *event) { if (!childAt(event->pos())) { - newWebView(true); + newWebView(Rekonq::New); return; } KTabWidget::mouseDoubleClickEvent(event); diff --git a/src/mainview.h b/src/mainview.h index faa43be9..75242fef 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -26,6 +26,7 @@ // Local Includes #include "webview.h" +#include "application.h" // KDE Includes #include @@ -109,7 +110,7 @@ public slots: * * @return a pointer to the new WebView */ - WebView *newWebView(bool makeCurrent = true); + WebView *newWebView(Rekonq::OpenType type = Rekonq::Default); /** * Core browser slot. Load an url in a webview -- cgit v1.2.1 From 0d324ed688eda0e1f172353d33ca33731b8f6764 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 2 May 2009 02:32:34 +0200 Subject: Open Back/Forward tabs fixed --- src/mainview.cpp | 2 +- src/mainview.h | 4 ++-- src/mainwindow.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mainview.cpp b/src/mainview.cpp index 9dbf800b..d4edeb19 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -341,7 +341,7 @@ WebView *MainView::newWebView(Rekonq::OpenType type) switch(type) { case Rekonq::Default: - if (makeTabCurrent) + if (!m_makeBackTab) { setCurrentWidget(webView); // this method does NOT take ownership of webView urlBar->setFocus(); diff --git a/src/mainview.h b/src/mainview.h index 75242fef..372902dd 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -75,7 +75,7 @@ public: WebView *currentWebView() const { return webView(currentIndex()); } int webViewIndex(WebView *webView) const { return indexOf(webView); } KAction *recentlyClosedTabsAction() const { return m_recentlyClosedTabsAction; } - void setMakeTabCurrent( bool b) { makeTabCurrent = b; } + void setMakeBackTab(bool b) { m_makeBackTab = b; } /** * show and hide TabBar if user doesn't choose @@ -192,7 +192,7 @@ private: QString m_loadingGitPath; - bool makeTabCurrent; + bool m_makeBackTab; }; #endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8426bb94..94e4dd11 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -352,7 +352,7 @@ void MainWindow::slotUpdateConfiguration() // ============== General ================== m_homePage = ReKonfig::homePage(); mainView()->showTabBar(); - mainView()->setMakeTabCurrent( ReKonfig::openTabsBack() ); + mainView()->setMakeBackTab( ReKonfig::openTabsBack() ); // =========== Fonts ============== QWebSettings *defaultSettings = QWebSettings::globalSettings(); -- cgit v1.2.1