Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
typing_test_layer.h
Go to the documentation of this file.
1#ifndef TYPING_TEST_LAYER_H
2#define TYPING_TEST_LAYER_H
3
4#include "../security_layer.h"
5
6class QLineEdit;
7class QLabel;
8
19class TypingTestLayer final : public SecurityLayer {
20 Q_OBJECT
21
22public:
30 explicit TypingTestLayer(QWidget *parent = nullptr);
31
35 ~TypingTestLayer() override;
36
41 void Initialize() override;
42
48 void Reset() override;
49
50private slots:
58 void OnTextChanged(const QString &text);
59
64 void UpdateHighlight() const;
65
66private:
73 void GenerateWords();
74
80 void UpdateDisplayText() const;
81
83 QLabel *title_label_;
89 QLineEdit *hidden_input_;
90
92 QStringList words_;
94 QString full_text_;
101};
102
103#endif // TYPING_TEST_LAYER_H
SecurityLayer(QWidget *parent=nullptr)
Constructs a SecurityLayer.
Definition security_layer.h:20
QLineEdit * hidden_input_
Hidden input field used to capture user keystrokes without being visible.
Definition typing_test_layer.h:89
TypingTestLayer(QWidget *parent=nullptr)
Constructs a TypingTestLayer. Initializes the UI elements (title, instructions, text display panel,...
Definition typing_test_layer.cpp:13
~TypingTestLayer() override
Destructor.
Definition typing_test_layer.cpp:68
bool test_started_
Flag indicating if the user has started typing.
Definition typing_test_layer.h:98
void Reset() override
Resets the layer to its initial state. Clears the input field, resets progress tracking,...
Definition typing_test_layer.cpp:80
QString full_text_
The complete text passage the user needs to type.
Definition typing_test_layer.h:94
QLabel * title_label_
Label displaying the layer title ("TYPING VERIFICATION TEST").
Definition typing_test_layer.h:83
QLabel * display_text_label_
Label displaying the text passage to be typed, with dynamic highlighting.
Definition typing_test_layer.h:87
void UpdateHighlight() const
Updates the text display label after the test is successfully completed. Sets the entire text to gree...
Definition typing_test_layer.cpp:280
int current_position_
Index of the next character the user needs to type correctly in full_text_.
Definition typing_test_layer.h:96
QLabel * instructions_label_
Label displaying instructions for the user.
Definition typing_test_layer.h:85
bool test_completed_
Flag indicating if the user has successfully completed the typing test.
Definition typing_test_layer.h:100
void UpdateDisplayText() const
Updates the display_text_label_ with formatted rich text. Highlights correctly typed characters in gr...
Definition typing_test_layer.cpp:202
void OnTextChanged(const QString &text)
Slot called when the text in the hidden_input_ field changes. Validates the entered text against the ...
Definition typing_test_layer.cpp:230
void Initialize() override
Initializes the layer for display. Resets the layer state, sets focus on the hidden input field,...
Definition typing_test_layer.cpp:71
void GenerateWords()
Generates a random text passage composed of words from a predefined pool. Ensures the generated text ...
Definition typing_test_layer.cpp:103
QStringList words_
List of words composing the current text passage.
Definition typing_test_layer.h:92