Kstars

opsfits.cpp
1 /*
2  SPDX-FileCopyrightText: 2017 Jasem Mutlaq <[email protected]>
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 
13 #ifdef HAVE_STELLARSOLVER
14 #include "kspaths.h"
15 #include "ekos/auxiliary/stellarsolverprofile.h"
16 #include <stellarsolver.h>
17 #endif
18 
19 OpsFITS::OpsFITS() : QFrame(KStars::Instance())
20 {
21  setupUi(this);
22 
23  connect(kcfg_LimitedResourcesMode, &QCheckBox::toggled, this, [this](bool toggled)
24  {
25  if (toggled)
26  {
27  kcfg_Auto3DCube->setChecked(false);
28  kcfg_AutoDebayer->setChecked(false);
29  kcfg_AutoWCS->setChecked(false);
30  }
31  });
32  connect(kcfg_Auto3DCube, &QCheckBox::toggled, this, [this](bool toggled)
33  {
34  if (toggled)
35  kcfg_LimitedResourcesMode->setChecked(false);
36  });
37  connect(kcfg_AutoDebayer, &QCheckBox::toggled, this, [this](bool toggled)
38  {
39  if (toggled)
40  kcfg_LimitedResourcesMode->setChecked(false);
41  });
42  connect(kcfg_AutoWCS, &QCheckBox::toggled, this, [this](bool toggled)
43  {
44  if (toggled)
45  kcfg_LimitedResourcesMode->setChecked(false);
46  });
47 #ifdef HAVE_STELLARSOLVER
48  setupHFROptions();
49 #else
50  editHfrProfile->setEnabled(false);
51  HfrOptionsProfiles->setEnabled(false);
52 #endif
53 }
54 
55 #ifdef HAVE_STELLARSOLVER
56 
57 void OpsFITS::loadStellarSolverProfiles()
58 {
59  QString savedOptionsProfiles = QDir(KSPaths::writableLocation(QStandardPaths::AppLocalDataLocation)).filePath("SavedHFRProfiles.ini");
60  if(QFile(savedOptionsProfiles).exists())
61  m_StellarSolverProfiles = StellarSolver::loadSavedOptionsProfiles(savedOptionsProfiles);
62  else
63  m_StellarSolverProfiles = Ekos::getDefaultHFROptionsProfiles();
64  HfrOptionsProfiles->clear();
65  for(auto param : m_StellarSolverProfiles)
66  HfrOptionsProfiles->addItem(param.listName);
67  HfrOptionsProfiles->setCurrentIndex(Options::hFROptionsProfile());
68 }
69 
70 void OpsFITS::setupHFROptions()
71 {
72  editHfrProfile->setEnabled(true);
73  HfrOptionsProfiles->setEnabled(true);
74 
75  editHfrProfile->setIcon(QIcon::fromTheme("document-edit"));
76  editHfrProfile->setAttribute(Qt::WA_LayoutUsesWidgetRect);
77 
78  connect(editHfrProfile, &QAbstractButton::clicked, this, [this]()
79  {
80  KConfigDialog *optionsEditor = new KConfigDialog(this, "OptionsProfileEditor", Options::self());
81  optionsProfileEditor = new Ekos::StellarSolverProfileEditor(this, Ekos::HFRProfiles, optionsEditor);
82 #ifdef Q_OS_OSX
84 #endif
85  KPageWidgetItem *mainPage = optionsEditor->addPage(optionsProfileEditor, i18n("HFR Options Profile Editor"));
86  mainPage->setIcon(QIcon::fromTheme("configure"));
87  connect(optionsProfileEditor, &Ekos::StellarSolverProfileEditor::optionsProfilesUpdated, this,
88  &OpsFITS::loadStellarSolverProfiles);
89  optionsProfileEditor->loadProfile(HfrOptionsProfiles->currentIndex());
90  optionsEditor->show();
91  });
92 
93  loadStellarSolverProfiles();
94 
95  connect(HfrOptionsProfiles, QOverload<int>::of(&QComboBox::activated), this, [](int index)
96  {
97  Options::setHFROptionsProfile(index);
98  });
99 }
100 
101 #endif
void clicked(bool checked)
QIcon fromTheme(const QString &name)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void toggled(bool checked)
void setIcon(const QIcon &icon)
QString i18n(const char *text, const TYPE &arg...)
void setWindowFlags(Qt::WindowFlags type)
KPageWidgetItem * addPage(QWidget *page, const QString &itemName, const QString &pixmapName=QString(), const QString &header=QString(), bool manage=true)
This is the main window for KStars. In addition to the GUI elements, the class contains the program c...
Definition: kstars.h:92
void setupUi(QWidget *widget)
void show()
QString filePath(const QString &fileName) const const
void activated(int index)
WA_LayoutUsesWidgetRect
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Aug 15 2022 04:04:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.