[kstars] kstars: Rework how configuration settings are applied. All this time _any_ configuration settings that changes resulted in a complete reload of many catalogs and database entries unnecessairly. It is now more granular and each page applies its own changes as necessary.

Jasem Mutlaq mutlaqja at ikarustech.com
Thu Dec 1 10:47:39 UTC 2016


Git commit 52a28143df73f22fe2f86eeff04b5da5ab57d47b by Jasem Mutlaq.
Committed on 01/12/2016 at 10:43.
Pushed by mutlaqja into branch 'master'.

Rework how configuration settings are applied. All this time _any_ configuration settings that changes resulted in a complete reload of many catalogs and database entries unnecessairly. It is now more granular and each page applies its own changes as necessary.
This needs extensive testing as I am not sure what other assumption were made when this configuration model was conceived. It now _appears_ to be applying changes only when necessary but I could have missed a few things here and there. Please test.
CCMAIL:kstars-devel at kde.org

M  +5    -16   kstars/kstarsactions.cpp
M  +66   -31   kstars/options/opscatalog.cpp
M  +1    -0    kstars/options/opscatalog.h
M  +43   -12   kstars/options/opscatalog.ui
M  +1    -1    kstars/options/opscolors.h
M  +58   -15   kstars/options/opsguides.cpp
M  +6    -1    kstars/options/opsguides.h
M  +64   -2    kstars/options/opsguides.ui
M  +16   -0    kstars/options/opssatellites.cpp
M  +1    -0    kstars/options/opssatellites.h
M  +15   -0    kstars/options/opssatellites.ui
M  +29   -3    kstars/options/opssolarsystem.cpp
M  +6    -1    kstars/options/opssolarsystem.h
M  +58   -0    kstars/options/opssolarsystem.ui

https://commits.kde.org/kstars/52a28143df73f22fe2f86eeff04b5da5ab57d47b

diff --git a/kstars/kstarsactions.cpp b/kstars/kstarsactions.cpp
index 3c69387..d5ff99e 100644
--- a/kstars/kstarsactions.cpp
+++ b/kstars/kstarsactions.cpp
@@ -763,25 +763,14 @@ void KStars::slotViewOps() {
     dialog->show();
 }
 
-void KStars::slotApplyConfigChanges() {
-    Options::self()->save();
-
-    // If the focus object was a constellation and the sky culture has changed, remove the focus object
-    if( map()->focusObject() && map()->focusObject()->type() == SkyObject::CONSTELLATION ) {
-        if( m_KStarsData->skyComposite()->currentCulture() != m_KStarsData->skyComposite()->getCultureName( (int)Options::skyCulture() ) || m_KStarsData->skyComposite()->isLocalCNames() != Options::useLocalConstellNames() ) {
-            map()->setClickedObject( NULL );
-            map()->setFocusObject( NULL );
-        }
-    }
+void KStars::slotApplyConfigChanges()
+{
+    Options::self()->save();    
 
     applyConfig();
-    data()->setFullTimeUpdate();
-    map()->forceUpdate();
 
-    m_KStarsData->skyComposite()->setCurrentCulture(  m_KStarsData->skyComposite()->getCultureName( (int)Options::skyCulture() ) );
-    m_KStarsData->skyComposite()->reloadCLines();
-    m_KStarsData->skyComposite()->reloadCNames();
-    m_KStarsData->skyComposite()->reloadConstellationArt();
+    //data()->setFullTimeUpdate();
+    //map()->forceUpdate();
 }
 
 void KStars::slotApplyWIConfigChanges() {
diff --git a/kstars/options/opscatalog.cpp b/kstars/options/opscatalog.cpp
index fe8577d..4810e0a 100644
--- a/kstars/options/opscatalog.cpp
+++ b/kstars/options/opscatalog.cpp
@@ -76,7 +76,7 @@ OpsCatalog::OpsCatalog()
     populateCustomCatalogs();
 
     connect( CatalogList, SIGNAL( itemClicked( QListWidgetItem* ) ), this, SLOT( updateCustomCatalogs() ) );
-    connect( CatalogList, SIGNAL( itemSelectionChanged() ), this, SLOT( selectCatalog() ) );
+    connect( CatalogList, SIGNAL( itemSelectionChanged() ), this, SLOT( selectCatalog() ) );    
     connect( AddCatalog, SIGNAL( clicked() ), this, SLOT( slotAddCatalog() ) );
     connect( LoadCatalog, SIGNAL( clicked() ), this, SLOT( slotLoadCatalog() ) );
     connect( RemoveCatalog, SIGNAL( clicked() ), this, SLOT( slotRemoveCatalog() ) );
@@ -93,6 +93,12 @@ OpsCatalog::OpsCatalog()
     connect( m_ConfigDialog->button(QDialogButtonBox::Apply), SIGNAL( clicked() ), SLOT( slotApply() ) );
     connect( m_ConfigDialog->button(QDialogButtonBox::Ok), SIGNAL( clicked() ), SLOT( slotApply() ) );
     connect( m_ConfigDialog->button(QDialogButtonBox::Cancel), SIGNAL( clicked() ), SLOT( slotCancel() ) );
+
+    // Keep track of changes
+    connect( CatalogList, &QListWidget::itemChanged, this, [&](){ isDirty = true;});
+    connect( catalogButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonPressed), this, [&](){ isDirty = true;});
+
+    isDirty = false;
 }
 
 //empty destructor
@@ -119,12 +125,21 @@ void OpsCatalog::updateCustomCatalogs() {
          * not contain the name. If it does, we remove it.
         */
         if (l.count() == 0) continue;  // skip the name if no match found
-        if ( l[0]->checkState()==Qt::Checked ) {
+        if ( l[0]->checkState()==Qt::Checked )
+        {
             if (!m_CheckedCatalogNames.contains(name))
+            {
                 m_CheckedCatalogNames.append(name);
-        } else if ( l[0]->checkState()==Qt::Unchecked ){
+                //isDirty = true;
+            }
+        }
+        else if ( l[0]->checkState()==Qt::Unchecked )
+        {
             if (m_CheckedCatalogNames.contains(name))
+            {
                 m_CheckedCatalogNames.removeAll(name);
+                //isDirty = true;
+            }
         }
     }
 
@@ -132,15 +147,20 @@ void OpsCatalog::updateCustomCatalogs() {
 }
 
 
-void OpsCatalog::selectCatalog() {
+void OpsCatalog::selectCatalog()
+{
     //If selected item is a custom catalog, enable the remove button (otherwise, disable it)
-    RemoveCatalog->setEnabled( false );
+    RemoveCatalog->setEnabled( false );    
 
     if ( ! CatalogList->currentItem() ) return;
 
-    foreach ( SkyComponent *sc, KStars::Instance()->data()->skyComposite()->customCatalogs() ) {
+    //isDirty = true;
+
+    foreach ( SkyComponent *sc, KStars::Instance()->data()->skyComposite()->customCatalogs() )
+    {
         CatalogComponent *cc = (CatalogComponent*)sc;
-        if ( CatalogList->currentItem()->text() == cc->name() ) {
+        if ( CatalogList->currentItem()->text() == cc->name() )
+        {
             RemoveCatalog->setEnabled( true );
             break;
         }
@@ -148,21 +168,27 @@ void OpsCatalog::selectCatalog() {
 }
 
 
-void OpsCatalog::slotAddCatalog() {
+void OpsCatalog::slotAddCatalog()
+{
     QPointer<AddCatDialog> ac = new AddCatDialog( KStars::Instance() );
-    if ( ac->exec()==QDialog::Accepted ) {
-        KStars::Instance()->data()->catalogdb()->AddCatalogContents( ac->filename() );
+    if ( ac->exec()==QDialog::Accepted )
+    {
+        KStars::Instance()->data()->catalogdb()->AddCatalogContents( ac->filename() );        
         refreshCatalogList();
+        isDirty=true;
     }
     delete ac;
 }
 
 
-void OpsCatalog::slotLoadCatalog() {
+void OpsCatalog::slotLoadCatalog()
+{
     //Get the filename from the user
     QString filename = QFileDialog::getOpenFileName(KStars::Instance(), QString(),  QDir::homePath(), "*");
-    if ( ! filename.isEmpty() ) {
+    if ( ! filename.isEmpty() )
+    {
         KStars::Instance()->data()->catalogdb()->AddCatalogContents(filename);
+        isDirty = true;
         refreshCatalogList();
     }
 
@@ -170,28 +196,31 @@ void OpsCatalog::slotLoadCatalog() {
 }
 
 
-void OpsCatalog::refreshCatalogList() {
+void OpsCatalog::refreshCatalogList()
+{
     KStars::Instance()->data()->catalogdb()->Catalogs();
     populateCustomCatalogs();
 }
 
 
-void OpsCatalog::slotRemoveCatalog() {
-    if (KMessageBox::warningYesNo(0,
-                     i18n("The selected database will be removed. "
-                           "This action cannot be reversed! Delete Catalog?"),
-                          i18n("Delete Catalog?") )
-            == KMessageBox::No) {
+void OpsCatalog::slotRemoveCatalog()
+{
+    if (KMessageBox::warningYesNo(0,  i18n("The selected database will be removed. This action cannot be reversed! Delete Catalog?"), i18n("Delete Catalog?") ) == KMessageBox::No)
+    {
             KMessageBox::information(0, "Catalog deletion cancelled.");
             return;
     }
+
+    isDirty = true;
+
     //Ask DB to remove catalog
     KStars::Instance()->data()->catalogdb()->RemoveCatalog( CatalogList->currentItem()->text() );
 
     // Remove from Options if it exists in it (i.e. was marked as visible)
     // This does not remove it from the database or from the widget in Options
     QList<QString> checkedlist = Options::showCatalogNames();
-    if (checkedlist.contains(CatalogList->currentItem()->text())) {
+    if (checkedlist.contains(CatalogList->currentItem()->text()))
+    {
         checkedlist.removeAll(CatalogList->currentItem()->text());
         Options::setShowCatalogNames(checkedlist);
     }
@@ -218,9 +247,14 @@ void OpsCatalog::slotSetDrawStarZoomOutMagnitude(double newValue) {
 }
 */
 
-void OpsCatalog::slotApply() {
-    refreshCatalogList();
-    Options::setShowCatalogNames(m_CheckedCatalogNames);
+void OpsCatalog::slotApply()
+{
+    if (isDirty == false)
+        return;
+
+    isDirty = false;
+
+    refreshCatalogList();    
 
     Options::setStarDensity( kcfg_StarDensity->value() );
     //    Options::setMagLimitDrawStarZoomOut( kcfg_MagLimitDrawStarZoomOut->value() );
@@ -228,26 +262,27 @@ void OpsCatalog::slotApply() {
     //FIXME: need to add the ShowDeepSky meta-option to the config dialog!
     //For now, I'll set showDeepSky to true if any catalog options changed
     if ( m_ShowMessier != Options::showMessier() || m_ShowMessImages != Options::showMessierImages()
-         || m_ShowNGC != Options::showNGC() || m_ShowIC != Options::showIC() ) {
+         || m_ShowNGC != Options::showNGC() || m_ShowIC != Options::showIC() )
+    {
         Options::setShowDeepSky( true );
     }
 
     updateCustomCatalogs();
 
-    // JM: Why are we calling this if no deep sky stuff was changed?
-    // AS: It's possible that custom catalogs have changed, which is probably why.
     KStars::Instance()->data()->skyComposite()->reloadDeepSky();
 
-    Options::setShowMessier( m_ShowMessier );
-    Options::setShowMessierImages( m_ShowMessImages );
-    Options::setShowNGC( m_ShowNGC );
-    Options::setShowIC( m_ShowIC );
-
     // update time for all objects because they might be not initialized
     // it's needed when using horizontal coordinates
     KStars::Instance()->data()->setFullTimeUpdate();
     KStars::Instance()->updateTime();
     KStars::Instance()->map()->forceUpdate();
+
+    Options::setShowCatalogNames(m_CheckedCatalogNames);
+
+    Options::setShowMessier( m_ShowMessier );
+    Options::setShowMessierImages( m_ShowMessImages );
+    Options::setShowNGC( m_ShowNGC );
+    Options::setShowIC( m_ShowIC );
 }
 
 
diff --git a/kstars/options/opscatalog.h b/kstars/options/opscatalog.h
index 80a8469..13c698a 100644
--- a/kstars/options/opscatalog.h
+++ b/kstars/options/opscatalog.h
@@ -74,6 +74,7 @@ private:
     QList<int> m_ShowCustomCatalog;
     float m_StarDensity;
     bool m_ShowMessier, m_ShowMessImages, m_ShowNGC, m_ShowIC;
+    bool isDirty=false;
 };
 
 #endif  //OPSCATALOG_H_
diff --git a/kstars/options/opscatalog.ui b/kstars/options/opscatalog.ui
index 0f9039a..74ea221 100644
--- a/kstars/options/opscatalog.ui
+++ b/kstars/options/opscatalog.ui
@@ -24,6 +24,9 @@
           <property name="text">
            <string>&Star Catalogs</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">catalogButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item>
@@ -125,6 +128,9 @@
             <property name="text">
              <string>Show &name</string>
             </property>
+            <attribute name="buttonGroup">
+             <string notr="true">catalogButtonGroup</string>
+            </attribute>
            </widget>
           </item>
           <item row="1" column="1">
@@ -132,6 +138,9 @@
             <property name="text">
              <string>Show ma&gnitude</string>
             </property>
+            <attribute name="buttonGroup">
+             <string notr="true">catalogButtonGroup</string>
+            </attribute>
            </widget>
           </item>
           <item row="0" column="0">
@@ -257,6 +266,9 @@
           <property name="text">
            <string>Deep-Sky Catalogs</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">catalogButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item>
@@ -285,6 +297,9 @@
             <property name="text">
              <string>Show na&me</string>
             </property>
+            <attribute name="buttonGroup">
+             <string notr="true">catalogButtonGroup</string>
+            </attribute>
            </widget>
           </item>
          </layout>
@@ -315,6 +330,9 @@
             <property name="text">
              <string>Show &long names</string>
             </property>
+            <attribute name="buttonGroup">
+             <string notr="true">catalogButtonGroup</string>
+            </attribute>
            </widget>
           </item>
           <item>
@@ -358,6 +376,9 @@
             <property name="text">
              <string>Show magni&tude</string>
             </property>
+            <attribute name="buttonGroup">
+             <string notr="true">catalogButtonGroup</string>
+            </attribute>
            </widget>
           </item>
          </layout>
@@ -503,19 +524,19 @@
        </layout>
       </item>
       <item>
-        <layout class="QHBoxLayout">
-          <item>
-            <widget class="QCheckBox" name="kcfg_ResolveNamesOnline">
-              <property name="text">
-                <string>Resolve names not known to KStars using online services</string>
-              </property>
-              <property name="toolTip">
-                <string>If this checkbox is checked, when an object name unknown to KStars is entered in the Find Dialog, KStars will contact online services (such as CDS Sesame) to learn about the object and then add it to the database.
+       <layout class="QHBoxLayout">
+        <item>
+         <widget class="QCheckBox" name="kcfg_ResolveNamesOnline">
+          <property name="toolTip">
+           <string>If this checkbox is checked, when an object name unknown to KStars is entered in the Find Dialog, KStars will contact online services (such as CDS Sesame) to learn about the object and then add it to the database.
                 The objects acquired in this manner are stored under a catalog that is called _Internet_Resolved as of this writing.</string>
-              </property>
-            </widget>
-          </item>
-        </layout>
+          </property>
+          <property name="text">
+           <string>Resolve names not known to KStars using online services</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
       </item>
       <item>
        <layout class="QHBoxLayout">
@@ -634,6 +655,9 @@ These magnitude limits do not affect IC objects, as the magnitudes for many IC o
           <property name="text">
            <string>Show objects of unknown magnitude</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">catalogButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item>
@@ -665,4 +689,11 @@ These magnitude limits do not affect IC objects, as the magnitudes for many IC o
  </customwidgets>
  <resources/>
  <connections/>
+ <buttongroups>
+  <buttongroup name="catalogButtonGroup">
+   <property name="exclusive">
+    <bool>false</bool>
+   </property>
+  </buttongroup>
+ </buttongroups>
 </ui>
diff --git a/kstars/options/opscolors.h b/kstars/options/opscolors.h
index c16a5c8..fca9a4f 100644
--- a/kstars/options/opscolors.h
+++ b/kstars/options/opscolors.h
@@ -56,7 +56,7 @@ private slots:
 private:
     bool setColors( const QString &filename );
 
-    QStringList PresetFileList;
+    QStringList PresetFileList;    
 };
 
 #endif  //OPSCOLORS_H_
diff --git a/kstars/options/opsguides.cpp b/kstars/options/opsguides.cpp
index 7c14ad2..d5e4a79 100644
--- a/kstars/options/opsguides.cpp
+++ b/kstars/options/opsguides.cpp
@@ -14,10 +14,13 @@
  *                                                                         *
  ***************************************************************************/
 
+#include <KConfigDialog>
+
 #include "opsguides.h"
 #include "ksfilereader.h"
 #include "kstars.h"
 #include "kstarsdata.h"
+#include "skymap.h"
 #include "skycomponents/skymapcomposite.h"
 #include "Options.h"
 
@@ -25,20 +28,14 @@ OpsGuides::OpsGuides()
         : QFrame(KStars::Instance())
 {
     setupUi( this );
-    connect( kcfg_ShowCNames, SIGNAL( toggled( bool ) ),
-             this, SLOT( slotToggleConstellOptions( bool ) ) );
-    connect( kcfg_ShowConstellationArt, SIGNAL( toggled( bool ) ),
-             this, SLOT( slotToggleConstellationArt( bool ) ) );
-    connect( kcfg_ShowMilkyWay, SIGNAL( toggled( bool ) ),
-             this, SLOT( slotToggleMilkyWayOptions( bool ) ) );
-    connect( kcfg_ShowGround, SIGNAL( toggled( bool ) ),
-             this, SLOT( slotToggleOpaqueGround( bool ) ) );
-    connect( kcfg_AutoSelectGrid, SIGNAL( toggled( bool ) ),
-             this, SLOT( slotToggleAutoSelectGrid( bool ) ) );
 
     foreach( const QString& item, KStarsData::Instance()->skyComposite()->getCultureNames() )
         kcfg_SkyCulture->addItem( i18nc("Sky Culture", item.toUtf8().constData() ) );
 
+    m_ConfigDialog = KConfigDialog::exists( "settings" );
+    connect( m_ConfigDialog->button(QDialogButtonBox::Apply), SIGNAL( clicked() ), SLOT( slotApply() ) );
+    connect( m_ConfigDialog->button(QDialogButtonBox::Ok), SIGNAL( clicked() ), SLOT( slotApply() ) );
+
     // When setting up the widget, update the enabled status of the
     // checkboxes depending on the options.
     slotToggleOpaqueGround( Options::showGround() ); 
@@ -47,30 +44,76 @@ OpsGuides::OpsGuides()
     slotToggleMilkyWayOptions( Options::showMilkyWay() );
     slotToggleAutoSelectGrid( Options::autoSelectGrid() );
 
+    connect( kcfg_ShowCNames, SIGNAL( toggled( bool ) ), this, SLOT( slotToggleConstellOptions( bool ) ) );
+    connect( kcfg_ShowConstellationArt, SIGNAL( toggled( bool ) ), this, SLOT( slotToggleConstellationArt( bool ) ) );
+    connect( kcfg_ShowMilkyWay, SIGNAL( toggled( bool ) ), this, SLOT( slotToggleMilkyWayOptions( bool ) ) );
+    connect( kcfg_ShowGround, SIGNAL( toggled( bool ) ), this, SLOT( slotToggleOpaqueGround( bool ) ) );
+    connect( kcfg_AutoSelectGrid, SIGNAL( toggled( bool ) ), this, SLOT( slotToggleAutoSelectGrid( bool ) ) );
+
+    // Track changes to apply settings
+    connect( constellationButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonPressed), this, [&](){ isDirty = true;});
+    connect( nameButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonPressed), this, [&](){ isDirty = true;});
+    connect( kcfg_SkyCulture, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), this, [&](){ isDirty = true; });
+
+    isDirty = false;
 }
 
 OpsGuides::~OpsGuides()
 {}
 
-void OpsGuides::slotToggleConstellOptions( bool state ) {
+void OpsGuides::slotToggleConstellOptions( bool state )
+{
     ConstellOptions->setEnabled( state );
 }
 
-void OpsGuides::slotToggleConstellationArt( bool state ) {
+void OpsGuides::slotToggleConstellationArt( bool state )
+{
     kcfg_ShowConstellationArt->setEnabled( state );
 }
 
-void OpsGuides::slotToggleMilkyWayOptions( bool state ) {
+void OpsGuides::slotToggleMilkyWayOptions( bool state )
+{
     kcfg_FillMilkyWay->setEnabled( state );
 }
 
-void OpsGuides::slotToggleOpaqueGround( bool state ) {
+void OpsGuides::slotToggleOpaqueGround( bool state )
+{
     kcfg_ShowHorizon->setEnabled( !state );
 }
 
-void OpsGuides::slotToggleAutoSelectGrid( bool state ) {
+void OpsGuides::slotToggleAutoSelectGrid( bool state )
+{
     kcfg_ShowEquatorialGrid->setEnabled( !state );
     kcfg_ShowHorizontalGrid->setEnabled( !state );
 }
 
+void OpsGuides::slotApply()
+{
+    if (isDirty == false)
+        return;
+
+    isDirty = false;
+
+    KStarsData *data = KStarsData::Instance();
+    SkyMap *map = SkyMap::Instance();
 
+    // If the focus object was a constellation and the sky culture has changed, remove the focus object
+    if( map->focusObject() && map->focusObject()->type() == SkyObject::CONSTELLATION )
+    {
+        if( data->skyComposite()->currentCulture() != data->skyComposite()->getCultureName(kcfg_SkyCulture->currentIndex()) ||
+            data->skyComposite()->isLocalCNames() != Options::useLocalConstellNames() )
+        {
+            map->setClickedObject( NULL );
+            map->setFocusObject( NULL );
+        }
+    }
+
+    data->skyComposite()->setCurrentCulture(  KStarsData::Instance()->skyComposite()->getCultureName( kcfg_SkyCulture->currentIndex() ) );
+    data->skyComposite()->reloadCLines();
+    data->skyComposite()->reloadCNames();
+    data->skyComposite()->reloadConstellationArt();
+
+    data->setFullTimeUpdate();
+    KStars::Instance()->updateTime();
+    map->forceUpdate();
+}
diff --git a/kstars/options/opsguides.h b/kstars/options/opsguides.h
index ea5aab9..159d710 100644
--- a/kstars/options/opsguides.h
+++ b/kstars/options/opsguides.h
@@ -19,7 +19,7 @@
 
 #include "ui_opsguides.h"
 
-class KStars;
+class KConfigDialog;
 
 /**
  * @class OpsGuides
@@ -35,12 +35,17 @@ public:
     ~OpsGuides();
 
 private slots:
+    void slotApply();
     void slotToggleConstellOptions( bool state );
     void slotToggleConstellationArt(bool state );
     void slotToggleMilkyWayOptions( bool state );
     void slotToggleOpaqueGround( bool state );
     void slotToggleAutoSelectGrid( bool state );
 
+private:
+    KConfigDialog *m_ConfigDialog;
+    bool isDirty = false;
+
 };
 
 #endif // OPSGUIDES_H_
diff --git a/kstars/options/opsguides.ui b/kstars/options/opsguides.ui
index bfcd4ee..e37208e 100644
--- a/kstars/options/opsguides.ui
+++ b/kstars/options/opsguides.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>446</width>
-    <height>262</height>
+    <width>454</width>
+    <height>279</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout_2">
@@ -28,6 +28,9 @@
            <property name="text">
             <string>&Constellation lines</string>
            </property>
+           <attribute name="buttonGroup">
+            <string notr="true">constellationButtonGroup</string>
+           </attribute>
           </widget>
          </item>
          <item>
@@ -57,6 +60,9 @@
          <property name="text">
           <string>Constellation &boundaries</string>
          </property>
+         <attribute name="buttonGroup">
+          <string notr="true">constellationButtonGroup</string>
+         </attribute>
         </widget>
        </item>
        <item>
@@ -64,6 +70,9 @@
          <property name="text">
           <string>Constellation Art</string>
          </property>
+         <attribute name="buttonGroup">
+          <string notr="true">constellationButtonGroup</string>
+         </attribute>
         </widget>
        </item>
        <item>
@@ -71,6 +80,9 @@
          <property name="text">
           <string>Highlight central constellation boundary</string>
          </property>
+         <attribute name="buttonGroup">
+          <string notr="true">constellationButtonGroup</string>
+         </attribute>
         </widget>
        </item>
        <item>
@@ -84,6 +96,9 @@
          <property name="text">
           <string>Constellation &names</string>
          </property>
+         <attribute name="buttonGroup">
+          <string notr="true">constellationButtonGroup</string>
+         </attribute>
         </widget>
        </item>
       </layout>
@@ -120,6 +135,9 @@
           <property name="text">
            <string>L&atin</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">nameButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item>
@@ -133,6 +151,9 @@
           <property name="text">
            <string>Localized</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">nameButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item>
@@ -146,6 +167,9 @@
           <property name="text">
            <string>Abbre&viated</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">nameButtonGroup</string>
+          </attribute>
          </widget>
         </item>
        </layout>
@@ -182,6 +206,9 @@
        <property name="text">
         <string>Ecliptic</string>
        </property>
+       <attribute name="buttonGroup">
+        <string notr="true">constellationButtonGroup</string>
+       </attribute>
       </widget>
      </item>
      <item row="2" column="0">
@@ -195,6 +222,9 @@
        <property name="text">
         <string>Fill Milk&y Way</string>
        </property>
+       <attribute name="buttonGroup">
+        <string notr="true">constellationButtonGroup</string>
+       </attribute>
       </widget>
      </item>
      <item row="0" column="1">
@@ -208,6 +238,9 @@
        <property name="text">
         <string>Hori&zon (line)</string>
        </property>
+       <attribute name="buttonGroup">
+        <string notr="true">constellationButtonGroup</string>
+       </attribute>
       </widget>
      </item>
      <item row="0" column="0">
@@ -221,6 +254,9 @@
        <property name="text">
         <string>Mil&ky Way</string>
        </property>
+       <attribute name="buttonGroup">
+        <string notr="true">constellationButtonGroup</string>
+       </attribute>
       </widget>
      </item>
      <item row="0" column="2">
@@ -234,6 +270,9 @@
        <property name="text">
         <string>Automatically select coordinate grid</string>
        </property>
+       <attribute name="buttonGroup">
+        <string notr="true">constellationButtonGroup</string>
+       </attribute>
       </widget>
      </item>
      <item row="6" column="0">
@@ -247,6 +286,9 @@
        <property name="text">
         <string>Flags</string>
        </property>
+       <attribute name="buttonGroup">
+        <string notr="true">constellationButtonGroup</string>
+       </attribute>
       </widget>
      </item>
      <item row="2" column="2">
@@ -260,6 +302,9 @@
        <property name="text">
         <string>Equatorial coordinate grid</string>
        </property>
+       <attribute name="buttonGroup">
+        <string notr="true">constellationButtonGroup</string>
+       </attribute>
       </widget>
      </item>
      <item row="4" column="2">
@@ -273,6 +318,9 @@
        <property name="text">
         <string>Horizontal coor&dinate grid</string>
        </property>
+       <attribute name="buttonGroup">
+        <string notr="true">constellationButtonGroup</string>
+       </attribute>
       </widget>
      </item>
      <item row="2" column="1">
@@ -286,6 +334,9 @@
        <property name="text">
         <string>Opaque &ground</string>
        </property>
+       <attribute name="buttonGroup">
+        <string notr="true">constellationButtonGroup</string>
+       </attribute>
       </widget>
      </item>
      <item row="4" column="0">
@@ -299,6 +350,9 @@
        <property name="text">
         <string>Celestial e&quator</string>
        </property>
+       <attribute name="buttonGroup">
+        <string notr="true">constellationButtonGroup</string>
+       </attribute>
       </widget>
      </item>
     </layout>
@@ -336,4 +390,12 @@
  </tabstops>
  <resources/>
  <connections/>
+ <buttongroups>
+  <buttongroup name="constellationButtonGroup">
+   <property name="exclusive">
+    <bool>false</bool>
+   </property>
+  </buttongroup>
+  <buttongroup name="nameButtonGroup"/>
+ </buttongroups>
 </ui>
diff --git a/kstars/options/opssatellites.cpp b/kstars/options/opssatellites.cpp
index b32597d..696f757 100644
--- a/kstars/options/opssatellites.cpp
+++ b/kstars/options/opssatellites.cpp
@@ -73,6 +73,10 @@ OpsSatellites::OpsSatellites()
     connect( m_ConfigDialog->button(QDialogButtonBox::Cancel), SIGNAL( clicked() ), SLOT( slotCancel() ) );
     connect( FilterEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotFilterReg( const QString & ) ) );
     connect( m_Model, SIGNAL( itemChanged( QStandardItem* ) ), this, SLOT( slotItemChanged( QStandardItem* ) ) );
+
+    connect( satelliteButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonPressed), this, [&](){ isDirty = true;});
+
+    isDirty = false;
 }
 
 OpsSatellites::~OpsSatellites() {
@@ -84,6 +88,8 @@ void OpsSatellites::slotUpdateTLEs()
     // Get new data files
     KStarsData::Instance()->skyComposite()->satellites()->updateTLEs();
 
+    isDirty = true;
+
     // Refresh satellites list
     updateListView();
 }
@@ -135,6 +141,11 @@ void OpsSatellites::updateListView()
 
 void OpsSatellites::slotApply()
 {
+    if (isDirty == false)
+        return;
+
+    isDirty = false;
+
     KStarsData* data = KStarsData::Instance();
     QString sat_name;
     QStringList selected_satellites;
@@ -186,6 +197,7 @@ void OpsSatellites::slotCancel()
 
 void OpsSatellites::slotShowSatellites( bool on )
 {
+    isDirty = true;
     kcfg_ShowVisibleSatellites->setEnabled( on );
     kcfg_ShowSatellitesLabels->setEnabled( on );
     kcfg_DrawSatellitesLikeStars->setEnabled( on );
@@ -196,6 +208,8 @@ void OpsSatellites::slotFilterReg( const QString& filter )
     m_SortModel->setFilterRegExp( QRegExp( filter, Qt::CaseInsensitive, QRegExp::RegExp ) );
     m_SortModel->setFilterKeyColumn( -1 );
     
+    isDirty = true;
+
     // Expand all categories when the user use filter
     if ( filter.length() > 0 )
         SatListTreeView->expandAll();
@@ -209,6 +223,8 @@ void OpsSatellites::slotItemChanged( QStandardItem* item )
         return;
     }
 
+    isDirty = true;
+
     QModelIndex sat_index;
     QStandardItem* sat_item;
     
diff --git a/kstars/options/opssatellites.h b/kstars/options/opssatellites.h
index cde7d1b..131f714 100644
--- a/kstars/options/opssatellites.h
+++ b/kstars/options/opssatellites.h
@@ -64,6 +64,7 @@ private:
     KConfigDialog *m_ConfigDialog;
     QStandardItemModel *m_Model;
     QSortFilterProxyModel *m_SortModel;
+    bool isDirty=false;
 
 private slots:
     void slotUpdateTLEs();
diff --git a/kstars/options/opssatellites.ui b/kstars/options/opssatellites.ui
index 8026c0a..224d381 100644
--- a/kstars/options/opssatellites.ui
+++ b/kstars/options/opssatellites.ui
@@ -29,6 +29,9 @@
             <property name="text">
              <string>Show satellites</string>
             </property>
+            <attribute name="buttonGroup">
+             <string notr="true">satelliteButtonGroup</string>
+            </attribute>
            </widget>
           </item>
           <item>
@@ -36,6 +39,9 @@
             <property name="text">
              <string>Show only visible satellites</string>
             </property>
+            <attribute name="buttonGroup">
+             <string notr="true">satelliteButtonGroup</string>
+            </attribute>
            </widget>
           </item>
          </layout>
@@ -47,6 +53,9 @@
             <property name="text">
              <string>Show labels</string>
             </property>
+            <attribute name="buttonGroup">
+             <string notr="true">satelliteButtonGroup</string>
+            </attribute>
            </widget>
           </item>
           <item>
@@ -54,6 +63,9 @@
             <property name="text">
              <string>Draw satellites like stars</string>
             </property>
+            <attribute name="buttonGroup">
+             <string notr="true">satelliteButtonGroup</string>
+            </attribute>
            </widget>
           </item>
          </layout>
@@ -106,4 +118,7 @@
  </widget>
  <resources/>
  <connections/>
+ <buttongroups>
+  <buttongroup name="satelliteButtonGroup"/>
+ </buttongroups>
 </ui>
diff --git a/kstars/options/opssolarsystem.cpp b/kstars/options/opssolarsystem.cpp
index 4fc22dd..c60cc4f 100644
--- a/kstars/options/opssolarsystem.cpp
+++ b/kstars/options/opssolarsystem.cpp
@@ -15,10 +15,13 @@
  *                                                                         *
  ***************************************************************************/
 
+#include <KActionCollection>
+#include <KConfigDialog>
+
 #include "opssolarsystem.h"
 #include "kstars.h"
-
-#include <KActionCollection>
+#include "kstarsdata.h"
+#include "skymap.h"
 
 OpsSolarSystem::OpsSolarSystem()
         : QFrame(KStars::Instance())
@@ -37,8 +40,16 @@ OpsSolarSystem::OpsSolarSystem()
 
     slotAsteroidWidgets( kcfg_ShowAsteroids->isChecked() );
     slotCometWidgets( kcfg_ShowComets->isChecked() );
-}
 
+    //Get a pointer to the KConfigDialog
+    m_ConfigDialog = KConfigDialog::exists( "settings" );
+
+    connect( m_ConfigDialog->button(QDialogButtonBox::Apply), SIGNAL( clicked() ), SLOT( slotApply() ) );
+    connect( m_ConfigDialog->button(QDialogButtonBox::Ok), SIGNAL( clicked() ), SLOT( slotApply() ) );
+    connect( m_ConfigDialog->button(QDialogButtonBox::Cancel), SIGNAL( clicked() ), SLOT( slotCancel() ) );
+
+    connect( solarButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonPressed), this, [&](){ isDirty = true;});
+}
 
 OpsSolarSystem::~OpsSolarSystem()
 {
@@ -81,3 +92,18 @@ void OpsSolarSystem::slotSelectPlanets() {
     kcfg_ShowNeptune->setChecked( b );
     //kcfg_ShowPluto->setChecked( b );
 }
+
+void OpsSolarSystem::slotApply()
+{
+    if (isDirty == false)
+        return;
+
+    isDirty = false;
+
+    // update time for all objects because they might be not initialized
+    // it's needed when using horizontal coordinates
+    KStars::Instance()->data()->setFullTimeUpdate();
+    KStars::Instance()->updateTime();
+    KStars::Instance()->map()->forceUpdate();
+}
+
diff --git a/kstars/options/opssolarsystem.h b/kstars/options/opssolarsystem.h
index bdf1225..2566b55 100644
--- a/kstars/options/opssolarsystem.h
+++ b/kstars/options/opssolarsystem.h
@@ -19,7 +19,7 @@
 
 #include "ui_opssolarsystem.h"
 
-class KStars;
+class KConfigDialog;
 
 /** @class OpsSolarSystem
 	*The Solar System page for the Options window.  This page allows the user
@@ -43,6 +43,11 @@ private slots:
     void slotCometWidgets(bool on);
     void slotSelectPlanets();
 
+    void slotApply();
+
+private:
+    bool isDirty=false;
+    KConfigDialog *m_ConfigDialog;
 };
 
 #endif
diff --git a/kstars/options/opssolarsystem.ui b/kstars/options/opssolarsystem.ui
index 943b5da..3915ffc 100644
--- a/kstars/options/opssolarsystem.ui
+++ b/kstars/options/opssolarsystem.ui
@@ -16,6 +16,9 @@
      <property name="text">
       <string>Show solar system objects</string>
      </property>
+     <attribute name="buttonGroup">
+      <string notr="true">solarButtonGroup</string>
+     </attribute>
     </widget>
    </item>
    <item>
@@ -37,6 +40,9 @@
           <property name="text">
            <string>Saturn</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">solarButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item row="3" column="2">
@@ -63,6 +69,9 @@
           <property name="text">
            <string>Mars</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">solarButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item row="2" column="2">
@@ -115,6 +124,9 @@
           <property name="text">
            <string>Venus</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">solarButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item row="0" column="0">
@@ -128,6 +140,9 @@
           <property name="text">
            <string>The sun</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">solarButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item row="0" column="1">
@@ -141,6 +156,9 @@
           <property name="text">
            <string>Jupiter</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">solarButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item row="1" column="0">
@@ -154,6 +172,9 @@
           <property name="text">
            <string>The moon</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">solarButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item row="2" column="0">
@@ -167,6 +188,9 @@
           <property name="text">
            <string>Mercury</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">solarButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item row="3" column="1">
@@ -180,6 +204,9 @@
           <property name="text">
            <string>Neptune</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">solarButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item row="4" column="2">
@@ -209,6 +236,9 @@
           <property name="text">
            <string>Uranus</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">solarButtonGroup</string>
+          </attribute>
          </widget>
         </item>
        </layout>
@@ -251,6 +281,9 @@
           <property name="text">
            <string>Asteroids</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">solarButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item row="0" column="1">
@@ -319,6 +352,9 @@
             <property name="text">
              <string>Show names</string>
             </property>
+            <attribute name="buttonGroup">
+             <string notr="true">solarButtonGroup</string>
+            </attribute>
            </widget>
           </item>
           <item>
@@ -367,6 +403,9 @@
           <property name="text">
            <string>Comets</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">solarButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item row="2" column="1">
@@ -380,6 +419,9 @@
           <property name="text">
            <string>Show names of comets within</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">solarButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item row="2" column="2">
@@ -444,6 +486,9 @@
         <property name="text">
          <string>Always show trail when tracking a solar system body</string>
         </property>
+        <attribute name="buttonGroup">
+         <string notr="true">solarButtonGroup</string>
+        </attribute>
        </widget>
       </item>
       <item>
@@ -459,6 +504,9 @@
           <property name="text">
            <string>Fade trails to background color</string>
           </property>
+          <attribute name="buttonGroup">
+           <string notr="true">solarButtonGroup</string>
+          </attribute>
          </widget>
         </item>
         <item>
@@ -513,6 +561,9 @@
         <property name="text">
          <string>Earth satellite tracks</string>
         </property>
+        <attribute name="buttonGroup">
+         <string notr="true">solarButtonGroup</string>
+        </attribute>
        </widget>
       </item>
       <item>
@@ -569,4 +620,11 @@
  </tabstops>
  <resources/>
  <connections/>
+ <buttongroups>
+  <buttongroup name="solarButtonGroup">
+   <property name="exclusive">
+    <bool>false</bool>
+   </property>
+  </buttongroup>
+ </buttongroups>
 </ui>


More information about the Kstars-devel mailing list