diff options
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r-- | src/mainwindow.cpp | 29 |
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); +} + } |