summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-09-23 09:33:07 +0200
committerAndrea Diamantini <adjam7@gmail.com>2009-09-23 09:33:07 +0200
commit3ba308e1e6c46438624ff573cee2657bf54111d3 (patch)
tree5749cb7dffa0c3060aae316afdd8e3fa19026a5d /src
parentfix page preview (diff)
parentopen a selected url text in a new tab/window (diff)
downloadrekonq-3ba308e1e6c46438624ff573cee2657bf54111d3.tar.xz
Merge commit 'refs/merge-requests/1580' of git://gitorious.org/rekonq/mainline into lionel
Diffstat (limited to 'src')
-rw-r--r--src/webview.cpp49
-rw-r--r--src/webview.h4
2 files changed, 34 insertions, 19 deletions
diff --git a/src/webview.cpp b/src/webview.cpp
index 21a24c4f..97f19d78 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -101,7 +101,6 @@ void WebView::setStatusBarText(const QString &string)
m_statusBarText = string;
}
-
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
QWebHitTestResult result = page()->mainFrame()->hitTestContent(event->pos());
@@ -123,7 +122,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
a->setData(result.linkUrl());
connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewWindow()));
menu.addAction(a);
-
+
a = pageAction(QWebPage::DownloadLinkToDisk);
a->setIcon(KIcon("document-save"));
menu.addAction(a);
@@ -132,7 +131,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
a->setIcon(KIcon("edit-copy"));
menu.addAction(a);
}
-
+
// is content editable && selected? Add CUT
if (result.isContentEditable() && result.isContentSelected())
{
@@ -142,7 +141,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
a->setShortcut(KStandardShortcut::cut().primary());
menu.addAction(a);
}
-
+
// is content selected) Add COPY
if(result.isContentSelected())
{
@@ -151,7 +150,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
a->setShortcut(KStandardShortcut::copy().primary());
menu.addAction(a);
}
-
+
// is content editable? Add PASTE
if(result.isContentEditable())
{
@@ -160,10 +159,10 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
a->setShortcut(KStandardShortcut::paste().primary());
menu.addAction(a);
}
-
+
// is content selected? Add SEARCH actions
if(result.isContentSelected())
- {
+ {
KActionMenu *searchMenu = new KActionMenu(i18n("Search with"), this);
KConfig config("kuriikwsfilterrc"); //Share with konqueror
@@ -174,7 +173,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
QString keywordDelimiter = cg.readEntry("KeywordDelimiter", ":");
KService::Ptr service;
KUriFilterData data;
-
+
Q_FOREACH(const QString &engine, favoriteEngines)
{
if(!engine.isEmpty())
@@ -191,10 +190,9 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
}
menu.addAction(searchMenu);
menu.addSeparator();
-
// TODO Add translate, show translation
}
-
+
// is an image?
if (!result.pixmap().isNull())
{
@@ -216,11 +214,28 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
if(result.linkUrl().isEmpty())
{
// page action
- menu.addAction(mainwindow->actionByName("new_tab"));
- menu.addAction(mainwindow->actionByName("new_window"));
+ if (selectedText().startsWith("http://") || selectedText().startsWith("https://"))
+ {
+ //open selected text url in a new tab
+ a = new KAction(KIcon("tab-new"), i18n("Open in New &Tab: "+selectedText().toUtf8()), this);
+ a->setData(QUrl(selectedText()));
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewTab()));
+ menu.addAction(a);
+
+ //open selected text url in a new window
+ a = new KAction(KIcon("window-new"), i18n("Open in New &Window: "+selectedText().toUtf8()), this);
+ a->setData(QUrl(selectedText()));
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewWindow()));
+ menu.addAction(a);
+ }
+ else
+ {
+ menu.addAction(mainwindow->actionByName("new_tab"));
+ menu.addAction(mainwindow->actionByName("new_window"));
+ }
menu.addSeparator();
}
-
+
QWebHistory *history = page()->history();
if(history->canGoBack())
{
@@ -228,7 +243,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
a->setIcon(KIcon("go-previous"));
menu.addAction(a);
}
-
+
if(history->canGoForward())
{
a = pageAction(QWebPage::Forward);
@@ -237,14 +252,14 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
}
menu.addAction(mainwindow->actionByName("view_redisplay"));
-
+
KActionMenu *frameMenu = new KActionMenu(i18n("Current Frame"), this);
a = pageAction(QWebPage::OpenFrameInNewWindow);
a->setText(i18n("Open in New Tab"));
a->setIcon(KIcon("view-right-new"));
frameMenu->addAction(a);
-
+
a = new KAction( KIcon("document-print-frame"), i18n("Print Frame"), this);
connect(a, SIGNAL(triggered()), this, SLOT(printFrame()));
frameMenu->addAction(a);
@@ -302,7 +317,7 @@ void WebView::mousePressEvent(QMouseEvent *event)
{
m_page->m_pressedButtons = event->buttons();
m_page->m_keyboardModifiers = event->modifiers();
-
+
switch(event->button())
{
case Qt::XButton1:
diff --git a/src/webview.h b/src/webview.h
index a132a193..baf8f9f5 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -45,7 +45,7 @@ class WebView : public QWebView
public:
explicit WebView(QWidget *parent = 0);
-
+
WebPage *page();
KUrl url() const;
QString lastStatusBarText() const;
@@ -73,7 +73,7 @@ private slots:
void slotLoadFinished(bool);
void printFrame();
-
+
void openLinkInNewWindow();
void openLinkInNewTab();