void RazorSensorsConfiguration::changeProgressBarColor()
{
    QAbstractButton* btn = qobject_cast<QAbstractButton*>(sender());

    if (btn)
    {
        QPalette pal = btn->palette();
        QColor color = QColorDialog::getColor(pal.color(QPalette::Normal, QPalette::Button), this);

        if (color.isValid())
        {
            pal.setColor(QPalette::Normal, QPalette::Button, color);
            btn->setPalette(pal);
            saveSettings();
        }
    }
    else
    {
        qDebug() << "RazorSensorsConfiguration::changeProgressBarColor():" << "invalid button cast";
    }
}
Пример #2
0
void ClsQNeuronStateVariableDisplay::setSelectedStates(list<string> lstStates) {
#ifdef DEBUG_CLSQSTATEVARIABLEDISPLAY
    cout << "ClsQNeuronStateVariableDisplay::setSelectedStates(list<string> lst)" << endl;
#endif

    QList<QAbstractButton *> lst = qbtngrpStateVariables->buttons ();
    QList<QAbstractButton*>::iterator it;

    for (it = lst.begin(); it != lst.end(); ++it) {
	string str= (string)((*it)->text().latin1());
	if(std::find(lstStates.begin(), lstStates.end(), str) != lstStates.end()){
	    QAbstractButton *qrb = (*it);
	    qrb->toggle();
 
	    string strSinkID = qrb->text().latin1() + strID;
	    QColor qc;	    
	    qc.setHsv(clsFEDataClient->getDataSinkColor(strSinkID), 255, 210);
	    QPalette palette = qrb->palette();
	    palette.setColor ( QColorGroup::Foreground, qc );
//	    palette.setColor ( QColorGroup::ButtonText, qc );
	    qrb->setPalette(palette);
	}
    }
};
Пример #3
0
void ClsQNeuronStateVariableDisplay::slotStateVariables(int ii){
#ifdef DEBUG_CLSQSTATEVARIABLEDISPLAY
    cout << "void ClsQNeuronStateVariableDisplay::slotStateVariables(int ii)" << endl;
#endif

    /*
    cout << "qbtngrpStateVariables->exclusive ( ): " << qbtngrpStateVariables->exclusive ( ) << endl;
    cout << "iCurrentStateButton: " << iCurrentStateButton << endl;
    cout << "ii: " << ii << endl;
    */

    QAbstractButton *btn = qbtngrpStateVariables->button ( ii );
    if(btn==NULL){
	return;
    } 
   

    if(qchkbxLiveData->isOn() && ii != iCurrentStateButton){
	if(btn->isChecked()){
	    //cout << "send request: " << btn->text().latin1() << endl;
	    /* send request */
	    string strSinkID = btn->text().latin1() + strID;

	    clsFEDataClient->addDataSink(strSinkID, clsFEGroup, btn->text().latin1(), strSelectedIndices);

	    QColor qc;
	    qc.setHsv(clsFEDataClient->getDataSinkColor(strSinkID), 255, 210);
	    QPalette palette = (btn)->palette();
	    palette.setColor ( QColorGroup::Foreground, qc );
	    (btn)->setPalette(palette);
	    if(bAverage){
		clsFEDataClient->setSinkMath(strSinkID, ClsFEDataSink::MATH_AVERAGE);
	    }

	    if(qbtngrpStateVariables->exclusive( ) && iCurrentStateButton >= 0){
		/* cancel rewquest of the last active checkbox (iCurrentStateButton) */
		QAbstractButton *btnCurrent =  qbtngrpStateVariables->button (iCurrentStateButton);
		
		if(btnCurrent!=NULL){
		    // cout << "cancel request: " << btnCurrent->text().latin1() << endl;
		    string strSinkID = btnCurrent->text().latin1() + strID;
		    clsFEDataClient->removeDataSink(strSinkID);
		    QColor qc;
		    qc.setRgb(0,0,0);

		    QPalette palette = btnCurrent->palette();
		    palette.setColor ( QColorGroup::Foreground, qc );
		    btnCurrent->setPalette(palette);
		}
	    }
	} else {
	    /* cancel request */
	    // cout << "cancel request: " << btn->text().latin1() << endl;
	    string strSinkID = btn->text().latin1() + strID;
	    clsFEDataClient->removeDataSink(strSinkID);
	    QColor qc;
	    qc.setRgb(0,0,0);
	    QPalette palette = (btn)->palette();
	    palette.setColor ( QColorGroup::Foreground, qc );
	    (btn)->setPalette(palette);
	}
    } 
    if(qbtngrpStateVariables->exclusive ( )){
	iCurrentStateButton = ii;
    }
};