From 42e6065c5519a0cc78e9d66345d6786d5ad15874 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 6 Sep 2009 11:04:03 +0200 Subject: Fixing rekonq Multi Windows behaviour and Added options about tabbed (or not) browsing.. --- src/application.cpp | 31 +++++++++++++++++++++++-------- src/mainview.cpp | 1 - src/mainview.h | 2 +- src/mainwindow.cpp | 12 +----------- src/mainwindow.h | 1 - src/rekonq.kcfg | 6 ++++++ src/settings_general.ui | 14 ++++++++++++++ src/webpage.cpp | 12 +++++++++--- src/webview.cpp | 14 +++++++++++--- src/webview.h | 1 + 10 files changed, 66 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index ee38c899..8324d212 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -85,21 +85,36 @@ int Application::newInstance() KCmdLineArgs::setCwd(QDir::currentPath().toUtf8()); KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); - // creating new window - MainWindow *w = newMainWindow(); - if (args->count() > 0) { - loadUrl(args->arg(0)); - - for (int i = 1; i < args->count(); ++i) + // opening links in new tabs in ONE window + if(ReKonfig::externalUrlNewTab()) + { + // creating 1st new window + newMainWindow(); + loadUrl(args->arg(0)); + + for (int i = 1; i < args->count(); ++i) + { + loadUrl(args->arg(i), Rekonq::NewCurrentTab); + } + args->clear(); + + } + else { - loadUrl(args->arg(i), Rekonq::NewCurrentTab); + // opening ONE window for each URL + for (int i = 0; i < args->count(); ++i) + { + loadUrl(args->arg(i), Rekonq::NewWindow); + } + args->clear(); } - args->clear(); } else { + // creating new window + MainWindow *w = newMainWindow(); w->slotHome(); } diff --git a/src/mainview.cpp b/src/mainview.cpp index ec26c359..a12ec8f9 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -568,4 +568,3 @@ void MainView::resizeEvent(QResizeEvent *event) { KTabWidget::resizeEvent(event); } - diff --git a/src/mainview.h b/src/mainview.h index 035b4695..c59cca1a 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -133,7 +133,7 @@ private slots: void webViewUrlChanged(const QUrl &url); void windowCloseRequested(); - + protected: virtual void mouseDoubleClickEvent(QMouseEvent *event); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 04db6f6f..c2e86014 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -191,7 +191,7 @@ void MainWindow::postLaunch() // --------- connect signals and slots connect(m_view, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(slotUpdateWindowTitle(const QString &))); connect(m_view, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *))); - + // update toolbar actions signals connect(m_view, SIGNAL(tabsChanged()), this, SLOT(slotUpdateActions())); connect(m_view, SIGNAL(currentChanged(int)), this, SLOT(slotUpdateActions())); @@ -829,16 +829,6 @@ void MainWindow::slotOpenNext() } -// WARNING: this change will be there until rekonq'll have ONE mainwindow -// (probably forever..) -void MainWindow::geometryChangeRequested(const QRect &geometry) -{ - Q_UNUSED(geometry) -// setGeometry(geometry); - kDebug() << "No geometry change allowed"; -} - - bool MainWindow::queryClose() { if (m_view->count() > 1) diff --git a/src/mainwindow.h b/src/mainwindow.h index f42ee02d..21cf1a4f 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -104,7 +104,6 @@ private slots: void slotBrowserLoading(bool); void slotUpdateActions(); void slotUpdateWindowTitle(const QString &title = QString()); - void geometryChangeRequested(const QRect &geometry); // history related void slotOpenPrevious(); diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index b27c4fd5..86b1a5df 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -14,6 +14,12 @@ http://www.kde.org/ + + true + + + true + true diff --git a/src/settings_general.ui b/src/settings_general.ui index 23904354..3adf615b 100644 --- a/src/settings_general.ui +++ b/src/settings_general.ui @@ -80,6 +80,20 @@ Tabbed Browsing + + + + Open links in new tab instead of new window + + + + + + + Open external URLs as new tab in existing window + + + diff --git a/src/webpage.cpp b/src/webpage.cpp index 7ef9ec1d..ede503a5 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -126,9 +126,15 @@ WebPage *WebPage::newWindow(WebWindowType type) kDebug() << "Modal Dialog ---------------------------------------"; } - // 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(!ReKonfig::openTabsBack()); + WebView *w = 0; + if(ReKonfig::openTabNoWindow()) + { + w = Application::instance()->mainWindow()->mainView()->newWebView(!ReKonfig::openTabsBack()); + } + else + { + w = Application::instance()->newMainWindow()->mainView()->currentWebView(); + } return w->page(); } diff --git a/src/webview.cpp b/src/webview.cpp index 13eeead5..292fd307 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -114,9 +114,9 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) if (!result.linkUrl().isEmpty()) { // link actions - a = pageAction(QWebPage::OpenLinkInNewWindow); - a->setText(i18n("Open in New &Tab")); - a->setIcon(KIcon("tab-new")); + a = new KAction(KIcon("tab-new"), i18n("Open in New &Tab"), this); + a->setData(result.linkUrl()); + connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewTab())); menu.addAction(a); a = new KAction(KIcon("window-new"), i18n("Open in New &Window"), this); @@ -364,3 +364,11 @@ void WebView::openLinkInNewWindow() KUrl url(a->data().toUrl()); Application::instance()->loadUrl(url, Rekonq::NewWindow); } + + +void WebView::openLinkInNewTab() +{ + KAction *a = qobject_cast(sender()); + KUrl url(a->data().toUrl()); + Application::instance()->loadUrl(url, Rekonq::SettingOpenTab); +} diff --git a/src/webview.h b/src/webview.h index 49bdccfb..f1e5272c 100644 --- a/src/webview.h +++ b/src/webview.h @@ -75,6 +75,7 @@ private slots: void printFrame(); void openLinkInNewWindow(); + void openLinkInNewTab(); private: WebPage *m_page; -- cgit v1.2.1