[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-02-25 11:10:08
Message-ID: 1172401808.256913.31316.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 637080 by haavard:

Fix RightToLeft support.

 M  +7 -2      ChangeLog  
 M  +15 -9     src/ktouchtextlinewidget.cpp  
 M  +35 -32    src/ktouchtrainer.cpp  


--- trunk/KDE/kdeedu/ktouch/ChangeLog #637079:637080
@@ -1,7 +1,12 @@
-2007-02-25 Håvard Frøiland <haavard@solveien.net>
+2007-02-26 Håvard Frøiland <haavard@solveien.net>
+  * Fixed: LeftToRight and RightToLeft should now work. there are still
+           some known problems with RightToLeft, but I am not sure if the
+           but is in KTouch. Use ktouch --reverse to test it.
+
+2007-02-24 Håvard Frøiland <haavard@solveien.net>
   * Fixed: Use of dead keys now works. (Bug: 118862, 134371)
 
-2007-02-25 Håvard Frøiland <haavard@solveien.net>
+2007-02-22 Håvard Frøiland <haavard@solveien.net>
   * Rewrote the sliding line using the graphicsview framework.
   * Lots of small fixes to get the kde 4 versjon more usable
 
--- trunk/KDE/kdeedu/ktouch/src/ktouchtextlinewidget.cpp #637079:637080
@@ -77,16 +77,18 @@
 
 void KTouchTextLineWidget::setStudentText(const QString& text) {
     student->setText(text);
+    double studentTextWidth = student->boundingRect().width();
+    double teacherTextWidth = teacher->boundingRect().width();
 
     if(direction == Qt::LeftToRight)
-        cursor->setPos(student->boundingRect().width(), 0);
+        cursor->setPos(studentTextWidth, 0);
     else
     {
-        cursor->setPos(teacher->boundingRect().width() - \
                student->boundingRect().width(), 0);
-        student->setPos(teacher->boundingRect().width() - \
student->boundingRect().width(), teacher->boundingRect().height() + 5); +        \
cursor->setPos(teacherTextWidth - studentTextWidth, 0); +        \
student->setPos(teacherTextWidth - studentTextWidth, teacher->boundingRect().height() \
+ 5);  }
 
-    if(teacher->text().startsWith(text)){
+    if(direction == Qt::LeftToRight ? teacher->text().startsWith(text) : \
teacher->text().endsWith(text)){  \
studentRect->setBrush(QBrush(Prefs::studentBackgroundColor()));  \
student->setBrush(QBrush(Prefs::studentTextColor()));  }
@@ -121,16 +123,20 @@
     QRectF rect = teacher->boundingRect();
 
     student->setFont(font);
-    student->setPos(0, rect.height() + 5);
 
     studentRect->setPath(roundedRectPathFactory(rect.x()-5, rect.y(), \
                rect.width()+10, rect.height(), qMin(rect.height(), \
                rect.width())/2));
     teacherRect->setPath(roundedRectPathFactory(rect.x()-5, rect.y(), \
rect.width()+10, rect.height(), qMin(rect.height(), rect.width())/2));  
-    cursor->setLine(2,rect.height() + 5  + 5, 2,rect.height() * 2 + 5 - 10);
-    if(direction == Qt::LeftToRight)
-        cursor->setPos(0, 0);
-    else
+    if(direction == Qt::LeftToRight){
+        cursor->setLine(2,rect.height() + 5  + 5, 2,rect.height() * 2 + 5 - 10);
+        cursor->setPos(student->boundingRect().width(), 0);
+        student->setPos(0, rect.height() + 5);
+    }
+    else{
+        cursor->setLine(-2,rect.height() + 5  + 5, -2,rect.height() * 2 + 5 - 10);
         cursor->setPos(teacher->boundingRect().width() - \
student->boundingRect().width(), 0); +        \
student->setPos(teacher->boundingRect().width() - student->boundingRect().width(), \
rect.height() + 5); +    }
 
     studentRect->setPos(0, rect.height() + 5);
 
--- trunk/KDE/kdeedu/ktouch/src/ktouchtrainer.cpp #637079:637080
@@ -95,10 +95,10 @@
     int old_student_text_len = m_studentText.length();
     // compose new student text depending in typing direction
     QString new_student_text = m_studentText;
-    if (Prefs::right2LeftTyping())
+    if (m_textLineWidget->layoutDirection() == Qt::LeftToRight)
+        new_student_text += key;
+    else
         new_student_text = key + new_student_text;
-    else
-        new_student_text += key;
 
 	// don ´t allow excessive amounts of characters per line
 	if (new_student_text.length() > m_teacherText.length()) {
@@ -115,28 +115,28 @@
         // nope, the key was wrong : beep !!!
         if (Prefs::beepOnError())  QApplication::beep();
         // check if the key is the first wrong key that was mistyped. Only then add \
                it
-		// to the wrong char statistics.
-        if (Prefs::right2LeftTyping()) {
-			if (m_teacherText.right(old_student_text_len)==m_studentText.right(old_student_text_len) \
                &&
-			    m_teacherText.length() > old_student_text_len)
-			{
-				// add the key the student ought to press to the wrong character stats
-				int next_key_index = m_teacherText.length() - old_student_text_len;
-//				kDebug() << "Wrong key = " << m_teacherText[next_key_index] << endl;
-				statsAddWrongChar( m_teacherText[next_key_index] );
-			}
+        // to the wrong char statistics.
+        if (m_textLineWidget->layoutDirection() == Qt::LeftToRight){
+            if (m_teacherText.left(old_student_text_len)==m_studentText.left(old_student_text_len) \
&& +                m_teacherText.length() > old_student_text_len)
+            {
+                // add the key the student ought to press to the wrong character \
stats +                int next_key_index = old_student_text_len;
+                statsAddWrongChar( m_teacherText[next_key_index] );
+            }
         }
+        /// \todo   Implement option whether subsequent mistyped keys should be \
remembered as missed +        ///         keys as well.
         else {
-			if (m_teacherText.left(old_student_text_len)==m_studentText.left(old_student_text_len) \
                &&
-				m_teacherText.length() > old_student_text_len)
-			{
-				// add the key the student ought to press to the wrong character stats
-				int next_key_index = old_student_text_len;
-				statsAddWrongChar( m_teacherText[next_key_index] );
-			}
-		}
-		/// \todo 	Implement option whether subsequent mistyped keys should be remembered \
                as missed
-		///			keys as well.
+            if (m_teacherText.right(old_student_text_len)==m_studentText.right(old_student_text_len) \
&& +                m_teacherText.length() > old_student_text_len)
+            {
+                // add the key the student ought to press to the wrong character \
stats +                int next_key_index = m_teacherText.length() - \
old_student_text_len; +//              kDebug() << "Wrong key = " << \
m_teacherText[next_key_index] << endl; +                statsAddWrongChar( \
m_teacherText[next_key_index] ); +            }
+        }
 	}
     updateWidgets(); // update all the other widgets (keyboard widget, status widget \
and statusbar)  }
@@ -151,14 +151,18 @@
 
     int len = m_studentText.length();
     if (len) {
-        if (m_teacherText.left(len)==m_studentText && m_teacherText.length()>=len) {
-            // we are removing a correctly typed char
-            if(Prefs::beepOnError){
+        if(Prefs::beepOnError){
+            if ((m_textLineWidget->layoutDirection() == Qt::LeftToRight) ? \
m_teacherText.left(len)==m_studentText && m_teacherText.length()>=len : \
m_teacherText.right(len)==m_studentText && m_teacherText.length()>=len) { +           \
// we are removing a correctly typed char  QApplication::beep();
             }
-			statsRemoveCorrectChar(m_studentText[len-1]);
         }
-        m_studentText = m_studentText.left(--len);
+        if (m_textLineWidget->layoutDirection() == Qt::LeftToRight){
+            m_studentText = m_studentText.left(--len);
+        }
+        else{
+            m_studentText = m_studentText.right(--len);
+        }
         updateWidgets(); // update all the widgets and the word count
         if (m_teacherText.left(len)==m_studentText)
             m_keyboardWidget->newKey(m_teacherText[len]);
@@ -166,7 +170,6 @@
             m_keyboardWidget->newKey(QChar(8));
     }
     else {
-        /// \todo Flash line when Backspace on empty line
         if(Prefs::beepOnError)
             QApplication::beep();
 	}
@@ -335,10 +338,10 @@
         return m_studentText.isEmpty();
 	int len = m_studentText.length();
     // different check for left and right writing
-    if (Prefs::right2LeftTyping())
+    if (m_textLineWidget->layoutDirection() == Qt::LeftToRight)
+        return (m_teacherText.left(len)==m_studentText && \
m_teacherText.length()>=len); +    else
         return m_teacherText.right(len)==m_studentText && \
                m_teacherText.length()>=len;
-    else
-	   return (m_teacherText.left(len)==m_studentText && m_teacherText.length()>=len); 
 }
 // ----------------------------------------------------------------------------
 


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

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