summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-04-19 12:13:19 +0200
committerAndrea Diamantini <adjam7@gmail.com>2009-04-19 12:13:19 +0200
commit1510e5115bf27218f8bf775e22927e213018ee86 (patch)
tree43cfbd84eed8bd59e91c7cc209b4c1a57c7f32d2
parentString fixing, as suggested (diff)
downloadrekonq-1510e5115bf27218f8bf775e22927e213018ee86.tar.xz
Porting "view page source" code to KDE
from Pawel's clone
-rw-r--r--src/mainwindow.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 077a057b..37e1f760 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -661,12 +661,29 @@ void MainWindow::slotViewPageSource()
if (!currentTab())
return;
- QString markup = currentTab()->page()->mainFrame()->toHtml();
- QPlainTextEdit *view = new QPlainTextEdit(markup);
- view->setWindowTitle(i18n("Page Source of ") + currentTab()->title());
- view->setMinimumWidth(640);
- view->setAttribute(Qt::WA_DeleteOnClose);
- view->show();
+ KUrl url(currentTab()->url());
+ bool isTempFile = false;
+ if (!url.isLocalFile())
+ {
+ KTemporaryFile sourceFile;
+
+ /// TODO: autochoose tempfile suffix
+ sourceFile.setSuffix(QString(".html"));
+ sourceFile.setAutoRemove(false);
+
+ if (sourceFile.open())
+ {
+ QDataStream stream(&sourceFile);
+ stream << currentTab()->page()->mainFrame()->toHtml().toUtf8();
+
+ url = KUrl();
+ url.setPath(sourceFile.fileName());
+ isTempFile = true;
+ }
+ }
+ KRun::runUrl(url, QLatin1String("text/plain"), this, isTempFile);
+}
+
}