Kstars

opsfits.cpp
1/*
2 SPDX-FileCopyrightText: 2017 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "opsfits.h"
8
9#include "Options.h"
10#include "kstars.h"
11#include "kstarsdata.h"
12#include "fitscommon.h"
13
14
15#ifdef HAVE_STELLARSOLVER
16#include "kspaths.h"
17#include "ekos/auxiliary/stellarsolverprofile.h"
18#include <stellarsolver.h>
19#endif
20
21OpsFITS::OpsFITS() : QFrame(KStars::Instance())
22{
23 setupUi(this);
24
25 connect(kcfg_LimitedResourcesMode, &QCheckBox::toggled, this, [this](bool toggled)
26 {
27 if (toggled)
28 {
29 kcfg_Auto3DCube->setChecked(false);
30 kcfg_AutoDebayer->setChecked(false);
31 kcfg_AutoWCS->setChecked(false);
32 kcfg_FitsCatalog->setCurrentIndex(CAT_SKYMAP);
33 }
34 });
35 connect(kcfg_Auto3DCube, &QCheckBox::toggled, this, [this](bool toggled)
36 {
37 if (toggled)
38 kcfg_LimitedResourcesMode->setChecked(false);
39 });
40 connect(kcfg_AutoDebayer, &QCheckBox::toggled, this, [this](bool toggled)
41 {
42 if (toggled)
43 kcfg_LimitedResourcesMode->setChecked(false);
44 });
45 connect(kcfg_AutoWCS, &QCheckBox::toggled, this, [this](bool toggled)
46 {
47 if (toggled)
48 kcfg_LimitedResourcesMode->setChecked(false);
49 });
50 connect(kcfg_FitsCatalog, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int index)
51 {
52 Options::setFitsCatalog(index);
53 if (index != CAT_SKYMAP)
54 kcfg_LimitedResourcesMode->setChecked(false);
55 });
56 hipsOpacity->setValue(Options::hIPSOpacity() * 100);
57 connect(hipsOpacity, &QSlider::valueChanged, this, [](int value)
58 {
59 Options::setHIPSOpacity(value / 100.0);
60 });
61 hipsOffsetX->setValue(Options::hIPSOffsetX());
62 connect(hipsOffsetX, QOverload<int>::of(&QSpinBox::valueChanged), this, [](int value)
63 {
64 Options::setHIPSOffsetX(value);
65 });
66 connect(hipsOffsetY, QOverload<int>::of(&QSpinBox::valueChanged), this, [](int value)
67 {
68 Options::setHIPSOffsetY(value);
69 });
70
71#ifdef HAVE_STELLARSOLVER
72 setupHFROptions();
73#else
74 editHfrProfile->setEnabled(false);
75 HfrOptionsProfiles->setEnabled(false);
76#endif
77}
78
79#ifdef HAVE_STELLARSOLVER
80
81void OpsFITS::loadStellarSolverProfiles()
82{
83 QString savedOptionsProfiles = QDir(KSPaths::writableLocation(
84 QStandardPaths::AppLocalDataLocation)).filePath("SavedHFRProfiles.ini");
85 if(QFile(savedOptionsProfiles).exists())
86 m_StellarSolverProfiles = StellarSolver::loadSavedOptionsProfiles(savedOptionsProfiles);
87 else
88 m_StellarSolverProfiles = Ekos::getDefaultHFROptionsProfiles();
89 HfrOptionsProfiles->clear();
90 for(auto param : m_StellarSolverProfiles)
91 HfrOptionsProfiles->addItem(param.listName);
92 HfrOptionsProfiles->setCurrentIndex(Options::hFROptionsProfile());
93}
94
95void OpsFITS::setupHFROptions()
96{
97 editHfrProfile->setEnabled(true);
98 HfrOptionsProfiles->setEnabled(true);
99
100 editHfrProfile->setIcon(QIcon::fromTheme("document-edit"));
101 editHfrProfile->setAttribute(Qt::WA_LayoutUsesWidgetRect);
102
103 connect(editHfrProfile, &QAbstractButton::clicked, this, [this]()
104 {
105 KConfigDialog *optionsEditor = new KConfigDialog(this, "OptionsProfileEditor", Options::self());
106 optionsProfileEditor = new Ekos::StellarSolverProfileEditor(this, Ekos::HFRProfiles, optionsEditor);
107#ifdef Q_OS_MACOS
109#endif
110 KPageWidgetItem *mainPage = optionsEditor->addPage(optionsProfileEditor, i18n("HFR Options Profile Editor"));
111 mainPage->setIcon(QIcon::fromTheme("configure"));
112 connect(optionsProfileEditor, &Ekos::StellarSolverProfileEditor::optionsProfilesUpdated, this,
113 &OpsFITS::loadStellarSolverProfiles);
114 optionsProfileEditor->loadProfile(HfrOptionsProfiles->currentText());
115 optionsEditor->show();
116 });
117
118 loadStellarSolverProfiles();
119
120 connect(HfrOptionsProfiles, QOverload<int>::of(&QComboBox::activated), this, [](int index)
121 {
122 Options::setHFROptionsProfile(index);
123 });
124}
125
126#endif
KPageWidgetItem * addPage(QWidget *page, const QString &itemName, const QString &pixmapName=QString(), const QString &header=QString(), bool manage=true)
void setIcon(const QIcon &icon)
This is the main window for KStars.
Definition kstars.h:89
QString i18n(const char *text, const TYPE &arg...)
void clicked(bool checked)
void toggled(bool checked)
void valueChanged(int value)
void activated(int index)
void currentIndexChanged(int index)
QString filePath(const QString &fileName) const const
QIcon fromTheme(const QString &name)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void valueChanged(int i)
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-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.