[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeedu/ktouch/src
From: Andreas Nicolai <Andreas.Nicolai () gmx ! net>
Date: 2007-06-21 2:26:49
Message-ID: 1182392809.454840.32717.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 678299 by ghorwin:
Added "Show only learned keys" feature. Configuration options for the feature is \
still missing, though.
M +4 -1 ktouch.cpp
M +6 -0 ktouch.h
M +4 -0 ktouch.kcfg
M +36 -9 ktouchkey.cpp
M +2 -1 ktouchkey.h
M +40 -0 ktouchkeyboardwidget.cpp
M +5 -0 ktouchkeyboardwidget.h
M +17 -0 ktouchlecture.cpp
M +4 -0 ktouchlecture.h
M +32 -0 ktouchlevelsummarydialog.cpp
M +2 -0 ktouchtrainer.cpp
--- trunk/KDE/kdeedu/ktouch/src/ktouch.cpp #678298:678299
@@ -698,7 +698,10 @@
m_keyboardLayoutAction= actionCollection()->add<KSelectAction>( \
"keyboard_layouts" ); m_keyboardLayoutAction->setText( i18n("&Keyboard Layouts") );
m_keyboardLayoutAction->setMenuAccelsEnabled(false);
- m_keyboardTitles << i18n("More keyboard layouts...");
+// TODO : add this back in when we have the KNewStuff feature implemented, were \
users +// can anonymously upload their keyboards and lectures which will then \
be offered in +// the diaolg that pops up for the "More keyboard layouts..." \
menu entry +// m_keyboardTitles << i18n("More keyboard layouts...");
m_keyboardLayoutAction->setItems(m_keyboardTitles);
connect (m_keyboardLayoutAction, SIGNAL(triggered(int)), this, \
SLOT(changeKeyboard(int)));
--- trunk/KDE/kdeedu/ktouch/src/ktouch.h #678298:678299
@@ -73,6 +73,12 @@
void changeStatusbarStats(unsigned int level_correct, unsigned int level_total, \
unsigned int level_words,
unsigned int session_correct, unsigned int session_total, unsigned int \
session_words);
+ ///< Returns list of user names.
+ const QStringList& userList() const { return m_userList; }
+ ///< A map with statistics for each user.
+ const QMap<QString, KTouchStatisticsData>& userStats() const { return m_userStats; \
} +
+
public slots:
/// Will be called when the "Apply"-button has been pressed in the preferences
/// dialog or when the user accepted the changes using the "OK"-button.
--- trunk/KDE/kdeedu/ktouch/src/ktouch.kcfg #678298:678299
@@ -85,6 +85,10 @@
<label >Whether to use colors on the keys or not.</label>
<default>true</default>
</entry>
+ <entry type="Bool" name="ShowLearnedKeysOnly" >
+ <label>Whether to show only the learned/known keys or always all keys.</label>
+ <default>true</default>
+ </entry>
<entry type="Bool" name="ShowKeyboard" >
<label >Whether to show the keyboard display.</label>
<default>true</default>
--- trunk/KDE/kdeedu/ktouch/src/ktouchkey.cpp #678298:678299
@@ -287,20 +287,47 @@
} // switch
} break; // HighlightedState
+
case FingerKeyState :
{
QLinearGradient grad(QPointF(0,0), QPointF(0.3*m_h,1.3*m_h));
- QColor c = colorScheme.m_backgroundH;
- grad.setColorAt(0,c);
- qreal h, s, v, a;
- c.getHsvF(&h, &s, &v, &a);
- c.setHsvF(h, s, v*0.8, a);
- grad.setColorAt(1,c);
- painter->setBrush( QBrush(grad) );
+ QColor c;
+ if (m_colorIndex<8) {
+ c = colorScheme.m_background[m_colorIndex];
+ grad.setColorAt(0,c);
+ qreal h, s, v, a;
+ c.getHsvF(&h, &s, &v, &a);
+ c.setHsvF(h, s, v*0.8, a);
+ grad.setColorAt(1,c);
+ painter->setBrush( QBrush(grad) );
+ }
+ else {
+ c = widget->palette().color(QPalette::Background);
+ painter->setBrush( c );
+ }
QPen p(colorScheme.m_frame);
p.setWidth(0); // only one pixel!
painter->setPen( p );
painter->drawRect(0, 0, m_w, m_h);
+ } break; // FingerKeyState
+
+ case DisabledState :
+ {
+ // we draw the keys grey to indicate that they are not learned yet
+ QLinearGradient grad(QPointF(0,0), QPointF(0.3*m_h,1.3*m_h));
+ //kDebug() << m_keyChar[0] << " m_colorIndex = " << m_colorIndex << endl;
+ QColor c(40,40,40);
+ grad.setColorAt(0,c);
+ qreal h, s, v, a;
+ c.getHsvF(&h, &s, &v, &a);
+ c.setHsvF(h, s, v*0.8, a);
+ grad.setColorAt(1,c);
+ painter->setBrush( QBrush(grad) );
+ QPen p(colorScheme.m_frame);
+ p.setWidth(0); // only one pixel!
+ painter->setPen( p );
+ painter->drawRect(0, 0, m_w, m_h);
+ if (m_type == Finger) {
// Finger keys get a special decoration
QRadialGradient radgrad(QPointF(m_w/2, m_h/2), qMin(m_w, m_h)*0.48, \
QPointF(m_w/2*0.9, m_h/2*0.9) ); radgrad.setColorAt(0, c);
@@ -308,9 +335,9 @@
radgrad.setColorAt(1, QColor(0,0,0,48));
painter->setBrush( QBrush(radgrad) );
painter->drawRect(0, 0, m_w, m_h);
+ }
+ }
- } break; // FingerKeyState
-
}
// draw text/decoration
--- trunk/KDE/kdeedu/ktouch/src/ktouchkey.h #678298:678299
@@ -63,7 +63,8 @@
NormalState, // normal key appearance on the keyboard
HighlightedState, // when indicating the next target key
FingerKeyState, // when indicating the origin key of the finger to be used
- ModifierState // when indicating a certain modifier key
+ ModifierState, // when indicating a certain modifier key
+ DisabledState // when indicating that the key is yet unknown to the user
};
/// Default constructor.
--- trunk/KDE/kdeedu/ktouch/src/ktouchkeyboardwidget.cpp #678298:678299
@@ -127,10 +127,50 @@
m_keyboard->setFont(Prefs::font());
}
+ setKnownChars(m_knownChars); // enable/disable keys
newKey(m_nextKey); // and finally display the "next to be pressed" key again
}
// --------------------------------------------------------------------------
+void KTouchKeyboardWidget::setKnownChars(const QSet<QChar>& knownChars) {
+ if (!Prefs::showKeyboard()) return;
+ if (!Prefs::showLearnedKeysOnly()) return;
+ kDebug() << "KTouchKeyboardWidget::setKnownChars: " << m_nextKey << endl;
+ m_knownChars = knownChars;
+ // loop over all keys and set them to disabled at first
+ QList<KTouchKey*>::iterator it;
+ for( it = m_keyboard->m_keys.begin(); it != m_keyboard->m_keys.end(); ++it ) {
+ KTouchKey * key = *it;
+ key->m_state = KTouchKey::DisabledState;
+ }
+ // now loop over all characters in the set, look up the corresponding key connector \
and + // re-enabled all active keys
+ for (QSet<QChar>::const_iterator char_it = knownChars.constBegin(); char_it != \
knownChars.constEnd(); ++char_it) { + KTouchKeyConnector & c = \
m_keyboard->m_connectors[(*char_it).unicode()]; + KTouchKey * targetKey = \
c.m_targetKey; + KTouchKey * modifierKey = c.m_modifierKey;
+ if (targetKey != NULL) {
+ targetKey->m_state = KTouchKey::NormalState;
+ KTouchKey * fingerKey = targetKey->m_fingerKey;
+ if (fingerKey != NULL) {
+ fingerKey->m_state = KTouchKey::NormalState;
+ }
+ }
+ if (modifierKey != NULL) {
+ modifierKey->m_state = KTouchKey::NormalState;
+ }
+ }
+ // now update all characters and thus effectively redraw the keyboard
+ for( it = m_keyboard->m_keys.begin(); it != m_keyboard->m_keys.end(); ++it ) {
+ KTouchKey * key = *it;
+ key->update();
+ }
+ // and show the new key again
+ newKey(m_nextKey);
+}
+// --------------------------------------------------------------------------
+
+
void KTouchKeyboardWidget::newKey(const QChar& nextChar) {
if (!Prefs::showKeyboard()) return;
--- trunk/KDE/kdeedu/ktouch/src/ktouchkeyboardwidget.h #678298:678299
@@ -19,6 +19,7 @@
#include <QList>
#include <QVector>
#include <QMap>
+#include <QSet>
class KUrl;
class KTouchKeyboard;
@@ -50,6 +51,9 @@
/// This means that the layout is basically recreated and if the layout \
type/language /// changed it will be reloaded.
void applyPreferences(QWidget * window, bool silent);
+ /// This sets the string with currently known characters and sets the keys that do \
not + /// contain a character of this list to inactive.
+ void setKnownChars(const QSet<QChar>& knownChars);
public slots:
/// This function displays the next key (or key combination) the user has to \
press. @@ -71,6 +75,7 @@
QString m_currentLayout; ///< The name of the currently used layout.
QChar m_nextKey; ///< The next to be pressed character.
+ QSet<QChar> m_knownChars; ///< String with already known characters in this \
lecture and level.
QGraphicsScene* m_scene; ///< The graphics scene
};
--- trunk/KDE/kdeedu/ktouch/src/ktouchlecture.cpp #678298:678299
@@ -120,6 +120,23 @@
}
// ----------------------------------------------------------------------------
+QSet<QChar> KTouchLecture::knownCharsInLevel(unsigned int level_num) const {
+ // loop over all levels so far and create a set with all characters known
+ QSet<QChar> knownChars;
+ for (unsigned int i=0; i<=level_num && i<static_cast<unsigned \
int>(m_lectureData.count()); ++i) { + const QString& s = \
m_lectureData[i].newChars(); + for (int j=0; j<s.count(); ++j) {
+ knownChars.insert(s[j]);
+ }
+ }
+ QString chars;
+ foreach (QChar ch, knownChars)
+ chars.append(ch);
+ kDebug() << "Known chars: " << chars << endl;
+ return knownChars;
+}
+// ----------------------------------------------------------------------------
+
bool KTouchLecture::readLecture(QTextStream& in) {
//kDebug() << "[KTouchLecture::loadLecture] Reading lecture file '" << \
lectureURL.url() << "'!" << endl; QString line;
--- trunk/KDE/kdeedu/ktouch/src/ktouchlecture.h #678298:678299
@@ -18,6 +18,7 @@
#include <QList>
#include <QTextStream>
+#include <QSet>
class KUrl;
@@ -57,9 +58,12 @@
void setTitle(const QString& title) { m_title = title; }
/// Sets the level data
void setLevel(unsigned int level_num, const KTouchLevelData& level);
+ /// Returns a set with all characters that are already known in the current \
lecture. + QSet<QChar> knownCharsInLevel(unsigned int level_num) const;
QString m_fontSuggestions; ///< Font suggestions for this lecture.
+
private:
/// Loads a lecture from file
bool readLecture(QTextStream& in);
--- trunk/KDE/kdeedu/ktouch/src/ktouchlevelsummarydialog.cpp #678298:678299
@@ -13,6 +13,13 @@
#include "ktouchlevelsummarydialog.h"
#include "ktouchlevelsummarydialog.moc"
+#include <QtGui>
+
+#include <kdebug.h>
+
+#include "prefs.h"
+#include "ktouch.h"
+
KTouchLevelSummaryDialog::KTouchLevelSummaryDialog(QWidget* parent) : \
QDialog(parent) { setupUi(this);
}
@@ -32,5 +39,30 @@
// setup the dialog according to the arguments
if (increaseLevel) {
}
+
+ const QStringList& userList = KTouchPtr->userList();
+ const QMap<QString, KTouchStatisticsData>& allUserStats = KTouchPtr->userStats();
+
+ // get the statistics data for this lecture and the current user
+ QString currentUser = Prefs::currentUserName();
+ QString currentFile = Prefs::currentLectureFile();
+
+ // get the statistics data for the current user
+ const KTouchStatisticsData& currentUserStats = allUserStats[currentUser];
+ // extract the data for the current lecture
+ const KTouchLectureStats& currentLectureStats = \
currentUserStats.m_lectureStats[currentFile]; +
+ kDebug() << "Level done" << currentUser << endl;
+ kDebug() << currentLectureStats.m_levelStats.count() << " Level stats available" << \
endl; +
+ // get all stats for this lesson and put them in the table
+ for (int i=0; i<currentLectureStats.m_levelStats.count(); ++i) {
+ // skip all that are not this level
+ if (currentLectureStats.m_levelStats[i].m_levelNum != levelStats.m_levelNum) \
continue; +
+
+ }
+
+ exec();
}
--- trunk/KDE/kdeedu/ktouch/src/ktouchtrainer.cpp #678298:678299
@@ -77,6 +77,8 @@
m_statusWidget->setNewChars( m_lecture->level(m_level).newChars() );
m_line=0;
newLine();
+ // finally tell the keyboard widget, that we have a new set of new chars
+ m_keyboardWidget->setKnownChars( m_lecture->knownCharsInLevel(m_level) );
}
// ----------------------------------------------------------------------------
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic