diff options
author | Johannes Tröscher <fritz_van_tom@hotmail.com> | 2011-07-26 12:16:43 +0200 |
---|---|---|
committer | Johannes Tröscher <fritz_van_tom@hotmail.com> | 2011-07-26 12:16:43 +0200 |
commit | b06de73dff2df02a22dde8d6c7aca5dad06d3845 (patch) | |
tree | 5c576ac157e62294eb586261ebef9fcba55baff8 /src | |
parent | use KTemporaryFile for tempfile in viewPageSource action. REVIEW:102087 (diff) | |
download | rekonq-b06de73dff2df02a22dde8d6c7aca5dad06d3845.tar.xz |
use KParts to view page source REVIEW:102085
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
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 <KParts/Part> #include <KParts/BrowserExtension> +#include <KMimeTypeTrader> // Qt Includes #include <QtCore/QTimer> @@ -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<KParts::ReadOnlyPart>(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); } |