7#include "profilewizard.h"
9#include <QDesktopServices>
15#include "auxiliary/kspaths.h"
16#include "ksnotification.h"
29 wizardPix->setPixmap(im);
31 remoteEquipmentSVG->
load(
QString(
":/icons/pi.svg"));
33 connect(buttonBox, SIGNAL(rejected()),
this, SLOT(
close()));
64 wizardContainer->setCurrentIndex(EQUIPMENT_LOCATION);
68 connect(localEquipmentB, SIGNAL(clicked()),
this, SLOT(processLocalEquipment()));
72 wizardContainer->setCurrentIndex(REMOTE_EQUIPMENT_SELECTION);
74 equipmentStellarmateB->setIcon(
QIcon(
":/icons/stellarmate.svg"));
77 equipmentAtikbaseB->setIcon(
QIcon(
":/icons/atikbase.svg"));
83 connect(remoteEquipmentNextB, SIGNAL(clicked()),
this, SLOT(processRemoteEquipment()));
86 connect(stellarMateEquipmentNextB, SIGNAL(clicked()),
this, SLOT(processPiEquipment()));
90 PiAutoDetectB->setEnabled(
false);
92 connect(PiAutoDetectB, SIGNAL(clicked()),
this, SLOT(detectStellarMate()));
96 connect(useExternalINDIB, SIGNAL(clicked()),
this, SLOT(processLocalMac()));
97 connect(useInternalINDIB, SIGNAL(clicked()),
this, SLOT(processLocalMac()));
100 connect(createProfileB, SIGNAL(clicked()),
this, SLOT(createProfile()));
103void ProfileWizard::reset()
105 useInternalServer =
true;
106 useWebManager =
false;
108 useRemoteAstrometry =
false;
109 useSkySafari =
false;
111 useGuiderType = INTERNAL_GUIDER;
116 wizardContainer->setCurrentIndex(INTRO);
119void ProfileWizard::processLocalEquipment()
121#if defined(Q_OS_MACOS)
122 wizardContainer->setCurrentIndex(MAC_LOCAL);
123#elif defined(Q_OS_WIN)
124 wizardContainer->setCurrentIndex(WINDOWS_LOCAL);
126 useInternalServer =
true;
127 useJoystickCheck->setEnabled(
true);
128 useRemoteAstrometryCheck->setEnabled(
false);
129 useWatchDogCheck->setEnabled(
false);
130 useSkySafariCheck->setEnabled(
true);
131 wizardContainer->setCurrentIndex(CREATE_PROFILE);
135void ProfileWizard::processRemoteEquipment()
138 remotePortEdit->text().toInt(&portOK);
142 KSNotification::error(
i18n(
"Invalid port."));
146 if (remoteHostEdit->text().isEmpty())
148 KSNotification::error(
i18n(
"Host name cannot be empty."));
152 useInternalServer =
false;
154 host = remoteHostEdit->text();
155 port = remotePortEdit->text();
157 if (webManagerNotSureB->isChecked())
165 useWebManager = webManagerYesR->isChecked();
167 useJoystickCheck->setEnabled(
true);
168 useRemoteAstrometryCheck->setEnabled(
true);
169 useWatchDogCheck->setEnabled(
true);
170 useSkySafariCheck->setEnabled(
true);
172 wizardContainer->setCurrentIndex(CREATE_PROFILE);
175void ProfileWizard::processPiEquipment()
177 if (PiHost->text().isEmpty())
179 KSNotification::error(
i18n(
"Host name cannot be empty."));
183 host = PiHost->text();
184 port = PiPort->text();
186 useInternalServer =
false;
187 useWebManager =
true;
189 useJoystickCheck->setEnabled(
true);
190 useRemoteAstrometryCheck->setEnabled(
true);
191 useWatchDogCheck->setEnabled(
true);
192 useSkySafariCheck->setEnabled(
true);
194 wizardContainer->setCurrentIndex(CREATE_PROFILE);
197void ProfileWizard::processLocalMac()
201 if (button ==
nullptr)
207 useInternalServer = (button == useInternalINDIB);
209 useJoystickCheck->setEnabled(
false);
210 useRemoteAstrometryCheck->setEnabled(
false);
211 useWatchDogCheck->setEnabled(
false);
212 useSkySafariCheck->setEnabled(
true);
214 wizardContainer->setCurrentIndex(CREATE_PROFILE);
217void ProfileWizard::createProfile()
219 if (profileNameEdit->text().isEmpty())
221 KSNotification::error(
i18n(
"Profile name cannot be empty."));
225 useJoystick = useJoystickCheck->isEnabled() && useJoystickCheck->isChecked();
226 useWatchDog = useWatchDogCheck->isEnabled() && useWatchDogCheck->isChecked();
227 useSkySafari = useSkySafariCheck->isEnabled() && useSkySafariCheck->isChecked();
228 useRemoteAstrometry = useRemoteAstrometryCheck->isEnabled() && useRemoteAstrometryCheck->isChecked();
229 if (useInternalGuiderR->isChecked())
230 useGuiderType = INTERNAL_GUIDER;
231 else if (usePHD2R->isChecked())
232 useGuiderType = PHD2_GUIDER;
234 useGuiderType = LIN_GUIDER;
236 profileName = profileNameEdit->text();
238 if (useInternalServer)
252 auxList <<
"Joystick";
254 auxList <<
"WatchDog";
256 auxList <<
"SkySafari";
257 if (useRemoteAstrometry)
258 auxList <<
"Astrometry";
263int ProfileWizard::selectedExternalGuider()
265 return useGuiderType;
268void ProfileWizard::detectStellarMate()
271 stellarMateDetectDialog->setMinimum(0);
272 stellarMateDetectDialog->setMaximum(0);
273 stellarMateDetectDialog->setWindowTitle(
i18nc(
"@title:window",
"Detecting StellarMate..."));
274 stellarMateDetectDialog->setLabelText(
i18n(
"Please wait while searching for StellarMate..."));
276 stellarMateDetectDialog->show();
280 qMDNS::getInstance()->disconnect();
288void ProfileWizard::processHostInfo(
QHostInfo info)
290 PiHost->setText(info.hostName());
292 stellarMateDetectDialog->close();
295void ProfileWizard::detectStellarMateTimeout()
297 if (stellarMateDetectDialog->isHidden() ==
false)
299 KSNotification::error(
i18n(
"Failed to detect any StellarMate gadget. Make sure it is powered and on the same network."));
300 stellarMateDetectDialog->close();
304void ProfileWizard::processRemoteEquipmentSelection()
308 wizardContainer->setCurrentIndex(GENERIC_EQUIPMENT);
309 else if (button == equipmentStellarmateB)
311 PiHost->setText(
"stellarmate.local");
312 wizardContainer->setCurrentIndex(PI_EQUIPMENT);
314 else if (button == equipmentAtikbaseB)
316 PiHost->setText(
"atikbase.local");
317 wizardContainer->setCurrentIndex(PI_EQUIPMENT);
This is the main window for KStars.
static KStars * Instance()
void lookup(const QString &name)
Performs a mDNS lookup to find the given host name.
static qMDNS * getInstance()
Returns the only running instance of this class.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
void connectToHost(const QHostAddress &address, quint16 port, OpenMode openMode)
virtual bool waitForConnected(int msecs)
bool openUrl(const QUrl &url)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
T qobject_cast(QObject *object)
QObject * sender() const const
bool load(const QString &fileName, const char *format, Qt::ImageConversionFlags flags)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)