1 /*
2  * Stellarium
3  * Copyright (C) 2016 Alexander Wolf
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  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
17 */
18 
19 #include <QDesktopServices>
20 #include <QUrl>
21 #include <QSettings>
22 
23 #include "StelApp.hpp"
24 #include "StelModuleMgr.hpp"
25 #include "StelUtils.hpp"
26 #include "StelLocaleMgr.hpp"
27 #include "GreatRedSpotDialog.hpp"
28 
29 #include "ui_greatRedSpotDialog.h"
30 
GreatRedSpotDialog()31 GreatRedSpotDialog::GreatRedSpotDialog() : StelDialog("GreatRedSpot")
32 {
33 	ui = new Ui_GreatRedSpotDialogForm;
34 }
35 
~GreatRedSpotDialog()36 GreatRedSpotDialog::~GreatRedSpotDialog()
37 {
38 	delete ui;
39 	ui=Q_NULLPTR;
40 }
41 
retranslate()42 void GreatRedSpotDialog::retranslate()
43 {
44 	if (dialog)
45 		ui->retranslateUi(dialog);
46 }
47 
createDialogContent()48 void GreatRedSpotDialog::createDialogContent()
49 {
50 	ui->setupUi(dialog);
51 
52 	//Signals and slots
53 	connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
54 	connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()));
55 	connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
56 
57 	SolarSystem* ss = GETSTELMODULE(SolarSystem);
58 	connectIntProperty(ui->longitudeSpinBox, "SolarSystem.customGrsLongitude");
59 	connectDoubleProperty(ui->driftDoubleSpinBox, "SolarSystem.customGrsDrift");
60 
61 	const StelLocaleMgr& locmgr = StelApp::getInstance().getLocaleMgr();
62 	QString fmt = QString("%1 hh:mm").arg(locmgr.getQtDateFormatStr());
63 	ui->jdDateTimeEdit->setDisplayFormat(fmt);
64 	ui->jdDateTimeEdit->setDateTime(StelUtils::jdToQDateTime(ss->getCustomGrsJD()));
65 	connect(ui->jdDateTimeEdit, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(setGrsJD(QDateTime)));
66 
67 	connect(ui->recentGrsMeasurementPushButton, SIGNAL(clicked(bool)), this, SLOT(openRecentGrsMeasurement()));
68 }
69 
setGrsJD(QDateTime dt)70 void GreatRedSpotDialog::setGrsJD(QDateTime dt)
71 {
72 	GETSTELMODULE(SolarSystem)->setCustomGrsJD(StelUtils::qDateTimeToJd(dt));
73 }
74 
openRecentGrsMeasurement()75 void GreatRedSpotDialog::openRecentGrsMeasurement()
76 {
77 	QSettings* conf = StelApp::getInstance().getSettings();
78 	QDesktopServices::openUrl(QUrl(conf->value("astro/grs_measurements_url", "http://jupos.privat.t-online.de/rGrs.htm").toString()));
79 }
80