[Kstars-devel] KDE/kdeedu/kstars/kstars

Akarsh Simha akarshsimha at gmail.com
Tue Dec 16 05:52:07 CET 2008


SVN commit 897451 by asimha:

When the '>' or '<' keys were pressed, the simulation clock (if
running) was halted, but the state of the action buttons on the
toolbar remained unchanged, leading to lot of confusion.

This commit fixes the issue:

+ Rectifying the syntax of QObject::connect(...) in kstarsinit.cpp

+ The correct slot to call on the KToggleAction that manages the
  stop/start of the simulation clock is setChecked(bool) and not
  setToggled(bool)

+ Since setChecked accepts a bool, two new slots and a new signal
  needed to be defined in order to translate clockStopped() and
  clockStarted() into a clockToggled(bool) signal

Many thanks to Andreas Hartmetz and Rohan McGovern for helping me out
with slots and signals!

CCMAIL: kstars-devel at kde.org



 M  +1 -2      kstarsinit.cpp  
 M  +16 -0     simclock.cpp  
 M  +16 -0     simclock.h  


--- trunk/KDE/kdeedu/kstars/kstars/kstarsinit.cpp #897450:897451
@@ -119,8 +119,7 @@
     ta->setIcon( KIcon( "media-playback-pause" ) );
     ta->setText( i18n( "Stop &Clock" ) );
     QObject::connect( ta, SIGNAL( triggered() ), this, SLOT( slotToggleTimer() ) );
-    QObject::connect(data()->clock(), SIGNAL(clockStarted()), ta, SLOT(slotToggled(false)) );
-    QObject::connect(data()->clock(), SIGNAL(clockStopped()), ta, SLOT(slotToggled(true)) );
+    QObject::connect(data()->clock(), SIGNAL(clockToggled(bool)), ta, SLOT(setChecked(bool)) );
     //UpdateTime() if clock is stopped (so hidden objects get drawn)
     QObject::connect(data()->clock(), SIGNAL(clockStopped()), this, SLOT(updateTime()) );
 
--- trunk/KDE/kdeedu/kstars/kstars/simclock.cpp #897450:897451
@@ -44,6 +44,9 @@
     ManualActive = false;
 
     QObject::connect(&tmr, SIGNAL(timeout()), this, SLOT(tick()));
+
+    QObject::connect(this, SIGNAL(clockStarted()), this, SLOT(slotClockStarted()));
+    QObject::connect(this, SIGNAL(clockStopped()), this, SLOT(slotClockStopped()));
 }
 
 SimClock::SimClock (const SimClock &old) :
@@ -58,6 +61,9 @@
     ManualActive = old.ManualActive;
 
     QObject::connect(&tmr, SIGNAL(timeout()), this, SLOT(tick()));
+
+    QObject::connect(this, SIGNAL(clockStarted()), this, SLOT(slotClockStarted()));
+    QObject::connect(this, SIGNAL(clockStopped()), this, SLOT(slotClockStopped()));
 }
 
 void SimClock::tick() {
@@ -155,6 +161,16 @@
     }
 }
 
+void SimClock::slotClockStarted() {
+    kDebug() << "Emitting clockToggled( false )";
+    emit clockToggled( false );
+}
+
+void SimClock::slotClockStopped() {
+    kDebug() << "Emitting clockToggled( true )";
+    emit clockToggled( true );
+}
+
 void SimClock::setUTC(const KStarsDateTime &newtime) {
     //DEBUG
     kDebug() << newtime.dateTime().toString();
--- trunk/KDE/kdeedu/kstars/kstars/simclock.h #897450:897451
@@ -126,7 +126,13 @@
     /**The clock has stopped */
     void clockStopped();
 
+    /** This is an signal that is called on either clock start or
+        clock stop with an appropriate boolean argument. Required so
+        that we can bind it to KToggleAction::slotToggled(bool) */
+    void clockToggled(bool);
+
 private:
+
     long double julianmark;
     KStarsDateTime UTC;
     QTimer tmr;
@@ -139,6 +145,16 @@
     //static int idgen;
     // how often to update
     static int TimerInterval;
+
+ private slots:
+    
+    /** These two slots subscribe to the clockStarted() and
+        clockStopped() signals and call the corresponding
+        clockToggled(bool) signal */
+
+    void slotClockStarted();
+
+    void slotClockStopped();
 };
 
 #endif


More information about the Kstars-devel mailing list