summaryrefslogtreecommitdiff
path: root/src/webview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webview.cpp')
-rw-r--r--src/webview.cpp113
1 files changed, 44 insertions, 69 deletions
diff --git a/src/webview.cpp b/src/webview.cpp
index 1dd5ad6a..f38d363e 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -53,7 +53,7 @@
WebView::WebView(QWidget* parent)
- : QWebView(parent)
+ : KWebView(parent, false)
, m_page(new WebPage(this))
, m_progress(0)
, m_mousePos(QPoint(0,0))
@@ -64,6 +64,11 @@ WebView::WebView(QWidget* parent)
connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&)));
connect(this, SIGNAL(loadProgress(int)), this, SLOT(updateProgress(int)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
+
+ connect(this, SIGNAL(linkMiddleOrCtrlClicked(const KUrl &)), this, SLOT(loadInNewTab(const KUrl &)) );
+
+ connect(this, SIGNAL(linkShiftClicked(const KUrl &)), this, SLOT(downloadRequest(const KUrl &)));
+ connect(page(), SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(downloadRequest(const QNetworkRequest &r)));
}
@@ -76,7 +81,7 @@ WebPage *WebView::page()
{
if(!m_page)
{
- m_page = new WebPage();
+ m_page = new WebPage(this);
setPage(m_page);
}
return m_page;
@@ -129,14 +134,8 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewWindow()));
menu.addAction(a);
- a = pageAction(QWebPage::DownloadLinkToDisk);
- a->setIcon(KIcon("document-save"));
- menu.addAction(a);
-
- a = pageAction(QWebPage::CopyLinkToClipboard);
- a->setIcon(KIcon("edit-copy"));
- menu.addAction(a);
-
+ menu.addAction(pageAction(KWebPage::DownloadLinkToDisk));
+ menu.addAction(pageAction(KWebPage::CopyLinkToClipboard));
menu.addSeparator();
}
@@ -144,33 +143,24 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
if (result.isContentEditable() && result.isContentSelected())
{
// actions for text selected in field
- a = pageAction(QWebPage::Cut);
- a->setIcon(KIcon("edit-cut"));
- a->setShortcut(KStandardShortcut::cut().primary());
- menu.addAction(a);
+ menu.addAction(pageAction(KWebPage::Cut));
}
// is content selected) Add COPY
if(result.isContentSelected())
{
- a = pageAction(QWebPage::Copy);
- a->setIcon(KIcon("edit-copy"));
- a->setShortcut(KStandardShortcut::copy().primary());
- a->setText(i18n("Copy"));
+ a = pageAction(KWebPage::Copy);
if(!result.linkUrl().isEmpty())
- a->setText(i18n("Copy Text")); //for link
+ a->setText(i18n("Copy Text")); //for link
else
- a->setText(i18n("Copy"));
+ a->setText(i18n("Copy"));
menu.addAction(a);
}
// is content editable? Add PASTE
if(result.isContentEditable())
{
- a = pageAction(QWebPage::Paste);
- a->setIcon(KIcon("edit-paste"));
- a->setShortcut(KStandardShortcut::paste().primary());
- menu.addAction(a);
+ menu.addAction(pageAction(KWebPage::Paste));
}
// is content selected? Add SEARCH actions
@@ -225,14 +215,8 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(viewImage(Qt::MouseButtons, Qt::KeyboardModifiers)));
menu.addAction(a);
- a = pageAction(QWebPage::DownloadImageToDisk);
- a->setIcon(KIcon("document-save"));
- menu.addAction(a);
-
- a = pageAction(QWebPage::CopyImageToClipboard);
- a->setIcon(KIcon("edit-copy"));
- menu.addAction(a);
-
+ menu.addAction(pageAction(KWebPage::DownloadImageToDisk));
+ menu.addAction(pageAction(KWebPage::CopyImageToClipboard));
menu.addSeparator();
}
@@ -278,16 +262,12 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
QWebHistory *history = page()->history();
if(history->canGoBack())
{
- a = pageAction(QWebPage::Back);
- a->setIcon(KIcon("go-previous"));
- menu.addAction(a);
+ menu.addAction(pageAction(KWebPage::Back));
}
if(history->canGoForward())
{
- a = pageAction(QWebPage::Forward);
- a->setIcon(KIcon("go-next"));
- menu.addAction(a);
+ menu.addAction(pageAction(KWebPage::Forward));
}
menu.addAction(mainwindow->actionByName("view_redisplay"));
@@ -302,10 +282,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
//Frame
KActionMenu *frameMenu = new KActionMenu(i18n("Current Frame"), this);
- a = pageAction(QWebPage::OpenFrameInNewWindow);
- a->setText(i18n("Open Frame in New Tab"));
- a->setIcon(KIcon("view-right-new"));
- frameMenu->addAction(a);
+ frameMenu->addAction(pageAction(KWebPage::OpenFrameInNewWindow));
a = new KAction( KIcon("document-print-frame"), i18n("Print Frame"), this);
connect(a, SIGNAL(triggered()), this, SLOT(printFrame()));
@@ -315,12 +292,8 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
menu.addSeparator();
- //Page
- a = pageAction(QWebPage::SelectAll);
- a->setIcon(KIcon("edit-select-all"));
- a->setShortcut(KStandardShortcut::selectAll().primary());
- a->setText(i18n("Select All"));
- menu.addAction(a);
+ // Page Actions
+ menu.addAction(pageAction(KWebPage::SelectAll));
menu.addAction(mainwindow->actionByName(KStandardAction::name(KStandardAction::SaveAs)));
menu.addAction(mainwindow->actionByName("page_source"));
@@ -331,9 +304,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled))
{
// Developer Extras actions
- a = pageAction(QWebPage::InspectElement);
- a->setIcon(KIcon("view-process-all"));
- menu.addAction(a);
+ menu.addAction(pageAction(KWebPage::InspectElement));
}
if(mainwindow->isFullScreen())
@@ -354,10 +325,10 @@ void WebView::mousePressEvent(QMouseEvent *event)
switch(event->button())
{
case Qt::XButton1:
- triggerPageAction(QWebPage::Back);
+ triggerPageAction(KWebPage::Back);
break;
case Qt::XButton2:
- triggerPageAction(QWebPage::Forward);
+ triggerPageAction(KWebPage::Forward);
break;
default:
QWebView::mousePressEvent(event);
@@ -378,20 +349,6 @@ QPoint WebView::mousePos()
}
-void WebView::wheelEvent(QWheelEvent *event)
-{
- if (QApplication::keyboardModifiers() & Qt::ControlModifier)
- {
- int numDegrees = event->delta() / 8;
- int numSteps = numDegrees / 15;
- setTextSizeMultiplier(textSizeMultiplier() + numSteps * 0.1);
- event->accept();
- return;
- }
- QWebView::wheelEvent(event);
-}
-
-
void WebView::search()
{
KAction *a = qobject_cast<KAction*>(sender());
@@ -455,15 +412,33 @@ void WebView::keyPressEvent(QKeyEvent *event)
{
if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_C))
{
- triggerPageAction(QWebPage::Copy);
+ triggerPageAction(KWebPage::Copy);
return;
}
if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_A))
{
- triggerPageAction(QWebPage::SelectAll);
+ triggerPageAction(KWebPage::SelectAll);
return;
}
QWebView::keyPressEvent(event);
}
+
+
+void WebView::loadInNewTab(const KUrl &url)
+{
+ Application::instance()->loadUrl(url, Rekonq::NewCurrentTab);
+}
+
+
+void WebView::downloadRequest(const KUrl &url)
+{
+ m_page->downloadRequest(QNetworkRequest(url));
+}
+
+
+void WebView::downloadRequest(const QNetworkRequest &request)
+{
+ m_page->downloadRequest(request);
+}