LandscapeMgr.cpp   LandscapeMgr.cpp 
skipping to change at line 259 skipping to change at line 259
landscapeBrightness += qMax(0.2/-12.*ssystem->getMoon()->get VMagnitude(core, true),0.)*moonPos[2]; landscapeBrightness += qMax(0.2/-12.*ssystem->getMoon()->get VMagnitude(core, true),0.)*moonPos[2];
// TODO make this more generic for non-atmosphere planets // TODO make this more generic for non-atmosphere planets
if(atmosphere->getFadeIntensity() == 1) if(atmosphere->getFadeIntensity() == 1)
{ {
// If the atmosphere is on, a solar eclipse might darken the sky // If the atmosphere is on, a solar eclipse might darken the sky
// otherwise we just use the sun position calculation above // otherwise we just use the sun position calculation above
landscapeBrightness *= (atmosphere->getRealDisplayIntensityF actor()+0.1); landscapeBrightness *= (atmosphere->getRealDisplayIntensityF actor()+0.1);
} }
// Brightness can't be over 1.f (see https://bugs.launchpad.net/stel
larium/+bug/1115364)
if (landscapeBrightness>0.95)
landscapeBrightness = 0.95;
// TODO: should calculate dimming with solar eclipse even without at mosphere on // TODO: should calculate dimming with solar eclipse even without at mosphere on
if (core->getCurrentLocation().planetName.contains("Sun")) if (core->getCurrentLocation().planetName.contains("Sun"))
{ {
// NOTE: Simple workaround for brightness of landscape when observing from the Sun. // NOTE: Simple workaround for brightness of landscape when observing from the Sun.
landscape->setBrightness(1.f); landscape->setBrightness(1.f);
} }
else else
landscape->setBrightness(landscapeBrightness+0.05); landscape->setBrightness(landscapeBrightness+0.05);
} }
skipping to change at line 624 skipping to change at line 628
{ {
return atmosphere->getRealDisplayIntensityFactor(); return atmosphere->getRealDisplayIntensityFactor();
} }
Landscape* LandscapeMgr::createFromFile(const QString& landscapeFile, const QString& landscapeId) Landscape* LandscapeMgr::createFromFile(const QString& landscapeFile, const QString& landscapeId)
{ {
QSettings landscapeIni(landscapeFile, StelIniFormat); QSettings landscapeIni(landscapeFile, StelIniFormat);
QString s; QString s;
if (landscapeIni.status() != QSettings::NoError) if (landscapeIni.status() != QSettings::NoError)
{ {
qWarning() << "ERROR parsing landscape.ini file: " << landsc apeFile; qWarning() << "ERROR parsing landscape.ini file: " << QDir:: toNativeSeparators(landscapeFile);
s = ""; s = "";
} }
else else
s = landscapeIni.value("landscape/type").toString(); s = landscapeIni.value("landscape/type").toString();
Landscape* ldscp = NULL; Landscape* ldscp = NULL;
if (s=="old_style") if (s=="old_style")
ldscp = new LandscapeOldStyle(); ldscp = new LandscapeOldStyle();
else if (s=="spherical") else if (s=="spherical")
ldscp = new LandscapeSpherical(); ldscp = new LandscapeSpherical();
skipping to change at line 702 skipping to change at line 706
} }
} }
return result; return result;
} }
QString LandscapeMgr::installLandscapeFromArchive(QString sourceFilePath, b ool display, bool toMainDirectory) QString LandscapeMgr::installLandscapeFromArchive(QString sourceFilePath, b ool display, bool toMainDirectory)
{ {
Q_UNUSED(toMainDirectory); Q_UNUSED(toMainDirectory);
if (!QFile::exists(sourceFilePath)) if (!QFile::exists(sourceFilePath))
{ {
qDebug() << "LandscapeMgr: File does not exist:" << sourceFi lePath; qDebug() << "LandscapeMgr: File does not exist:" << QDir::to NativeSeparators(sourceFilePath);
emit errorUnableToOpen(sourceFilePath); emit errorUnableToOpen(sourceFilePath);
return QString(); return QString();
} }
QDir parentDestinationDir; QDir parentDestinationDir;
//TODO: Fix the "for all users" option //TODO: Fix the "for all users" option
parentDestinationDir.setPath(StelFileMgr::getUserDir()); parentDestinationDir.setPath(StelFileMgr::getUserDir());
if (!parentDestinationDir.exists("landscapes")) if (!parentDestinationDir.exists("landscapes"))
{ {
//qDebug() << "LandscapeMgr: No 'landscapes' subdirectory ex ists in" << parentDestinationDir.absolutePath(); //qDebug() << "LandscapeMgr: No 'landscapes' subdirectory ex ists in" << parentDestinationDir.absolutePath();
if (!parentDestinationDir.mkdir("landscapes")) if (!parentDestinationDir.mkdir("landscapes"))
{ {
qWarning() << "LandscapeMgr: Unable to install lands cape: Unable to create sub-directory 'landscapes' in" << parentDestinationD ir.absolutePath(); qWarning() << "LandscapeMgr: Unable to install lands cape: Unable to create sub-directory 'landscapes' in" << QDir::toNativeSepa rators(parentDestinationDir.absolutePath());
emit errorUnableToOpen(QDir::cleanPath(parentDestina tionDir.filePath("landscapes")));//parentDestinationDir.absolutePath() emit errorUnableToOpen(QDir::cleanPath(parentDestina tionDir.filePath("landscapes")));//parentDestinationDir.absolutePath()
return QString(); return QString();
} }
} }
QDir destinationDir (parentDestinationDir.absoluteFilePath("landscap es")); QDir destinationDir (parentDestinationDir.absoluteFilePath("landscap es"));
KZip sourceArchive(sourceFilePath); KZip sourceArchive(sourceFilePath);
if(!sourceArchive.open(QIODevice::ReadOnly)) if(!sourceArchive.open(QIODevice::ReadOnly))
{ {
qWarning() << "LandscapeMgr: Unable to open as a ZIP archive :" << sourceFilePath; qWarning() << "LandscapeMgr: Unable to open as a ZIP archive :" << QDir::toNativeSeparators(sourceFilePath);
emit errorNotArchive(); emit errorNotArchive();
return QString(); return QString();
} }
//Detect top directory //Detect top directory
const KArchiveDirectory * archiveTopDirectory = NULL; const KArchiveDirectory * archiveTopDirectory = NULL;
QStringList topLevelContents = sourceArchive.directory()->entries(); QStringList topLevelContents = sourceArchive.directory()->entries();
if(topLevelContents.contains("landscape.ini")) if(topLevelContents.contains("landscape.ini"))
{ {
//If the landscape archive has no top level directory... //If the landscape archive has no top level directory...
skipping to change at line 818 skipping to change at line 822
return QString(); return QString();
} }
} }
//Copy the landscape directory to the target //Copy the landscape directory to the target
//sourceArchive.directory()->copyTo(destinationDir.absolutePath()); //sourceArchive.directory()->copyTo(destinationDir.absolutePath());
//This case already has been handled - and commented out - above. :) //This case already has been handled - and commented out - above. :)
if(destinationDir.exists(landscapeID)) if(destinationDir.exists(landscapeID))
{ {
qWarning() << "LandscapeMgr: A subdirectory" << landscapeID << "already exists in" << destinationDir.absolutePath() << "Its contents ma y be overwritten."; qWarning() << "LandscapeMgr: A subdirectory" << landscapeID << "already exists in" << QDir::toNativeSeparators(destinationDir.absoluteP ath()) << "Its contents may be overwritten.";
} }
else if(!destinationDir.mkdir(landscapeID)) else if(!destinationDir.mkdir(landscapeID))
{ {
qWarning() << "LandscapeMgr: Unable to install landscape. Un able to create" << landscapeID << "directory in" << destinationDir.absolute Path(); qWarning() << "LandscapeMgr: Unable to install landscape. Un able to create" << landscapeID << "directory in" << QDir::toNativeSeparator s(destinationDir.absolutePath());
emit errorUnableToOpen(QDir::cleanPath(destinationDir.filePa th(landscapeID))); emit errorUnableToOpen(QDir::cleanPath(destinationDir.filePa th(landscapeID)));
return QString(); return QString();
} }
destinationDir.cd(landscapeID); destinationDir.cd(landscapeID);
QString destinationDirPath = destinationDir.absolutePath(); QString destinationDirPath = destinationDir.absolutePath();
QStringList landscapeFileEntries = archiveTopDirectory->entries(); QStringList landscapeFileEntries = archiveTopDirectory->entries();
foreach (QString entry, landscapeFileEntries) foreach (QString entry, landscapeFileEntries)
{ {
const KArchiveEntry * archEntry = archiveTopDirectory->entry (entry); const KArchiveEntry * archEntry = archiveTopDirectory->entry (entry);
if(archEntry->isFile()) if(archEntry->isFile())
skipping to change at line 849 skipping to change at line 853
//If necessary, make the new landscape the current landscape //If necessary, make the new landscape the current landscape
if (display) if (display)
{ {
setCurrentLandscapeID(landscapeID); setCurrentLandscapeID(landscapeID);
} }
//Make sure that everyone knows that the list of available landscape s has changed //Make sure that everyone knows that the list of available landscape s has changed
emit landscapesChanged(); emit landscapesChanged();
qDebug() << "LandscapeMgr: Successfully installed landscape director y" << landscapeID << "to" << destinationDir.absolutePath(); qDebug() << "LandscapeMgr: Successfully installed landscape director y" << landscapeID << "to" << QDir::toNativeSeparators(destinationDir.absolu tePath());
return landscapeID; return landscapeID;
} }
bool LandscapeMgr::removeLandscape(QString landscapeID) bool LandscapeMgr::removeLandscape(QString landscapeID)
{ {
if (landscapeID.isEmpty()) if (landscapeID.isEmpty())
{ {
qWarning() << "LandscapeMgr: Error! No landscape ID passed t o removeLandscape()."; qWarning() << "LandscapeMgr: Error! No landscape ID passed t o removeLandscape().";
return false; return false;
} }
skipping to change at line 878 skipping to change at line 882
QString landscapePath = getLandscapePath(landscapeID); QString landscapePath = getLandscapePath(landscapeID);
if (landscapePath.isEmpty()) if (landscapePath.isEmpty())
return false; return false;
QDir landscapeDir(landscapePath); QDir landscapeDir(landscapePath);
foreach (QString fileName, landscapeDir.entryList(QDir::Files | QDir ::NoDotAndDotDot)) foreach (QString fileName, landscapeDir.entryList(QDir::Files | QDir ::NoDotAndDotDot))
{ {
if(!landscapeDir.remove(fileName)) if(!landscapeDir.remove(fileName))
{ {
qWarning() << "LandscapeMgr: Unable to remove" << fi leName; qWarning() << "LandscapeMgr: Unable to remove" << QD ir::toNativeSeparators(fileName);
emit errorRemoveManually(landscapeDir.absolutePath() ); emit errorRemoveManually(landscapeDir.absolutePath() );
return false; return false;
} }
} }
landscapeDir.cdUp(); landscapeDir.cdUp();
if(!landscapeDir.rmdir(landscapeID)) if(!landscapeDir.rmdir(landscapeID))
{ {
qWarning() << "LandscapeMgr: Error! Landscape" << landscapeI D qWarning() << "LandscapeMgr: Error! Landscape" << landscapeI D
<< "could not be removed. " << "could not be removed. "
<< "Some files were deleted, but not all. " << "Some files were deleted, but not all. "
<< endl << endl
<< "LandscapeMgr: You can delete manually " << QDir::cleanPath(landscapeDir.filePath(landscapeID)); << "LandscapeMgr: You can delete manually " << QDir::cleanPath(landscapeDir.filePath(landscapeID));
emit errorRemoveManually(QDir::cleanPath(landscapeDir.filePa th(landscapeID))); emit errorRemoveManually(QDir::cleanPath(landscapeDir.filePa th(landscapeID)));
return false; return false;
} }
qDebug() << "LandscapeMgr: Successfully removed" << landscapePath; qDebug() << "LandscapeMgr: Successfully removed" << QDir::toNativeSe parators(landscapePath);
//If the landscape has been selected, revert to the default one //If the landscape has been selected, revert to the default one
//TODO: Make this optional? //TODO: Make this optional?
if (getCurrentLandscapeID() == landscapeID) if (getCurrentLandscapeID() == landscapeID)
{ {
if(getDefaultLandscapeID() == landscapeID) if(getDefaultLandscapeID() == landscapeID)
{ {
setDefaultLandscapeID(packagedLandscapeIDs.first()); setDefaultLandscapeID(packagedLandscapeIDs.first());
//TODO: Find what happens if a missing landscape is specified in the configuration file //TODO: Find what happens if a missing landscape is specified in the configuration file
} }
skipping to change at line 958 skipping to change at line 962
QDir landscapeDir(landscapePath); QDir landscapeDir(landscapePath);
if (landscapeDir.exists("landscape.ini")) if (landscapeDir.exists("landscape.ini"))
{ {
QString landscapeSettingsPath = landscapeDir.filePath("lands cape.ini"); QString landscapeSettingsPath = landscapeDir.filePath("lands cape.ini");
QSettings landscapeSettings(landscapeSettingsPath, StelIniFo rmat); QSettings landscapeSettings(landscapeSettingsPath, StelIniFo rmat);
landscapeName = landscapeSettings.value("landscape/name").to String(); landscapeName = landscapeSettings.value("landscape/name").to String();
} }
else else
{ {
qWarning() << "LandscapeMgr: Error! Landscape directory" << landscapePath << "does not contain a 'landscape.ini' file"; qWarning() << "LandscapeMgr: Error! Landscape directory" << QDir::toNativeSeparators(landscapePath) << "does not contain a 'landscape.i ni' file";
} }
return landscapeName; return landscapeName;
} }
quint64 LandscapeMgr::loadLandscapeSize(QString landscapeID) quint64 LandscapeMgr::loadLandscapeSize(QString landscapeID)
{ {
quint64 landscapeSize = 0; quint64 landscapeSize = 0;
if (landscapeID.isEmpty()) if (landscapeID.isEmpty())
{ {
 End of changes. 11 change blocks. 
10 lines changed or deleted 15 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/