Commit 05b8f16b authored by Robert Lancaster's avatar Robert Lancaster Committed by Jasem Mutlaq
Browse files

OSX Bundling patch

parent 203e5b24
......@@ -31,6 +31,21 @@ OpsEkos::OpsEkos()
//Get a pointer to the KConfigDialog
m_ConfigDialog = KConfigDialog::exists( "settings" );
#ifdef Q_OS_OSX
connect(solverInternal, SIGNAL(clicked()), this, SLOT(toggleSolverInternal()));
solverInternal->setToolTip(i18n("Internal or External Plate Solver."));
connect(configInternal, SIGNAL(clicked()), this, SLOT(toggleConfigInternal()));
configInternal->setToolTip(i18n("Internal or External Astrometry.cfg."));
connect(wcsInternal, SIGNAL(clicked()), this, SLOT(toggleWCSInternal()));
wcsInternal->setToolTip(i18n("Internal or External WCS Info."));
#else
solverInternal->setVisible(false);
configInternal->setVisible(false);
wcsInternal->setVisible(false);
#endif
connect( m_ConfigDialog->button(QDialogButtonBox::Apply), SIGNAL( clicked() ), SLOT( slotApply() ) );
connect( m_ConfigDialog->button(QDialogButtonBox::Ok), SIGNAL( clicked() ), SLOT( slotApply() ) );
connect( m_ConfigDialog->button(QDialogButtonBox::Cancel), SIGNAL( clicked() ), SLOT( slotCancel() ) );
......@@ -39,6 +54,33 @@ OpsEkos::OpsEkos()
OpsEkos::~OpsEkos() {}
void OpsEkos::toggleSolverInternal()
{
kcfg_astrometrySolver->setEnabled(!solverInternal->isChecked());
if(solverInternal->isChecked())
kcfg_astrometrySolver->setText("*Internal Solver*");
else
kcfg_astrometrySolver->setText("/usr/local/bin/solve-field");
}
void OpsEkos::toggleConfigInternal()
{
kcfg_astrometryConfFile->setEnabled(!configInternal->isChecked());
if(configInternal->isChecked())
kcfg_astrometryConfFile->setText("*Internal astrometry.cfg*");
else
kcfg_astrometryConfFile->setText("/etc/astrometry.cfg");
}
void OpsEkos::toggleWCSInternal()
{
kcfg_astrometryWCSInfo->setEnabled(!wcsInternal->isChecked());
if(wcsInternal->isChecked())
kcfg_astrometryWCSInfo->setText("*Internal wcsinfo*");
else
kcfg_astrometryWCSInfo->setText("/usr/local/bin/wcsinfo");
}
void OpsEkos::slotApply()
{
EkosManager *ekosManager = KStars::Instance()->ekosManager();
......
......@@ -33,6 +33,9 @@ public:
private slots:
void slotApply();
void toggleSolverInternal();
void toggleConfigInternal();
void toggleWCSInternal();
private:
KConfigDialog *m_ConfigDialog;
......
......@@ -6,15 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>504</width>
<height>372</height>
<width>658</width>
<height>506</height>
</rect>
</property>
<property name="windowTitle">
<string>TabWidget</string>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="generalTab">
<attribute name="title">
......@@ -359,48 +359,54 @@
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_15">
<item row="0" column="2">
<widget class="QLineEdit" name="kcfg_astrometrySolver">
<property name="toolTip">
<string>Astrometry.net solve-field binary</string>
</property>
<property name="text">
<string>solver:</string>
<string/>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="kcfg_astrometrySolver">
<item row="1" column="5">
<widget class="QLineEdit" name="kcfg_astrometryAPIKey">
<property name="toolTip">
<string>Astrometry.net solve-field binary</string>
<string>Astrometry.net configuration file</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_16">
<item row="2" column="5">
<widget class="QCheckBox" name="kcfg_astrometryUseJPEG">
<property name="toolTip">
<string>Use JPEG format, instead of FITS, to upload images to the online astrometry.net service</string>
</property>
<property name="text">
<string>wcsinfo:</string>
<string>Use JPG for upload</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="kcfg_astrometryWCSInfo">
<property name="toolTip">
<string>Astrometry.net wcsinfo binary</string>
</property>
<widget class="QCheckBox" name="wcsInternal">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_14">
<item row="1" column="4">
<widget class="QLabel" name="label_17">
<property name="text">
<string>config:</string>
<string>API Key:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="1" column="2">
<widget class="QLineEdit" name="kcfg_astrometryConfFile">
<property name="toolTip">
<string>Astrometry.net configuration file</string>
......@@ -410,31 +416,52 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_17">
<item row="1" column="1">
<widget class="QLabel" name="label_14">
<property name="text">
<string>API Key:</string>
<string>config:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="kcfg_astrometryAPIKey">
<item row="2" column="1">
<widget class="QLabel" name="label_18">
<property name="text">
<string>API URL:</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QLineEdit" name="kcfg_astrometryWCSInfo">
<property name="toolTip">
<string>Astrometry.net configuration file</string>
<string>Astrometry.net wcsinfo binary</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_18">
<item row="1" column="0">
<widget class="QCheckBox" name="configInternal">
<property name="text">
<string>API URL:</string>
<string/>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="0" column="1">
<widget class="QLabel" name="label_15">
<property name="text">
<string>solver:</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_16">
<property name="text">
<string>wcsinfo:</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="kcfg_astrometryAPIURL">
<property name="toolTip">
<string>Astrometry.net configuration file</string>
......@@ -444,16 +471,10 @@
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QCheckBox" name="kcfg_astrometryUseJPEG">
<property name="toolTip">
<string>Use JPEG format, instead of FITS, to upload images to the online astrometry.net service</string>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="solverInternal">
<property name="text">
<string>Use JPG for upload</string>
</property>
<property name="checked">
<bool>true</bool>
<string/>
</property>
</widget>
</item>
......
......@@ -85,8 +85,12 @@ void DeviceManager::startServer()
kWarning() << "managed_devices was not set! Cannot start server!";
return;
}
*serverProcess << Options::indiServer();
#ifdef Q_OS_OSX
if(Options::indiServer()=="*Internal INDI Server*")
*serverProcess << QCoreApplication::applicationDirPath()+"/indi/indiserver";
else
#endif
*serverProcess << Options::indiServer();
*serverProcess << "-v" << "-p" << QString::number(port);
......
......@@ -951,7 +951,13 @@ bool DriverManager::readXMLDrivers()
QDir indiDir;
QString driverName;
if (indiDir.cd(Options::indiDriversDir()) == false)
QString driversDir=Options::indiDriversDir();
#ifdef Q_OS_OSX
if(driversDir=="*Internal INDI Drivers*")
driversDir=QCoreApplication::applicationDirPath()+"/indi";
#endif
if (indiDir.cd(driversDir) == false)
{
KMessageBox::error(0, i18n("Unable to find INDI Drivers directory: %1\nPlease make sure to set the correct path in KStars configuration", Options::indiDriversDir()));
return false;
......@@ -980,7 +986,7 @@ bool DriverManager::readXMLDrivers()
}
}
driverName = QString("%1/%2").arg(Options::indiDriversDir()).arg(fileInfo.fileName());
driverName = QString("%1/%2").arg(driversDir).arg(fileInfo.fileName());
processXMLDriver(driverName);
}
......
......@@ -497,7 +497,13 @@ bool INDIDriver::readXMLDrivers()
QDir indiDir;
QString driverName;
if (indiDir.cd(Options::indiDriversDir()) == false)
QString driversDir=Options::indiDriversDir();
#ifdef Q_OS_OSX
if(driversDir=="*Internal INDI Drivers*")
driversDir=QCoreApplication::applicationDirPath()+"/indi";
#endif
if (indiDir.cd(driversDir) == false)
{
KMessageBox::error(0, xi18n("Unable to find INDI Drivers directory: %1\nPlease make sure to set the correct path in KStars configuration", Options::indiDriversDir()));
return false;
......@@ -526,7 +532,7 @@ bool INDIDriver::readXMLDrivers()
}
}
driverName = QString("%1/%2").arg(Options::indiDriversDir()).arg(fileInfo.fileName());
driverName = QString("%1/%2").arg(driversDir).arg(fileInfo.fileName());
processXMLDriver(driverName);
}
......
......@@ -41,7 +41,19 @@ OpsINDI::OpsINDI()
kcfg_fitsDir->setText ( Options::fitsDir());
selectFITSDirB->setIcon( QIcon::fromTheme( "document-open-folder", QIcon(":/icons/breeze/default/document-open-folder.svg")) );
selectFITSDirB->setAttribute(Qt::WA_LayoutUsesWidgetRect);
selectDriversDirB->setIcon( QIcon::fromTheme( "document-open-folder", QIcon(":/icons/breeze/default/document-open-folder.svg")) );
selectDriversDirB->setAttribute(Qt::WA_LayoutUsesWidgetRect);
#ifdef Q_OS_OSX
connect(indiInternal, SIGNAL(clicked()), this, SLOT(toggleINDIInternal()));
indiInternal->setToolTip(i18n("Internal or External INDI Server."));
connect(driversInternal, SIGNAL(clicked()), this, SLOT(toggleDriversInternal()));
driversInternal->setToolTip(i18n("Internal or External INDI Drivers."));
#else
indiInternal->setVisible(false);
driversInternal->setVisible(false);
#endif
connect(selectFITSDirB, SIGNAL(clicked()), this, SLOT(saveFITSDirectory()));
connect(selectDriversDirB, SIGNAL(clicked()), this, SLOT(saveDriversDirectory()));
......@@ -55,6 +67,24 @@ OpsINDI::OpsINDI()
OpsINDI::~OpsINDI() {}
void OpsINDI::toggleINDIInternal()
{
kcfg_indiServer->setEnabled(!indiInternal->isChecked());
if(indiInternal->isChecked())
kcfg_indiServer->setText("*Internal INDI Server*");
else
kcfg_indiServer->setText("/usr/local/bin/indiserver");
}
void OpsINDI::toggleDriversInternal()
{
kcfg_indiDriversDir->setEnabled(!driversInternal->isChecked());
if(driversInternal->isChecked())
kcfg_indiDriversDir->setText("*Internal INDI Drivers*");
else
kcfg_indiDriversDir->setText("/usr/local/bin/");
}
void OpsINDI::saveFITSDirectory()
{
QString dir = QFileDialog::getExistingDirectory(KStars::Instance(), i18n("FITS Default Directory"), kcfg_fitsDir->text());
......
......@@ -34,6 +34,8 @@ private slots:
void saveFITSDirectory();
void saveDriversDirectory();
void slotShowLogFiles();
void toggleINDIInternal();
void toggleDriversInternal();
private:
KConfigDialog *m_ConfigDialog;
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>444</width>
<height>350</height>
<width>543</width>
<height>417</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
......@@ -19,6 +19,13 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="indiInternal">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="videoLabel_2">
<property name="toolTip">
......@@ -40,6 +47,16 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="spacing">
<number>-1</number>
</property>
<item>
<widget class="QCheckBox" name="driversInternal">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="videoLabel_3">
<property name="toolTip">
......
......@@ -71,8 +71,23 @@ bool ServerManager::start()
bool connected=false;
int fd=0;
if (serverProcess == NULL)
if (serverProcess == NULL){
serverProcess = new QProcess(this);
#ifdef Q_OS_OSX
QString driversDir=Options::indiDriversDir();
if(driversDir=="*Internal INDI Drivers*")
driversDir=QCoreApplication::applicationDirPath()+"/indi";
QString indiServerDir=Options::indiServer();
if(indiServerDir=="*Internal INDI Server*")
indiServerDir=QCoreApplication::applicationDirPath()+"/indi";
else if(indiServerDir.length()>10)
indiServerDir=Options::indiServer().mid(0,Options::indiServer().length()-10);
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QStringList envlist = env.toStringList();
envlist.replaceInStrings(QRegularExpression("^(?i)PATH=(.*)"), "PATH=/usr/bin:/usr/local/bin:" + driversDir + ":" + indiServerDir + ":\\1");
serverProcess->setEnvironment(envlist);
#endif
}
QStringList args;
......@@ -101,7 +116,13 @@ bool ServerManager::start()
serverProcess->setProcessChannelMode(QProcess::SeparateChannels);
serverProcess->setReadChannel(QProcess::StandardError);
serverProcess->start(Options::indiServer(), args);
#ifdef Q_OS_OSX
if(Options::indiServer()=="*Internal INDI Server*")
serverProcess->start(QCoreApplication::applicationDirPath()+"/indi/indiserver", args);
else
#endif
serverProcess->start(Options::indiServer(), args);
connected = serverProcess->waitForStarted();
......@@ -147,18 +168,38 @@ bool ServerManager::startDriver(DriverInfo *dv)
managedDrivers.append(dv);
dv->setServerManager(this);
QString driversDir=Options::indiDriversDir();
QString indiServerDir=Options::indiServer();
#ifdef Q_OS_OSX
if(driversDir=="*Internal INDI Drivers*")
driversDir=QCoreApplication::applicationDirPath()+"/indi";
if(indiServerDir=="*Internal INDI Server*")
indiServerDir=QCoreApplication::applicationDirPath()+"/indi";
else if(indiServerDir.length()>10)
indiServerDir=Options::indiServer().mid(0,Options::indiServer().length()-10);
#endif
QStringList paths;
paths << "/usr/bin" << "/usr/local/bin" << driversDir << indiServerDir;
if (QStandardPaths::findExecutable(dv->getDriver()).isEmpty())
{
KMessageBox::error(NULL, i18n("Driver %1 was not found on the system. Please make sure the package that provides the '%1' binary is installed.", dv->getDriver()));
return false;
if(QStandardPaths::findExecutable(dv->getDriver(),paths).isEmpty()){
KMessageBox::error(NULL, i18n("Driver %1 was not found on the system. Please make sure the package that provides the '%1' binary is installed.", dv->getDriver()));
return false;
}
}
out << "start " << dv->getDriver();
if (dv->getUniqueLabel().isEmpty() == false)
out << " -n \"" << dv->getUniqueLabel() << "\"";
if (dv->getSkeletonFile().isEmpty() == false)
out << " -s \"" << Options::indiDriversDir() << QDir::separator() << dv->getSkeletonFile() << "\"";
out << " -s \"" << driversDir << QDir::separator() << dv->getSkeletonFile() << "\"";
out << endl;
out.flush();
......
......@@ -75,6 +75,10 @@ KStars::KStars( bool doSplash, bool clockrun, const QString &startdate )
//Note: You need to make sure the environment variables for KStars are set correctly to get this running properly.
#ifdef Q_OS_OSX
QProcess* klauncher = new QProcess(this);
// QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
// QString stringPath = QCoreApplication::applicationDirPath();
// env.insert("QT_PLUGIN_PATH", stringPath + "/../plugins");
// klauncher->setProcessEnvironment(env);
klauncher->start("kdeinit5");
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment