kstarsactions.cpp 55.7 KB
Newer Older
Chris Howells's avatar
adding  
Chris Howells committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/***************************************************************************
                          kstarsactions.cpp  -  K Desktop Planetarium
                             -------------------
    begin                : Mon Feb 25 2002
    copyright            : (C) 2002 by Jason Harris
    email                : jharris@30doradus.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
17 18

//needed in slotRunScript() for chmod() syscall (remote script downloaded to temp file)
Patrick Spendrin's avatar
Patrick Spendrin committed
19 20 21 22 23

#ifdef _WIN32
#include <windows.h>
#undef interface
#endif
24
#include <sys/stat.h>
25
#include <config-kstars.h>
26

27 28 29
#include <QCheckBox>
#include <QDir>
#include <QTextStream>
30
#include <QDialog>
31
#include <QDockWidget>
32
#include <QPointer>
33
#include <QInputDialog>
34 35
#include <QQuickWindow>
#include <QQuickView>
36
#include <QDebug>
Jasem Mutlaq's avatar
Jasem Mutlaq committed
37 38 39 40 41 42 43
#include <QAction>
#include <QFileDialog>
#include <QMenu>
#include <QStatusBar>
#include <QProcess>
#include <QIcon>
#include <QTemporaryFile>
44
#include <QStandardPaths>
Jasem Mutlaq's avatar
Jasem Mutlaq committed
45

Jasem Mutlaq's avatar
Jasem Mutlaq committed
46 47 48 49
#include <KActionCollection>
#include <KActionMenu>
#include <KToggleAction>
#include <KMessageBox>
50 51
#include <KTipDialog>
#include <KConfigDialog>
Jasem Mutlaq's avatar
Jasem Mutlaq committed
52

Jasem Mutlaq's avatar
Jasem Mutlaq committed
53
#include <kns3/downloaddialog.h>
Chris Howells's avatar
adding  
Chris Howells committed
54

55 56 57
#include "options/opscatalog.h"
#include "options/opsguides.h"
#include "options/opssolarsystem.h"
58
#include "options/opssatellites.h"
59
#include "options/opssupernovae.h"
60 61
#include "options/opscolors.h"
#include "options/opsadvanced.h"
62

63
#include "Options.h"
Chris Howells's avatar
adding  
Chris Howells committed
64
#include "kstars.h"
65
#include "kstarsdata.h"
66
#include "kstarsdatetime.h"
67
#include "skymap.h"
68 69
#include "skyobjects/skyobject.h"
#include "skyobjects/ksplanetbase.h"
70
#include "simclock.h"
71 72 73 74 75
#include "dialogs/timedialog.h"
#include "dialogs/locationdialog.h"
#include "dialogs/finddialog.h"
#include "dialogs/focusdialog.h"
#include "dialogs/fovdialog.h"
76
#include "dialogs/exportimagedialog.h"
77
#include "printing/printingwizard.h"
78
#include "kswizard.h"
79 80 81
#include "tools/astrocalc.h"
#include "tools/altvstime.h"
#include "tools/wutdialog.h"
82
#include "tools/observinglist.h"
83
#include "tools/eyepiecefield.h"
84
#include "tools/adddeepskyobject.h"
85

Jasem Mutlaq's avatar
Jasem Mutlaq committed
86 87 88
#include "tools/whatsinteresting/wiview.h"
#include "tools/whatsinteresting/wilpsettings.h"
#include "tools/whatsinteresting/wiequipsettings.h"
89

90
#include "tools/skycalendar.h"
91 92
#include "tools/scriptbuilder.h"
#include "tools/planetviewer.h"
Akarsh Simha's avatar
Akarsh Simha committed
93
//#include "tools/jmoontool.h"
94 95
//FIXME Port to KF5
//#include "tools/moonphasetool.h"
96
#include "tools/flagmanager.h"
97
#include "tools/horizonmanager.h"
98
#include "oal/execute.h"
Henry de Valence's avatar
Purge.  
Henry de Valence committed
99
#include "projections/projector.h"
100
#include "imageexporter.h"
101

102
#include <KSharedConfig>
103

Jasem Mutlaq's avatar
Jasem Mutlaq committed
104
#ifdef HAVE_INDI
105
#include <basedevice.h>
106 107
#include "indi/telescopewizardprocess.h"
#include "indi/opsindi.h"
Jasem Mutlaq's avatar
Jasem Mutlaq committed
108 109
#include "indi/drivermanager.h"
#include "indi/guimanager.h"
110
#include "indi/indilistener.h"
111 112
#endif

113 114 115 116
#ifdef HAVE_NOTIFYCONFIG
#include <KNotifyConfigWidget>
#endif

117
#include "skycomponents/catalogcomponent.h"
118
#include "skycomponents/skymapcomposite.h"
119 120
#include "skycomponents/solarsystemcomposite.h"
#include "skycomponents/cometscomponent.h"
121
#include "skycomponents/asteroidscomponent.h"
122
#include "skycomponents/supernovaecomponent.h"
123
#include "skycomponents/satellitescomponent.h"
124

Jasem Mutlaq's avatar
Jasem Mutlaq committed
125
#ifdef HAVE_CFITSIO
126
#include "fitsviewer/fitsviewer.h"
127
#include "fitsviewer/opsfits.h"
Jasem Mutlaq's avatar
Jasem Mutlaq committed
128
#ifdef HAVE_INDI
129 130
#include "ekos/ekosmanager.h"
#include "ekos/opsekos.h"
131
#endif
132 133
#endif

134
#ifdef HAVE_XPLANET
135
#include "xplanet/opsxplanet.h"
136 137
#endif

138
// #include "libkdeedu/kdeeduui/kdeeduglossary.h"
139

Chris Howells's avatar
adding  
Chris Howells committed
140 141 142 143
//This file contains function definitions for Actions declared in kstars.h

/** ViewToolBar Action.  All of the viewToolBar buttons are connected to this slot. **/

144 145
void KStars::slotViewToolBar()
{
146 147
    KToggleAction *a   = (KToggleAction *)sender();
    KConfigDialog *kcd = KConfigDialog::exists("settings");
148

149
    if (a == actionCollection()->action("show_stars"))
150
    {
151 152
        Options::setShowStars(a->isChecked());
        if (kcd)
153
        {
154
            opcatalog->kcfg_ShowStars->setChecked(a->isChecked());
155
        }
156
    }
157
    else if (a == actionCollection()->action("show_deepsky"))
158
    {
159 160
        Options::setShowDeepSky(a->isChecked());
        if (kcd)
161
        {
162
            opcatalog->kcfg_ShowDeepSky->setChecked(a->isChecked());
163
        }
164
    }
165
    else if (a == actionCollection()->action("show_planets"))
166
    {
167 168
        Options::setShowSolarSystem(a->isChecked());
        if (kcd)
169
        {
170
            opsolsys->kcfg_ShowSolarSystem->setChecked(a->isChecked());
171
        }
172
    }
173
    else if (a == actionCollection()->action("show_clines"))
174
    {
175 176
        Options::setShowCLines(a->isChecked());
        if (kcd)
177
        {
178
            opguides->kcfg_ShowCLines->setChecked(a->isChecked());
179
        }
180
    }
181
    else if (a == actionCollection()->action("show_cnames"))
182
    {
183 184
        Options::setShowCNames(a->isChecked());
        if (kcd)
185
        {
186
            opguides->kcfg_ShowCNames->setChecked(a->isChecked());
187
        }
188
    }
189
    else if (a == actionCollection()->action("show_cbounds"))
190
    {
191 192
        Options::setShowCBounds(a->isChecked());
        if (kcd)
193
        {
194
            opguides->kcfg_ShowCBounds->setChecked(a->isChecked());
195
        }
196
    }
197
    else if (a == actionCollection()->action("show_constellationart"))
198
    {
199 200
        Options::setShowConstellationArt(a->isChecked());
        if (kcd)
201
        {
202
            opguides->kcfg_ShowConstellationArt->setChecked(a->isChecked());
203
        }
204
    }
205
    else if (a == actionCollection()->action("show_mw"))
206
    {
207 208
        Options::setShowMilkyWay(a->isChecked());
        if (kcd)
209
        {
210
            opguides->kcfg_ShowMilkyWay->setChecked(a->isChecked());
211
        }
212
    }
213
    else if (a == actionCollection()->action("show_equatorial_grid"))
214
    {
215 216 217 218
        // if autoSelectGrid is selected and the user clicked the
        // show_equatorial_grid button, he probably wants us to disable
        // the autoSelectGrid and display the equatorial grid.
        Options::setAutoSelectGrid(false);
219 220
        Options::setShowEquatorialGrid(a->isChecked());
        if (kcd)
221
        {
222
            opguides->kcfg_ShowEquatorialGrid->setChecked(a->isChecked());
223
            opguides->kcfg_AutoSelectGrid->setChecked(false);
224
        }
225
    }
226
    else if (a == actionCollection()->action("show_horizontal_grid"))
227
    {
228
        Options::setAutoSelectGrid(false);
229 230
        Options::setShowHorizontalGrid(a->isChecked());
        if (kcd)
231
        {
232
            opguides->kcfg_ShowHorizontalGrid->setChecked(a->isChecked());
233
            opguides->kcfg_AutoSelectGrid->setChecked(false);
234
        }
235
    }
236
    else if (a == actionCollection()->action("show_horizon"))
237
    {
238 239
        Options::setShowGround(a->isChecked());
        if (!a->isChecked() && Options::useRefraction())
240
        {
241 242
            QString caption = i18n("Refraction effects disabled");
            QString message = i18n("When the horizon is switched off, refraction effects are temporarily disabled.");
243

244
            KMessageBox::information(this, message, caption, "dag_refract_hide_ground");
245
        }
246
        if (kcd)
247
        {
248
            opguides->kcfg_ShowGround->setChecked(a->isChecked());
249
        }
250
    }
251
    else if (a == actionCollection()->action("show_flags"))
252
    {
253 254
        Options::setShowFlags(a->isChecked());
        if (kcd)
255
        {
256
            opguides->kcfg_ShowFlags->setChecked(a->isChecked());
257
        }
258
    }
259
    else if (a == actionCollection()->action("show_satellites"))
260
    {
261 262
        Options::setShowSatellites(a->isChecked());
        if (kcd)
263
        {
264
            opssatellites->kcfg_ShowSatellites->setChecked(a->isChecked());
265
        }
266
    }
267
    else if (a == actionCollection()->action("show_supernovae"))
268
    {
269 270
        Options::setShowSupernovae(a->isChecked());
        if (kcd)
271
        {
272
            opssupernovae->kcfg_ShowSupernovae->setChecked(a->isChecked());
273
        }
274 275 276 277 278 279 280 281
    }

    // update time for all objects because they might be not initialized
    // it's needed when using horizontal coordinates
    data()->setFullTimeUpdate();
    updateTime();

    map()->forceUpdate();
Chris Howells's avatar
adding  
Chris Howells committed
282 283
}

284 285 286
void KStars::slotINDIToolBar()
{
#ifdef HAVE_INDI
287
    KToggleAction *a = (KToggleAction *)sender();
288

289
    if (a == actionCollection()->action("show_control_panel"))
290
    {
291 292 293 294 295 296 297 298
        if (a->isChecked())
        {
            GUIManager::Instance()->raise();
            GUIManager::Instance()->activateWindow();
            GUIManager::Instance()->showNormal();
        }
        else
            GUIManager::Instance()->hide();
299
    }
300
    else if (a == actionCollection()->action("show_ekos"))
301
    {
302 303 304 305 306 307 308 309
        if (a->isChecked())
        {
            ekosManager()->raise();
            ekosManager()->activateWindow();
            ekosManager()->showNormal();
        }
        else
            ekosManager()->hide();
310
    }
311
    else if (a == actionCollection()->action("lock_telescope"))
312 313 314 315 316 317 318
    {
        if (INDIListener::Instance()->size() == 0)
        {
            KMessageBox::sorry(0, i18n("KStars did not find any active telescopes."));
            return;
        }

319
        ISD::GDInterface *oneScope = nullptr;
320

321
        foreach (ISD::GDInterface *gd, INDIListener::Instance()->getDevices())
322
        {
323
            INDI::BaseDevice *bd = gd->getBaseDevice();
324 325 326 327

            if (gd->getType() != KSTARS_TELESCOPE)
                continue;

Csaba Kertesz's avatar
Csaba Kertesz committed
328
            if (bd == nullptr)
329 330 331 332
                continue;

            if (bd->isConnected() == false)
            {
333 334
                KMessageBox::error(
                    0, i18n("Telescope %1 is offline. Please connect and retry again.", gd->getDeviceName()));
335 336 337 338 339 340 341
                return;
            }

            oneScope = gd;
            break;
        }

Csaba Kertesz's avatar
Csaba Kertesz committed
342
        if (oneScope == nullptr)
343 344 345 346 347
        {
            KMessageBox::sorry(0, i18n("KStars did not find any active telescopes."));
            return;
        }

348 349 350 351
        if (a->isChecked())
            oneScope->runCommand(INDI_CENTER_LOCK);
        else
            oneScope->runCommand(INDI_CENTER_UNLOCK);
352
    }
353
    else if (a == actionCollection()->action("show_fits_viewer"))
354
    {
355 356 357 358 359 360 361 362
        if (m_FITSViewers.isEmpty())
        {
            a->setEnabled(false);
            return;
        }

        if (a->isChecked())
        {
363
            foreach (FITSViewer *view, m_FITSViewers)
364 365 366 367 368 369 370 371 372 373 374
            {
                if (view->getTabs().empty() == false)
                {
                    view->raise();
                    view->activateWindow();
                    view->showNormal();
                }
            }
        }
        else
        {
375
            foreach (FITSViewer *view, m_FITSViewers)
376 377 378 379
            {
                view->hide();
            }
        }
380 381
    }

382 383 384
#endif
}

Chris Howells's avatar
adding  
Chris Howells committed
385 386
/** Major Dialog Window Actions **/

387 388
void KStars::slotCalculator()
{
389 390
    if (!m_AstroCalc)
        m_AstroCalc = new AstroCalc(this);
391
    m_AstroCalc->show();
392
}
393

394 395
void KStars::slotWizard()
{
396
    QPointer<KSWizard> wizard = new KSWizard(this);
397
    if (wizard->exec() == QDialog::Accepted)
398
    {
399
        Options::setRunStartupWizard(false); //don't run on startup next time
Robert Lancaster's avatar
Robert Lancaster committed
400 401 402 403
        updateLocationFromWizard(*(wizard->geo()));
    }
    delete wizard;
}
404

405 406
void KStars::updateLocationFromWizard(GeoLocation geo)
{
407
    data()->setLocation(geo);
Robert Lancaster's avatar
Robert Lancaster committed
408 409
    // adjust local time to keep UT the same.
    // create new LT without DST offset
410
    KStarsDateTime ltime = data()->geo()->UTtoLT(data()->ut());
411

Robert Lancaster's avatar
Robert Lancaster committed
412
    // reset timezonerule to compute next dst change
413
    data()->geo()->tzrule()->reset_with_ltime(ltime, data()->geo()->TZ0(), data()->isTimeRunningForward());
414

Robert Lancaster's avatar
Robert Lancaster committed
415
    // reset next dst change time
416
    data()->setNextDSTChange(data()->geo()->tzrule()->nextDSTChange());
417

Robert Lancaster's avatar
Robert Lancaster committed
418 419
    // reset local sideral time
    data()->syncLST();
420

Robert Lancaster's avatar
Robert Lancaster committed
421 422
    // Make sure Numbers, Moon, planets, and sky objects are updated immediately
    data()->setFullTimeUpdate();
423

Robert Lancaster's avatar
Robert Lancaster committed
424 425
    // If the sky is in Horizontal mode and not tracking, reset focus such that
    // Alt/Az remain constant.
426
    if (!Options::isTracking() && Options::useAltAz())
427
    {
428
        map()->focus()->HorizontalToEquatorial(data()->lst(), data()->geo()->lat());
429
    }
Robert Lancaster's avatar
Robert Lancaster committed
430 431 432 433

    // recalculate new times and objects
    data()->setSnapNextFocus();
    updateTime();
434 435
}

436 437
void KStars::slotDownload()
{
438 439
    // 2017-07-04: Explicitly load kstars.knsrc from resources file
    QPointer<KNS3::DownloadDialog> dlg(new KNS3::DownloadDialog(":/kconfig/kstars.knsrc", this));
440
    dlg->exec();
Frederik Gladhorn's avatar
Frederik Gladhorn committed
441 442

    // Get the list of all the installed entries.
443 444
    KNS3::Entry::List installed_entries;
    KNS3::Entry::List changed_entries;
445 446
    if (dlg)
    {
447
        installed_entries = dlg->installedEntries();
448
        changed_entries   = dlg->changedEntries();
449 450 451
    }

    delete dlg;
Frederik Gladhorn's avatar
Frederik Gladhorn committed
452

453 454 455 456
    foreach (const KNS3::Entry &entry, installed_entries)
    {
        foreach (const QString &name, entry.installedFiles())
        {
457
            if (name.endsWith(QLatin1String(".cat")))
458 459
            {
                data()->catalogdb()->AddCatalogContents(name);
Frederik Gladhorn's avatar
Frederik Gladhorn committed
460
                // To start displaying the custom catalog, add it to SkyMapComposite
461 462 463

                QString catalogName = data()->catalogdb()->GetCatalogName(name);
                Options::setShowCatalogNames(Options::showCatalogNames() << catalogName);
Frederik Gladhorn's avatar
Frederik Gladhorn committed
464 465
                Options::setCatalogFile(Options::catalogFile() << name);
                Options::setShowCatalog(Options::showCatalog() << 1);
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480
            }
        }

        KStars::Instance()->data()->skyComposite()->reloadDeepSky();
        // update time for all objects because they might be not initialized
        // it's needed when using horizontal coordinates
        KStars::Instance()->data()->setFullTimeUpdate();
        KStars::Instance()->updateTime();
        KStars::Instance()->map()->forceUpdate();
    }

    foreach (const KNS3::Entry &entry, changed_entries)
    {
        foreach (const QString &name, entry.uninstalledFiles())
        {
481
            if (name.endsWith(QLatin1String(".cat")))
482 483 484 485 486 487
            {
                data()->catalogdb()->RemoveCatalog(name);
                // To start displaying the custom catalog, add it to SkyMapComposite
                QStringList catFile = Options::catalogFile();
                catFile.removeOne(name);
                Options::setCatalogFile(catFile);
488 489 490
            }
        }
    }
491
}
Jason Harris's avatar
Jason Harris committed
492

493 494
void KStars::slotAVT()
{
495 496
    if (!m_AltVsTime)
        m_AltVsTime = new AltVsTime(this);
497
    m_AltVsTime->show();
498 499
}

500 501
void KStars::slotWUT()
{
502 503
    if (!m_WUTDialog)
        m_WUTDialog = new WUTDialog(this);
Jasem Mutlaq's avatar
Jasem Mutlaq committed
504
    m_WUTDialog->show();
505
}
506

Jasem Mutlaq's avatar
Jasem Mutlaq committed
507
//FIXME Port to QML2
508
//#if 0
509 510
void KStars::slotWISettings()
{
511
    if (!m_WIView)
512
        slotToggleWIView();
Jasem Mutlaq's avatar
Jasem Mutlaq committed
513
    if (m_WIView && !m_wiDock->isVisible())
514
        slotToggleWIView();
515

516 517
    if (KConfigDialog::showDialog("wisettings"))
    {
Jasem Mutlaq's avatar
Jasem Mutlaq committed
518
        m_WIEquipmentSettings->populateScopeListWidget();
519 520
        return;
    }
521

522
    KConfigDialog *dialog = new KConfigDialog(this, "wisettings", Options::self());
523

524
    connect(dialog, SIGNAL(settingsChanged(const QString &)), this, SLOT(slotApplyWIConfigChanges()));
525

526
    m_WISettings          = new WILPSettings(this);
527
    m_WIEquipmentSettings = new WIEquipSettings();
528 529
    dialog->addPage(m_WISettings, i18n("Light Pollution Settings"));
    dialog->addPage(m_WIEquipmentSettings, i18n("Equipment Settings - Equipment Type and Parameters"));
530
    dialog->exec();
531
    if (m_WIEquipmentSettings)
532
        m_WIEquipmentSettings->setAperture(); //Something isn't working with this!
533 534
}

535
void KStars::slotToggleWIView()
536
{
Jasem Mutlaq's avatar
Jasem Mutlaq committed
537
    if (!m_WIView)
538
    {
539
        m_WIView = new WIView(0);
Jasem Mutlaq's avatar
Jasem Mutlaq committed
540
        m_wiDock = new QDockWidget(this);
541
        m_wiDock->setStyleSheet("QDockWidget::title{background-color:black;}");
Jasem Mutlaq's avatar
Jasem Mutlaq committed
542 543
        m_wiDock->setObjectName("What's Interesting");
        m_wiDock->setAllowedAreas(Qt::RightDockWidgetArea);
544
        QWidget *container = QWidget::createWindowContainer(m_WIView->getWIBaseView());
Jasem Mutlaq's avatar
Jasem Mutlaq committed
545
        m_wiDock->setWidget(container);
546
        m_wiDock->setMinimumWidth(400);
Jasem Mutlaq's avatar
Jasem Mutlaq committed
547
        addDockWidget(Qt::RightDockWidgetArea, m_wiDock);
548 549
        connect(m_wiDock, SIGNAL(visibilityChanged(bool)), actionCollection()->action("show_whatsinteresting"),
                SLOT(setChecked(bool)));
Jasem Mutlaq's avatar
Jasem Mutlaq committed
550
        m_wiDock->setVisible(true);
551 552
    }
    else
553
    {
554
        m_wiDock->setVisible(!m_wiDock->isVisible());
555
    }
556
}
557

558 559
void KStars::slotCalendar()
{
560 561
    if (!m_SkyCalendar)
        m_SkyCalendar = new SkyCalendar(this);
562
    m_SkyCalendar->show();
563 564
}

565 566
void KStars::slotGlossary()
{
567 568
    // 	GlossaryDialog *dlg = new GlossaryDialog( this, true );
    // 	QString glossaryfile =data()->stdDirs->findResource( "data", "kstars/glossary.xml" );
Jasem Mutlaq's avatar
Jasem Mutlaq committed
569
    // 	QUrl u = glossaryfile;
570
    // 	Glossary *g = new Glossary( u );
571
    // 	g->setName( i18n( "Knowledge" ) );
572 573
    // 	dlg->addGlossary( g );
    // 	dlg->show();
574 575
}

