Logo Search packages:      
Sourcecode: kbruch version File versions  Download package

ExercisePercentage::ExercisePercentage ( QWidget *  parent = 0 )

constructor

Definition at line 47 of file exercisepercentage.cpp.

                                                        :
    ExerciseBase (parent)
{
#ifdef DEBUG
    kDebug() << "constructor ExercisePercentage()";
#endif

    /* create a new task */
    QApplication::setOverrideCursor (Qt::WaitCursor); /* show the sand clock */
    createTask();
    QApplication::restoreOverrideCursor(); /* show the normal cursor */

    // to validate, that the input is an int
    KIntValidator *valnum = new KIntValidator (this);

    QFont defaultFont = SettingsClass::taskFont();
    defaultFont.setBold (true);
    defaultFont.setPointSize (10);

    // the next thing to do on a button click would be to check the entered
    // result
    m_currentState = _CHECK_TASK;

    taskWidget = new QWidget (this);
    taskWidget->setObjectName ("taskWidget");
    checkWidget = new QWidget (this);
    checkWidget->setObjectName ("checkWidget");

    baseGrid = new QGridLayout (this);
    baseGrid->setObjectName ("baseGrid");
    baseGrid->setColumnStretch (0, 1);

    baseGrid->addWidget (taskWidget, 0, 0);
    baseGrid->addWidget (checkWidget, 0, 1);

    taskLayout = new QGridLayout (taskWidget);
    taskLayout->setObjectName ("taskLayout");
    taskLayout->setRowStretch (0, 1);
    taskLayout->setRowStretch (4, 1);
    taskLayout->setColumnStretch (0, 1);
    taskLayout->setColumnStretch (3, 1);

    checkLayout = new QGridLayout (checkWidget);
    checkLayout->setObjectName ("checkLayout");

    /* Task: percentage question */
    defaultFont.setPointSize (16);
    m_taskLabel = new QLabel (this);
    m_taskLabel->setObjectName ("m_taskLabel");
    m_taskLabel->setFont (defaultFont);
    m_taskLabel->setText (i18nc ("%1 percentage of %2", "%1% of %2 = ", m_numberPercentage ,  m_numberPercentageOf));
    taskLayout->addWidget (m_taskLabel, 1, 1, 2, 1);

    /* Input question: result of question */
    answer_edit = new KLineEdit (taskWidget);
    answer_edit->setObjectName ("answer_edit");
    answer_edit->setValidator (valnum);  // use the int validator
    answer_edit->setToolTip (i18n ("Enter the result of percentage question"));
    answer_edit->setFixedSize (85, 42);
    answer_edit->setAlignment (Qt::AlignHCenter);
    answer_edit->setFont (defaultFont);
    QObject::connect (answer_edit, SIGNAL (returnPressed (const QString &)), this,
                      SLOT (answerReturnPressed (const QString &)));
    taskLayout->addWidget (answer_edit, 1, 2, 2, 1);

    // next is the result widget
    m_resultWidget = new ResultWidget (checkWidget, m_result);
    m_resultWidget->setObjectName ("m_resultWidget");
    checkLayout->addWidget (m_resultWidget, 0, 0, 1, 2);

    // the right aligned button
    defaultFont.setPointSize (10);
    m_checkButton = new QPushButton (checkWidget);
    m_checkButton->setObjectName ("m_checkButton");
    m_checkButton->setText (i18n ("&Check"));
    m_checkButton->setDefault (true); // is the default button of the dialog
    m_checkButton->setToolTip (i18n ("Click on this button to check your result. The button will not work if you have not entered a result yet."));
    m_checkButton->setFont (defaultFont);
    QObject::connect (m_checkButton, SIGNAL (clicked()), this, SLOT (slotCheckButtonClicked()));
    checkLayout->addWidget (m_checkButton, 2, 0);

    // the right aligned button
    m_skipButton = new QPushButton (checkWidget);
    m_skipButton->setObjectName ("m_skipButton");
    m_skipButton->setText (i18n ("&Skip"));
    m_skipButton->setToolTip (i18n ("Click on this button to skip this question."));
    m_skipButton->setFont (defaultFont);
    QObject::connect (m_skipButton, SIGNAL (clicked()), this, SLOT (slotSkipButtonClicked()));
    checkLayout->addWidget (m_skipButton, 2, 1);

    // that the user can start typing without moving the focus
    //numer_edit->setFocus();
    answer_edit->setFocus();

    setLayout (baseGrid);
    taskWidget->setLayout (taskLayout);
    checkWidget->setLayout (checkLayout);

    // add tooltip and qwhatsthis help to the widget
    setToolTip (i18n ("In this exercise you have to work with percentage questions."));
    setWhatsThis (i18n ("In this exercise you have to enter the fraction of the given number."));

}

Generated by  Doxygen 1.6.0   Back to index