Kstars

opsimageoverlay.cpp
1/*
2 SPDX-FileCopyrightText: 2023 Hy Murveit <hy@murveit.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "opsimageoverlay.h"
8
9#include "ekos/auxiliary/stellarsolverprofileeditor.h"
10#include "ksfilereader.h"
11#include "kspaths.h"
12#include "kstars.h"
13#include "kstarsdata.h"
14#include "Options.h"
15#include "skymap.h"
16#include "skycomponents/skymapcomposite.h"
17#include "skycomponents/imageoverlaycomponent.h"
18
19#include <KConfigDialog>
20
21#include <QPushButton>
22#include <QFileDialog>
23#include <QPushButton>
24#include <QDesktopServices>
25
26OpsImageOverlay::OpsImageOverlay() : QFrame(KStars::Instance())
27{
28 setupUi(this);
29
30 m_ConfigDialog = KConfigDialog::exists("settings");
31
32 connect(m_ConfigDialog->button(QDialogButtonBox::Apply), SIGNAL(clicked()), SLOT(slotApply()));
33 connect(m_ConfigDialog->button(QDialogButtonBox::Ok), SIGNAL(clicked()), SLOT(slotApply()));
34
35 ImageOverlayComponent *overlayComponent = dynamic_cast<ImageOverlayComponent*>(
36 KStarsData::Instance()->skyComposite()->imageOverlay());
37 connect(solveButton, &QPushButton::clicked, overlayComponent, &ImageOverlayComponent::startSolving,
39 connect(refreshB, &QPushButton::clicked, overlayComponent, &ImageOverlayComponent::reload,
41 connect(kcfg_ShowImageOverlays, &QCheckBox::stateChanged, [](int state)
42 {
43 Options::setShowImageOverlays(state);
44 });
45 connect(kcfg_ShowSelectedImageOverlay, &QCheckBox::stateChanged, [](int state)
46 {
47 Options::setShowSelectedImageOverlay(state);
48 });
49 connect(kcfg_ShowImageOverlaysBelowCatalogs, &QCheckBox::stateChanged, [](int state)
50 {
51 Options::setShowImageOverlaysBelowCatalogs(state);
52 });
53 connect(kcfg_ImageOverlayMaxDimension, QOverload<int>::of(&QSpinBox::valueChanged), [](int value)
54 {
55 Options::setImageOverlayMaxDimension(value);
56 });
57 connect(kcfg_ImageOverlayTimeout, QOverload<int>::of(&QSpinBox::valueChanged), [](int value)
58 {
59 Options::setImageOverlayTimeout(value);
60 });
61 connect(kcfg_ImageOverlayDefaultScale, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [](double value)
62 {
63 Options::setImageOverlayDefaultScale(value);
64 });
65 connect(imageOverlayShowDirButton, &QPushButton::clicked, []()
66 {
67 QDesktopServices::openUrl(QUrl::fromLocalFile(QDir(KSPaths::writableLocation(
68 QStandardPaths::AppLocalDataLocation)).filePath("imageOverlays")));
69 });
70
71 editAlignProfile->setIcon(QIcon::fromTheme("document-edit"));
72 editAlignProfile->setAttribute(Qt::WA_LayoutUsesWidgetRect);
73
74 KConfigDialog * m_EditorDialog = new KConfigDialog(this, "imageOverlayProfileEditor", Options::self());
75 m_ProfileEditor.reset(new Ekos::StellarSolverProfileEditor(this, Ekos::AlignProfiles, m_EditorDialog));
76 KPageWidgetItem *page = m_EditorDialog->addPage(m_ProfileEditor.get(), i18n("Image Overlay Align Options Profiles Editor"));
77
78 connect(editAlignProfile, &QAbstractButton::clicked, this, [this, page]
79 {
80 m_ProfileEditor->loadProfile(imageOverlaySolverProfile->currentText());
81 KConfigDialog * d = KConfigDialog::exists("imageOverlayProfileEditor");
82 if(d)
83 {
84 d->setCurrentPage(page);
85 d->show();
86 }
87 });
88
89 syncOptions();
90}
91
92QTableWidget *OpsImageOverlay::table ()
93{
94 return imageOverlayTable;
95}
96
97QGroupBox *OpsImageOverlay::tableTitleBox()
98{
99 return ImageOverlayTableBox;
100}
101
102QPlainTextEdit *OpsImageOverlay::statusDisplay ()
103{
104 return imageOverlayStatus;
105}
106
107QPushButton *OpsImageOverlay::solvePushButton ()
108{
109 return solveButton;
110}
111QComboBox *OpsImageOverlay::solverProfile ()
112{
113 return imageOverlaySolverProfile;
114}
115
116void OpsImageOverlay::syncOptions()
117{
118 kcfg_ShowImageOverlays->setChecked(Options::showImageOverlays());
119 kcfg_ImageOverlayMaxDimension->setValue(Options::imageOverlayMaxDimension());
120 kcfg_ImageOverlayTimeout->setValue(Options::imageOverlayTimeout());
121 kcfg_ImageOverlayDefaultScale->setValue(Options::imageOverlayDefaultScale());
122}
123
124void OpsImageOverlay::slotApply()
125{
126 KStarsData *data = KStarsData::Instance();
127 SkyMap *map = SkyMap::Instance();
128
129 data->setFullTimeUpdate();
131 map->forceUpdate();
132}
Represents the ImageOverlay overlay.
KPageWidgetItem * addPage(QWidget *page, const QString &itemName, const QString &pixmapName=QString(), const QString &header=QString(), bool manage=true)
static KConfigDialog * exists(const QString &name)
KStarsData is the backbone of KStars.
Definition kstarsdata.h:74
void setFullTimeUpdate()
The Sky is updated more frequently than the moon, which is updated more frequently than the planets.
SkyMapComposite * skyComposite()
Definition kstarsdata.h:168
This is the main window for KStars.
Definition kstars.h:89
static KStars * Instance()
Definition kstars.h:121
void updateTime(const bool automaticDSTchange=true)
Update time-dependent data and (possibly) repaint the sky map.
Definition kstars.cpp:592
This is the canvas on which the sky is painted.
Definition skymap.h:54
QString i18n(const char *text, const TYPE &arg...)
void clicked(bool checked)
void stateChanged(int state)
bool openUrl(const QUrl &url)
void valueChanged(double d)
QIcon fromTheme(const QString &name)
void valueChanged(int i)
UniqueConnection
WA_LayoutUsesWidgetRect
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QUrl fromLocalFile(const QString &localFile)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.