1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
/***************************************************************************
* ktouch.h *
* -------- *
* Copyright (C) 2000 by Håvard Frøiland, 2004 by Andreas Nicolai *
* ghorwin@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef KTOUCH_H
#define KTOUCH_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <tqcolor.h>
#include <tqstringlist.h>
#include <tqvaluevector.h>
#include <tdemainwindow.h>
#include <tdeapplication.h>
#include <kurl.h>
class TQLabel;
class TDEToggleAction;
class TDEActionMenu;
class TDESelectAction;
class KTouchStatus;
class KTouchSlideLine;
class KTouchKeyboardWidget;
class KTouchTrainer;
class KTouchPrefTrainingLayout;
class KTouchPrefKeyboardLayout;
class KTouchPrefGeneralLayout;
class KTouchPrefColorsLayout;
#include "ktouchlecture.h"
#include "ktouchstatisticsdata.h"
/// This is the main window of KTouch.
///
/// It handles the lecture, training data, status and all other widgets that are
/// needed to get the program running. Since all special tasks are delegated to the
/// appropriate widgets and classes, the remaining code in KTouch is basically the
/// startup and TDEAction stuff.<p>
/// A word about dialogs. All dialogs in this program are not created by default.
/// Instead they are created "on first use". This
/// saves memory (because we don't need them always) and the startup speed increases.<p>
/// One central function - the keyPressEvent() - is responsable for getting the actual
/// typed char. It delegates the character to the trainer
/// (KTouchTrainer), which will then process it. So the heavy work lies in the trainer
/// object and all the widgets.
class KTouch : public TDEMainWindow {
Q_OBJECT
public:
/// Constructor, creates the KTouch proggy.
KTouch();
/// Destructor, releases memory of KTouch trainer.
~KTouch();
/// Returns the available lecture files
const TQStringList& lectureFiles() const { return m_lectureFiles; }
/// Returns the statistics object for the current lecture (as reference)
KTouchLectureStats& getCurrentLectureStats();
/// Clears the statistics data.
void clearStatistics();
/// Updates the status bar text.
void changeStatusbarMessage(const TQString& text);
/// Updates the status bar statistics.
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);
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.
void applyPreferences();
/// Called from the configuration dialog.
void configOverrideLectureFontToggled(bool on);
/// Called from the configuration dialog.
void configOverrideKeyboardFontToggled(bool on);
/// Called from the configuration dialog.
void configAutoLevelChangeToggled(bool on);
/// Called from the configuration dialog.
void configCommonColorsToggled(bool on);
void fileOpenLecture(); ///< The action File->Open lecture...
void fileEditLecture(); ///< The action File->Edit lecture...
void fileEditColors(); ///< The action File->Edit colors...
void fileEditKeyboard(); ///< The action File->Edit keyboard...
void fileQuit(); ///< The action File->Quit
void trainingNewSession(); ///< The action Training->Start new training session...
void trainingPause(); ///< The action Training->Pause training
void trainingStatistics(); ///< The action Training->Show training statistics...
void optionsPreferences(); ///< The action Settings->Configure KTouch...
/// Quick-changes the keyboard layout (called from menu).
void changeKeyboard(int num);
/// Quick-changes the colour scheme used on the keyboard (called from menu).
void changeColor(int num);
/// Quick-changes the current training lecture file (called from menu).
void changeLecture(int num);
protected:
/// Reimplementated to save preferences and
bool queryExit();
/// Some layout fixes here...
void resizeEvent(TQResizeEvent *);
/// Accepts a typed char.
void keyPressEvent(TQKeyEvent *keyEvent);
void imEndEvent (TQIMEvent *e);
private:
// *** BEGIN - Session management ***
/// Will be called when this app is restored due to session management.
void readProperties(TDEConfig *config);
/// Will be called when the app should save its state for session management purposes.
void saveProperties(TDEConfig *config);
// *** END - Session management ***
/// Initialises the program during a normal startup
void init();
/// Creates the layout and GUI setup for a practice session
void initTrainingSession();
/// Creates the (standard) actions and entries in the menu.
void setupActions();
/// This function updates the font used in the sliding line of a font suggestions was
/// made for the current lecture.
/// Call this function whenever you have read a new lecture file to update
/// the slide line widget.
void updateFontFromLecture();
/// This function populates the file lists with the installed training, keyboard and
/// examination files.
void updateFileLists();
/// Updates the check mark in the lecture-quick-selection menu depending on the
/// lecture in Prefs::currentLectureFile().
void updateLectureActionCheck();
/// Updates the check mark in the keyboard-quick-selection menu depending on the
/// lecture in Prefs::currentKeyboardFile().
void updateKeyboardActionCheck();
// *** Public member variables ***
TDEAction *m_trainingPause; ///< Action for "pause training session".
TDESelectAction *m_keyboardLayoutAction;
TDESelectAction *m_keyboardColorAction;
TDESelectAction *m_defaultLectureAction;
KTouchStatus *m_statusWidget; ///< Pointer to the status widget on top of the main widget.
KTouchSlideLine *m_slideLineWidget; ///< Pointer to the sliding line widget.
KTouchKeyboardWidget *m_keyboardWidget; ///< Pointer to the keyboard widget.
KTouchTrainer *m_trainer; ///< The training 'master' (runs the training).
KTouchLecture m_lecture; ///< The lecture data.
KTouchPrefGeneralLayout * m_pageGeneral; ///< The general configuration page.
KTouchPrefTrainingLayout * m_pageTraining; ///< The training configuration page.
KTouchPrefKeyboardLayout * m_pageKeyboard; ///< The keyboard configuration page.
KTouchPrefColorsLayout * m_pageColors; ///< The color scheme configuration page.
TQStringList m_lectureFiles; ///< A list of all default lecture files.
TQStringList m_lectureTitles; ///< A list of the titles of all default lecture files.
TQStringList m_examinationFiles; ///< A list of all default examination files.
TQStringList m_examinationTitles; ///< A list of the titles of all default examination files.
TQStringList m_keyboardFiles; ///< A list of all default keyboard layout files.
TQStringList m_keyboardTitles; ///< A list of the titles of all default keyboard layout files.
KTouchStatisticsData m_stats; ///< All user statistics are kept here.
TQChar m_lastDeadKey; ///< Temporary storage of last dead key.
};
/// A global pointer to the main widget (actually only used to retrieve some data).
extern KTouch * KTouchPtr;
#endif // KTOUCH_H
|