diff options
| -rw-r--r-- | src/mainwindow.cpp | 24 | 
1 files changed, 9 insertions, 15 deletions
| diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c0ca149e..833e69d3 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -979,25 +979,19 @@ void MainWindow::viewPageSource()      if (!w)          return; -    KUrl url = w->url(); -      QString code = w->page()->mainFrame()->toHtml(); -    // find a safe file name... -    QUrl tempUrl = QUrl(url.url()); -    QByteArray name = tempUrl.toEncoded(QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::StripTrailingSlash); -    QString filePath = KStandardDirs::locateLocal("tmp", QString("code/") + name.toBase64(), true); - -    QFile temp(filePath); +    KTemporaryFile tmpFile; +    tmpFile.setAutoRemove(false); +    if (!tmpFile.open()) +        return; -    if (temp.open(QFile::WriteOnly | QFile::Truncate)) -    { -        QTextStream out(&temp); -        out << code; -    } +    QTextStream out(&tmpFile); +    out << code; +    tmpFile.close(); +    KUrl tmpUrl(tmpFile.fileName()); -    KRun::runUrl(QString(QL1S("file://") + temp.fileName()), QL1S("text/plain"), this, false); -    return; +    KRun::runUrl(tmpUrl, QL1S("text/plain"), this, false);  } | 
