[education/kstars] kstars/ekos: Fix issue where combo box in global config where not getting saved

Jasem Mutlaq <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit ed45dee635000f4fc82ba2c3393a0331bff50a2d by Jasem Mutlaq.
Committed on 27/07/2026 at 19:02.
Pushed by mutlaqja into branch 'master'.

Fix issue where combo box in global config where not getting saved

M  +16   -8    kstars/ekos/align/align_settings.cpp
M  +4    -4    kstars/ekos/align/align_solver.cpp
M  +16   -7    kstars/ekos/auxiliary/darklibrary.cpp
M  +0    -6    kstars/ekos/ekoslive/message.cpp
M  +16   -7    kstars/ekos/focus/focus.cpp
M  +16   -7    kstars/ekos/guide/guide.cpp
M  +16   -8    kstars/ekos/mount/mount.cpp

https://invent.kde.org/education/kstars/-/commit/ed45dee635000f4fc82ba2c3393a0331bff50a2d

diff --git a/kstars/ekos/align/align_settings.cpp b/kstars/ekos/align/align_settings.cpp
index b2f5165e79..d7760524c2 100644
--- a/kstars/ekos/align/align_settings.cpp
+++ b/kstars/ekos/align/align_settings.cpp
@@ -573,12 +573,15 @@ void Align::setAllSettings(const QVariantMap &settings)
     // performing the changes.
     disconnectSettings();
 
+    QSet<QString> comboKeys;
+
     for (auto &name : settings.keys())
     {
         // Combo
         auto comboBox = findChild<QComboBox*>(name);
         if (comboBox)
         {
+            comboKeys.insert(name);
             syncControl(settings, name, comboBox);
             continue;
         }
@@ -616,16 +619,21 @@ void Align::setAllSettings(const QVariantMap &settings)
         }
     }
 
-    // Sync to options
-    for (auto &key : settings.keys())
+    // Sync to options: build a map with combo indices for kcfg (UInt properties)
+    QVariantMap optionValues = settings;
+    for (auto &key : comboKeys)
     {
-        auto value = settings[key];
-        // Save immediately
-        Options::self()->setProperty(key.toLatin1(), value);
-        Options::self()->save();
+        auto cb = findChild<QComboBox*>(key);
+        if (cb)
+            optionValues[key] = cb->currentIndex();
+    }
+    KSUtils::setGlobalSettings(optionValues);
 
-        m_Settings[key] = value;
-        m_GlobalSettings[key] = value;
+    // m_Settings and m_GlobalSettings keep the original string values
+    for (auto &key : settings.keys())
+    {
+        m_Settings[key] = settings[key];
+        m_GlobalSettings[key] = settings[key];
     }
 
     Q_EMIT settingsUpdated(getAllSettings());
diff --git a/kstars/ekos/align/align_solver.cpp b/kstars/ekos/align/align_solver.cpp
index 346cca336c..d8d90f5045 100644
--- a/kstars/ekos/align/align_solver.cpp
+++ b/kstars/ekos/align/align_solver.cpp
@@ -479,7 +479,7 @@ void Align::setCaptureComplete()
         QDir dir;
         QDateTime now = KStarsData::Instance()->lt();
         QString path = QDir(KSPaths::writableLocation(QStandardPaths::AppLocalDataLocation)).filePath("align/" +
-            now.toString("yyyy-MM-dd"));
+                       now.toString("yyyy-MM-dd"));
         dir.mkpath(path);
         QString name     = "align_frame_" + now.toString("HH-mm-ss") + ".fits";
         QString filename = path + QStringLiteral("/") + name;
@@ -534,7 +534,7 @@ void Align::startSolving()
             {
                 appendLogText(
                     i18n("No index files were found on your system in the specified index file directories."
-                         "Please download some index files or add the correct directory to the list."));
+                     "Please download some index files or add the correct directory to the list."));
                 KConfigDialog * alignSettings = KConfigDialog::exists("alignsettings");
                 if(alignSettings && m_IndexFilesPage)
                 {
@@ -568,7 +568,7 @@ void Align::startSolving()
         if(type == SSolver::SOLVER_LOCALASTROMETRY || type == SSolver::SOLVER_ASTAP || type == SSolver::SOLVER_WATNEYASTROMETRY)
         {
             QString filename = QDir::tempPath() + QString("/solver%1.fits").arg(QUuid::createUuid().toString().remove(
-                    QRegularExpression("[-{}]")));
+                                   QRegularExpression("[-{}]")));
             m_AlignView->saveImage(filename);
             filenameToUse = filename;
         }
@@ -576,7 +576,7 @@ void Align::startSolving()
         if(type == SSolver::SOLVER_ONLINEASTROMETRY )
         {
             QString filename = QDir::tempPath() + QString("/solver%1.fits").arg(QUuid::createUuid().toString().remove(
-                    QRegularExpression("[-{}]")));
+                                   QRegularExpression("[-{}]")));
             m_AlignView->saveImage(filename);
             filenameToUse = filename;
         }
diff --git a/kstars/ekos/auxiliary/darklibrary.cpp b/kstars/ekos/auxiliary/darklibrary.cpp
index 9852d908e7..6317a5e1f3 100644
--- a/kstars/ekos/auxiliary/darklibrary.cpp
+++ b/kstars/ekos/auxiliary/darklibrary.cpp
@@ -1869,12 +1869,15 @@ void DarkLibrary::setAllSettings(const QVariantMap &settings)
     // performing the changes.
     disconnectSettings();
 
+    QSet<QString> comboKeys;
+
     for (auto &name : settings.keys())
     {
         // Combo
         auto comboBox = findChild<QComboBox*>(name);
         if (comboBox)
         {
+            comboKeys.insert(name);
             syncControl(settings, name, comboBox);
             continue;
         }
@@ -1912,15 +1915,21 @@ void DarkLibrary::setAllSettings(const QVariantMap &settings)
         }
     }
 
-    // Sync to options
-    for (auto &key : settings.keys())
+    // Sync to options: build a map with combo indices for kcfg (UInt properties)
+    QVariantMap optionValues = settings;
+    for (auto &key : comboKeys)
     {
-        auto value = settings[key];
-        // Save immediately
-        Options::self()->setProperty(key.toLatin1(), value);
+        auto cb = findChild<QComboBox*>(key);
+        if (cb)
+            optionValues[key] = cb->currentIndex();
+    }
+    KSUtils::setGlobalSettings(optionValues);
 
-        m_Settings[key] = value;
-        m_GlobalSettings[key] = value;
+    // m_Settings and m_GlobalSettings keep the original string values
+    for (auto &key : settings.keys())
+    {
+        m_Settings[key] = settings[key];
+        m_GlobalSettings[key] = settings[key];
     }
 
     Q_EMIT settingsUpdated(getAllSettings());
diff --git a/kstars/ekos/ekoslive/message.cpp b/kstars/ekos/ekoslive/message.cpp
index 1d76944617..0f87a3b3b7 100644
--- a/kstars/ekos/ekoslive/message.cpp
+++ b/kstars/ekos/ekoslive/message.cpp
@@ -691,7 +691,6 @@ void Message::processGuideCommands(const QString &command, const QJsonObject &pa
     {
         auto settings = payload.toVariantMap();
         guide->setAllSettings(settings);
-        KSUtils::setGlobalSettings(settings);
     }
     else if (command == commands[GUIDE_GET_ALL_SETTINGS])
         sendGuideSettings(guide->getAllSettings());
@@ -746,7 +745,6 @@ void Message::processFocusCommands(const QString &command, const QJsonObject &pa
     {
         auto settings = payload.toVariantMap();
         focus->setAllSettings(settings);
-        KSUtils::setGlobalSettings(settings);
     }
 
     else if (command == commands[FOCUS_GET_ALL_SETTINGS])
@@ -826,7 +824,6 @@ void Message::processMountCommands(const QString &command, const QJsonObject &pa
     {
         auto settings = payload.toVariantMap();
         mount->setAllSettings(settings);
-        KSUtils::setGlobalSettings(settings);
     }
     else if (command == commands[MOUNT_GET_ALL_SETTINGS])
         sendMountSettings(mount->getAllSettings());
@@ -905,7 +902,6 @@ void Message::processAlignCommands(const QString &command, const QJsonObject &pa
     {
         auto settings = payload.toVariantMap();
         align->setAllSettings(settings);
-        KSUtils::setGlobalSettings(settings);
     }
     else if (command == commands[ALIGN_GET_ALL_SETTINGS])
         sendAlignSettings(align->getAllSettings());
@@ -1044,7 +1040,6 @@ void Message::processSchedulerCommands(const QString &command, const QJsonObject
     {
         auto settings = payload.toVariantMap();
         scheduler->setAllSettings(settings);
-        KSUtils::setGlobalSettings(settings);
     }
     else if (command == commands[SCHEDULER_SAVE_FILE])
     {
@@ -1675,7 +1670,6 @@ void Message::processDarkLibraryCommands(const QString &command, const QJsonObje
     {
         auto settings = payload.toVariantMap();
         Ekos::DarkLibrary::Instance()->setAllSettings(settings);
-        KSUtils::setGlobalSettings(settings);
     }
     else if(command == commands[DARK_LIBRARY_GET_ALL_SETTINGS])
         sendDarkLibrarySettings(Ekos::DarkLibrary::Instance()->getAllSettings());
diff --git a/kstars/ekos/focus/focus.cpp b/kstars/ekos/focus/focus.cpp
index 795e933600..79153a8976 100644
--- a/kstars/ekos/focus/focus.cpp
+++ b/kstars/ekos/focus/focus.cpp
@@ -7869,12 +7869,15 @@ void Focus::setAllSettings(QVariantMap &settings)
     // Scrub the data just in case
     settings.remove(opticalTrainCombo->objectName());
 
+    QSet<QString> comboKeys;
+
     for (auto &name : settings.keys())
     {
         // Combo
         auto comboBox = findChild<QComboBox*>(name);
         if (comboBox)
         {
+            comboKeys.insert(name);
             syncControl(settings, name, comboBox);
             continue;
         }
@@ -7928,15 +7931,21 @@ void Focus::setAllSettings(QVariantMap &settings)
         }
     }
 
-    // Sync to options
-    for (auto &key : settings.keys())
+    // Sync to options: build a map with combo indices for kcfg (UInt properties)
+    QVariantMap optionValues = settings;
+    for (auto &key : comboKeys)
     {
-        auto value = settings[key];
-        // Save immediately
-        Options::self()->setProperty(key.toLatin1(), value);
+        auto cb = findChild<QComboBox*>(key);
+        if (cb)
+            optionValues[key] = cb->currentIndex();
+    }
+    KSUtils::setGlobalSettings(optionValues);
 
-        m_Settings[key] = value;
-        m_GlobalSettings[key] = value;
+    // m_Settings and m_GlobalSettings keep the original string values
+    for (auto &key : settings.keys())
+    {
+        m_Settings[key] = settings[key];
+        m_GlobalSettings[key] = settings[key];
     }
 
     Q_EMIT settingsUpdated(getAllSettings());
diff --git a/kstars/ekos/guide/guide.cpp b/kstars/ekos/guide/guide.cpp
index f7ad8f1c4a..bfa52d0cad 100644
--- a/kstars/ekos/guide/guide.cpp
+++ b/kstars/ekos/guide/guide.cpp
@@ -3715,12 +3715,15 @@ void Guide::setAllSettings(const QVariantMap &settings)
     // performing the changes.
     disconnectSettings();
 
+    QSet<QString> comboKeys;
+
     for (auto &name : settings.keys())
     {
         // Combo
         auto comboBox = findChild<QComboBox*>(name);
         if (comboBox)
         {
+            comboKeys.insert(name);
             syncControl(settings, name, comboBox);
             continue;
         }
@@ -3750,15 +3753,21 @@ void Guide::setAllSettings(const QVariantMap &settings)
         }
     }
 
-    // Sync to options
-    for (auto &key : settings.keys())
+    // Sync to options: build a map with combo indices for kcfg (UInt properties)
+    QVariantMap optionValues = settings;
+    for (auto &key : comboKeys)
     {
-        auto value = settings[key];
-        // Save immediately
-        Options::self()->setProperty(key.toLatin1(), value);
+        auto cb = findChild<QComboBox*>(key);
+        if (cb)
+            optionValues[key] = cb->currentIndex();
+    }
+    KSUtils::setGlobalSettings(optionValues);
 
-        m_Settings[key] = value;
-        m_GlobalSettings[key] = value;
+    // m_Settings and m_GlobalSettings keep the original string values
+    for (auto &key : settings.keys())
+    {
+        m_Settings[key] = settings[key];
+        m_GlobalSettings[key] = settings[key];
     }
 
     Q_EMIT settingsUpdated(getAllSettings());
diff --git a/kstars/ekos/mount/mount.cpp b/kstars/ekos/mount/mount.cpp
index 752ed5f1c6..f4f42acab7 100644
--- a/kstars/ekos/mount/mount.cpp
+++ b/kstars/ekos/mount/mount.cpp
@@ -1488,12 +1488,15 @@ void Mount::setAllSettings(const QVariantMap &settings)
     // performing the changes.
     disconnectSyncSettings();
 
+    QSet<QString> comboKeys;
+
     for (auto &name : settings.keys())
     {
         // Combo
         auto comboBox = findChild<QComboBox*>(name);
         if (comboBox)
         {
+            comboKeys.insert(name);
             syncControl(settings, name, comboBox);
             continue;
         }
@@ -1531,16 +1534,21 @@ void Mount::setAllSettings(const QVariantMap &settings)
         }
     }
 
-    // Sync to options
-    for (auto &key : settings.keys())
+    // Sync to options: build a map with combo indices for kcfg (UInt properties)
+    QVariantMap optionValues = settings;
+    for (auto &key : comboKeys)
     {
-        auto value = settings[key];
-        // Save immediately
-        Options::self()->setProperty(key.toLatin1(), value);
-        Options::self()->save();
+        auto cb = findChild<QComboBox*>(key);
+        if (cb)
+            optionValues[key] = cb->currentIndex();
+    }
+    KSUtils::setGlobalSettings(optionValues);
 
-        m_Settings[key] = value;
-        m_GlobalSettings[key] = value;
+    // m_Settings and m_GlobalSettings keep the original string values
+    for (auto &key : settings.keys())
+    {
+        m_Settings[key] = settings[key];
+        m_GlobalSettings[key] = settings[key];
     }
 
     Q_EMIT settingsUpdated(getAllSettings());
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.