[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/ktouch
From:       Håvard Frøiland <haavard () solveien ! net>
Date:       2007-04-01 18:49:12
Message-ID: 1175453352.166079.26214.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 648955 by haavard:

Added a message when last level has been completed, in automatic level change mode.

 M  +2 -0      ChangeLog  
 M  +30 -12    src/ktouchtrainer.cpp  
 M  +3 -0      src/ktouchtrainer.h  


--- trunk/KDE/kdeedu/ktouch/ChangeLog #648954:648955
@@ -1,4 +1,6 @@
 2007-04-01 Håvard Frøiland <haavard@solveien.net>
+  * Added a message when last message has been completed when automatic
+    level change is enabled, telling the user that he/she is finished.
   * Fix color's for student and text line. (respect settings)
 
 2007-03-16 Håvard Frøiland <haavard@solveien.net>
--- trunk/KDE/kdeedu/ktouch/src/ktouchtrainer.cpp #648954:648955
@@ -16,6 +16,7 @@
 #include <QLCDNumber>
 #include <QFile>
 #include <QTimer>
+#include <QMessageBox>
 
 #include <kdebug.h>
 #include <kpushbutton.h>
@@ -262,6 +263,8 @@
 	m_statusWidget->updateSpeed( 0 );
 	m_trainingPaused=true;		// Go into "Pause" mode
 	m_trainingTimer->stop();    // Training timer will be started on first keypress.
+
+    updateLevelChangeButtons();
 }
 // ----------------------------------------------------------------------------
 
@@ -292,6 +295,11 @@
 }
 // ----------------------------------------------------------------------------
 
+void KTouchTrainer::updateLevelChangeButtons() {
+    m_statusWidget->levelUpBtn->setEnabled(m_level < m_lecture->levelCount() - 1);
+    m_statusWidget->levelDownBtn->setEnabled(m_level > 0);
+}
+
 void KTouchTrainer::storeTrainingStatistics() {
 	// at first get a reference to the statistics data of the current lecture
 	KTouchLectureStats& data = KTouchPtr->getCurrentLectureStats();
@@ -330,18 +338,20 @@
         player->play(m_levelUpSound.url());
     }
 
-    ++m_level;  // increase the level
-    if (m_level>=m_lecture->levelCount()) {
-        // already at max level? Let's stay there
-        m_level=m_lecture->levelCount()-1;
-		/// \todo Do something when last level is completed
+    if (m_level < m_lecture->levelCount() - 1) {
+        m_level++;
     }
+    else {
+        levelAllComplete();
+    }
 
     m_incLinesCount = 0;
     m_decLinesCount = 0;
+
     // Store level statistics if level is increased
     statsChangeLevel();
     gotoFirstLine();
+    updateLevelChangeButtons();
 }
 // ----------------------------------------------------------------------------
 
@@ -351,16 +361,24 @@
         if(Prefs::soundOnLevel()){
             player->play(m_levelDownSound.url());
         }
-	}
-	m_incLinesCount = 0;
-	m_decLinesCount = 0;
+    }
+    m_incLinesCount = 0;
+    m_decLinesCount = 0;
 
-	// Store level statistics if level is increased
-	statsChangeLevel();
-	gotoFirstLine();
+    // Store level statistics if level is increased
+    statsChangeLevel();
+    gotoFirstLine();
+    updateLevelChangeButtons();
 }
-// ----------------------------------------------------------------------------
 
+void KTouchTrainer::levelAllComplete() {
+    QMessageBox::information(0, tr("You rock!"),
+                   tr("You have finished this training exercise.\n"
+                      "This training session will start from the beginning."));
+    statsChangeLevel();
+    startTraining(false);
+}
+
 void KTouchTrainer::timerTick() {
     if (m_trainingPaused) return;
     // Add the timer interval. I think we can neglect the error we make when the \
                session is
--- trunk/KDE/kdeedu/ktouch/src/ktouchtrainer.h #648954:648955
@@ -150,6 +150,9 @@
 	/// Stores level stats and resets level stats (this function is called from \
levelUp() and levelDown()  /// right before a new level and new line is started).
 	void statsChangeLevel();
+
+    void updateLevelChangeButtons();
+    void levelAllComplete();
 	
     KTouchStatusWidget     *m_statusWidget;         ///< Pointer to the status \
                widget on top of the main window.
     KTouchTextLineWidget   *m_textLineWidget;       ///< Pointer to the sliding line \
widget.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic