Commit 24a7f711 authored by Frederik Gladhorn's avatar Frederik Gladhorn
Browse files

Implement setting of different font for practice modes.

One font and size per language. Can be configured in
language settings in the editor.

BUG: 237056
BUG: 266263
FIXED-IN: KDE 4.7
parent 4786c800
......@@ -44,8 +44,8 @@ public:
virtual void setSolutionPronunciation(const QString& pronunciationText) = 0;
virtual void setQuestionPronunciation(const QString& pronunciationText) = 0;
virtual void setQuestionFont(const QFont& font) {}
virtual void setSolutionFont(const QFont& font) {}
virtual void setQuestionFont(const QFont& font) = 0;
virtual void setSolutionFont(const QFont& font) = 0;
virtual void setSynonym(const QString& entry) = 0;
......
......@@ -22,8 +22,8 @@
using namespace Practice;
ComparisonModeWidget::ComparisonModeWidget (GuiFrontend *frontend, QWidget* parent )
: AbstractModeWidget (frontend, parent)
ComparisonModeWidget::ComparisonModeWidget(GuiFrontend *frontend, QWidget* parent)
: AbstractModeWidget(frontend, parent)
{
m_ui = new Ui::ComparisonPracticeWidget();
m_ui->setupUi(this);
......@@ -37,8 +37,19 @@ ComparisonModeWidget::ComparisonModeWidget (GuiFrontend *frontend, QWidget* pare
m_ui->superlativeSolutionLabel->setPalette(m_correctPalette);
}
ComparisonModeWidget::~ComparisonModeWidget()
void ComparisonModeWidget::setQuestionFont(const QFont& font)
{
m_ui->questionLabel->setFont(font);
}
void ComparisonModeWidget::setSolutionFont(const QFont& font)
{
m_ui->absoluteSolutionLabel->setFont(font);
m_ui->comparativeSolutionLabel->setFont(font);
m_ui->superlativeSolutionLabel->setFont(font);
m_ui->absoluteEdit->setFont(font);
m_ui->comparativeEdit->setFont(font);
m_ui->superlativeEdit->setFont(font);
}
void ComparisonModeWidget::setQuestion(const QVariant& question)
......
......@@ -30,7 +30,6 @@ class ComparisonModeWidget: public AbstractModeWidget
public:
ComparisonModeWidget(GuiFrontend *frontend, QWidget *parent = 0);
virtual ~ComparisonModeWidget();
virtual QVariant userInput();
virtual void setQuestion(const QVariant& question);
......@@ -40,6 +39,8 @@ public:
virtual void setFeedbackState(AbstractFrontend::ResultState feedbackState) {Q_UNUSED(feedbackState);}
virtual void setResultState(AbstractFrontend::ResultState resultState) {Q_UNUSED(resultState);}
virtual void setQuestionFont(const QFont& font);
virtual void setSolutionFont(const QFont& font);
virtual void setQuestionSound(const KUrl& soundUrl);
virtual void setSolutionSound(const KUrl& soundUrl);
virtual void setSolutionPronunciation(const QString& pronunciationText);
......
......@@ -60,6 +60,17 @@ ConjugationModeWidget::~ConjugationModeWidget()
qDeleteAll(m_personWidgets);
}
void ConjugationModeWidget::setQuestionFont(const QFont& font)
{
m_ui->questionLabel->setFont(font);
}
void ConjugationModeWidget::setSolutionFont(const QFont& font)
{
m_ui->infinitiveEdit->setFont(font);
m_solutionFont = font;
}
void ConjugationModeWidget::setQuestion(const QVariant& question)
{
if (!question.canConvert<ConjugationData>()) {
......@@ -75,9 +86,12 @@ void ConjugationModeWidget::setQuestion(const QVariant& question)
int i = 0;
foreach(const QString& pp, data.personalPronouns) {
m_personWidgets.at(i)->person->setText(pp);
m_personWidgets.at(i)->person->setFont(m_solutionFont);
m_personWidgets.at(i)->input->clear();
m_personWidgets.at(i)->input->setPalette(QApplication::palette());
m_personWidgets.at(i)->input->setFont(m_solutionFont);
m_personWidgets.at(i)->solution->clear();
m_personWidgets.at(i)->solution->setFont(m_solutionFont);
connect(m_personWidgets.at(i)->input, SIGNAL(returnPressed()), this, SLOT(nextConjugationForm()));
++i;
}
......
......@@ -41,6 +41,8 @@ public:
virtual void setFeedbackState(AbstractFrontend::ResultState feedbackState) {Q_UNUSED(feedbackState);}
virtual void setResultState(AbstractFrontend::ResultState resultState) {Q_UNUSED(resultState);}
virtual void setQuestionFont(const QFont& font);
virtual void setSolutionFont(const QFont& font);
virtual void setQuestionSound(const KUrl& soundUrl);
virtual void setSolutionSound(const KUrl& soundUrl);
virtual void setSolutionPronunciation(const QString& pronunciationText);
......@@ -61,6 +63,7 @@ private:
Ui::ConjugationPracticeWidget* m_ui;
QStringList m_solution;
QList<PersonConjugationSolutionWidgets*> m_personWidgets;
QFont m_solutionFont;
};
}
......
......@@ -28,6 +28,16 @@ FlashCardModeWidget::FlashCardModeWidget (GuiFrontend *frontend, QWidget* parent
m_ui->setupUi(this);
}
void FlashCardModeWidget::setQuestionFont(const QFont& font)
{
m_ui->questionLabel->setFont(font);
}
void FlashCardModeWidget::setSolutionFont(const QFont& font)
{
m_ui->solutionLabel->setFont(font);
}
void FlashCardModeWidget::setQuestion(const QVariant& question)
{
m_ui->questionLabel->setMinimumSize(QSize(0, 0));
......
......@@ -38,6 +38,8 @@ public:
virtual void setQuestion(const QVariant& question);
virtual void setSolution(const QVariant& solution);
virtual void setQuestionFont(const QFont& font);
virtual void setSolutionFont(const QFont& font);
virtual void setHint(const QVariant& hint);
virtual void setFeedback(const QVariant& feedback) {Q_UNUSED(feedback);}
virtual void setFeedbackState(AbstractFrontend::ResultState feedbackState) {Q_UNUSED(feedbackState);}
......
......@@ -35,6 +35,12 @@ MixedLettersModeWidget::MixedLettersModeWidget(GuiFrontend *frontend, QWidget *p
connect(m_ui->answerEdit, SIGNAL(textChanged(QString)), this, SLOT(updatePixmap()));
}
void MixedLettersModeWidget::setSolutionFont(const QFont& font)
{
m_solutionFont = font;
WrittenPracticeWidget::setSolutionFont(font);
}
void MixedLettersModeWidget::setQuestion(const QVariant& question)
{
m_question = question.toString();
......@@ -49,13 +55,14 @@ void MixedLettersModeWidget::showQuestion()
void MixedLettersModeWidget::updatePixmap()
{
QFontMetrics fm(font());
QFontMetrics fm(m_solutionFont);
int charHeight = fm.height();
int charWidth = fm.averageCharWidth();
m_pixmap = QPixmap(charWidth*m_mixedSolution.length()*2 + charWidth, charHeight*3);
m_pixmap.fill(QColor(0,0,0,0));
QPainter p(&m_pixmap);
p.setFont(m_solutionFont);
KColorScheme scheme(QPalette::Active);
QPen defaultPen = p.pen();
defaultPen.setColor(palette().color(QPalette::WindowText));
......
......@@ -37,6 +37,7 @@ public:
virtual void setQuestion(const QVariant& question);
virtual void setSolution(const QVariant& solution);
virtual void setSolutionFont(const QFont& font);
public slots:
void showQuestion();
......@@ -50,6 +51,7 @@ private:
QString m_question;
QList<int> m_positions;
QPixmap m_pixmap;
QFont m_solutionFont;
};
}
......
......@@ -41,6 +41,16 @@ MultiplechoiceModeWidget::MultiplechoiceModeWidget (GuiFrontend *frontend, QWidg
}
void MultiplechoiceModeWidget::setQuestionFont ( const QFont& font )
{
m_ui->questionLabel->setFont(font);
}
void MultiplechoiceModeWidget::setSolutionFont ( const QFont& font )
{
m_solutionFont = font;
}
void MultiplechoiceModeWidget::setQuestion(const QVariant& question)
{
if (!question.canConvert<MultipleChoiceData>()) {
......@@ -70,6 +80,7 @@ void MultiplechoiceModeWidget::setQuestion(const QVariant& question)
foreach(QRadioButton *radio,m_choiceButtons){
radio->setText(data.choices[j]);
radio->setToolTip(data.choices[j]);
radio->setFont(m_solutionFont);
j++;
}
}
......@@ -89,7 +100,6 @@ void MultiplechoiceModeWidget::showQuestion()
radio->setEnabled(true);
}
QTimer::singleShot(0, m_choiceButtons[0], SLOT(setFocus()));
}
......
......@@ -41,6 +41,8 @@ public:
virtual void setFeedbackState(AbstractFrontend::ResultState feedbackState) {Q_UNUSED(feedbackState);}
virtual void setResultState(AbstractFrontend::ResultState resultState) {Q_UNUSED(resultState);}
virtual void setQuestionFont(const QFont& font);
virtual void setSolutionFont(const QFont& font);
virtual void setQuestionSound(const KUrl& soundUrl);
virtual void setSolutionSound(const KUrl& soundUrl);
virtual void setSolutionPronunciation(const QString& pronunciationText);
......@@ -53,7 +55,7 @@ public Q_SLOTS:
virtual void showSolution();
virtual void setNumberOfRadioButtons(const int numberOfChoices);
virtual void showSynonym();
protected:
virtual bool eventFilter(QObject *obj, QEvent *event);
private:
......@@ -62,6 +64,7 @@ private:
QList<QRadioButton*> m_choiceButtons;
QList<QAction*> m_actions;
LatexRenderer *m_latexRenderer;
QFont m_solutionFont;
};
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment