Kstars

opsguide.cpp
1/*
2 SPDX-FileCopyrightText: 2003 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "opsguide.h"
8
9#include "Options.h"
10#include "kstars.h"
11#include "auxiliary/ksnotification.h"
12#include "internalguide/internalguider.h"
13#include "ekos/auxiliary/stellarsolverprofileeditor.h"
14#include "kspaths.h"
15
16#include <KConfigDialog>
17
18#include <QCheckBox>
19#include <QComboBox>
20#include <QFileDialog>
21#include <QPushButton>
22#include <QStringList>
23
24namespace Ekos
25{
26OpsGuide::OpsGuide() : QFrame(KStars::Instance())
27{
28 setupUi(this);
29
30 //Get a pointer to the KConfigDialog
31 m_ConfigDialog = KConfigDialog::exists("guidesettings");
32
33 editGuideProfile->setIcon(QIcon::fromTheme("document-edit"));
34 editGuideProfile->setAttribute(Qt::WA_LayoutUsesWidgetRect);
35
36 if (Options::gPGEnabled())
37 {
38 // this option is an old one. Allowing users who have this set to keep their setting.
39 Options::setGPGEnabled(false);
40 Options::setRAGuidePulseAlgorithm(GPG_ALGORITHM);
41 kcfg_RAGuidePulseAlgorithm->setCurrentIndex(static_cast<int>(GPG_ALGORITHM));
42 }
43
44
45 connect(editGuideProfile, &QAbstractButton::clicked, this, [this]()
46 {
47 KConfigDialog *optionsEditor = new KConfigDialog(this, "OptionsProfileEditor", Options::self());
48 optionsProfileEditor = new StellarSolverProfileEditor(this, Ekos::GuideProfiles, optionsEditor);
49#ifdef Q_OS_MACOS
51#endif
52 KPageWidgetItem *mainPage = optionsEditor->addPage(optionsProfileEditor, i18n("Guide Options Profile Editor"));
53 mainPage->setIcon(QIcon::fromTheme("configure"));
54 connect(optionsProfileEditor, &StellarSolverProfileEditor::optionsProfilesUpdated, this, &OpsGuide::loadOptionsProfiles);
55 optionsProfileEditor->loadProfile(kcfg_GuideOptionsProfile->currentText());
56 optionsEditor->show();
57 });
58
59 loadOptionsProfiles();
60
61 connect(m_ConfigDialog, &KConfigDialog::settingsChanged, this, &OpsGuide::settingsUpdated);
62}
63
64void OpsGuide::setRAGuidePulseAlg(int index)
65{
66
67 switch (index)
68 {
69 case STANDARD_ALGORITHM:
70 kcfg_RAHysteresis->setDisabled(true);
71 kcfg_RAIntegralGain->setDisabled(false);
72 break;
73 case HYSTERESIS_ALGORITHM:
74 kcfg_RAHysteresis->setDisabled(false);
75 kcfg_RAIntegralGain->setDisabled(true);
76 break;
77 case LINEAR_ALGORITHM:
78 kcfg_RAHysteresis->setDisabled(true);
79 kcfg_RAIntegralGain->setDisabled(true);
80 break;
81 case GPG_ALGORITHM:
82 kcfg_RAHysteresis->setDisabled(true);
83 kcfg_RAIntegralGain->setDisabled(true);
84 break;
85 default:
86 kcfg_RAHysteresis->setDisabled(false);
87 kcfg_RAIntegralGain->setDisabled(false);
88 break;
89 }
90}
91
92void OpsGuide::setDECGuidePulseAlg(int index)
93{
94 switch (index)
95 {
96 case STANDARD_ALGORITHM:
97 kcfg_DECHysteresis->setDisabled(true);
98 kcfg_DECIntegralGain->setDisabled(false);
99 break;
100 case HYSTERESIS_ALGORITHM:
101 kcfg_DECHysteresis->setDisabled(false);
102 kcfg_DECIntegralGain->setDisabled(true);
103 break;
104 case LINEAR_ALGORITHM:
105 kcfg_DECHysteresis->setDisabled(true);
106 kcfg_DECIntegralGain->setDisabled(true);
107 break;
108 default:
109 kcfg_DECHysteresis->setDisabled(false);
110 kcfg_DECIntegralGain->setDisabled(false);
111 break;
112 }
113}
114
115void OpsGuide::loadOptionsProfiles()
116{
117 QString savedOptionsProfiles = QDir(KSPaths::writableLocation(
118 QStandardPaths::AppLocalDataLocation)).filePath("SavedGuideProfiles.ini");
119 if(QFile(savedOptionsProfiles).exists())
120 optionsList = StellarSolver::loadSavedOptionsProfiles(savedOptionsProfiles);
121 else
122 optionsList = getDefaultGuideOptionsProfiles();
123 kcfg_GuideOptionsProfile->clear();
124 for(SSolver::Parameters param : optionsList)
125 kcfg_GuideOptionsProfile->addItem(param.listName);
126 kcfg_GuideOptionsProfile->setCurrentIndex(Options::guideOptionsProfile());
127}
128}
KPageWidgetItem * addPage(QWidget *page, const QString &itemName, const QString &pixmapName=QString(), const QString &header=QString(), bool manage=true)
static KConfigDialog * exists(const QString &name)
void settingsChanged(const QString &dialogName)
void setIcon(const QIcon &icon)
QString i18n(const char *text, const TYPE &arg...)
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:83
void clicked(bool checked)
QString filePath(const QString &fileName) const const
QIcon fromTheme(const QString &name)
WA_LayoutUsesWidgetRect
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void show()
void setWindowFlags(Qt::WindowFlags type)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Apr 25 2025 11:58:35 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.