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"));
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()));
103 void ProfileWizard::reset()
105 useInternalServer =
true;
106 useWebManager =
false;
108 useRemoteAstrometry =
false;
109 useSkySafari =
false;
111 useGuiderType = INTERNAL_GUIDER;
116 wizardContainer->setCurrentIndex(INTRO);
119 void ProfileWizard::processLocalEquipment()
121 #if defined(Q_OS_OSX)
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);
135 void 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);
175 void 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);
197 void ProfileWizard::processLocalMac()
199 QPushButton *button = qobject_cast<QPushButton *>(sender());
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);
217 void 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";
263 int ProfileWizard::selectedExternalGuider()
265 return useGuiderType;
268 void 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();
288 void ProfileWizard::processHostInfo(
QHostInfo info)
290 PiHost->setText(info.hostName());
292 stellarMateDetectDialog->close();
295 void 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();
304 void ProfileWizard::processRemoteEquipmentSelection()
306 QToolButton *button = qobject_cast<QToolButton*>(sender());
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);