[kstars] kstars: This patch contains 3 fixes. First, It will allow kstars to handle drivers that have xml files but no binary files. That way, if your remote server has a driver that your local computer does not, then you can still use the driver in remote mode, but not local mode in kstars.

Jasem Mutlaq null at kde.org
Tue Feb 14 10:01:08 UTC 2017


Git commit 6c76b5c7c9ce98cc7584ffca3f56f2a7494e2724 by Jasem Mutlaq, on behalf of Robert Lancaster.
Committed on 14/02/2017 at 05:34.
Pushed by mutlaqja into branch 'master'.

This patch contains 3 fixes. First, It will allow kstars to handle drivers that have xml files but no binary files.  That way, if your remote server has a driver that your local computer does not, then you can still use the driver in remote mode, but not local mode in kstars.
I made it so that in both the device manager and in the profile editor, drivers that have no binary file are displayed with a remote icon.  Also in the profile editor, when in local mode, the remote drivers do not appear.
Second, this patch addresses a fits view default size problem.  I improved the algorithm for calculating what the default size should be based on the viewport and I updated the base size to reflect the correct size of the fits view inside the fits viewer.
And finally, I made several corrections for OS X where the windows were not QT Tools and they could end up behind the main application window.

CCMAIL:kstars-devel at kde.org

M  +4    -0    kstars/ekos/capture/dslrinfodialog.cpp
M  +82   -52   kstars/ekos/profileeditor.cpp
M  +29   -3    kstars/indi/drivermanager.cpp
M  +2    -0    kstars/indi/drivermanager.h
M  +4    -0    kstars/indi/streamwg.cpp

https://commits.kde.org/kstars/6c76b5c7c9ce98cc7584ffca3f56f2a7494e2724

diff --git a/kstars/ekos/capture/dslrinfodialog.cpp b/kstars/ekos/capture/dslrinfodialog.cpp
index 1e89156b6..ba164c6cc 100644
--- a/kstars/ekos/capture/dslrinfodialog.cpp
+++ b/kstars/ekos/capture/dslrinfodialog.cpp
@@ -16,6 +16,10 @@
 
 DSLRInfo::DSLRInfo(QWidget *parent, ISD::CCD *ccd) : QDialog(parent)
 {
+#ifdef Q_OS_OSX
+        setWindowFlags(Qt::Tool| Qt::WindowStaysOnTopHint);
+#endif
+
     setupUi(this);
 
     currentCCD = ccd;
diff --git a/kstars/ekos/profileeditor.cpp b/kstars/ekos/profileeditor.cpp
index 7fe634e49..9a008f496 100644
--- a/kstars/ekos/profileeditor.cpp
+++ b/kstars/ekos/profileeditor.cpp
@@ -194,6 +194,8 @@ ProfileInfo *ProfileEditor::getPi() const
 
 void ProfileEditor::setRemoteMode(bool enable)
 {
+    loadDrivers();//This is needed to reload the drivers because some may not be available locally
+
     ui->remoteHost->setEnabled(enable);
     ui->remoteHostLabel->setEnabled(enable);
     ui->remotePort->setEnabled(enable);
@@ -394,92 +396,116 @@ void ProfileEditor::setPi(ProfileInfo *value)
 
 void ProfileEditor::loadDrivers()
 {
-    ui->mountCombo->addItem("--");
-    ui->ccdCombo->addItem("--");
-    ui->guiderCombo->addItem("--");
-    ui->AOCombo->addItem("--");
-    ui->focuserCombo->addItem("--");
-    ui->filterCombo->addItem("--");
-    ui->domeCombo->addItem("--");
-    ui->weatherCombo->addItem("--");
-    ui->aux1Combo->addItem("--");
-    ui->aux2Combo->addItem("--");
-    ui->aux3Combo->addItem("--");
-    ui->aux4Combo->addItem("--");
+
+    QVector<QComboBox*> boxes;
+    boxes.append(ui->mountCombo);
+    boxes.append(ui->ccdCombo);
+    boxes.append(ui->guiderCombo);
+    boxes.append(ui->AOCombo);
+    boxes.append(ui->focuserCombo);
+    boxes.append(ui->filterCombo);
+    boxes.append(ui->domeCombo);
+    boxes.append(ui->weatherCombo);
+    boxes.append(ui->aux1Combo);
+    boxes.append(ui->aux2Combo);
+    boxes.append(ui->aux3Combo);
+    boxes.append(ui->aux4Combo);
+
+    QVector<QString> selectedItems;
+
+    foreach(QComboBox *box,boxes){
+        selectedItems.append(box->currentText());
+        box->clear();
+        box->addItem("--");
+        box->setMaxVisibleItems(20);
+    }
+
+    QIcon remoteIcon=QIcon::fromTheme("modem", QIcon(":/icons/breeze/default/modem.svg"));
 
     foreach(DriverInfo *dv, DriverManager::Instance()->getDrivers())
     {
+        bool locallyAvailable=false;
+        QIcon icon;
+        if (dv->getAuxInfo().contains("LOCALLY_AVAILABLE"))
+            locallyAvailable = dv->getAuxInfo().value("LOCALLY_AVAILABLE", false).toBool();
+        if(!locallyAvailable){
+            if(ui->localMode->isChecked())
+                continue;
+            else
+                icon=remoteIcon;
+        }
+
         switch (dv->getType())
         {
         case KSTARS_TELESCOPE:
         {
-            ui->mountCombo->addItem(dv->getTreeLabel());
+            ui->mountCombo->addItem(icon, dv->getTreeLabel());
         }
         break;
 
         case KSTARS_CCD:
         {
-            ui->ccdCombo->addItem(dv->getTreeLabel());
-            ui->guiderCombo->addItem(dv->getTreeLabel());
+            ui->ccdCombo->addItem(icon, dv->getTreeLabel());
+            ui->guiderCombo->addItem(icon, dv->getTreeLabel());
 
-            ui->aux1Combo->addItem(dv->getTreeLabel());
-            ui->aux2Combo->addItem(dv->getTreeLabel());
-            ui->aux3Combo->addItem(dv->getTreeLabel());
-            ui->aux4Combo->addItem(dv->getTreeLabel());
+            ui->aux1Combo->addItem(icon, dv->getTreeLabel());
+            ui->aux2Combo->addItem(icon, dv->getTreeLabel());
+            ui->aux3Combo->addItem(icon, dv->getTreeLabel());
+            ui->aux4Combo->addItem(icon, dv->getTreeLabel());
         }
         break;
 
         case KSTARS_ADAPTIVE_OPTICS:
         {
-            ui->AOCombo->addItem(dv->getTreeLabel());
+            ui->AOCombo->addItem(icon, dv->getTreeLabel());
         }
         break;
 
         case KSTARS_FOCUSER:
         {
-            ui->focuserCombo->addItem(dv->getTreeLabel());
+            ui->focuserCombo->addItem(icon, dv->getTreeLabel());
 
-            ui->aux1Combo->addItem(dv->getTreeLabel());
-            ui->aux2Combo->addItem(dv->getTreeLabel());
-            ui->aux3Combo->addItem(dv->getTreeLabel());
-            ui->aux4Combo->addItem(dv->getTreeLabel());
+            ui->aux1Combo->addItem(icon, dv->getTreeLabel());
+            ui->aux2Combo->addItem(icon, dv->getTreeLabel());
+            ui->aux3Combo->addItem(icon, dv->getTreeLabel());
+            ui->aux4Combo->addItem(icon, dv->getTreeLabel());
         }
         break;
 
         case KSTARS_FILTER:
         {
-            ui->filterCombo->addItem(dv->getTreeLabel());
+            ui->filterCombo->addItem(icon, dv->getTreeLabel());
 
-            ui->aux1Combo->addItem(dv->getTreeLabel());
-            ui->aux2Combo->addItem(dv->getTreeLabel());
-            ui->aux3Combo->addItem(dv->getTreeLabel());
-            ui->aux4Combo->addItem(dv->getTreeLabel());
+            ui->aux1Combo->addItem(icon, dv->getTreeLabel());
+            ui->aux2Combo->addItem(icon, dv->getTreeLabel());
+            ui->aux3Combo->addItem(icon, dv->getTreeLabel());
+            ui->aux4Combo->addItem(icon, dv->getTreeLabel());
         }
         break;
 
         case KSTARS_DOME:
         {
-            ui->domeCombo->addItem(dv->getTreeLabel());
+            ui->domeCombo->addItem(icon, dv->getTreeLabel());
         }
         break;
 
         case KSTARS_WEATHER:
         {
-            ui->weatherCombo->addItem(dv->getTreeLabel());
+            ui->weatherCombo->addItem(icon, dv->getTreeLabel());
 
-            ui->aux1Combo->addItem(dv->getTreeLabel());
-            ui->aux2Combo->addItem(dv->getTreeLabel());
-            ui->aux3Combo->addItem(dv->getTreeLabel());
-            ui->aux4Combo->addItem(dv->getTreeLabel());
+            ui->aux1Combo->addItem(icon, dv->getTreeLabel());
+            ui->aux2Combo->addItem(icon, dv->getTreeLabel());
+            ui->aux3Combo->addItem(icon, dv->getTreeLabel());
+            ui->aux4Combo->addItem(icon, dv->getTreeLabel());
         }
         break;
 
         case KSTARS_AUXILIARY:
         {
-            ui->aux1Combo->addItem(dv->getTreeLabel());
-            ui->aux2Combo->addItem(dv->getTreeLabel());
-            ui->aux3Combo->addItem(dv->getTreeLabel());
-            ui->aux4Combo->addItem(dv->getTreeLabel());
+            ui->aux1Combo->addItem(icon, dv->getTreeLabel());
+            ui->aux2Combo->addItem(icon, dv->getTreeLabel());
+            ui->aux3Combo->addItem(icon, dv->getTreeLabel());
+            ui->aux4Combo->addItem(icon, dv->getTreeLabel());
         }
         break;
 
@@ -490,17 +516,21 @@ void ProfileEditor::loadDrivers()
     }
 
     //ui->mountCombo->setCurrentIndex(-1);
-    ui->mountCombo->model()->sort(0);
-    ui->ccdCombo->model()->sort(0);
-    ui->guiderCombo->model()->sort(0);
-    ui->AOCombo->model()->sort(0);
-    ui->focuserCombo->model()->sort(0);
-    ui->filterCombo->model()->sort(0);
-    ui->domeCombo->model()->sort(0);
-    ui->weatherCombo->model()->sort(0);
-    ui->aux1Combo->model()->sort(0);
-    ui->aux2Combo->model()->sort(0);
-    ui->aux3Combo->model()->sort(0);
-    ui->aux4Combo->model()->sort(0);
+
+     for(int i=0;i<boxes.count();i++){
+         QComboBox *box=boxes.at(i);
+         QString selectedItemText=selectedItems.at(i);
+         int index=box->findText(selectedItemText);
+         if(index==-1){
+             if(ui->localMode->isChecked())
+                 box->setCurrentIndex(0);
+             else
+                 box->addItem(remoteIcon,selectedItemText);
+
+         } else{
+             box->setCurrentIndex(index);
+         }
+         box->model()->sort(0);
+     }
 }
 
diff --git a/kstars/indi/drivermanager.cpp b/kstars/indi/drivermanager.cpp
index 52d79c604..6825440e1 100644
--- a/kstars/indi/drivermanager.cpp
+++ b/kstars/indi/drivermanager.cpp
@@ -183,12 +183,17 @@ void DriverManager::processDeviceStatus(DriverInfo *dv)
                      cState = dv->getClientState() && dState;
 
 
+                 bool locallyAvailable=false;
+                 if (dv->getAuxInfo().contains("LOCALLY_AVAILABLE"))
+                    locallyAvailable = dv->getAuxInfo().value("LOCALLY_AVAILABLE", false).toBool();
+
                  switch (mode)
                  {
                     case SERVER_ONLY:
                      ui->runServiceB->setEnabled(!dState);
                      ui->stopServiceB->setEnabled(dState);
-                     item->setIcon(LOCAL_STATUS_COLUMN, dState ? ui->runningPix : ui->stopPix);
+                     if(locallyAvailable)
+                        item->setIcon(LOCAL_STATUS_COLUMN, dState ? ui->runningPix : ui->stopPix);
                      if (dState)
                      {
                          item->setIcon(LOCAL_MODE_COLUMN, ui->serverMode);
@@ -206,7 +211,8 @@ void DriverManager::processDeviceStatus(DriverInfo *dv)
                     case SERVER_CLIENT:
                      ui->runServiceB->setEnabled(!cState);
                      ui->stopServiceB->setEnabled(cState);
-                     item->setIcon(LOCAL_STATUS_COLUMN, cState ? ui->runningPix : ui->stopPix);
+                     if(locallyAvailable)
+                        item->setIcon(LOCAL_STATUS_COLUMN, cState ? ui->runningPix : ui->stopPix);
                      if (cState)
                      {
                          item->setIcon(LOCAL_MODE_COLUMN, ui->localMode);
@@ -1204,10 +1210,18 @@ bool DriverManager::buildDriverElement(XMLEle *root, QTreeWidgetItem *DGroup, De
 
         version = pcdataXMLEle(el);
 
+        bool driverIsAvailable=checkDriverAvailability(driver);
+
+        vMap.insert("LOCALLY_AVAILABLE", driverIsAvailable);
+        QIcon remoteIcon=QIcon::fromTheme("modem", QIcon(":/icons/breeze/default/modem.svg"));
+
         QTreeWidgetItem *device = new QTreeWidgetItem(DGroup);
 
     device->setText(LOCAL_NAME_COLUMN, label);
-    device->setIcon(LOCAL_STATUS_COLUMN, ui->stopPix);
+    if(driverIsAvailable)
+        device->setIcon(LOCAL_STATUS_COLUMN, ui->stopPix);
+    else
+        device->setIcon(LOCAL_STATUS_COLUMN, remoteIcon);
     device->setText(LOCAL_VERSION_COLUMN, version);
     device->setText(LOCAL_PORT_COLUMN, port);
 
@@ -1237,6 +1251,18 @@ bool DriverManager::buildDriverElement(XMLEle *root, QTreeWidgetItem *DGroup, De
     return true;
 }
 
+bool DriverManager::checkDriverAvailability(QString driver){
+    QString indiServerDir=Options::indiServer();
+    if(Options::indiServerIsInternal())
+        indiServerDir=QCoreApplication::applicationDirPath()+"/indi";
+    else
+       indiServerDir=QFileInfo(Options::indiServer()).dir().path();
+
+    QFile driverFile(indiServerDir + "/" + driver);
+
+    return driverFile.exists();
+}
+
 void DriverManager::updateCustomDrivers()
 {
 
diff --git a/kstars/indi/drivermanager.h b/kstars/indi/drivermanager.h
index 46068d9a0..5784c5a03 100644
--- a/kstars/indi/drivermanager.h
+++ b/kstars/indi/drivermanager.h
@@ -136,6 +136,8 @@ private:
     QList<ClientManager *> clients;
     QStringList driversStringList;
 
+    bool checkDriverAvailability(QString driver);
+
     INDIDBus indiDBUS;
 
 public slots:
diff --git a/kstars/indi/streamwg.cpp b/kstars/indi/streamwg.cpp
index 374d60668..600f907cb 100644
--- a/kstars/indi/streamwg.cpp
+++ b/kstars/indi/streamwg.cpp
@@ -38,6 +38,10 @@
 
 RecordOptions::RecordOptions(QWidget *parent) : QDialog(parent)
 {
+#ifdef Q_OS_OSX
+        setWindowFlags(Qt::Tool| Qt::WindowStaysOnTopHint);
+#endif
+
     setupUi(this);
 
     dirPath     = QUrl::fromLocalFile(QDir::homePath());



More information about the Kstars-devel mailing list