Kstars

opsguides.cpp
1/*
2 SPDX-FileCopyrightText: 2005 Jason Harris <jharris@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "opsguides.h"
8
9#include "ksfilereader.h"
10#include "kstars.h"
11#include "kstarsdata.h"
12#include "Options.h"
13#include "skymap.h"
14#include "skycomponents/skymapcomposite.h"
15#include "auxiliary/kspaths.h"
16
17#include <KConfigDialog>
18
19#include <QPushButton>
20#include <QFileDialog>
21
22OpsGuides::OpsGuides() : QFrame(KStars::Instance())
23{
24 setupUi(this);
25
26 foreach (const QString &item, KStarsData::Instance()->skyComposite()->getCultureNames())
27 SkyCultureComboBox->addItem(i18nc("Sky Culture", item.toUtf8().constData()));
28
29 m_ConfigDialog = KConfigDialog::exists("settings");
30
31 connect(m_ConfigDialog->button(QDialogButtonBox::Apply), SIGNAL(clicked()), SLOT(slotApply()));
32 connect(m_ConfigDialog->button(QDialogButtonBox::Ok), SIGNAL(clicked()), SLOT(slotApply()));
33
34 // When setting up the widget, update the enabled status of the
35 // checkboxes depending on the options.
36 slotToggleOpaqueGround(Options::showGround());
37 slotToggleConstellOptions(Options::showCNames());
38 slotToggleConstellationArt(Options::showConstellationArt());
39 slotToggleMilkyWayOptions(Options::showMilkyWay());
40 slotToggleAutoSelectGrid(Options::autoSelectGrid());
41 SkyCultureComboBox->setCurrentIndex(KStarsData::Instance()->skyComposite()->getCultureNames().indexOf(
42 Options::skyCulture()));
43
44 connect(kcfg_ShowCNames, SIGNAL(toggled(bool)), this, SLOT(slotToggleConstellOptions(bool)));
45 connect(kcfg_ShowConstellationArt, SIGNAL(toggled(bool)), this, SLOT(slotToggleConstellationArt(bool)));
46 connect(kcfg_ShowMilkyWay, SIGNAL(toggled(bool)), this, SLOT(slotToggleMilkyWayOptions(bool)));
47 connect(kcfg_ShowGround, SIGNAL(toggled(bool)), this, SLOT(slotToggleOpaqueGround(bool)));
48 connect(kcfg_AutoSelectGrid, SIGNAL(toggled(bool)), this, SLOT(slotToggleAutoSelectGrid(bool)));
49
50 // Track changes to apply settings
51 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
53 [&]()
54 {
55 isDirty = true;
56 });
57 connect(nameButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonPressed), this,
58 [&]()
59 {
60 isDirty = true;
61 });
62 #else
63 connect(constellationButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::idPressed), this,
64 [&]()
65 {
66 isDirty = true;
67 });
68 connect(nameButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::idPressed), this,
69 [&]()
70 {
71 isDirty = true;
72 });
73 #endif
74 connect(SkyCultureComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this,
75 [&]()
76 {
77 Options::setSkyCulture(KStarsData::Instance()->skyComposite()->getCultureName(SkyCultureComboBox->currentIndex()));
78 isDirty = true;
79 });
80
81 isDirty = false;
82
83}
84
85void OpsGuides::slotToggleConstellOptions(bool state)
86{
87 ConstellOptions->setEnabled(state);
88}
89
90void OpsGuides::slotToggleConstellationArt(bool state)
91{
92 kcfg_ShowConstellationArt->setEnabled(state);
93}
94
95void OpsGuides::slotToggleMilkyWayOptions(bool state)
96{
97 kcfg_FillMilkyWay->setEnabled(state);
98}
99
100void OpsGuides::slotToggleOpaqueGround(bool state)
101{
102 kcfg_ShowHorizon->setEnabled(!state);
103}
104
105void OpsGuides::slotToggleAutoSelectGrid(bool state)
106{
107 kcfg_ShowEquatorialGrid->setEnabled(!state);
108 kcfg_ShowHorizontalGrid->setEnabled(!state);
109}
110
111void OpsGuides::slotApply()
112{
113 if (isDirty == false)
114 return;
115
116 isDirty = false;
117
118 KStarsData *data = KStarsData::Instance();
119 SkyMap *map = SkyMap::Instance();
120
121 // If the focus object was a constellation and the sky culture has changed, remove the focus object
122 if (map->focusObject() && map->focusObject()->type() == SkyObject::CONSTELLATION)
123 {
124 if (data->skyComposite()->currentCulture() !=
125 data->skyComposite()->getCultureName(SkyCultureComboBox->currentIndex()) ||
126 data->skyComposite()->isLocalCNames() != Options::useLocalConstellNames())
127 {
128 map->setClickedObject(nullptr);
129 map->setFocusObject(nullptr);
130 }
131 }
132
133 data->skyComposite()->setCurrentCulture(
134 KStarsData::Instance()->skyComposite()->getCultureName(SkyCultureComboBox->currentIndex()));
135 data->skyComposite()->reloadCLines();
136 data->skyComposite()->reloadCNames();
137 data->skyComposite()->reloadConstellationArt();
138
139 data->setFullTimeUpdate();
140 KStars::Instance()->updateTime();
141 map->forceUpdate();
142}
static KConfigDialog * exists(const QString &name)
KStarsData is the backbone of KStars.
Definition kstarsdata.h:72
void setFullTimeUpdate()
The Sky is updated more frequently than the moon, which is updated more frequently than the planets.
SkyMapComposite * skyComposite()
Definition kstarsdata.h:166
This is the main window for KStars.
Definition kstars.h:91
static KStars * Instance()
Definition kstars.h:123
This is the canvas on which the sky is painted.
Definition skymap.h:54
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void buttonPressed(QAbstractButton *button)
void idPressed(int id)
const char * constData() const const
void activated(int index)
QByteArray toUtf8() const const
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:48:27 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.