[Kstars-devel] [kstars] kstars: Create KAction to advance one step forward / backward in time.

Jérome SONRIER jsid at emor3j.fr.eu.org
Thu Apr 21 03:05:30 CEST 2011


Git commit 28961b85f9b61349c2a66f2805cfbc212abffaf1 by Jérome SONRIER.
Committed on 21/04/2011 at 03:04.
Pushed by jsonrier into branch 'master'.

Create KAction to advance one step forward / backward in time.
We can now add buttons on the toolbar and remap shortcuts for these actions.

CCMAIL: kstars-devel at kde.org
CCBUG: 116495

M  +6    -0    kstars/kstars.h     
M  +16   -2    kstars/kstarsactions.cpp     
M  +8    -0    kstars/kstarsinit.cpp     
M  +1    -19   kstars/skymapevents.cpp     

http://commits.kde.org/kstars/28961b85f9b61349c2a66f2805cfbc212abffaf1

diff --git a/kstars/kstars.h b/kstars/kstars.h
index 1d9d3dc..6516f9e 100644
--- a/kstars/kstars.h
+++ b/kstars/kstars.h
@@ -458,6 +458,12 @@ private slots:
 
     /** action slot: toggle whether kstars clock is running or not */
     void slotToggleTimer();
+    
+    /** action slot: advance one step forward in time */
+    void slotStepForward();
+    
+    /** action slot: advance one step backward in time */
+    void slotStepBackward();
 
     /** action slot: open dialog for finding a named object */
     void slotFind();
diff --git a/kstars/kstarsactions.cpp b/kstars/kstarsactions.cpp
index 51bc9de..d0f4094 100644
--- a/kstars/kstarsactions.cpp
+++ b/kstars/kstarsactions.cpp
@@ -159,8 +159,6 @@ void KStars::slotViewToolBar() {
     
            KMessageBox::information( this, message, caption, "dag_refract_hide_ground" );
         }
-
-
         if ( kcd ) {
             opguides->kcfg_ShowGround->setChecked( a->isChecked() );
         }
@@ -689,6 +687,22 @@ void KStars::slotToggleTimer() {
     }
 }
 
+void KStars::slotStepForward() {
+    if ( data()->clock()->isActive() )
+        data()->clock()->stop();
+    data()->clock()->manualTick( true );
+    map()->forceUpdate();
+}
+
+void KStars::slotStepBackward() {
+    if ( data()->clock()->isActive() )
+        data()->clock()->stop();
+    data()->clock()->setClockScale( -1.0 * data()->clock()->scale() ); //temporarily need negative time step
+    data()->clock()->manualTick( true );
+    data()->clock()->setClockScale( -1.0 * data()->clock()->scale() ); //reset original sign of time step
+    map()->forceUpdate();
+}
+
 //Pointing
 void KStars::slotPointFocus() {
     // In the following cases, we set slewing=true in order to disengage tracking
diff --git a/kstars/kstarsinit.cpp b/kstars/kstarsinit.cpp
index c76d2f0..6b3a9d6 100644
--- a/kstars/kstarsinit.cpp
+++ b/kstars/kstarsinit.cpp
@@ -171,6 +171,14 @@ void KStars::initActions() {
     QObject::connect(data()->clock(), SIGNAL(clockToggled(bool)), ka, SLOT(setChecked(bool)) );
     //UpdateTime() if clock is stopped (so hidden objects get drawn)
     QObject::connect(data()->clock(), SIGNAL(clockToggled(bool)), this, SLOT(updateTime()) );
+    actionCollection()->addAction("time_step_forward", this, SLOT( slotStepForward() ) )
+        << i18n("Advance one step forward in time")
+        << KIcon("media-skip-forward" )
+        << KShortcut( Qt::Key_Greater, Qt::Key_Period );
+    actionCollection()->addAction("time_step_backward", this, SLOT( slotStepBackward() ) )
+        << i18n("Advance one step backward in time")
+        << KIcon("media-skip-backward" )
+        << KShortcut( Qt::Key_Less, Qt::Key_Comma );
 
     // ==== Pointing Menu ================
     actionCollection()->addAction("zenith", this, SLOT( slotPointFocus() ) )
diff --git a/kstars/skymapevents.cpp b/kstars/skymapevents.cpp
index 3810061..be08210 100644
--- a/kstars/skymapevents.cpp
+++ b/kstars/skymapevents.cpp
@@ -220,25 +220,7 @@ void SkyMap::keyPressEvent( QKeyEvent *e ) {
         if( rulerMode )
             slotCancelRulerMode();
         break;
-    case Qt::Key_Comma:  //advance one step backward in time
-    case Qt::Key_Less:
-        if ( data->clock()->isActive() )
-            data->clock()->stop();
-        data->clock()->setClockScale( -1.0 * data->clock()->scale() ); //temporarily need negative time step
-        data->clock()->manualTick( true );
-        data->clock()->setClockScale( -1.0 * data->clock()->scale() ); //reset original sign of time step
-        update();
-        qApp->processEvents();
-        break;
-
-    case Qt::Key_Period: //advance one step forward in time
-    case Qt::Key_Greater:
-        if ( data->clock()->isActive() ) data->clock()->stop();
-        data->clock()->manualTick( true );
-        update();
-        qApp->processEvents();
-        break;
-
+ 
     case Qt::Key_C: //Center clicked object
         if ( clickedObject() ) slotCenter();
         break;


More information about the Kstars-devel mailing list