Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 629c2a4c authored by Luigi Toscano's avatar Luigi Toscano

Port away from KTemporaryFile to QTemporaryFile

The temporary file, which is removed when the preview dialog is closed,
does not need to be created in the same place where the HTML is stored,
which (maybe) could be problematic for a direct editing of a remote URL.
So just use the standard temporary directory. With the change,
remove few additional dependencies on KUrl.
parent 4bfd2fea
......@@ -2706,7 +2706,7 @@ void KImageMapEditor::mapDelete()
}
void KImageMapEditor::mapPreview() {
HTMLPreviewDialog dialog(widget(), url(), getHtmlCode());
HTMLPreviewDialog dialog(widget(), getHtmlCode());
dialog.exec();
}
......
......@@ -31,6 +31,7 @@
#include <QGridLayout>
#include <QLinkedList>
#include <QFrame>
#include <QTemporaryFile>
#include <QVBoxLayout>
// KDE Frameworks
......@@ -39,7 +40,6 @@
#include "kimagemapeditor_debug.h"
#include <khtmlview.h>
#include <khtml_part.h>
#include <ktemporaryfile.h>
#include <kstandardguiitem.h>
#include <kvbox.h>
#include <KSharedConfig>
......@@ -647,12 +647,10 @@ void PreferencesDialog::slotApply( void ) {
emit preferencesChanged();
}
HTMLPreviewDialog::HTMLPreviewDialog(QWidget* parent, const KUrl & url, const QString & htmlCode)
HTMLPreviewDialog::HTMLPreviewDialog(QWidget* parent, const QString & htmlCode)
: KDialog(parent)
{
tempFile = new KTemporaryFile();
tempFile->setPrefix(url.directory(KUrl::AppendTrailingSlash));
tempFile->setSuffix(".html");
tempFile = new QTemporaryFile(QDir::tempPath() + QLatin1String("/kime_preview_XXXXXX.html"));
tempFile->open();
setCaption(i18n("Preview"));
setButtons(Ok);
......@@ -672,7 +670,7 @@ HTMLPreviewDialog::HTMLPreviewDialog(QWidget* parent, const KUrl & url, const QS
// htmlView->setHScrollBarMode(QScrollView::Auto);
// dialog->resize(dialog->calculateSize(edit->maxLineWidth(),edit->numLines()*));
// dialog->adjustSize();
htmlPart->openUrl(KUrl( tempFile->fileName() ));
htmlPart->openUrl(QUrl::fromLocalFile(tempFile->fileName()));
QLabel* lbl = new QLabel( page );
lbl->setObjectName( "urllabel" );
......
......@@ -23,7 +23,6 @@
#include <QLinkedList>
#include <kdialog.h>
#include <kurl.h>
#include "kimagemapeditor.h"
......@@ -168,15 +167,15 @@ Q_OBJECT
};
class KHTMLPart;
class KTemporaryFile;
class QTemporaryFile;
class HTMLPreviewDialog : public KDialog{
public:
HTMLPreviewDialog(QWidget *, const KUrl &, const QString &);
HTMLPreviewDialog(QWidget *, const QString &);
~HTMLPreviewDialog();
private:
KHTMLPart* htmlPart;
KTemporaryFile* tempFile;
QTemporaryFile* tempFile;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment