• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Stellarium / stellarium / 6685397774

29 Oct 2023 07:37PM UTC coverage: 11.735% (-0.002%) from 11.737%
6685397774

push

github

10110111
Deduplicate title bar implementation

131 of 131 new or added lines in 56 files covered. (100.0%)

14842 of 126472 relevant lines covered (11.74%)

21617.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/plugins/MeteorShowers/src/gui/MSConfigDialog.cpp
1
/*
2
 * Stellarium: Meteor Showers Plug-in
3
 * Copyright (C) 2013-2015 Marcos Cardinot
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
18
*/
19

20
#include <QColorDialog>
21

22
#include "MSConfigDialog.hpp"
23
#include "StelApp.hpp"
24
#include "StelGui.hpp"
25
#include "StelModuleMgr.hpp"
26
#include "StelTranslator.hpp"
27
#include "ui_MSConfigDialog.h"
28

29
MSConfigDialog::MSConfigDialog(MeteorShowersMgr* mgr)
×
30
        : StelDialog("MeteorShowers")
31
        , m_mgr(mgr)
×
32
        , m_ui(new Ui_MSConfigDialog)
×
33
        , m_updateTimer(Q_NULLPTR)
×
34
{
35
}
×
36

37
MSConfigDialog::~MSConfigDialog()
×
38
{
39
        if (m_updateTimer)
×
40
        {
41
                m_updateTimer->stop();
×
42
                delete m_updateTimer;
×
43
                m_updateTimer = Q_NULLPTR;
×
44
        }
45
        delete m_ui;
×
46
}
×
47

48
void MSConfigDialog::retranslate()
×
49
{
50
        if (dialog)
×
51
        {
52
                m_ui->retranslateUi(dialog);
×
53
                setAboutHtml();
×
54
        }
55
}
×
56

57
void MSConfigDialog::createDialogContent()
×
58
{
59
        m_ui->setupUi(dialog);
×
60
        m_ui->tabs->setCurrentIndex(0);
×
61

62
        // Kinetic scrolling
63
        kineticScrollingList << m_ui->about;
×
64
        StelGui* gui= dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
×
65
        if (gui)
×
66
        {
67
                enableKineticScrolling(gui->getFlagUseKineticScrolling());
×
68
                connect(gui, SIGNAL(flagUseKineticScrollingChanged(bool)), this, SLOT(enableKineticScrolling(bool)));
×
69
        }
70

71
        connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
×
72
        connect(m_ui->titleBar, &TitleBar::closeClicked, this, &StelDialog::close);
×
73
        connect(m_ui->titleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
×
74
        connect(m_ui->bRestoreDefaults, SIGNAL(clicked()), this, SLOT(restoreDefaults()));
×
75

76
        // General tab
77
        connect(m_ui->enableAtStartUp, SIGNAL(clicked(bool)), m_mgr, SLOT(setEnableAtStartup(bool)));
×
78
        connect(m_ui->showEnableButton, SIGNAL(clicked(bool)), m_mgr, SLOT(setShowEnableButton(bool)));
×
79
        connect(m_ui->showSearchButton, SIGNAL(clicked(bool)), m_mgr, SLOT(setShowSearchButton(bool)));
×
80

81
        // Radiant tab
82
        connect(m_ui->enableMarker, SIGNAL(clicked(bool)), m_mgr, SLOT(setEnableMarker(bool)));
×
83
        connect(m_ui->activeRadiantsOnly, SIGNAL(clicked(bool)), m_mgr, SLOT(setActiveRadiantOnly(bool)));
×
84
        connect(m_ui->enableLabels, SIGNAL(clicked(bool)), m_mgr, SLOT(setEnableLabels(bool)));
×
85
        connect(m_ui->fontSize, SIGNAL(valueChanged(int)), m_mgr, SLOT(setFontSize(int)));
×
86

87
        connectColorButton(m_ui->setColorARG, "MeteorShowers.colorARG", "MeteorShowers/colorARG");
×
88
        connectColorButton(m_ui->setColorARC, "MeteorShowers.colorARC", "MeteorShowers/colorARC");
×
89
        connectColorButton(m_ui->setColorIR,  "MeteorShowers.colorIR",  "MeteorShowers/colorIR");
×
90

91
        // Update tab
92
        connect(m_ui->enableUpdates, SIGNAL(clicked(bool)), m_mgr, SLOT(setEnableAutoUpdates(bool)));
×
93
        connect(m_ui->updateFrequency, SIGNAL(valueChanged(int)), m_mgr, SLOT(setUpdateFrequencyHours(int)));
×
94
        connect(m_ui->bUpdate, SIGNAL(clicked()), m_mgr, SLOT(updateCatalog()));
×
95

96
        connect(m_ui->enableUpdates, SIGNAL(clicked()), this, SLOT(refreshUpdateTab()));
×
97
        connect(m_ui->updateFrequency, SIGNAL(valueChanged(int)), this, SLOT(refreshUpdateTab()));
×
98
        connect(m_ui->bUpdate, SIGNAL(clicked()), this, SLOT(refreshUpdateTab()));
×
99
        connect(m_mgr, SIGNAL(updateStateChanged(MeteorShowersMgr::UpdateState)), this, SLOT(updateStateReceiver(MeteorShowersMgr::UpdateState)));
×
100
        connect(m_mgr, SIGNAL(jsonUpdateComplete(void)), this, SLOT(updateCompleteReceiver(void)));        
×
101
        m_updateTimer = new QTimer(this);
×
102
        connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(refreshUpdateTab()));
×
103
        m_updateTimer->start(7000); // Duration of time to display changing status in update tab
×
104

105
        // About tab
106
        setAboutHtml();
×
107
        if (gui)
×
108
        {
109
                m_ui->about->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet));
