From b06de73dff2df02a22dde8d6c7aca5dad06d3845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Tr=C3=B6scher?= Date: Tue, 26 Jul 2011 12:16:43 +0200 Subject: use KParts to view page source REVIEW:102085 --- src/mainwindow.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 833e69d3..d0d4d401 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -79,6 +79,7 @@ #include #include +#include // Qt Includes #include @@ -979,6 +980,7 @@ void MainWindow::viewPageSource() if (!w) return; + KUrl url = w->url(); QString code = w->page()->mainFrame()->toHtml(); KTemporaryFile tmpFile; @@ -991,7 +993,18 @@ void MainWindow::viewPageSource() tmpFile.close(); KUrl tmpUrl(tmpFile.fileName()); - KRun::runUrl(tmpUrl, QL1S("text/plain"), this, false); + KParts::ReadOnlyPart *pa = KMimeTypeTrader::createPartInstanceFromQuery(QL1S("text/plain"), w, this, QString()); + if (pa) + { + WebTab *srcTab = m_view->newWebTab(true); + srcTab->page()->setIsOnRekonqPage(true); + srcTab->setPart(pa, tmpUrl); + srcTab->urlBar()->setQUrl(url.pathOrUrl()); + m_view->setTabText(m_view->currentIndex(), i18n("Source of: ") + url.prettyUrl()); + updateActions(); + } + else + KRun::runUrl(tmpUrl, QL1S("text/plain"), this, false); } -- cgit v1.2.1