1 /* 2 SPDX-FileCopyrightText: 2009 Daniel Laidig <d.laidig@gmx.de> 3 SPDX-License-Identifier: GPL-2.0-or-later 4 */ 5 6 #ifndef PRACTICE_ABSTRACTFRONTEND_H 7 #define PRACTICE_ABSTRACTFRONTEND_H 8 9 #include <KEduVocText> 10 #include <QFont> 11 #include <QObject> 12 13 class QUrl; 14 15 namespace Practice 16 { 17 class AbstractFrontend : public QObject 18 { 19 Q_OBJECT 20 public: 21 enum Mode { 22 None, 23 FlashCard, 24 MixedLetters, 25 MultipleChoice, 26 Written, 27 Conjugation, 28 Comparison, 29 ExampleSentence, 30 }; 31 32 enum ResultState { 33 QuestionState, 34 AnswerCorrect, 35 AnswerSynonym, 36 AnswerWrong, 37 }; 38 39 explicit AbstractFrontend(QObject *parent = nullptr); ~AbstractFrontend()40 ~AbstractFrontend() override 41 { 42 } 43 44 /** 45 * Enables access to the input of the user. 46 * This is queried by the backend when it needs to evaluate the input. 47 */ 48 virtual QVariant userInput() = 0; 49 50 /** The status such as lesson or number of words has changed */ 51 virtual void setFinishedWordsTotalWords(int finished, int total) = 0; 52 53 /** fonts for learning and known languages. These will be used to 54 * set question and answer fonts for individual entries. 55 */ 56 virtual QFont knownLangFont() const = 0; 57 virtual QFont learningLangFont() const = 0; 58 virtual void setKnownLangFont(const QFont &font) = 0; 59 virtual void setLearningLangFont(const QFont &font) = 0; 60 61 virtual void setQuestion(const QVariant &question) = 0; 62 virtual void setSolution(const QVariant &solution) = 0; 63 virtual void setFeedback(const QVariant &feedback) = 0; 64 65 virtual void setQuestionFont(const QFont &font) = 0; 66 virtual void setSolutionFont(const QFont &font) = 0; 67 68 virtual void setHint(const QVariant &hint) = 0; 69 virtual void setQuestionImage(const QUrl &img) = 0; 70 virtual void setSolutionImage(const QUrl &img) = 0; 71 virtual void setQuestionSound(const QUrl &soundUrl) = 0; 72 virtual void setSolutionSound(const QUrl &soundUrl) = 0; 73 virtual void setSolutionPronunciation(const QString &pronunciationText) = 0; 74 virtual void setQuestionPronunciation(const QString &pronunciationText) = 0; 75 76 virtual void setLessonName(const QString &lesson) = 0; 77 virtual void showGrade(int preGrade, int grade) = 0; 78 79 /** The feedback state tells the user if the currently entered word is correct 80 (independent of whether the word is counted as correct) **/ 81 virtual void setFeedbackState(ResultState feedbackState) = 0; 82 83 /** The result state indicated whether a word is counted as correct (and grades are raised) 84 and can be changed by the user. **/ 85 virtual void setResultState(ResultState resultState) = 0; 86 virtual ResultState resultState() = 0; 87 88 /** set a new synonym that should be shown */ 89 virtual void setSynonym(const QString &entry) = 0; 90 91 public Q_SLOTS: 92 /** enter question mode - the user is asked to provide the solution */ 93 virtual void showQuestion() = 0; 94 /** enter show solution mode - the solution is shown */ 95 virtual void showSolution() = 0; 96 97 /** show the synonyms */ 98 virtual void showSynonym() = 0; 99 100 /** switch between different modes such as written, flash card, etc */ 101 virtual void setMode(Practice::AbstractFrontend::Mode mode) = 0; 102 virtual void setBoxes(grade_t currentBox, grade_t newBoxIfCorrect, grade_t newBoxIfWrong) = 0; 103 104 Q_SIGNALS: 105 void continueAction(); 106 void hintAction(); 107 void skipAction(); 108 /** request to stop practicing */ 109 void stopPractice(); 110 }; 111 112 } 113 114 #endif // PRACTICE_ABSTRACTFRONTEND_H 115