From 1e32755e0c8caa5be6c12dd6675a477e5dae9155 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 4 Sep 2009 00:48:41 +0200 Subject: Open in new Window Action --- src/application.cpp | 12 +++++++++++- src/application.h | 3 ++- src/webview.cpp | 16 +++++++++++++++- src/webview.h | 2 ++ 4 files changed, 30 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index 44b0142e..3a0b1606 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -310,7 +310,16 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) } WebView *webView = 0; - MainWindow *w = mainWindow(); + MainWindow *w = 0; + + if(type == Rekonq::NewWindow) + { + w = newMainWindow(); + } + else + { + w = mainWindow(); + } switch(type) { @@ -328,6 +337,7 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) case Rekonq::NewBackTab: webView = w->mainView()->newWebView(false); break; + case Rekonq::NewWindow: case Rekonq::CurrentTab: webView = w->mainView()->currentWebView(); w->mainView()->urlBar()->setUrl(loadingUrl.prettyUrl()); diff --git a/src/application.h b/src/application.h index 14e4c1f6..60aec259 100644 --- a/src/application.h +++ b/src/application.h @@ -78,7 +78,8 @@ namespace Rekonq CurrentTab, ///< open url in current tab SettingOpenTab, ///< open url according to users settings NewCurrentTab, ///< open url in new tab and make it current - NewBackTab ///< open url in new tab in background + NewBackTab, ///< open url in new tab in background + NewWindow ///< open url in new window }; } diff --git a/src/webview.cpp b/src/webview.cpp index 85e0e996..19c5e421 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -116,7 +116,12 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) // link actions a = pageAction(QWebPage::OpenLinkInNewWindow); a->setText(i18n("Open Link in New &Tab")); - a->setIcon(KIcon("window-new")); + a->setIcon(KIcon("tab-new")); + menu.addAction(a); + + a = new KAction(KIcon("window-new"), i18n("Open Link in New &Window"), this); + a->setData( result.linkUrl() ); + connect(a, SIGNAL( triggered(bool) ), this, SLOT( openLinkInNewWindow() ) ); menu.addAction(a); a = pageAction(QWebPage::DownloadLinkToDisk); @@ -211,6 +216,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) { // page action menu.addAction(mainwindow->actionByName("new_tab")); + menu.addAction(mainwindow->actionByName("new_window")); menu.addSeparator(); } @@ -349,3 +355,11 @@ void WebView::printFrame() { Application::instance()->mainWindow()->printRequested(page()->currentFrame()); } + + +void WebView::openLinkInNewWindow() +{ + KAction *a = qobject_cast(sender()); + KUrl url(a->data().toUrl()); + Application::instance()->loadUrl(url, Rekonq::NewWindow); +} diff --git a/src/webview.h b/src/webview.h index 259c1d83..49bdccfb 100644 --- a/src/webview.h +++ b/src/webview.h @@ -73,6 +73,8 @@ private slots: void slotLoadFinished(bool); void printFrame(); + + void openLinkInNewWindow(); private: WebPage *m_page; -- cgit v1.2.1