void PropertyPanel::setTitleColors()
{
	QPalette palette = titleFrame->palette();
	palette.setActive( highlightColorGroup( palette.active() ) );
	palette.setInactive( highlightColorGroup( palette.inactive() ) );
	palette.setDisabled( highlightColorGroup( palette.disabled() ) );
	titleFrame->setPalette( palette );
}
void PaletteEditorAdvanced::setPreviewPalette( const QPalette& pal )
{
    QColorGroup cg;

    switch (selectedPalette) {
    case 0:
    default:
	cg = pal.active();
	break;
    case 1:
	cg = pal.inactive();
	break;
    case 2:
	cg = pal.disabled();
	break;
    }
    previewPalette.setActive( cg );
    previewPalette.setInactive( cg );
    previewPalette.setDisabled( cg );
}
Beispiel #3
0
void PaletteEditor::setPreviewPalette( const QPalette& pal )
{
    QColorGroup cg;

    switch (paletteCombo->currentItem()) {
    case 0:
    default:
        cg = pal.active();
        break;
    case 1:
        cg = pal.inactive();
        break;
    case 2:
        cg = pal.disabled();
        break;
    }
    previewPalette.setActive( cg );
    previewPalette.setInactive( cg );
    previewPalette.setDisabled( cg );

    previewFrame->setPreviewPalette(previewPalette);
}
Beispiel #4
0
/**	- checks the entered result and compares it to the task's result
		- shows the correct result and informs the user if he was right or wrong
		- if the user entered the result unreduced, he will be informed about it
		- if the user entered a 0 for the denominator, he will be informed about
		  it (division by zero)
		- emits signals if task was solved right or wrong */
