Skip to content

Commit

Permalink
Updating CMakeLists to copy Data directory into the app bundle on Mac
Browse files Browse the repository at this point in the history
builds so that it doesn't have to be done in the build script.  Also
changing the name of it to match the name craft uses so that we don't
get two copies if using the nightly builds
  • Loading branch information
rlancaste authored and knro committed Nov 20, 2020
1 parent 9e37695 commit 3384e05
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
32 changes: 12 additions & 20 deletions kstars/auxiliary/ksutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1238,26 +1238,18 @@ void copyResourcesFolderFromAppBundle(QString folder)
}
}

bool copyDataFolderFromAppBundleIfNeeded() //The method returns true if the data directory is good to go.
bool setupMacKStarsIfNeeded() // This method will return false if the KStars data directory doesn't exist when it's done
{
//This will copy the locale folder, the notifications folder, and the sounds folder and any missing files in them to Application Support if needed.
copyResourcesFolderFromAppBundle("locale");
copyResourcesFolderFromAppBundle("knotifications5");
copyResourcesFolderFromAppBundle("sounds");

//This will check for the data directory and if its not present, it will run the wizard.
QString dataLocation =
QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kstars", QStandardPaths::LocateDirectory);
if (dataLocation.isEmpty()) //If there is no kstars user data directory
{
QPointer<KSWizard> wizard = new KSWizard(new QFrame());
wizard->exec(); //This will pause the startup until the user installs the data directory from the Wizard.

dataLocation =
QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kstars", QStandardPaths::LocateDirectory);
if (dataLocation.isEmpty())
return false;
//This will copy the KStars data directory
copyResourcesFolderFromAppBundle("kstars");

if(Options::kStarsFirstRun())
{
//This sets some important OS X options.
Options::setIndiServerIsInternal(true);
Options::setIndiServer("*Internal INDI Server*");
Expand All @@ -1271,16 +1263,16 @@ bool copyDataFolderFromAppBundleIfNeeded() //The method returns true if the data
Options::setSextractorBinary("*Internal Sextractor*");
Options::setAstrometryWCSIsInternal(true);
Options::setAstrometryWCSInfo("*Internal wcsinfo*");
Options::setAstrometryUseNoFITS2FITS(false);
Options::setXplanetIsInternal(true);
Options::setXplanetPath("*Internal XPlanet*");
Options::setRunStartupWizard(false); //don't run on startup because we are doing it now.

return true; //This means the data directory is good to go now that we created it from the default.
}
//This will copy any of the critical KStars files from the app bundle to application support if they are missing.
copyResourcesFolderFromAppBundle("kstars");
return true; //This means the data directory was good to go from the start and the wizard did not run.

QString dataLocation =
QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kstars", QStandardPaths::LocateDirectory);
if (dataLocation.isEmpty()) //If there is no kstars user data directory
return false;

return true;
}


Expand Down
2 changes: 1 addition & 1 deletion kstars/auxiliary/ksutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ QString getDefaultPath(const QString &option);

#ifdef Q_OS_OSX
void copyResourcesFolderFromAppBundle(QString folder);
bool copyDataFolderFromAppBundleIfNeeded(); //The boolean returns true if the data folders are good to go.
bool setupMacKStarsIfNeeded(); //The boolean returns true if the data folders are good to go.
bool configureAstrometry();
bool replaceIndexFileNotYetSet();
bool copyRecursively(QString sourceFolder, QString destFolder);
Expand Down
5 changes: 5 additions & 0 deletions kstars/kstars.kcfg
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,11 @@
</entry>
</group>
<group name="General">
<entry name="KStarsFirstRun" type="Bool">
<label>Is this the first time running KStars?</label>
<whatsthis>This allows KStars to perform several operations if it has never been installed before.</whatsthis>
<default>true</default>
</entry>
<entry name="AlwaysRecomputeCoordinates" type="Bool">
<label>Always recompute coordinates</label>
<whatsthis>Checking this option causes recomputation of current equatorial coordinates from catalog coordinates (i.e. application of precession, nutation and aberration corrections) for every redraw of the map. This makes processing slower when there are many stars to handle, but is more likely to be bug free. There are known bugs in the rendering of stars when this recomputation is avoided.</whatsthis>
Expand Down
3 changes: 2 additions & 1 deletion kstars/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ int main(int argc, char *argv[])

#ifdef Q_OS_OSX
//Note, this function will return true on OS X if the data directories are good to go. If not, quit with error code 1!
if (!KSUtils::copyDataFolderFromAppBundleIfNeeded())
if (!KSUtils::setupMacKStarsIfNeeded())
{
KSNotification::sorry(i18n("Sorry, without a KStars Data Directory, KStars cannot operate. Exiting program now."));
return 1;
}
#endif
Options::setKStarsFirstRun(false);
app.setApplicationVersion(KSTARS_VERSION);
/**
* enable high dpi support
Expand Down

0 comments on commit 3384e05

Please sign in to comment.