opsekos.cpp 2.63 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
/*  INDI Options
    Copyright (C) 2003 Jasem Mutlaq (mutlaqja@ikarustech.com)

    This application 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.
    
 */

Jasem Mutlaq's avatar
Jasem Mutlaq committed
11
#include <QPushButton>
Jasem Mutlaq's avatar
Jasem Mutlaq committed
12
#include <QFileDialog>
13
14
15
16
#include <QCheckBox>
#include <QStringList>
#include <QComboBox>

Jasem Mutlaq's avatar
Jasem Mutlaq committed
17
#include <KConfigDialog>
18

Jasem Mutlaq's avatar
Jasem Mutlaq committed
19
20
#include "opsekos.h"
#include "Options.h"
21
#include "kstarsdata.h"
22
#include "ekosmanager.h"
23
#include "guide.h"
24

25
OpsEkos::OpsEkos()
26
        : QTabWidget( KStars::Instance() )
27
28
29
30
31
32
{
    setupUi(this);
    
    //Get a pointer to the KConfigDialog
    m_ConfigDialog = KConfigDialog::exists( "settings" );

33
34
    selectPHD2B->setIcon(QIcon::fromTheme("document-open"));

Jasem Mutlaq's avatar
Jasem Mutlaq committed
35
36
37
    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() ) );
38
    connect( selectPHD2B, SIGNAL(clicked()), this, SLOT(slotSelectPHD2Exec()));
39
    connect( kcfg_UseEkosGuider, SIGNAL(toggled(bool)), this, SLOT(slotCheckGuideModule()));
40

41
42
43
44
45
46
47
}


OpsEkos::~OpsEkos() {}

void OpsEkos::slotApply()
{
48
    EkosManager *ekosManager = KStars::Instance()->ekosManager();
49

50
    if (ekosManager)
51
    {
52
        //ekosManager->refreshRemoteDrivers();
53
54
55
56
57
58

        Ekos::Guide *guideModule = ekosManager->guideModule();

        if (guideModule)
            guideModule->setGuiderProcess(kcfg_UseEkosGuider->isChecked() ? Ekos::Guide::GUIDE_INTERNAL : Ekos::Guide::GUIDE_PHD2);
    }
59
60
61
62
}

void OpsEkos::slotCancel()
{
63
}
64

65
66
67
68
69
70
71
72
73
void OpsEkos::slotSelectPHD2Exec()
{
    QUrl phd2URL = QFileDialog::getOpenFileUrl(this, i18n("Select PHD2 Executable"));
    if (phd2URL.isEmpty())
        return;

    kcfg_PHD2Exec->setText(phd2URL.path());
}

74
75
76
void OpsEkos::slotCheckGuideModule()
{
    EkosManager *ekosManager = KStars::Instance()->ekosManager();
77

78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
    if (ekosManager)
    {
        Ekos::Guide *guideModule = ekosManager->guideModule();

        if (guideModule == NULL)
            return;

        if (guideModule->isCalibrating() || guideModule->isGuiding())
        {
           kcfg_UseEkosGuider->disconnect();
           kcfg_UseEkosGuider->setChecked(!kcfg_UseEkosGuider->isChecked());
           connect( kcfg_UseEkosGuider, SIGNAL(toggled(bool)), this, SLOT(slotCheckGuideModule()));

           KMessageBox::error(KStars::Instance(), i18n("Cannot change guider while guiding process is busy."));
        }
    }
}