void TaskView::showResult()
{
	QString tmp_str; /* to build a string for a label */
	QPalette pal;
	QColorGroup cg;

	// change the tooltip of the check button
	QToolTip::add(m_checkButton, i18n("Click on this button to get to the next task."));

	numer_edit->setEnabled(false);
	deno_edit->setEnabled(false);

	result = current_task.solve();
	m_resultWidget->setResult(result);
	m_resultWidget->show();

	// an empty numerator field will be interpreted as 0
	if (numer_edit->text().isEmpty() == true)
		numer_edit->setText("0");

	// an empty denominator field will be interpreted as 1
	if (deno_edit->text().isEmpty() == true)
		deno_edit->setText("1");

	/* store the entered result to check it, but without reducing */
	entered_result.setNumerator(numer_edit->text().toInt(), false);
	entered_result.setDenominator(deno_edit->text().toInt(), false);

	// check the entered result; 0/1 == 0/5 -> true,
	// but 0/1 == 0/0 -> false
	// a 0 for denominator is never allowed (always counted as wrong)
	//
	// we have to get the 0 directly from the input field, because
	// Ratio::setDenominator(0, false) will set the denominator to 1 to ensure
	// the Ratio is valid
	if ( (deno_edit->text().toInt() != 0) && ((entered_result == result) ||
		  (result.numerator() == 0 && entered_result.numerator() == 0)) )
	{
		// emit the signal for correct
		signalTaskSolvedCorrect();

		/* yes, the user entered the correct result */
		result_label->setText(i18n("CORRECT"));
		pal = result_label->palette(); /* set green font color */
		cg = pal.active();
		cg.setColor(QColorGroup::Foreground, QColor(6, 179, 0));
		pal.setActive(cg);
		cg = pal.inactive();
		cg.setColor(QColorGroup::Foreground, QColor(6, 179, 0));
		pal.setInactive(cg);
		result_label->setPalette(pal);
		result_label->show(); /* show the result at the end of the task */
	} else {
		// emit the signal for wrong
		signalTaskSolvedWrong();

		/* no, the user entered the wrong result */
		result_label->setText(i18n("WRONG"));
		pal = result_label->palette(); /* set red font color */
		cg = pal.active();
		cg.setColor(QColorGroup::Foreground, QColor(red));
		pal.setActive(cg);
		cg = pal.inactive();
		cg.setColor(QColorGroup::Foreground, QColor(red));
		pal.setInactive(cg);
		result_label->setPalette(pal);

		result_label->show(); /* show the result at the end of the task */

		// if the user entered a 0 for the denominator (division by 0) we have to
		// get the 0 directly from the input field, because
		// Ratio::setDenominator(0, true) will set the denominator to 1 to ensure
		// the Ratio is valid
		if (deno_edit->text().toInt() == 0)
		{
			KMessageBox::information(this,
			                         i18n("You entered a 0 as the denominator. This means division by zero, which is not allowed. This task will be counted as not correctly solved."));
		} else {
			/* maybe the entered ratio was not reduced */
			entered_result.reduce();
			if (entered_result == result)
				KMessageBox::information(this,
				                         i18n("You entered the correct result, but not reduced.\nAlways enter your results as reduced. This task will be counted as not correctly solved."));
		}
	} /* if (entered_result == result) */
}
Beispiel #5
0
ViewReadLinetree3::ViewReadLinetree3( bool open,
                                                                        QWidget* parent,
                                                                    const char* name,
                                                                        bool modal,
                                                                        WFlags fl )
    : QDialog( parent, name, modal, fl ),
        __open(open)
{
    if ( !name )
        setName( "ViewReadLinetree3" );
    resize( 500, 250 );
    if(open)setCaption( tr( "Read Linetree" ) );
        else setCaption( tr( "Save Linetree" ) );

    buttonLig = new QToolButton( this, "buttonLig" );
    buttonLig->setGeometry( QRect( 450, 10, 40, 21 ) );
    buttonLig->setText( tr( "..." ) );
    QObject::connect( buttonLig,SIGNAL(clicked()),this,SLOT(SelectLigFile()));

    QLabel * labelDta = new QLabel( this, "labelDta" );
    labelDta->setGeometry( QRect( 10, 60, 61, 20 ) );
    labelDta->setText( tr( "Dta File" ) );

    buttonDta = new QToolButton( this, "buttonDta" );
    buttonDta->setGeometry( QRect( 450, 60, 40, 21 ) );
    buttonDta->setText( tr( "..." ) );
    QObject::connect( buttonDta,SIGNAL(clicked()),this,SLOT(SelectDtaFile()));

    QLabel * labelSmb = new QLabel( this, "labelSmb" );
    labelSmb->setGeometry( QRect( 10, 110, 61, 20 ) );
    labelSmb->setText( tr( "SMB Path" ) );

    buttonSmb = new QToolButton( this, "buttonSmb" );
    buttonSmb->setGeometry( QRect( 450, 110, 40, 21 ) );
    buttonSmb->setText( tr( "..." ) );
    QObject::connect( buttonSmb,SIGNAL(clicked()),this,SLOT(SelectSMBPath()));

    QLabel * labelLig = new QLabel( this, "labelLig" );
    labelLig->setGeometry( QRect( 10, 10, 61, 20 ) );
    labelLig->setText( tr( "Lig File" ) );

    editLig = new QLineEdit( this, "editLig" );
    editLig->setGeometry( QRect( 100, 10, 350, 22 ) );

    editDta = new QLineEdit( this, "editDta" );
    editDta->setGeometry( QRect( 100, 60, 350, 22 ) );
        if(!DTA_FILENAME.isEmpty())editDta->setText( tr(DTA_FILENAME) );

    editSmb = new QLineEdit( this, "editSmb" );
    editSmb->setGeometry( QRect( 100, 110, 350, 22 ) );
	if(SMB_PATH.isEmpty())    {
	  SMB_PATH = (TOOLS(getPlantGLDir())+"share/plantgl/SMBFiles").c_str() ;
	}
    if(!SMB_PATH.isEmpty())editSmb->setText( tr( SMB_PATH ) );

    labelKey = new QLabel( this, "labelKey" );
    labelKey->setGeometry( QRect( 10, 160, 89, 20 ) );
    if(open)labelKey->setText( tr( "Key :" ) );
        else labelKey->setText("Key : [AMAPmod]");

    editKey = new QLineEdit( this, "editKey" );
    editKey->setGeometry( QRect( 100, 160, 350, 22 ) );
        editKey->setReadOnly(open);
        editKey->setFont(QFont("courier", 8));
        QPalette pal = editKey->palette();
    QColorGroup cg = pal.active();
    cg.setColor( QColorGroup::Base, QColor( 212, 208, 200) );
    pal.setActive( cg );
        cg = pal.inactive();
    cg.setColor( QColorGroup::Base, QColor( 212, 208, 200) );
    pal.setInactive( cg );
        cg = pal.disabled();
    cg.setColor( QColorGroup::Base, QColor( 212, 208, 200) );
    pal.setDisabled( cg );
    editKey->setProperty( "palette", pal );
    editKey->setEchoMode(QLineEdit::Password);
    if(!open)editKey->setText(PGL(LinetreePrinter)::PROTECTION.c_str());
    QObject::connect( editKey,SIGNAL(textChanged(const QString&)),this,SLOT(checkKey(const QString&)));
	DblClickEater * dblCkEater = new DblClickEater(editKey);
    labelKey->installEventFilter( dblCkEater );

        if(!open){
                QToolButton * buttonKey = new QToolButton( this, "buttonKey" );
                buttonKey->setGeometry( QRect( 450, 160, 40, 21 ) );
                buttonKey->setText( tr( "Reset" ) );
                QObject::connect( buttonKey,SIGNAL(clicked()),this,SLOT(resetKey()));
        }


    buttonCancel = new QPushButton( this, "buttonCancel" );
    buttonCancel->setGeometry( QRect( 390, 200, 104, 28 ) );
    buttonCancel->setText( tr( "&Cancel" ) );
    QObject::connect( buttonCancel,SIGNAL(clicked()),this,SLOT(reject()));

    buttonOk = new QPushButton( this, "buttonOk" );
    buttonOk->setGeometry( QRect( 280, 200, 104, 28 ) );
    buttonOk->setText( tr( "&Ok" ) );
    QObject::connect( buttonOk,SIGNAL(clicked()),this,SLOT(ok()));

    endianBox = new QCheckBox( this, "endianBox" );
    endianBox->setGeometry( QRect( 10, 205, 90, 20 ) );
	endianBox->setText( tr( "Big Endian" ) );
	endianBox->setChecked(true);

    if(open){
    QPushButton * buttonTestEndianess = new QPushButton( this, "TestEndianess" );
    buttonTestEndianess->setGeometry( QRect( 100, 200, 54, 28 ) );
    buttonTestEndianess->setText( tr( "Test" ) );
    QObject::connect( buttonTestEndianess,SIGNAL(clicked()),this,SLOT(testEndianess()));
	}

	if(!LIG_FILENAME.isEmpty()){
       editLig->setText( tr(LIG_FILENAME) );
       checkKey();
	}

}
Beispiel #6
0
/**	- checks, if the user solved the task correctly
		- emits signals if task was solved correctly or wrong */