×
110
        }
111
        updateGuiFromSettings();
×
112
        init();
×
113
}
×
114

115
void MSConfigDialog::restoreDefaults()
×
116
{
117
        if (askConfirmation())
×
118
        {
119
                qDebug() << "[MeteorShower] restore defaults...";
×
120
                m_mgr->restoreDefaultSettings();
×
121
        }
122
        else
123
                qDebug() << "[MeteorShower] restore defaults is canceled...";
×
124
}
×
125

126
void MSConfigDialog::init()
×
127
{
128
        // General tab
129
        m_ui->enableAtStartUp->setChecked(m_mgr->getEnableAtStartup());
×
130
        m_ui->showEnableButton->setChecked(m_mgr->getShowEnableButton());
×
131
        m_ui->showSearchButton->setChecked(m_mgr->getShowSearchButton());
×
132

133
        // Radiant tab
134
        m_ui->enableMarker->setChecked(m_mgr->getEnableMarker());
×
135
        m_ui->activeRadiantsOnly->setChecked(m_mgr->getActiveRadiantOnly());
×
136
        m_ui->enableLabels->setChecked(m_mgr->getEnableLabels());
×
137
        m_ui->fontSize->setValue(m_mgr->getFontSize());
×
138

139
        // Update tab
140
        refreshUpdateTab();
×
141
}
×
142

143
void MSConfigDialog::refreshUpdateTab()
×
144
{
145
        m_ui->enableUpdates->setChecked(m_mgr->getEnableAutoUpdates());
×
146
        m_ui->updateFrequency->setValue(m_mgr->getUpdateFrequencyHours());
×
147
        m_ui->nextUpdate->setDateTime(m_mgr->getNextUpdate());
×
148

149
        m_ui->lastUpdate->setDateTime(m_mgr->getLastUpdate());
×
150
        m_ui->bUpdate->setEnabled(true);
×
151

152
        QString nextUpdate = q_("Next update");
×
153
        if (!m_mgr->getEnableAutoUpdates())
×
154
                m_ui->status->setText(q_("Internet updates disabled"));
×
155
        else if (m_mgr->getUpdateState() == MeteorShowersMgr::Updating)
×
156
                m_ui->status->setText(q_("Updating..."));
×
157
        else
158
        {
159
                m_ui->status->setText("-");
×
160
        }
161
}
×
162

163
void MSConfigDialog::updateStateReceiver(MeteorShowersMgr::UpdateState state)
×
164
{
165
        if (state==MeteorShowersMgr::Updating)
×
166
                m_ui->status->setText(q_("Updating now..."));
×
167
        else if (state==MeteorShowersMgr::DownloadError || state==MeteorShowersMgr::OtherError)
×
168
        {
169
                m_ui->status->setText(q_("Update error"));
×
170
                m_updateTimer->start();  // make sure message is displayed for a while...
×
171
        }
172
}
×
173

174
void MSConfigDialog::updateCompleteReceiver(void)
×
175
{
176
        m_ui->status->setText(QString(q_("Successfully updated")));
×
177
        m_updateTimer->start();
×
178
        QTimer *timer = new QTimer(this);
×
179
        connect(timer, SIGNAL(timeout()), this, SLOT(refreshUpdateTab()));
×
180
        setAboutHtml();
×
181
}
×
182

183
void MSConfigDialog::updateGuiFromSettings(void)
×
184
{
185
        m_ui->enableUpdates->setChecked(m_mgr->getEnableAutoUpdates());
×
186
        refreshUpdateTab();
×
187
}
×
188

189
void MSConfigDialog::setAboutHtml()
×
190
{
191
        QString html = "<html><head></head><body>"
192
        "<h2>" + q_("Meteor Showers Plug-in") + "</h2>"
×
193
        "<table width=\"90%\">"
194
                "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</strong></td><td>" + METEORSHOWERS_PLUGIN_VERSION + "</td></tr>"
×
195
                "<tr><td><strong>" + q_("License") + ":</strong></td><td>" + METEORSHOWERS_PLUGIN_LICENSE + "</td></tr>"
×
196
                "<tr><td><strong>" + q_("Author") + ":</strong></td><td>Marcos Cardinot &lt;mcardinot@gmail.com&gt;</td></tr>"
×
197
                "<tr><td rowspan='2'><strong>" + q_("Contributors") + ":</strong></td><td>Alexander Wolf</td></tr>"
×
198
                "<tr><td>Worachate Boonplod</td></tr>"
199
        "</table>"
200
        "<p>"
201
        + q_(
×
202
                "This plugin enables you to simulate and predict periodic meteor showers and "
203
                "to display a marker for each active and inactive radiant."
204
        ) +
×
205
        "</p>"
206
        "<p>"
207
        + q_(
×
208
                "By a single click on the radiant's marker, you can see all the "
209
                "details about its position and activity. Most data used on this "
210
                "plugin comes from the official <a href=\"https://imo.net\">International "
211
                "Meteor Organization</a> catalog and <a href=\"https://www.ta3.sk/IAUC22DB/MDC2007/\">IAU Meteor Data Center</a>."
212
        ) +
×
213
        "</p>"
214
        + q_(
×
215
        "<p>"
216
                "It has three types of markers:"
217
                "<dl>"
218
                        "<dt><strong>Confirmed</strong></dt><dd>"
219
                                "The radiant is active and its data was confirmed."
220
                                " Thus, this is a historical (really occurred in the past) or predicted"
221
                                " meteor shower."
222
                        "</dd>"
223
                        "<dt><strong>Generic</strong></dt><dd>"
224
                                "The radiant is active, but its data was not confirmed."
225
                                " It means that this can occur in real life, but that we do not have proper"
226
                                " data about its activity for the current year."
227
                        "</dd>"
228
                        "<dt><strong>Inactive</strong></dt><dd>"
229
                                "The radiant is inactive for the current sky date."
230
                        "</dt>"
231
                "</dl>"
232
        "</p>"
233
        )
234
        + "<p>"
×
235
        + q_("This plugin uses two models to calculate ZHR, assuming that the activity profile of meteor "
×
236
                "shower follows the double exponential shape. To predict the local hourly rate, altitude of "
237
                "radiant and limiting magnitude of the sky are taken into account. "
238
                "Moonlight can also reduce the hourly rate, but it doesn't take into account.") +
×
239
        "</p>" +
×
240
        "<h3>" + q_("Terms") + "</h3>"
×
241
        "<dl><dt><strong>" + q_("Meteor shower") + "</strong></dt><dd>" +
×
242
                q_("A meteor shower is a celestial event in which a number of meteors are observed to "
×
243
                "radiate, or originate, from one point in the night sky. These meteors are caused by "
244
                "streams of cosmic debris called meteoroids entering Earth's atmosphere at extremely "
245
                "high speeds on parallel trajectories. Most meteors are smaller than a grain of sand, "
246
                "so almost all of them disintegrate and never hit the Earth's surface. Intense or "
247
                "unusual meteor showers are known as meteor outbursts and meteor storms, which may "
248
                "produce greater than 1,000 meteors an hour.") +
×
249
        "<br/></dd>"
250
        "<dt><strong>" + q_("Radiant") + "</strong></dt><dd>" +
×
251
                q_("The radiant or apparent radiant of a meteor shower is the point in the sky, from "
×
252
                   "which (to a planetary observer) meteors appear to originate. The Perseids, for "
253
                   "example, are meteors which appear to come from a point within the constellation "
254
                   "of Perseus.") +        
×
255
        "<p>" +
×
256
                q_("An observer might see such a meteor anywhere in the sky but the direction of motion, "
×
257
                   "when traced back, will point to the radiant. A meteor that does not point back to the "
258
                   "known radiant for a given shower is known as a sporadic and is not considered part of "
259
                   "that shower.") +
×
260
        "</p>"
261
        "<p>" + q_("Many showers have a radiant point that changes position during the interval when it "
×
262
                   "appears. For example, the radiant point for the October Delta Aurigids drifts by more than a "
263
                   "degree per night.") +
×
264
        "</p></dd>"
265
        "<dt><strong>" + q_("Zenithal Hourly Rate (ZHR)") + "</strong></dt><dd>" +
×
266
                q_("In astronomy, the Zenithal Hourly Rate (ZHR) of a meteor shower is the number of meteors "
×
267
                   "a single observer would see in one hour under a clear, dark sky (limiting apparent "
268
                   "magnitude of 6.5) if the radiant of the shower were at the zenith. The rate that can "
269
                   "effectively be seen is nearly always lower and decreases the closer the radiant is to "
270
                   "the horizon.") +
×
271
        "<br/></dd>"
272
        "<dt><strong>ZHR<sub>max</sub></strong></dt><dd>" +
×
273
                q_("The maximum ZHR of a meteor shower at peak date and time when Earth passes through the "
×
274
                   "densest region of meteoroid stream.") +
×
275
        "<br/></dd>" +
×
276
        "<dt><strong>" + q_("Current ZHR") + "</strong></dt><dd>" +
×
277
                q_("The ZHR at given time, assuming that the activity profile of meteor shower follows the double exponential shape.") +
×
278
        "<br/></dd>" +
×
279
        "<dt><strong>" + q_("Local Hourly Rate") + "</strong></dt><dd>" +
×
280
                q_("The number of meteors in one hour for current location, it is the actual expected rate, calculated by "
×
281
                   "taking altitude of radiant (hourly rate decreases the closer the radiant is to the horizon) and "
282
                   "limiting magnitude of the sky into account. It is nearly always lower than <i>current ZHR</i>. "
283
                   "Moonlight can also reduce the hourly rate, but it doesn't take into account..") +
×
284
        "<br/></dd>" +
×
285
        "<dt><strong>" + q_("Population index") + "</strong></dt><dd>" +
×
286
                q_("The population index indicates the magnitude distribution of the meteor showers. The "
×
287
                   "values below 2.5 correspond to distributions where bright meteors are more frequent "
288
                   "than average, while values above 3.0 mean that the share of faint meteors is larger "
289
                   "than usual.") +
×
290
        "<br/></dd>"
291
        "<dt><strong>" + q_("Solar longitude") + "</strong></dt><dd>" +
×
292
                q_("Solar longitude (equinox J2000) gives the position of the Earth on its orbit. "
×
293
                   "It is a more appropriate information on a meteor shower than the date.") +
×
294
        "</dd></dl>" +
×
295
        "<h3>" + q_("Notes") + "</h3>"
×
296
        "<p>" + q_("This plugin was initially created as a project of the ESA Summer of Code in Space 2013.") + "</p>"
×
297
        "<h3>" + q_("Info") + "</h3>"
×
298
        "<p>" + q_("Info about meteor showers you can get here:") + "</p>"
×
299
        "<ul>"
300
        // TRANSLATORS: The numbers contain the opening and closing tag of an HTML link
301
        "<li>" + QString(q_("%1Meteor shower%2 - article in Wikipedia")).arg("<a href=\"https://en.wikipedia.org/wiki/Meteor_Showers\">", "</a>") + "</li>"
×
302
        // TRANSLATORS: The numbers contain the opening and closing tag of an HTML link
303
        "<li>" + QString(q_("%1International Meteor Organization%2")).arg("<a href=\"https://www.imo.net/\">", "</a>") + "</li>"
×
304
        // TRANSLATORS: The numbers contain the opening and closing tag of an HTML link
305
        "<li>" + QString(q_("%1IAU Meteor Data Center%2")).arg("<a href=\"https://www.ta3.sk/IAUC22DB/MDC2007/\">", "</a>") + "</li>"
×
306
        // TRANSLATORS: The numbers contain the opening and closing tag of an HTML link
307
        "<li>" + QString(q_("%1Major Showers Observations%2")).arg("<a href=\"https://www.imo.net/observations/methods/visual-observation/major/\">", "</a>") + "</li>"
×
308
        "</ul>";
×
309

310
        html += StelApp::getInstance().getModuleMgr().getStandardSupportLinksInfo("Meteor Showers plugin");
×
311
        html += "</body></html>";
×
312

313
        m_ui->about->setHtml(html);
×
314
        // TRANSLATORS: duration
315
        m_ui->updateFrequency->setSuffix(qc_(" h","time unit"));
×
316
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc