7#include "profileeditor.h"
9#include "geolocation.h"
10#include "kstarsdata.h"
11#include "ksnotification.h"
13#include "guide/guide.h"
14#include "indi/driverinfo.h"
15#include "indi/drivermanager.h"
16#include "profilescriptdialog.h"
17#include "ui_indihub.h"
19#include "ekos_debug.h"
21#include <QNetworkInterface>
23#include <QDesktopServices>
32 setObjectName(
"profileEditorDialog");
36 ui =
new ProfileEditorUI(
this);
47 setLayout(mainLayout);
49 setWindowTitle(
i18nc(
"@title:window",
"Profile Editor"));
56 connect(buttonBox, SIGNAL(rejected()),
this, SLOT(reject()));
57 connect(buttonBox, SIGNAL(accepted()),
this, SLOT(saveProfile()));
63 QUrl url(QString(
"http://" + ui->remoteHost->text() +
":8624"));
64 QDesktopServices::openUrl(url);
69 ui->openWebManagerB->setEnabled(enabled);
70 ui->remoteDrivers->setEnabled(enabled || ui->localMode->isChecked());
71 ui->scriptsB->setEnabled(enabled || ui->localMode->isChecked());
74 connect(ui->guideTypeCombo, SIGNAL(activated(
int)),
this, SLOT(updateGuiderSelection(
int)));
79 ui->remoteMode->setChecked(
true);
80 ui->localMode->setEnabled(
false);
83 connect(ui->remoteMode, SIGNAL(toggled(
bool)),
this, SLOT(setRemoteMode(
bool)));
92 ui->remoteDrivers->setToolTip(ui->remoteDriversLabel->toolTip());
93 ui->aux1Combo->setToolTip(ui->aux1Label->toolTip());
94 ui->aux2Combo->setToolTip(ui->aux2Label->toolTip());
95 ui->aux3Combo->setToolTip(ui->aux3Label->toolTip());
96 ui->aux4Combo->setToolTip(ui->aux4Label->toolTip());
97 ui->filterCombo->setToolTip(ui->filterLabel->toolTip());
98 ui->AOCombo->setToolTip(ui->AOLabel->toolTip());
99 ui->domeCombo->setToolTip(ui->domeLabel->toolTip());
100 ui->weatherCombo->setToolTip(ui->weatherLabel->toolTip());
101 ui->localMode->setToolTip(ui->modeLabel->toolTip());
102 ui->remoteMode->setToolTip(ui->modeLabel->toolTip());
103 ui->remoteHostLabel->setToolTip(ui->remoteHost->toolTip());
104 ui->remotePortLabel->setToolTip(ui->remotePort->toolTip());
105 ui->externalGuidePortLabel->setToolTip(ui->externalGuidePort->toolTip());
106 ui->INDIWebManagerPortLabel->setToolTip(ui->INDIWebManagerPort->toolTip());
107 ui->guideTypeCombo->setToolTip(ui->guidingTypeLabel->toolTip());
108 ui->externalGuideHostLabel->setToolTip(ui->externalGuideHost->toolTip());
111void ProfileEditor::saveProfile()
113 bool newProfile = (pi.
isNull());
115 if (ui->profileIN->text().isEmpty())
117 KSNotification::error(
i18n(
"Cannot save an empty profile."));
125 for (
auto &profileInfo : existingProfiles)
127 if (ui->profileIN->text() == profileInfo->name)
129 KSNotification::error(
i18n(
"Profile name already exists."));
133 int id = KStarsData::Instance()->
userdb()->AddProfile(ui->profileIN->text());
134 pi.
reset(
new ProfileInfo(
id, ui->profileIN->text()));
137 pi->name = ui->profileIN->text();
140 if (ui->localMode->isChecked())
144 pi->INDIWebManagerPort = -1;
150 pi->host = ui->remoteHost->text().trimmed();
151 pi->port = ui->remotePort->text().toInt();
152 if (ui->INDIWebManagerCheck->isChecked())
153 pi->INDIWebManagerPort = ui->INDIWebManagerPort->text().toInt();
155 pi->INDIWebManagerPort = -1;
160 if (ui->loadSiteCheck->
isEnabled() && ui->loadSiteCheck->isChecked())
162 pi->city = KStarsData::Instance()->
geo()->
name();
163 pi->province = KStarsData::Instance()->
geo()->
province();
164 pi->country = KStarsData::Instance()->
geo()->
country();
169 pi->province.clear();
173 pi->indihub = m_INDIHub;
176 pi->autoConnect = ui->autoConnectCheck->isChecked();
178 pi->portSelector = ui->portSelectorCheck->isChecked();
181 pi->guidertype = ui->guideTypeCombo->currentIndex();
182 if (pi->guidertype != Ekos::Guide::GUIDE_INTERNAL)
184 pi->guiderhost = ui->externalGuideHost->text();
185 pi->guiderport = ui->externalGuidePort->text().toInt();
187 if (pi->guidertype == Ekos::Guide::GUIDE_PHD2)
189 Options::setPHD2Host(pi->guiderhost);
190 Options::setPHD2Port(pi->guiderport);
192 else if (pi->guidertype == Ekos::Guide::GUIDE_LINGUIDER)
194 Options::setLinGuiderHost(pi->guiderhost);
195 Options::setLinGuiderPort(pi->guiderport);
199 if (ui->mountCombo->currentText().isEmpty() || ui->mountCombo->currentText() ==
"--")
200 pi->drivers.remove(
"Mount");
202 pi->drivers[
"Mount"] = ui->mountCombo->currentText();
204 if (ui->ccdCombo->currentText().isEmpty() || ui->ccdCombo->currentText() ==
"--")
205 pi->drivers.remove(
"CCD");
207 pi->drivers[
"CCD"] = ui->ccdCombo->currentText();
209 if (ui->guiderCombo->currentText().isEmpty() || ui->guiderCombo->currentText() ==
"--")
210 pi->drivers.remove(
"Guider");
212 pi->drivers[
"Guider"] = ui->guiderCombo->currentText();
214 if (ui->focuserCombo->currentText().isEmpty() || ui->focuserCombo->currentText() ==
"--")
215 pi->drivers.remove(
"Focuser");
217 pi->drivers[
"Focuser"] = ui->focuserCombo->currentText();
219 if (ui->filterCombo->currentText().isEmpty() || ui->filterCombo->currentText() ==
"--")
220 pi->drivers.remove(
"Filter");
222 pi->drivers[
"Filter"] = ui->filterCombo->currentText();
224 if (ui->AOCombo->currentText().isEmpty() || ui->AOCombo->currentText() ==
"--")
225 pi->drivers.remove(
"AO");
227 pi->drivers[
"AO"] = ui->AOCombo->currentText();
229 if (ui->domeCombo->currentText().isEmpty() || ui->domeCombo->currentText() ==
"--")
230 pi->drivers.remove(
"Dome");
232 pi->drivers[
"Dome"] = ui->domeCombo->currentText();
234 if (ui->weatherCombo->currentText().isEmpty() || ui->weatherCombo->currentText() ==
"--")
235 pi->drivers.remove(
"Weather");
237 pi->drivers[
"Weather"] = ui->weatherCombo->currentText();
239 if (ui->aux1Combo->currentText().isEmpty() || ui->aux1Combo->currentText() ==
"--")
240 pi->drivers.remove(
"Aux1");
242 pi->drivers[
"Aux1"] = ui->aux1Combo->currentText();
244 if (ui->aux2Combo->currentText().isEmpty() || ui->aux2Combo->currentText() ==
"--")
245 pi->drivers.remove(
"Aux2");
247 pi->drivers[
"Aux2"] = ui->aux2Combo->currentText();
249 if (ui->aux3Combo->currentText().isEmpty() || ui->aux3Combo->currentText() ==
"--")
250 pi->drivers.remove(
"Aux3");
252 pi->drivers[
"Aux3"] = ui->aux3Combo->currentText();
254 if (ui->aux4Combo->currentText().isEmpty() || ui->aux4Combo->currentText() ==
"--")
255 pi->drivers.remove(
"Aux4");
257 pi->drivers[
"Aux4"] = ui->aux4Combo->currentText();
259 pi->remotedrivers = ui->remoteDrivers->text();
261 KStarsData::Instance()->
userdb()->SaveProfile(pi);
270void ProfileEditor::setRemoteMode(
bool enable)
282 ui->mountCombo->setEditable(enable);
283 ui->ccdCombo->setEditable(enable);
284 ui->guiderCombo->setEditable(enable);
285 ui->focuserCombo->setEditable(enable);
286 ui->filterCombo->setEditable(enable);
287 ui->AOCombo->setEditable(enable);
288 ui->domeCombo->setEditable(enable);
289 ui->weatherCombo->setEditable(enable);
290 ui->aux1Combo->setEditable(enable);
291 ui->aux2Combo->setEditable(enable);
292 ui->aux3Combo->setEditable(enable);
293 ui->aux4Combo->setEditable(enable);
301 ui->INDIWebManagerCheck->setChecked(
false);
304 ui->scriptsB->
setEnabled(!enable || ui->INDIWebManagerCheck->isChecked());
311 ui->profileIN->setText(pi->name);
313 ui->loadSiteCheck->setChecked(!pi->city.isEmpty());
314 ui->autoConnectCheck->setChecked(pi->autoConnect);
315 ui->portSelectorCheck->setChecked(pi->portSelector);
317 if (pi->city.isEmpty() ==
false)
319 if (pi->province.isEmpty())
320 ui->loadSiteCheck->setText(ui->loadSiteCheck->text() +
QString(
" (%1, %2)").arg(pi->country, pi->city));
322 ui->loadSiteCheck->setText(ui->loadSiteCheck->text() +
323 QString(
" (%1, %2, %3)").arg(pi->country, pi->province, pi->city));
326 if (pi->host.isEmpty() ==
false)
328 ui->remoteHost->setText(pi->host);
331 ui->remoteMode->setChecked(
true);
333 if (pi->INDIWebManagerPort > 0)
335 ui->INDIWebManagerCheck->setChecked(
true);
336 ui->INDIWebManagerPort->setText(
QString::number(pi->INDIWebManagerPort));
340 ui->INDIWebManagerCheck->setChecked(
false);
341 ui->INDIWebManagerPort->setText(
"8624");
345 if (pi->remotedrivers.isEmpty() ==
false)
346 ui->remoteDrivers->setText(pi->remotedrivers);
348 ui->guideTypeCombo->setCurrentIndex(pi->guidertype);
349 updateGuiderSelection(ui->guideTypeCombo->currentIndex());
350 if (pi->guidertype == Ekos::Guide::GUIDE_PHD2)
352 Options::setPHD2Host(pi->guiderhost);
353 Options::setPHD2Port(pi->guiderport);
355 else if (pi->guidertype == Ekos::Guide::GUIDE_LINGUIDER)
357 Options::setLinGuiderHost(pi->guiderhost);
358 Options::setLinGuiderPort(pi->guiderport);
374 if ((row = ui->mountCombo->findText(value)) == -1)
376 ui->mountCombo->addItem(value);
377 row = ui->mountCombo->count() - 1;
381 ui->mountCombo->setCurrentIndex(row);
383 else if (key ==
"CCD")
385 if ((row = ui->ccdCombo->findText(value)) == -1)
387 ui->ccdCombo->addItem(value);
388 row = ui->ccdCombo->count() - 1;
391 ui->ccdCombo->setCurrentIndex(row);
393 else if (key ==
"Guider")
395 if ((row = ui->guiderCombo->findText(value)) == -1)
397 ui->guiderCombo->addItem(value);
398 row = ui->guiderCombo->count() - 1;
401 ui->guiderCombo->setCurrentIndex(row);
403 else if (key ==
"Focuser")
405 if ((row = ui->focuserCombo->findText(value)) == -1)
407 ui->focuserCombo->addItem(value);
408 row = ui->focuserCombo->count() - 1;
411 ui->focuserCombo->setCurrentIndex(row);
413 else if (key ==
"Filter")
415 if ((row = ui->filterCombo->findText(value)) == -1)
417 ui->filterCombo->addItem(value);
418 row = ui->filterCombo->count() - 1;
421 ui->filterCombo->setCurrentIndex(row);
423 else if (key ==
"AO")
425 if ((row = ui->AOCombo->findText(value)) == -1)
427 ui->AOCombo->addItem(value);
428 row = ui->AOCombo->count() - 1;
431 ui->AOCombo->setCurrentIndex(row);
433 else if (key ==
"Dome")
435 if ((row = ui->domeCombo->findText(value)) == -1)
437 ui->domeCombo->addItem(value);
438 row = ui->domeCombo->count() - 1;
441 ui->domeCombo->setCurrentIndex(row);
443 else if (key ==
"Weather")
445 if ((row = ui->weatherCombo->findText(value)) == -1)
447 ui->weatherCombo->addItem(value);
448 row = ui->weatherCombo->count() - 1;
451 ui->weatherCombo->setCurrentIndex(row);
453 else if (key ==
"Aux1")
455 if ((row = ui->aux1Combo->findText(value)) == -1)
457 ui->aux1Combo->addItem(value);
458 row = ui->aux1Combo->count() - 1;
461 ui->aux1Combo->setCurrentIndex(row);
463 else if (key ==
"Aux2")
465 if ((row = ui->aux2Combo->findText(value)) == -1)
467 ui->aux2Combo->addItem(value);
468 row = ui->aux2Combo->count() - 1;
471 ui->aux2Combo->setCurrentIndex(row);
473 else if (key ==
"Aux3")
475 if ((row = ui->aux3Combo->findText(value)) == -1)
477 ui->aux3Combo->addItem(value);
478 row = ui->aux3Combo->count() - 1;
481 ui->aux3Combo->setCurrentIndex(row);
483 else if (key ==
"Aux4")
485 if ((row = ui->aux4Combo->findText(value)) == -1)
487 ui->aux4Combo->addItem(value);
488 row = ui->aux4Combo->count() - 1;
491 ui->aux4Combo->setCurrentIndex(row);
495 m_INDIHub = pi->indihub;
500 bool locallyAvailable =
false;
501 if (driver->getAuxInfo().contains(
"LOCALLY_AVAILABLE"))
502 locallyAvailable = driver->getAuxInfo().value(
"LOCALLY_AVAILABLE",
false).toBool();
504 if (!locallyAvailable)
506 "<nobr>Available as <b>Remote</b> Driver. To use locally, install the corresponding driver.<nobr/>");
508 toolTipText =
i18n(
"<nobr><b>Label</b>: %1 ━ <b>Driver</b>: %2 ━ <b>Exec</b>: %3<nobr/>",
509 driver->getLabel(), driver->getName(), driver->getExecutable());
514void ProfileEditor::loadDrivers()
517 QString selectedMount = ui->mountCombo->currentText();
518 QString selectedCamera = ui->ccdCombo->currentText();
519 QString selectedGuider = ui->guiderCombo->currentText();
520 QString selectedFocuser = ui->focuserCombo->currentText();
521 QString selectedAux1 = ui->aux1Combo->currentText();
522 QString selectedAux2 = ui->aux2Combo->currentText();
523 QString selectedAux3 = ui->aux3Combo->currentText();
524 QString selectedAux4 = ui->aux4Combo->currentText();
527 boxes.
append(ui->mountCombo);
528 boxes.
append(ui->ccdCombo);
529 boxes.
append(ui->guiderCombo);
530 boxes.
append(ui->AOCombo);
531 boxes.
append(ui->focuserCombo);
532 boxes.
append(ui->filterCombo);
533 boxes.
append(ui->domeCombo);
534 boxes.
append(ui->weatherCombo);
535 boxes.
append(ui->aux1Combo);
536 boxes.
append(ui->aux2Combo);
537 boxes.
append(ui->aux3Combo);
538 boxes.
append(ui->aux4Combo);
544 selectedItems.
append(box->currentText());
547 box->setMaxVisibleItems(20);
553 delete (m_MountModel);
555 delete (m_CameraModel);
557 delete (m_GuiderModel);
559 delete (m_FocuserModel);
561 delete (m_Aux1Model);
563 delete (m_Aux2Model);
565 delete (m_Aux3Model);
567 delete (m_Aux4Model);
570 const bool isLocal = ui->localMode->isChecked();
577 << KSTARS_SPECTROGRAPHS
580 populateManufacturerCombo(m_MountModel, ui->mountCombo, selectedMount, isLocal,
QList<DeviceFamily>() << KSTARS_TELESCOPE);
581 populateManufacturerCombo(m_CameraModel, ui->ccdCombo, selectedCamera, isLocal,
QList<DeviceFamily>() << KSTARS_CCD);
582 populateManufacturerCombo(m_GuiderModel, ui->guiderCombo, selectedGuider, isLocal,
QList<DeviceFamily>() << KSTARS_CCD);
583 populateManufacturerCombo(m_FocuserModel, ui->focuserCombo, selectedFocuser, isLocal,
585 populateManufacturerCombo(m_Aux1Model, ui->aux1Combo, selectedAux1, isLocal, auxFamily);
586 populateManufacturerCombo(m_Aux2Model, ui->aux2Combo, selectedAux2, isLocal, auxFamily);
587 populateManufacturerCombo(m_Aux3Model, ui->aux3Combo, selectedAux3, isLocal, auxFamily);
588 populateManufacturerCombo(m_Aux4Model, ui->aux4Combo, selectedAux4, isLocal, auxFamily);
592 bool locallyAvailable =
false;
594 if (driver->getAuxInfo().contains(
"LOCALLY_AVAILABLE"))
595 locallyAvailable = driver->getAuxInfo().value(
"LOCALLY_AVAILABLE",
false).toBool();
596 if (!locallyAvailable)
598 if (ui->localMode->isChecked())
604 QString toolTipText = getTooltip(driver);
606 switch (driver->getType())
611 case KSTARS_ADAPTIVE_OPTICS:
613 ui->AOCombo->addItem(icon, driver->getLabel());
614 ui->AOCombo->setItemData(ui->AOCombo->count() - 1, toolTipText,
Qt::ToolTipRole);
623 ui->filterCombo->addItem(icon, driver->getLabel());
624 ui->filterCombo->setItemData(ui->filterCombo->count() - 1, toolTipText,
Qt::ToolTipRole);
630 ui->domeCombo->addItem(icon, driver->getLabel());
631 ui->domeCombo->setItemData(ui->domeCombo->count() - 1, toolTipText,
Qt::ToolTipRole);
637 ui->weatherCombo->addItem(icon, driver->getLabel());
638 ui->weatherCombo->setItemData(ui->weatherCombo->count() - 1, toolTipText,
Qt::ToolTipRole);
642 case KSTARS_AUXILIARY:
643 case KSTARS_SPECTROGRAPHS:
644 case KSTARS_DETECTORS:
653 for (
int i = 4; i < boxes.count(); i++)
656 QString selectedItemText = selectedItems.
at(i);
657 int index = box->
findText(selectedItemText);
660 if (ui->localMode->isChecked())
663 box->
addItem(remoteIcon, selectedItemText);
674void ProfileEditor::setProfileName(
const QString &name)
676 ui->profileIN->setText(name);
679void ProfileEditor::setAuxDrivers(
const QStringList &aux)
683 if (auxList.isEmpty())
685 ui->aux1Combo->setCurrentText(auxList.first());
686 auxList.removeFirst();
688 if (auxList.isEmpty())
690 ui->aux2Combo->setCurrentText(auxList.first());
691 auxList.removeFirst();
693 if (auxList.isEmpty())
695 ui->aux3Combo->setCurrentText(auxList.first());
696 auxList.removeFirst();
698 if (auxList.isEmpty())
700 ui->aux4Combo->setCurrentText(auxList.first());
703void ProfileEditor::setHostPort(
const QString &host,
const QString &port)
705 ui->remoteMode->setChecked(
true);
706 ui->remoteHost->setText(host);
707 ui->remotePort->setText(port);
710void ProfileEditor::setWebManager(
bool enabled,
const QString &port)
712 ui->INDIWebManagerCheck->setChecked(
enabled);
713 ui->INDIWebManagerPort->setText(port);
716void ProfileEditor::setGuiderType(
int type)
718 ui->guideTypeCombo->setCurrentIndex(type);
719 if (type != Ekos::Guide::GUIDE_INTERNAL)
728void ProfileEditor::setConnectionOptionsEnabled(
bool enable)
740 ui->INDIWebManagerPortLabel->
setEnabled(enable);
745 updateGuiderSelection(ui->guideTypeCombo->currentIndex());
751void ProfileEditor::updateGuiderSelection(
int id)
754 if (
id == Ekos::Guide::GUIDE_INTERNAL)
756 ui->externalGuideHost->setText(
"localhost");
757 ui->externalGuidePort->clear();
760 ui->externalGuideHostLabel->
setEnabled(
false);
762 ui->externalGuidePortLabel->
setEnabled(
false);
774 if (pi && pi->guidertype ==
id)
776 host = pi->guiderhost;
777 port = pi->guiderport;
780 if (
id == Ekos::Guide::GUIDE_PHD2)
783 host = Options::pHD2Host();
785 port = Options::pHD2Port();
787 else if (
id == Ekos::Guide::GUIDE_LINGUIDER)
790 host = Options::linGuiderHost();
792 port = Options::linGuiderPort();
795 ui->externalGuideHost->setText(host);
800void ProfileEditor::setSettings(
const QJsonObject &profile)
802 ui->profileIN->setText(profile[
"name"].
toString());
803 ui->autoConnectCheck->setChecked(profile[
"auto_connect"].toBool(
true));
804 ui->portSelectorCheck->setChecked(profile[
"port_selector"].toBool(
false));
805 ui->localMode->setChecked(profile[
"mode"].
toString() ==
"local");
806 ui->remoteMode->setChecked(profile[
"mode"].
toString() ==
"remote");
807 ui->remoteHost->setText(profile[
"remote_host"].
toString(
"localhost"));
808 ui->remotePort->setText(profile[
"remote_port"].
toString(
"7624"));
809 ui->guideTypeCombo->setCurrentText(profile[
"guiding"].
toString(
i18n(
"Internal")));
810 ui->externalGuideHost->setText(profile[
"remote_guiding_host"].
toString((
"localhost")));
811 ui->externalGuidePort->setText(profile[
"remote_guiding_port"].
toString(
"4400"));
812 ui->INDIWebManagerCheck->setChecked(profile[
"use_web_manager"].toBool());
813 ui->remoteDrivers->setText(profile[
"remote"].
toString(ui->remoteDrivers->text()));
815 m_INDIHub = profile[
"indihub"].toInt(m_INDIHub);
820 ui->mountCombo->setCurrentIndex(0);
823 ui->mountCombo->addItem(mount);
824 ui->mountCombo->setCurrentIndex(ui->mountCombo->count() - 1);
827 const QString ccd = profile[
"ccd"].toString(
"--");
829 ui->ccdCombo->setCurrentIndex(0);
832 ui->ccdCombo->addItem(ccd);
833 ui->ccdCombo->setCurrentIndex(ui->ccdCombo->count() - 1);
836 const QString guider = profile[
"guider"].toString(
"--");
838 ui->guiderCombo->setCurrentIndex(0);
841 ui->guiderCombo->addItem(guider);
842 ui->guiderCombo->setCurrentIndex(ui->guiderCombo->count() - 1);
845 const QString focuser = profile[
"focuser"].toString(
"--");
847 ui->focuserCombo->setCurrentIndex(0);
850 ui->focuserCombo->addItem(focuser);
851 ui->focuserCombo->setCurrentIndex(ui->focuserCombo->count() - 1);
854 ui->filterCombo->setCurrentText(profile[
"filter"].
toString(
"--"));
855 ui->AOCombo->setCurrentText(profile[
"ao"].
toString(
"--"));
856 ui->domeCombo->setCurrentText(profile[
"dome"].
toString(
"--"));
857 ui->weatherCombo->setCurrentText(profile[
"weather"].
toString(
"--"));
859 const auto aux1 = profile[
"aux1"].toString(
"--");
860 if (aux1.isEmpty() || aux1 ==
"--")
861 ui->aux1Combo->setCurrentIndex(0);
864 ui->aux1Combo->addItem(aux1);
865 ui->aux1Combo->setCurrentIndex(ui->aux1Combo->count() - 1);
868 const auto aux2 = profile[
"aux2"].toString(
"--");
869 if (aux2.isEmpty() || aux2 ==
"--")
870 ui->aux2Combo->setCurrentIndex(0);
873 ui->aux2Combo->addItem(aux2);
874 ui->aux2Combo->setCurrentIndex(ui->aux2Combo->count() - 1);
877 const auto aux3 = profile[
"aux3"].toString(
"--");
878 if (aux3.isEmpty() || aux3 ==
"--")
879 ui->aux3Combo->setCurrentIndex(0);
882 ui->aux3Combo->addItem(aux3);
883 ui->aux3Combo->setCurrentIndex(ui->aux3Combo->count() - 1);
886 const auto aux4 = profile[
"aux4"].toString(
"--");
887 if (aux4.isEmpty() || aux4 ==
"--")
888 ui->aux4Combo->setCurrentIndex(0);
891 ui->aux4Combo->addItem(aux4);
892 ui->aux4Combo->setCurrentIndex(ui->aux4Combo->count() - 1);
896void ProfileEditor::scanNetwork()
898 delete (m_ProgressDialog);
900 m_ProgressDialog->setWindowTitle(
i18nc(
"@title:window",
"Scanning Network"));
901 m_ProgressDialog->setLabelText(
i18n(
"Scanning network for INDI Web Managers..."));
907 m_ProgressDialog->setMinimum(0);
908 m_ProgressDialog->setMaximum(0);
909 m_ProgressDialog->show();
910 m_ProgressDialog->raise();
912 m_CancelScan =
false;
916 { return a.toString() < b.toString();});
927 scanIP(
"10.250.250.1");
934 for (
int i = 1; i <= 254; i++)
943void ProfileEditor::scanIP(
const QString &ip)
945 QUrl url(
QString(
"http://%1:8624/api/server/status").arg(ip));
947 qCDebug(KSTARS_EKOS) <<
"Scanning" << url;
950 m_Replies.
append(response);
960 m_ProgressDialog->close();
961 ui->remoteHost->setText(ip);
963 qCDebug(KSTARS_EKOS) <<
"Found Web Manager server at" << ip;
965 KSNotification::info(
i18n(
"Found INDI Web Manager at %1", ip));
970void ProfileEditor::clearAllRequests()
975 oneReply->deleteLater();
981void ProfileEditor::showINDIHub()
987 indihub.modeButtonGroup->setId(indihub.offR, 0);
988 indihub.modeButtonGroup->setId(indihub.solorR, 1);
989 indihub.modeButtonGroup->setId(indihub.shareR, 2);
990 indihub.modeButtonGroup->setId(indihub.roboticR, 3);
992 indihub.logoLabel->setPixmap(
QIcon(
":/icons/indihub_logo.svg").pixmap(
QSize(128, 128)));
994 indihub.modeButtonGroup->button(m_INDIHub)->setChecked(
true);
999 m_INDIHub = indihub.modeButtonGroup->checkedId();
1011 if (!families.
contains(driver->getType()))
1014 QString manufacturer = driver->manufacturer();
1018 if (model->
findItems(manufacturer).empty())
1026 parentItem = manufacturers.
first();
1032 if (selectedDriver == driver->getLabel())
1033 selectedItem = item;
1065 if (!families.
contains(driver->getType()))
1068 bool locallyAvailable =
false;
1069 if (driver->getAuxInfo().contains(
"LOCALLY_AVAILABLE"))
1070 locallyAvailable = driver->getAuxInfo().value(
"LOCALLY_AVAILABLE",
false).toBool();
1071 icon = locallyAvailable ?
QIcon() : remoteIcon;
1082void ProfileEditor::executeScriptEditor()
1088 currentDrivers << oneCombo->currentText();
1091 for (
auto &oneDriver : ui->remoteDrivers->text().split(
","))
1092 currentDrivers << oneDriver;
1093 currentDrivers.
sort();
1094 ProfileScriptDialog dialog(currentDrivers, pi->scripts,
this);
1096 auto settings = dialog.jsonSettings();
bool GetAllProfiles(QList< QSharedPointer< ProfileInfo > > &profiles)
GetAllProfiles Return all profiles in a QList.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
char * toString(const EngineQuery &query)
KIOCORE_EXPORT SimpleJob * mount(bool ro, const QByteArray &fstype, const QString &dev, const QString &point, JobFlags flags=DefaultFlags)
PostalAddress address(const QVariant &location)
virtual void sort(int column, Qt::SortOrder order)
void setCurrentIndex(const QModelIndex &index)
void addItem(const QIcon &icon, const QString &text, const QVariant &userData)
void setCurrentIndex(int index)
void setCurrentText(const QString &text)
int findText(const QString &text, Qt::MatchFlags flags) const const
QAbstractItemModel * model() const const
void setModelColumn(int visibleColumn)
virtual void setModel(QAbstractItemModel *model)
void setRootModelIndex(const QModelIndex &index)
void setView(QAbstractItemView *itemView)
QIcon fromTheme(const QString &name)
QByteArray toJson(JsonFormat format) const const
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
bool contains(const AT &value) const const
qsizetype removeAll(const AT &t)
bool removeOne(const AT &t)
QModelIndex parent() const const
QNetworkReply * get(const QNetworkRequest &request)
QList< QHostAddress > allAddresses()
NetworkError error() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QList< T > findChildren(Qt::FindChildOptions options) const const
void setObjectName(QAnyStringView name)
bool isNull() const const
void appendRow(QStandardItem *item)
virtual void setData(const QVariant &value, int role)
void setSelectable(bool selectable)
void appendRow(QStandardItem *item)
QList< QStandardItem * > findItems(const QString &text, Qt::MatchFlags flags, int column) const const
QModelIndex indexFromItem(const QStandardItem *item) const const
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
QString number(double n, char format, int precision)
QString & remove(QChar ch, Qt::CaseSensitivity cs)
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
void sort(Qt::CaseSensitivity cs)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
virtual void setModel(QAbstractItemModel *model) override
void sortByColumn(int column, Qt::SortOrder order)