576 577
void KStars::slotScriptBuilder()
{
578 579
    if (!m_ScriptBuilder)
        m_ScriptBuilder = new ScriptBuilder(this);
580
    m_ScriptBuilder->show();
581
}
582

583 584
void KStars::slotSolarSystem()
{
585 586
    if (!m_PlanetViewer)
        m_PlanetViewer = new PlanetViewer(this);
587
    m_PlanetViewer->show();
588
}
Akarsh Simha's avatar
Akarsh Simha committed
589
/*
590
void KStars::slotJMoonTool() {
Jasem Mutlaq's avatar
Jasem Mutlaq committed
591 592
    if ( ! m_JMoonTool ) m_JMoonTool = new JMoonTool(this);
    m_JMoonTool->show();
593
}
Akarsh Simha's avatar
Akarsh Simha committed
594
*/
595

596 597
void KStars::slotMoonPhaseTool()
{
598 599 600
    //FIXME Port to KF5
    //if( ! mpt ) mpt = new MoonPhaseTool( this );
    //mpt->show();
601 602
}

603 604
void KStars::slotFlagManager()
{
605 606
    if (!m_FlagManager)
        m_FlagManager = new FlagManager(this);
607
    m_FlagManager->show();
608 609
}

610 611
void KStars::slotTelescopeWizard()
{
Jasem Mutlaq's avatar
Jasem Mutlaq committed
612
#ifdef HAVE_INDI
613
#ifndef Q_OS_WIN
Robert Lancaster's avatar
Robert Lancaster committed
614

615
    QString indiServerDir = Options::indiServer();
Robert Lancaster's avatar
Robert Lancaster committed
616

617
#ifdef Q_OS_OSX
618 619
    if (Options::indiServerIsInternal())
        indiServerDir = QCoreApplication::applicationDirPath() + "/indi";
620
    else
621
        indiServerDir = QFileInfo(Options::indiServer()).dir().path();
622
#endif
Robert Lancaster's avatar
Robert Lancaster committed
623 624

    QStringList paths;
625 626
    paths << "/usr/bin"
          << "/usr/local/bin" << indiServerDir;
Robert Lancaster's avatar
Robert Lancaster committed
627

Jasem Mutlaq's avatar
Jasem Mutlaq committed
628
    if (QStandardPaths::findExecutable("indiserver").isEmpty())
629
    {
630
        if (QStandardPaths::findExecutable("indiserver", paths).isEmpty())
631
        {
632 633
            KMessageBox::error(nullptr, i18n("Unable to find INDI server. Please make sure the package that provides "
                                             "the 'indiserver' binary is installed."));
Robert Lancaster's avatar
Robert Lancaster committed
634 635
            return;
        }
636
    }
637
#endif
638

639 640 641
    QPointer<telescopeWizardProcess> twiz = new telescopeWizardProcess(this);
    twiz->exec();
    delete twiz;
642
#endif
643 644
}

645
void KStars::slotINDIPanel()
646
{
Jasem Mutlaq's avatar
Jasem Mutlaq committed
647
#ifdef HAVE_INDI
648
#ifndef Q_OS_WIN
Robert Lancaster's avatar
Robert Lancaster committed
649

650
    QString indiServerDir = Options::indiServer();
Robert Lancaster's avatar
Robert Lancaster committed
651

652
#ifdef Q_OS_OSX
653 654
    if (Options::indiServerIsInternal())
        indiServerDir = QCoreApplication::applicationDirPath() + "/indi";
655
    else
656
        indiServerDir = QFileInfo(Options::indiServer()).dir().path();
657
#endif
Robert Lancaster's avatar
Robert Lancaster committed
658 659

    QStringList paths;
660 661
    paths << "/usr/bin"
          << "/usr/local/bin" << indiServerDir;
Robert Lancaster's avatar
Robert Lancaster committed
662

Jasem Mutlaq's avatar
Jasem Mutlaq committed
663
    if (QStandardPaths::findExecutable("indiserver").isEmpty())
664
    {
665
        if (QStandardPaths::findExecutable("indiserver", paths).isEmpty())
666
        {
667 668
            KMessageBox::error(nullptr, i18n("Unable to find INDI server. Please make sure the package that provides "
                                             "the 'indiserver' binary is installed."));
Robert Lancaster's avatar
Robert Lancaster committed
669 670
            return;
        }
671
    }
672
#endif
Jasem Mutlaq's avatar
Jasem Mutlaq committed
673
    GUIManager::Instance()->updateStatus();
674
#endif
675 676
}

677
void KStars::slotINDIDriver()
678
{
Jasem Mutlaq's avatar
Jasem Mutlaq committed
679
#ifdef HAVE_INDI
680
#ifndef Q_OS_WIN
Robert Lancaster's avatar
Robert Lancaster committed
681

682
    QString indiServerDir = Options::indiServer();
Robert Lancaster's avatar
Robert Lancaster committed
683

684
#ifdef Q_OS_OSX
685 686
    if (Options::indiServerIsInternal())
        indiServerDir = QCoreApplication::applicationDirPath() + "/indi";
687
    else
688
        indiServerDir = QFileInfo(Options::indiServer()).dir().path();
689
#endif
Robert Lancaster's avatar
Robert Lancaster committed
690 691

    QStringList paths;
692 693
    paths << "/usr/bin"
          << "/usr/local/bin" << indiServerDir;
Robert Lancaster's avatar
Robert Lancaster committed
694

Jasem Mutlaq's avatar
Jasem Mutlaq committed
695
    if (QStandardPaths::findExecutable("indiserver").isEmpty())
696
    {
697
        if (QStandardPaths::findExecutable("indiserver", paths).isEmpty())
698
        {
699 700
            KMessageBox::error(nullptr, i18n("Unable to find INDI server. Please make sure the package that provides "
                                             "the 'indiserver' binary is installed."));
Robert Lancaster's avatar
Robert Lancaster committed
701 702
            return;
        }
703
    }
704
#endif
705

706 707 708 709
    DriverManager::Instance()->raise();
    DriverManager::Instance()->activateWindow();
    DriverManager::Instance()->showNormal();

710
#endif
711 712
}

713 714
void KStars::slotEkos()
{
Jasem Mutlaq's avatar
Jasem Mutlaq committed
715 716
#ifdef HAVE_CFITSIO
#ifdef HAVE_INDI
717

718
#ifndef Q_OS_WIN
Robert Lancaster's avatar
Robert Lancaster committed
719

720
    QString indiServerDir = Options::indiServer();
Robert Lancaster's avatar
Robert Lancaster committed
721

722
#ifdef Q_OS_OSX
723 724
    if (Options::indiServerIsInternal())
        indiServerDir = QCoreApplication::applicationDirPath() + "/indi";
725
    else
726
        indiServerDir = QFileInfo(Options::indiServer()).dir().path();
727
#endif
Robert Lancaster's avatar
Robert Lancaster committed
728 729

    QStringList paths;
730 731
    paths << "/usr/bin"
          << "/usr/local/bin" << indiServerDir;
Robert Lancaster's avatar
Robert Lancaster committed
732

Jasem Mutlaq's avatar
Jasem Mutlaq committed
733
    if (QStandardPaths::findExecutable("indiserver").isEmpty())
734
    {
735
        if (QStandardPaths::findExecutable("indiserver", paths).isEmpty())
736
        {
737 738
            KMessageBox::error(nullptr, i18n("Unable to find INDI server. Please make sure the package that provides "
                                             "the 'indiserver' binary is installed."));
Robert Lancaster's avatar
Robert Lancaster committed
739 740
            return;
        }
741
    }
742
#endif
743

744 745 746
    ekosManager()->raise();
    ekosManager()->activateWindow();
    ekosManager()->showNormal();
747 748

#endif
Jasem Mutlaq's avatar