Ejemplo n.º 1
0
Button::Button(const QString& label, int nstates, QWidget* parent): QPushButton(label, parent)
{
	setNumStates(nstates);
	setState(0);
	
	connect(this, SIGNAL(pressed()), this, SLOT(toggle()));
}
Ejemplo n.º 2
0
/*!
    Constructs the UiDigitalGenerator with the given \a parent.
*/
UiDigitalGenerator::UiDigitalGenerator(DigitalSignals* digitalSignals,
                                       QWidget *parent) :
    QWidget(parent)
{
    int defaultStates = 32;
    mSignals = digitalSignals;

    GeneratorDevice* device = DeviceManager::instance().activeDevice()
            ->generatorDevice();
    if (device != NULL) {
        defaultStates = device->maxNumDigitalStates();
    }

    // Deallocation: ownership changed when calling setLayout
    QVBoxLayout* verticalLayout = new QVBoxLayout();

    mTable = createTable();

    verticalLayout->addWidget(createToolBar());
    verticalLayout->addWidget(mTable);

    setLayout(verticalLayout);


    setNumStates(defaultStates);
}
Ejemplo n.º 3
0
/*!
    Called when the active device has been changed.
*/
void UiDigitalGenerator::handleDeviceChanged()
{
    GeneratorDevice* device = DeviceManager::instance().activeDevice
            ()->generatorDevice();
    if (device == NULL) return;

    // ### maximum number of states

    mStatesBox->setMaximum(device->maxNumDigitalStates());

    QList<DigitalSignal*> digitalSignals = device->digitalSignals();

    // ### selected number of states

    int states = device->maxNumDigitalStates();
    if (digitalSignals.size() > 0) {
        // Use num states for the first digital
        // signal as num states. All signals have the same size.
        states = digitalSignals.at(0)->numStates();
    }
    setNumStates(states);

    // ### digital signals
    mSignals->syncSignalsWithDevice();

    mAddAction->setEnabled(device->unusedDigitalIds().size() > 0);
}
Ejemplo n.º 4
0
//parse received data buffer and update values
//1 -> next 2 bytes are rules
//2 -> next byte is number of states
//3 -> next 6 bytes are colors
//4 -> disable mic
//5 -> enable mic
static void parseBuffer(){
	seqNum = comBuf[0];
	int i = 1;
	uint8_t numBytes = bitsRcvd/8;
	while(i<numBytes){
		if(comBuf[i]==1){
			if(i+2<numBytes){
				setRules(comBuf[i+1],comBuf[i+2]); 
			}
			i+=3;
		}else if(comBuf[i]==2){
			if(i+1<numBytes){
				setNumStates(comBuf[i+1]);
			}
			i+=2;
		}else if(comBuf[i]==3){
			if(i+6<numBytes){
				setColors(comBuf+i+1);
			}
			i+=7;
		}else if(comBuf[i]==4){
			soundEn = 0;
			i++;
		}else if(comBuf[i]==5){
			soundEn = 1;
			i++;
		}else{
			i++;
		}
	}
}
Ejemplo n.º 5
0
int Button::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QPushButton::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 2)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 2;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = getState(); break;
        case 1: *reinterpret_cast< int*>(_v) = getNumStates(); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setState(*reinterpret_cast< int*>(_v)); break;
        case 1: setNumStates(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}