Bi-monthly release with minor bug fixes and improvements
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
QStringList getAstrometryDataDirs()
{
QStringList dataDirs;
QString confPath = KSUtils::getAstrometryConfFilePath();
QFile confFile(confPath);
if (confFile.open(QIODevice::ReadOnly) == false)
{
bool confFileExists = false;
if(Options::astrometryConfFileIsInternal())
{
if(KSUtils::configureLocalAstrometryConfIfNecessary())
{
if (confFile.open(QIODevice::ReadOnly))
confFileExists = true;
}
}
if(!confFileExists)
{
KSNotification::error(i18n("Astrometry configuration file corrupted or missing: %1\nPlease set the "
"configuration file full path in INDI options.",
confPath));
return dataDirs;
}
if(KSUtils::configureLocalAstrometryConfIfNecessary())
//Note maybe the Mac and Linux versions of creating the local astrometry conf file and index file folder can be merged.
//I moved both of them here and this method references each one separately.
//One is createLocalAstrometryConf and the other is configureAstrometry
bool configureLocalAstrometryConfIfNecessary()
{
#if defined(Q_OS_LINUX)
QString confPath = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("astrometry") +
QLatin1String("/astrometry.cfg");
if (QFileInfo(confPath).exists() == false)
{
if(createLocalAstrometryConf() == false)
return false;
}
#elif defined(Q_OS_OSX)
if(configureAstrometry() == false)
{
KMessageBox::information(
nullptr,
i18n(
"Failed to properly configure astrometry config file. Please click the options button in the lower right of the Astrometry Tab in Ekos to correct your settings. Then try starting Ekos again."),
i18n("Astrometry Config File Error"), "astrometry_configuration_failure_warning");
return false;
}
#endif
return true;
}
if(createLocalAstrometryConf() == false)
//Can this and the mac method be merged somehow? See KSUtils::configureAstrometry.
bool createLocalAstrometryConf()
{
bool rc = false;
QString confPath = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("astrometry") +
QLatin1String("/astrometry.cfg");
QString systemConfPath = "/etc/astrometry.cfg";
// Check if directory already exists, if it doesn't create one
QDir writableDir(KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("astrometry"));
if (writableDir.exists() == false)
{
rc = writableDir.mkdir(KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("astrometry"));
if (rc == false)
{
qCCritical(KSTARS) << "Failed to create local astrometry directory";
return false;
}
}
// Now copy system astrometry.cfg to local directory
rc = QFile(systemConfPath).copy(confPath);
if (rc == false)
{
qCCritical(KSTARS) << "Failed to copy" << systemConfPath << "to" << confPath;
return false;
}
QFile localConf(confPath);
// Open file and add our own path to it
if (localConf.open(QFile::ReadWrite))
{
QString all = localConf.readAll();
QStringList lines = all.split("\n");
for (int i = 0; i < lines.count(); i++)
{
if (lines[i].startsWith("add_path"))
{
lines.insert(i + 1, QString("add_path %1astrometry").arg(KSPaths::writableLocation(QStandardPaths::GenericDataLocation)));
break;
}
}
// Clear contents
localConf.resize(0);
// Now write back all the lines including our own inserted above
QTextStream out(&localConf);
for(const QString &line : lines)
out << line << '\n';
localConf.close();
return true;
}
qCCritical(KSTARS) << "Failed to open local astrometry config" << confPath;
return false;
} }
// Now copy system astrometry.cfg to local directory
rc = QFile(systemConfPath).copy(confPath);
if (rc == false)
{
qCCritical(KSTARS) << "Failed to copy" << systemConfPath << "to" << confPath;
return false;
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.