summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasem Mutlaq <mutlaqja@ikarustech.com>2016-08-17 15:36:30 (GMT)
committerJasem Mutlaq <mutlaqja@ikarustech.com>2016-08-17 15:36:30 (GMT)
commit0dc41aa88888ca8d28edcd50ed287a627c47fb80 (patch)
treea746d94e03fdb5e99fc2b2688790d882d4a97726
parentf2d0c31e15b14c45cae76ad64eb7e5583d77abb6 (diff)
Remove temporary files. If origin is local files, ask for confirmation first
-rw-r--r--kstars/auxiliary/imageviewer.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/kstars/auxiliary/imageviewer.cpp b/kstars/auxiliary/imageviewer.cpp
index e2cb27a..d52d50a 100644
--- a/kstars/auxiliary/imageviewer.cpp
+++ b/kstars/auxiliary/imageviewer.cpp
@@ -172,12 +172,16 @@ void ImageViewer::init(QString caption, QString capText)
m_Caption->setFont( capFont );
}
-ImageViewer::~ImageViewer() {
- /*if ( downloadJob ) {
- // close job quietly, without emitting a result
- downloadJob->kill( KJob::Quietly );
- delete downloadJob;
- }*/
+ImageViewer::~ImageViewer()
+{
+ QString filename = file.fileName();
+ if (filename.startsWith("/tmp/") || filename.contains("/Temp"))
+ {
+ if (m_ImageUrl.isEmpty() == false ||
+ KMessageBox::questionYesNo(0, i18n("Remove temporary file %1 from disk?", filename), i18n("Confirm Removal"),
+ KStandardGuiItem::yes(), KStandardGuiItem::no(), i18n("imageviewer_temporary_file_removal")) == KMessageBox::Yes)
+ QFile::remove(filename);
+ }
QApplication::restoreOverrideCursor();
}
@@ -189,9 +193,6 @@ void ImageViewer::loadImageFromURL()
if (!saveURL.isValid())
qDebug()<<"tempfile-URL is malformed\n";
- //downloadJob = KIO::copy (m_ImageUrl, saveURL); // starts the download asynchron
- //connect (downloadJob, SIGNAL (result (KJob *)), SLOT (downloadReady (KJob *)));
-
QApplication::setOverrideCursor(Qt::WaitCursor);
connect(&downloadJob, SIGNAL(downloaded()), this, SLOT(downloadReady()));