summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasem Mutlaq <mutlaqja@ikarustech.com>2016-08-10 15:40:03 (GMT)
committerJasem Mutlaq <mutlaqja@ikarustech.com>2016-08-10 15:40:03 (GMT)
commitd2ad5cc2deaa2c664966a1923f5e50d6412fa110 (patch)
tree633b128660193cd5baf8b53dab0554bbc8971ab5
parentfbd8f8892924ff6ce4a198a1a80f730fb698e215 (diff)
+ Using toLocalFile() instead of path() to avoid cross-platform file location issues.
+ ImageViewer save dialog will remember last location + Observing Session will not be saved if list is empty
-rw-r--r--kstars/auxiliary/imageviewer.cpp17
-rw-r--r--kstars/auxiliary/imageviewer.h5
-rw-r--r--kstars/dialogs/addcatdialog.h2
-rw-r--r--kstars/ekos/capture.cpp16
-rw-r--r--kstars/ekos/onlineastrometryparser.cpp4
-rw-r--r--kstars/ekos/opsekos.cpp2
-rw-r--r--kstars/ekos/scheduler.cpp46
-rw-r--r--kstars/fitsviewer/fitstab.cpp10
-rw-r--r--kstars/fitsviewer/fitsviewer.cpp2
-rw-r--r--kstars/indi/indielement.cpp4
-rw-r--r--kstars/indi/streamwg.cpp2
-rw-r--r--kstars/kstarsactions.cpp8
-rw-r--r--kstars/oal/execute.cpp2
-rw-r--r--kstars/printing/pwizprint.cpp2
-rw-r--r--kstars/skycomponents/satellitescomponent.cpp2
-rw-r--r--kstars/tools/observinglist.cpp15
-rw-r--r--kstars/tools/scriptbuilder.cpp6
17 files changed, 80 insertions, 65 deletions
diff --git a/kstars/auxiliary/imageviewer.cpp b/kstars/auxiliary/imageviewer.cpp
index ed942a1..142d5b0 100644
--- a/kstars/auxiliary/imageviewer.cpp
+++ b/kstars/auxiliary/imageviewer.cpp
@@ -37,6 +37,8 @@
#include <KLocalizedString>
#include <KMessageBox>
+QUrl ImageViewer::lastURL = QUrl::fromLocalFile(QDir::homePath());
+
ImageLabel::ImageLabel( QWidget *parent ) : QFrame( parent )
{
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
@@ -102,7 +104,7 @@ ImageViewer::ImageViewer (const QUrl &url, const QString &capText, QWidget *pare
if (m_ImageUrl.isLocalFile())
{
- loadImage(m_ImageUrl.path());
+ loadImage(m_ImageUrl.toLocalFile());
return;
}
@@ -285,12 +287,12 @@ bool ImageViewer::showImage()
void ImageViewer::saveFileToDisc()
{
QFileDialog dialog;
- dialog.selectFile(m_ImageUrl.fileName().remove(m_ImageUrl.path()));
- dialog.setFileMode(QFileDialog::AnyFile);
- QUrl newURL = dialog.getSaveFileUrl(KStars::Instance(), i18n("Save Image")); // save-dialog with default filename
+
+ QUrl newURL = dialog.getSaveFileUrl(KStars::Instance(), i18n("Save Image"), lastURL); // save-dialog with default filename
if (!newURL.isEmpty())
{
- QFile f (newURL.adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path() + '/' + newURL.fileName());
+ //QFile f (newURL.adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).toLocalFile() + '/' + newURL.fileName());
+ QFile f(newURL.toLocalFile());
if (f.exists())
{
int r=KMessageBox::warningContinueCancel(static_cast<QWidget *>(parent()),
@@ -302,6 +304,9 @@ void ImageViewer::saveFileToDisc()
f.remove();
}
+
+ lastURL = QUrl(newURL.toString(QUrl::RemoveFilename));
+
saveFile (newURL);
}
}
@@ -314,7 +319,7 @@ void ImageViewer::saveFile (QUrl &url)
//QUrl tmpURL((file.fileName()));
//tmpURL.setScheme("file");
- if (file.copy(url.path()) == false)
+ if (file.copy(url.toLocalFile()) == false)
//if (KIO::file_copy(tmpURL, url)->exec() == false)
{
QString text = i18n ("Saving of the image %1 failed.", url.toString());
diff --git a/kstars/auxiliary/imageviewer.h b/kstars/auxiliary/imageviewer.h
index 4c647bd..e07d423 100644
--- a/kstars/auxiliary/imageviewer.h
+++ b/kstars/auxiliary/imageviewer.h
@@ -105,13 +105,14 @@ private:
bool fileIsImage;
QString filename;
- //KIO::Job *downloadJob; // download job of image -> 0 == no job is running
-
FileDownloader downloadJob;
ImageLabel *m_View;
QLabel *m_Caption;
+ // Share among image viewers
+ static QUrl lastURL;
+
private slots:
/** Initialize (common part of onstructors) */
void init(QString caption, QString capText);
diff --git a/kstars/dialogs/addcatdialog.h b/kstars/dialogs/addcatdialog.h
index 0912277..87a13b9 100644
--- a/kstars/dialogs/addcatdialog.h
+++ b/kstars/dialogs/addcatdialog.h
@@ -60,7 +60,7 @@ public:
/**
*@return the filename of the custom catalog.
*/
- QString filename() const { return acd->CatalogURL->url().path(); }
+ QString filename() const { return acd->CatalogURL->url().toLocalFile(); }
private slots:
/**
diff --git a/kstars/ekos/capture.cpp b/kstars/ekos/capture.cpp
index 0973465..b96e318 100644
--- a/kstars/ekos/capture.cpp
+++ b/kstars/ekos/capture.cpp
@@ -1870,7 +1870,7 @@ void Capture::syncTelescopeInfo()
void Capture::saveFITSDirectory()
{
- QString dir = QFileDialog::getExistingDirectory(KStars::Instance(), i18n("FITS Save Directory"), dirPath.path());
+ QString dir = QFileDialog::getExistingDirectory(KStars::Instance(), i18n("FITS Save Directory"), dirPath.toLocalFile());
if (dir.isEmpty())
return;
@@ -1887,14 +1887,14 @@ void Capture::loadSequenceQueue()
if (fileURL.isValid() == false)
{
- QString message = i18n( "Invalid URL: %1", fileURL.path() );
+ QString message = i18n( "Invalid URL: %1", fileURL.toLocalFile() );
KMessageBox::sorry( 0, message, i18n( "Invalid URL" ) );
return;
}
dirPath = QUrl(fileURL.url(QUrl::RemoveFilename));
- loadSequenceQueue(fileURL.path());
+ loadSequenceQueue(fileURL.toLocalFile());
}
@@ -2169,7 +2169,7 @@ void Capture::saveSequenceQueue()
{
QUrl backupCurrent = sequenceURL;
- if (sequenceURL.path().startsWith("/tmp/") || sequenceURL.path().contains("/Temp"))
+ if (sequenceURL.toLocalFile().startsWith("/tmp/") || sequenceURL.toLocalFile().contains("/Temp"))
sequenceURL.clear();
// If no changes made, return.
@@ -2188,10 +2188,10 @@ void Capture::saveSequenceQueue()
dirPath = QUrl(sequenceURL.url(QUrl::RemoveFilename));
- if (sequenceURL.path().contains('.') == 0)
- sequenceURL.setPath(sequenceURL.path() + ".esq");
+ if (sequenceURL.toLocalFile().endsWith(".esq") == false)
+ sequenceURL.setPath(sequenceURL.toLocalFile() + ".esq");
- if (QFile::exists(sequenceURL.path()))
+ if (QFile::exists(sequenceURL.toLocalFile()))
{
int r = KMessageBox::warningContinueCancel(0,
i18n( "A file named \"%1\" already exists. "
@@ -2204,7 +2204,7 @@ void Capture::saveSequenceQueue()
if ( sequenceURL.isValid() )
{
- if ( (saveSequenceQueue(sequenceURL.path())) == false)
+ if ( (saveSequenceQueue(sequenceURL.toLocalFile())) == false)
{
KMessageBox::error(KStars::Instance(), i18n("Failed to save sequence queue"), i18n("Save"));
return;
diff --git a/kstars/ekos/onlineastrometryparser.cpp b/kstars/ekos/onlineastrometryparser.cpp
index 972fdc0..d561548 100644
--- a/kstars/ekos/onlineastrometryparser.cpp
+++ b/kstars/ekos/onlineastrometryparser.cpp
@@ -200,7 +200,7 @@ void OnlineAstrometryParser::authenticate()
QUrl url(apiURL);
QString method = "login";
- url.setPath(QString("%1%2").arg(url.path()).arg(method));
+ url.setPath(QString("%1%2").arg(url.toLocalFile()).arg(method));
request.setUrl(url);
QVariantMap apiReq;
@@ -231,7 +231,7 @@ void OnlineAstrometryParser::uploadFile()
QUrl url(apiURL);
QString method = "upload/";
- url.setPath(QString("%1%2").arg(url.path()).arg(method));
+ url.setPath(QString("%1%2").arg(url.toLocalFile()).arg(method));
request.setUrl(url);
QHttpMultiPart reqEntity(QHttpMultiPart::FormDataType);
diff --git a/kstars/ekos/opsekos.cpp b/kstars/ekos/opsekos.cpp
index 3187ca9..757babf 100644
--- a/kstars/ekos/opsekos.cpp
+++ b/kstars/ekos/opsekos.cpp
@@ -68,7 +68,7 @@ void OpsEkos::slotSelectPHD2Exec()
if (phd2URL.isEmpty())
return;
- kcfg_PHD2Exec->setText(phd2URL.path());
+ kcfg_PHD2Exec->setText(phd2URL.toLocalFile());
}
void OpsEkos::slotCheckGuideModule()
diff --git a/kstars/ekos/scheduler.cpp b/kstars/ekos/scheduler.cpp
index 8f17e19..a756b4d 100644
--- a/kstars/ekos/scheduler.cpp
+++ b/kstars/ekos/scheduler.cpp
@@ -312,7 +312,7 @@ void Scheduler::selectFITS()
setDirty();
- fitsEdit->setText(fitsURL.path());
+ fitsEdit->setText(fitsURL.toLocalFile());
//raBox->clear();
//decBox->clear();
@@ -334,7 +334,7 @@ void Scheduler::selectSequence()
setDirty();
- sequenceEdit->setText(sequenceURL.path());
+ sequenceEdit->setText(sequenceURL.toLocalFile());
// For object selection, all fields must be filled
if ( (raBox->isEmpty() == false && decBox->isEmpty() == false && nameEdit->text().isEmpty() == false)
@@ -355,7 +355,7 @@ void Scheduler::selectStartupScript()
dirPath = QUrl(startupScriptURL.url(QUrl::RemoveFilename));
mDirty=true;
- startupScript->setText(startupScriptURL.path());
+ startupScript->setText(startupScriptURL.toLocalFile());
}
void Scheduler::selectShutdownScript()
@@ -367,7 +367,7 @@ void Scheduler::selectShutdownScript()
dirPath = QUrl(shutdownScriptURL.url(QUrl::RemoveFilename));
mDirty=true;
- shutdownScript->setText(shutdownScriptURL.path());
+ shutdownScript->setText(shutdownScriptURL.toLocalFile());
}
void Scheduler::addJob()
@@ -626,7 +626,7 @@ void Scheduler::loadJob(QModelIndex i)
if (job->getFITSFile().isEmpty() == false)
{
- fitsEdit->setText(job->getFITSFile().path());
+ fitsEdit->setText(job->getFITSFile().toLocalFile());
fitsURL = job->getFITSFile();
}
else
@@ -635,7 +635,7 @@ void Scheduler::loadJob(QModelIndex i)
fitsURL = QUrl();
}
- sequenceEdit->setText(job->getSequenceFile().path());
+ sequenceEdit->setText(job->getSequenceFile().toLocalFile());
sequenceURL = job->getSequenceFile();
profileCombo->setCurrentText(job->getProfile());
@@ -2929,14 +2929,14 @@ void Scheduler::load()
if (fileURL.isValid() == false)
{
- QString message = i18n( "Invalid URL: %1", fileURL.path() );
+ QString message = i18n( "Invalid URL: %1", fileURL.toLocalFile() );
KMessageBox::sorry( 0, message, i18n( "Invalid URL" ) );
return;
}
dirPath = QUrl(fileURL.url(QUrl::RemoveFilename));
- loadScheduler(fileURL.path());
+ loadScheduler(fileURL.toLocalFile());
}
bool Scheduler::loadScheduler(const QString &fileURL)
@@ -3188,7 +3188,7 @@ void Scheduler::save()
{
QUrl backupCurrent = schedulerURL;
- if (schedulerURL.path().startsWith("/tmp/") || schedulerURL.path().contains("/Temp"))
+ if (schedulerURL.toLocalFile().startsWith("/tmp/") || schedulerURL.toLocalFile().contains("/Temp"))
schedulerURL.clear();
// If no changes made, return.
@@ -3207,10 +3207,10 @@ void Scheduler::save()
dirPath = QUrl(schedulerURL.url(QUrl::RemoveFilename));
- if (schedulerURL.path().contains('.') == 0)
- schedulerURL.setPath(schedulerURL.path() + ".esl");
+ if (schedulerURL.toLocalFile().contains('.') == 0)
+ schedulerURL.setPath(schedulerURL.toLocalFile() + ".esl");
- if (QFile::exists(schedulerURL.path()))
+ if (QFile::exists(schedulerURL.toLocalFile()))
{
int r = KMessageBox::warningContinueCancel(0,
i18n( "A file named \"%1\" already exists. "
@@ -3241,11 +3241,11 @@ void Scheduler::save()
bool Scheduler::saveScheduler(const QUrl &fileURL)
{
QFile file;
- file.setFileName(fileURL.path());
+ file.setFileName(fileURL.toLocalFile());
if ( !file.open( QIODevice::WriteOnly))
{
- QString message = i18n( "Unable to write to file %1", fileURL.path());
+ QString message = i18n( "Unable to write to file %1", fileURL.toLocalFile());
KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
return false;
}
@@ -3267,9 +3267,9 @@ bool Scheduler::saveScheduler(const QUrl &fileURL)
outstream << "</Coordinates>" << endl;
if (job->getFITSFile().isValid() && job->getFITSFile().isEmpty() == false)
- outstream << "<FITS>" << job->getFITSFile().path() << "</FITS>" << endl;
+ outstream << "<FITS>" << job->getFITSFile().toLocalFile() << "</FITS>" << endl;
- outstream << "<Sequence>" << job->getSequenceFile().path() << "</Sequence>" << endl;
+ outstream << "<Sequence>" << job->getSequenceFile().toLocalFile() << "</Sequence>" << endl;
outstream << "<StartupCondition>" << endl;
if (job->getFileStartupCondition() == SchedulerJob::START_ASAP)
@@ -3341,7 +3341,7 @@ bool Scheduler::saveScheduler(const QUrl &fileURL)
outstream << "</SchedulerList>" << endl;
- appendLogText(i18n("Scheduler list saved to %1", fileURL.path()));
+ appendLogText(i18n("Scheduler list saved to %1", fileURL.toLocalFile()));
file.close();
return true;
}
@@ -3576,7 +3576,7 @@ void Scheduler::startCapture()
{
captureInterface->call(QDBus::AutoDetect,"clearSequenceQueue");
- QString url = currentJob->getSequenceFile().path();
+ QString url = currentJob->getSequenceFile().toLocalFile();
QList<QVariant> dbusargs;
dbusargs.append(url);
@@ -3640,7 +3640,7 @@ void Scheduler::setDirty()
bool Scheduler::estimateJobTime(SchedulerJob *job)
{
QFile sFile;
- sFile.setFileName(job->getSequenceFile().path());
+ sFile.setFileName(job->getSequenceFile().toLocalFile());
if ( !sFile.open( QIODevice::ReadOnly))
{
@@ -4277,11 +4277,11 @@ void Scheduler::startMosaicTool()
if (saveScheduler(mosaicURL))
{
- appendLogText(i18n("Mosaic file %1 saved successfully.", mosaicURL.path()));
+ appendLogText(i18n("Mosaic file %1 saved successfully.", mosaicURL.toLocalFile()));
}
else
{
- appendLogText(i18n("Error saving mosaic file %1. Please reload job.", mosaicURL.path()));
+ appendLogText(i18n("Error saving mosaic file %1. Please reload job.", mosaicURL.toLocalFile()));
}
}
}
@@ -4289,7 +4289,7 @@ void Scheduler::startMosaicTool()
XMLEle * Scheduler::getSequenceJobRoot()
{
QFile sFile;
- sFile.setFileName(sequenceURL.path());
+ sFile.setFileName(sequenceURL.toLocalFile());
if ( !sFile.open( QIODevice::ReadOnly))
{
@@ -4318,7 +4318,7 @@ XMLEle * Scheduler::getSequenceJobRoot()
bool Scheduler::createJobSequence(XMLEle *root, const QString &prefix, const QString &outputDir)
{
QFile sFile;
- sFile.setFileName(sequenceURL.path());
+ sFile.setFileName(sequenceURL.toLocalFile());
if ( !sFile.open( QIODevice::ReadOnly))
{
diff --git a/kstars/fitsviewer/fitstab.cpp b/kstars/fitsviewer/fitstab.cpp
index 3223c51..602ed77 100644
--- a/kstars/fitsviewer/fitstab.cpp
+++ b/kstars/fitsviewer/fitstab.cpp
@@ -250,7 +250,7 @@ bool FITSTab::saveFile()
QUrl currentDir(Options::fitsDir());
currentDir.setScheme("file");
- if (currentURL.path().startsWith("/tmp/") || currentURL.path().contains("/Temp"))
+ if (currentURL.toLocalFile().startsWith("/tmp/") || currentURL.toLocalFile().contains("/Temp"))
currentURL.clear();
// If no changes made, return.
@@ -267,10 +267,10 @@ bool FITSTab::saveFile()
return false;
}
- if (currentURL.path().contains('.') == 0)
- currentURL.setPath(currentURL.path() + ".fits");
+ if (currentURL.toLocalFile().contains('.') == 0)
+ currentURL.setPath(currentURL.toLocalFile() + ".fits");
- if (QFile::exists(currentURL.path()))
+ if (QFile::exists(currentURL.toLocalFile()))
{
int r = KMessageBox::warningContinueCancel(0,
i18n( "A file named \"%1\" already exists. "
@@ -285,7 +285,7 @@ bool FITSTab::saveFile()
if ( currentURL.isValid() )
{
- if ( (err_status = saveFITS('!' + currentURL.path())) != 0)
+ if ( (err_status = saveFITS('!' + currentURL.toLocalFile())) != 0)
{
// -1000 = user canceled
if (err_status == -1000)
diff --git a/kstars/fitsviewer/fitsviewer.cpp b/kstars/fitsviewer/fitsviewer.cpp
index 9b7351e..4c71348 100644
--- a/kstars/fitsviewer/fitsviewer.cpp
+++ b/kstars/fitsviewer/fitsviewer.cpp
@@ -480,7 +480,7 @@ void FITSViewer::openFile()
return;
lastURL = QUrl(fileURL.url(QUrl::RemoveFilename));
- QString fpath = fileURL.path();
+ QString fpath = fileURL.toLocalFile();
QString cpath;
diff --git a/kstars/indi/indielement.cpp b/kstars/indi/indielement.cpp
index 096e273..ce299fa 100644
--- a/kstars/indi/indielement.cpp
+++ b/kstars/indi/indielement.cpp
@@ -663,9 +663,9 @@ void INDI_E::browseBlob()
return;
if ( currentURL.isValid() )
- write_w->setText(currentURL.path());
+ write_w->setText(currentURL.toLocalFile());
- fp.setFileName(currentURL.path());
+ fp.setFileName(currentURL.toLocalFile());
if ( (pos = filename.lastIndexOf(".")) != -1)
format = filename.mid (pos, filename.length());
diff --git a/kstars/indi/streamwg.cpp b/kstars/indi/streamwg.cpp
index 389b895..5cbc2f2 100644
--- a/kstars/indi/streamwg.cpp
+++ b/kstars/indi/streamwg.cpp
@@ -159,7 +159,7 @@ void StreamWG::captureImage()
if ( currentFileURL.isValid() )
{
- streamFrame->kPix.save(currentFileURL.path(), fmt.toLatin1());
+ streamFrame->kPix.save(currentFileURL.toLocalFile(), fmt.toLatin1());
}
else
{
diff --git a/kstars/kstarsactions.cpp b/kstars/kstarsactions.cpp
index 8a8f0f4..be72f01 100644
--- a/kstars/kstarsactions.cpp
+++ b/kstars/kstarsactions.cpp
@@ -789,12 +789,12 @@ void KStars::slotOpenFITS()
// Reported as fixed in Qt 5.6
// Emerged Qt 5.5 with patch is not working
#ifdef Q_OS_WIN
- if (fileURL.path().startsWith("/"))
- fileURL.setPath(fileURL.path().right(fileURL.path().count()-1));
+ if (fileURL.toLocalFile().startsWith("/"))
+ fileURL.setPath(fileURL.toLocalFile().right(fileURL.toLocalFile().count()-1));
#endif
// Remember last directory
- path.setUrl(fileURL.path());
+ path.setUrl(fileURL.toLocalFile());
FITSViewer * fv = new FITSViewer(this);
// Error opening file
@@ -819,7 +819,7 @@ void KStars::slotExportImage() {
}
//Warn user if file exists!
- if (QFile::exists(fileURL.path()))
+ if (QFile::exists(fileURL.toLocalFile()))
{
int r=KMessageBox::warningContinueCancel(parentWidget(),
i18n( "A file named \"%1\" already exists. Overwrite it?" , fileURL.fileName()),
diff --git a/kstars/oal/execute.cpp b/kstars/oal/execute.cpp
index fbd1356..36dc898 100644
--- a/kstars/oal/execute.cpp
+++ b/kstars/oal/execute.cpp
@@ -308,7 +308,7 @@ void Execute::slotEndSession() {
if( fileURL.isValid() ) {
- QFile f( fileURL.path() );
+ QFile f( fileURL.toLocalFile() );
if( ! f.open( QIODevice::WriteOnly ) ) {
QString message = i18n( "Could not open file %1", f.fileName() );
KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
diff --git a/kstars/printing/pwizprint.cpp b/kstars/printing/pwizprint.cpp
index bbbfe76..33d1cc5 100644
--- a/kstars/printing/pwizprint.cpp
+++ b/kstars/printing/pwizprint.cpp
@@ -82,7 +82,7 @@ void PWizPrintUI::slotExport()
}
//Warn user if file exists!
- if(QFile::exists(url.path()))
+ if(QFile::exists(url.toLocalFile()))
{
int r=KMessageBox::warningContinueCancel(parentWidget(),
i18n( "A file named \"%1\" already exists. Overwrite it?" , url.fileName()),
diff --git a/kstars/skycomponents/satellitescomponent.cpp b/kstars/skycomponents/satellitescomponent.cpp
index 6842933..493b116 100644
--- a/kstars/skycomponents/satellitescomponent.cpp
+++ b/kstars/skycomponents/satellitescomponent.cpp
@@ -148,7 +148,7 @@ void SatellitesComponent::updateTLEs()
if (response->error() == QNetworkReply::NoError)
{
- QFile file(group->tleFilename().path());
+ QFile file(group->tleFilename().toLocalFile());
if (file.open(QFile::WriteOnly))
{
file.write(response->readAll());
diff --git a/kstars/tools/observinglist.cpp b/kstars/tools/observinglist.cpp
index 1a1d7b7..4506eb3 100644
--- a/kstars/tools/observinglist.cpp
+++ b/kstars/tools/observinglist.cpp
@@ -750,7 +750,7 @@ void ObservingList::slotOpenList()
if ( fileURL.isValid() )
{
- f.setFileName( fileURL.path() );
+ f.setFileName( fileURL.toLocalFile() );
//FIXME do we still need to do this?
/*
if ( ! fileURL.isLocalFile() ) {
@@ -798,7 +798,7 @@ void ObservingList::slotOpenList()
//Newly-opened list should not trigger isModified flag
isModified = false;
f.close();
- } else if ( ! fileURL.path().isEmpty() ) {
+ } else if ( ! fileURL.toLocalFile().isEmpty() ) {
KMessageBox::sorry( 0 , i18n( "The specified file is invalid" ) );
}
}
@@ -817,9 +817,12 @@ void ObservingList::saveCurrentList() {
}
void ObservingList::slotSaveSessionAs(bool nativeSave) {
+ if (sessionList().isEmpty())
+ return;
+
QUrl fileURL = QFileDialog::getSaveFileUrl(KStars::Instance(), i18n("Save Observing List"), QUrl(), "KStars Observing List (*.obslist)" );
if ( fileURL.isValid() ) {
- FileName = fileURL.path();
+ FileName = fileURL.toLocalFile();
slotSaveSession(nativeSave);
}
}
@@ -886,6 +889,12 @@ void ObservingList::slotLoadWishList() {
}
void ObservingList::slotSaveSession(bool nativeSave) {
+ if (sessionList().isEmpty())
+ {
+ KMessageBox::error(0, i18n("Cannot save an empty session list!"));
+ return;
+ }
+
if ( FileName.isEmpty() ) {
slotSaveSessionAs(nativeSave);
return;
diff --git a/kstars/tools/scriptbuilder.cpp b/kstars/tools/scriptbuilder.cpp
index 8d8c3ff..a1594af 100644
--- a/kstars/tools/scriptbuilder.cpp
+++ b/kstars/tools/scriptbuilder.cpp
@@ -756,7 +756,7 @@ void ScriptBuilder::slotOpen() {
if ( currentFileURL.isValid() )
{
- currentDir = currentFileURL.path();
+ currentDir = currentFileURL.toLocalFile();
ScriptList.clear();
sb->ScriptListBox->clear();
@@ -819,13 +819,13 @@ void ScriptBuilder::slotSave()
}
if ( currentFileURL.isValid() ) {
- currentDir = currentFileURL.path();
+ currentDir = currentFileURL.toLocalFile();
if ( currentFileURL.isLocalFile() ) {
fname = currentFileURL.toLocalFile();
//Warn user if file exists
- if (newFilename == true && QFile::exists(currentFileURL.path())) {
+ if (newFilename == true && QFile::exists(currentFileURL.toLocalFile())) {
int r=KMessageBox::warningContinueCancel(static_cast<QWidget *>(parent()),
i18n( "A file named \"%1\" already exists. "
"Overwrite it?" , currentFileURL.fileName()),