void ExerciseFactorize::showResult()
{
    QString tmp_str, tmp_str2; /* to build a string for a label */
    QPalette pal;
    QColorGroup cg;
    uint uint_result = 0;

    // change the tooltip of the check button
    QToolTip::add(m_checkButton, i18n("Click on this button to get to the next task."));

    // disable prime factor buttons
    m_factor2Button->setEnabled(false);
    m_factor3Button->setEnabled(false);
    m_factor5Button->setEnabled(false);
    m_factor7Button->setEnabled(false);
    m_factor11Button->setEnabled(false);
    m_factor13Button->setEnabled(false);
    m_factor17Button->setEnabled(false);
    m_factor19Button->setEnabled(false);

    // disable factor removal button as well
    m_removeLastFactorButton->setEnabled(false);

    // show the result
    m_factorsWidget->setFactors(m_factorsResult);
    m_factorsWidget->show();

    // now calculate the product of the prime factors entered by the user
    for (uint tmp_uint = 0; tmp_uint < m_factorsEntered.count(); tmp_uint++)
    {
        if (tmp_uint == 0)
        {
            uint_result = m_factorsEntered[0];
        } else {
            uint_result *= m_factorsEntered[tmp_uint];
        }
    }

    if (uint_result == m_taskNumber)
    {
        // emit the signal for correct
        signalExerciseSolvedCorrect();

        /* yes, the user entered the correct result */
        result_label->setText(i18n("CORRECT"));
        pal = result_label->palette(); /* set green font color */
        cg = pal.active();
        cg.setColor(QColorGroup::Foreground, QColor(6, 179, 0));
        pal.setActive(cg);
        cg = pal.inactive();
        cg.setColor(QColorGroup::Foreground, QColor(6, 179, 0));
        pal.setInactive(cg);
        result_label->setPalette(pal);
    } else {
        // emit the signal for wrong
        signalExerciseSolvedWrong();

        /* no, the user entered the wrong result */
        result_label->setText(i18n("WRONG"));
        pal = result_label->palette(); /* set red font color */
        cg = pal.active();
        cg.setColor(QColorGroup::Foreground, QColor(red));
        pal.setActive(cg);
        cg = pal.inactive();
        cg.setColor(QColorGroup::Foreground, QColor(red));
        pal.setInactive(cg);
        result_label->setPalette(pal);

    } /* if (entered_result == result) */

    result_label->show(); /* show the result at the end of the task */

    return;
}