[Kstars-devel] [kstars] kstars: Save current state of clock (stopped or running) on shutdown

Jérome SONRIER jsid at emor3j.fr.eu.org
Sat Jul 16 19:07:46 CEST 2011


Git commit ce9a202671bc4fe870a3a75d6095da76bf9020be by Jérome SONRIER.
Committed on 16/07/2011 at 19:07.
Pushed by jsonrier into branch 'master'.

Save current state of clock (stopped or running) on shutdown

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

M  +2    -0    kstars/kstarsinit.cpp
M  +5    -1    kstars/kstars.cpp
M  +3    -0    kstars/kstarsactions.cpp
M  +6    -1    kstars/kstars.kcfg

http://commits.kde.org/kstars/ce9a202671bc4fe870a3a75d6095da76bf9020be

diff --git a/kstars/kstars.cpp b/kstars/kstars.cpp
index d067e11..39193aa 100644
--- a/kstars/kstars.cpp
+++ b/kstars/kstars.cpp
@@ -82,7 +82,11 @@ KStars::KStars( bool doSplash, bool clockrun, const QString &startdate ) :
         data()->changeDateTime( data()->geo()->LTtoUT( startDate ) );
     else
         data()->changeDateTime( KStarsDateTime::currentUtcDateTime() );
-
+    
+    // Initialize clock. If --paused is not in the comand line, look in options
+    if ( clockrun )
+        StartClockRunning =  Options::runClock();
+    
     // Setup splash screen
     KStarsSplash *splash = 0;
     if ( doSplash ) {
diff --git a/kstars/kstars.kcfg b/kstars/kstars.kcfg
index 6d088d7..1e8f5ef 100644
--- a/kstars/kstars.kcfg
+++ b/kstars/kstars.kcfg
@@ -685,10 +685,15 @@
 		</entry>
 		<!-- TODO: Hilarious label and whatsthis strings used to preserve "translation invariance". Please fix in 4.7 -->
 		<entry name="UseGL" type="Bool">
-		        <label>Switch to OpenGL backend</label>
+		    <label>Switch to OpenGL backend</label>
 			<whatsthis>This version of KStars comes with new experimental OpenGL support. Our experience is that OpenGL works much faster on machines with hardware acceleration. Would you like to switch to OpenGL painting backends?</whatsthis>
 			<default>false</default>
 		</entry>
+        <entry name="RunClock" type="Bool">
+            <label>Run clock</label>
+            <whatsthis>The state of the clock (running or not)</whatsthis>
+            <default>true</default>
+        </entry>
 	</group>
 
 	<group name="Colors">
diff --git a/kstars/kstarsactions.cpp b/kstars/kstarsactions.cpp
index e917cac..b65ee5a 100644
--- a/kstars/kstarsactions.cpp
+++ b/kstars/kstarsactions.cpp
@@ -685,6 +685,9 @@ void KStars::slotToggleTimer() {
         if ( data()->clock()->isManualMode() )
             map()->forceUpdate();
     }
+    
+    // Update clock state in options
+    Options::setRunClock( data()->clock()->isActive() );
 }
 
 void KStars::slotStepForward() {
diff --git a/kstars/kstarsinit.cpp b/kstars/kstarsinit.cpp
index 7f4471e..30c871a 100644
--- a/kstars/kstarsinit.cpp
+++ b/kstars/kstarsinit.cpp
@@ -167,6 +167,8 @@ void KStars::initActions() {
     ka = actionCollection()->add<KToggleAction>("clock_startstop")
         << i18n("Stop &Clock" )
         << KIcon("media-playback-pause" );
+    if ( ! StartClockRunning )
+        ka->toggle();
     QObject::connect( ka, SIGNAL( triggered() ), this, SLOT( slotToggleTimer() ) );
     QObject::connect(data()->clock(), SIGNAL(clockToggled(bool)), ka, SLOT(setChecked(bool)) );
     //UpdateTime() if clock is stopped (so hidden objects get drawn)


More information about the Kstars-devel mailing list