void QQuickCustomAffector::affectSystem(qreal dt) { //Acts a bit differently, just emits affected for everyone it might affect, when the only thing is connecting to affected(x,y) bool justAffected = (m_acceleration == &m_nullVector && m_velocity == &m_nullVector && m_position == &m_nullVector && isAffectedConnected()); if (!isAffectConnected() && !justAffected) { QQuickParticleAffector::affectSystem(dt); return; } if (!m_enabled) return; updateOffsets(); QList<QQuickParticleData*> toAffect; foreach (QQuickParticleGroupData* gd, m_system->groupData) if (activeGroup(m_system->groupData.key(gd))) foreach (QQuickParticleData* d, gd->data) if (shouldAffect(d)) toAffect << d; if (toAffect.isEmpty()) return; if (justAffected) { foreach (QQuickParticleData* d, toAffect) {//Not postAffect to avoid saying the particle changed if (m_onceOff) m_onceOffed << qMakePair(d->group, d->index); emit affected(d->curX(), d->curY()); } return; } if (m_onceOff) dt = 1.0; QQmlEngine *qmlEngine = ::qmlEngine(this); QV4::ExecutionEngine *v4 = QV8Engine::getV4(qmlEngine->handle()); QV4::Scope scope(v4); QV4::Scoped<QV4::ArrayObject> array(scope, v4->newArrayObject(toAffect.size())); QV4::ScopedValue v(scope); for (int i=0; i<toAffect.size(); i++) array->putIndexed(i, (v = toAffect[i]->v4Value())); if (dt >= simulationCutoff || dt <= simulationDelta) { affectProperties(toAffect, dt); emit affectParticles(QQmlV4Handle(array), dt); } else { int realTime = m_system->timeInt; m_system->timeInt -= dt * 1000.0; while (dt > simulationDelta) { m_system->timeInt += simulationDelta * 1000.0; dt -= simulationDelta; affectProperties(toAffect, simulationDelta); emit affectParticles(QQmlV4Handle(array), simulationDelta); } m_system->timeInt = realTime; if (dt > 0.0) { affectProperties(toAffect, dt); emit affectParticles(QQmlV4Handle(array), dt); } } foreach (QQuickParticleData* d, toAffect) if (d->update == 1.0) postAffect(d); }
void QQuickCustomAffector::affectSystem(qreal dt) { //Acts a bit differently, just emits affected for everyone it might affect, when the only thing is connecting to affected(x,y) bool justAffected = (m_acceleration == &m_nullVector && m_velocity == &m_nullVector && m_position == &m_nullVector && isAffectedConnected()); if (!isAffectConnected() && !justAffected) { QQuickParticleAffector::affectSystem(dt); return; } if (!m_enabled) return; updateOffsets(); QList<QQuickParticleData*> toAffect; foreach (QQuickParticleGroupData* gd, m_system->groupData) if (activeGroup(m_system->groupData.key(gd))) foreach (QQuickParticleData* d, gd->data) if (shouldAffect(d)) toAffect << d; if (toAffect.isEmpty()) return; if (justAffected) { foreach (QQuickParticleData* d, toAffect) {//Not postAffect to avoid saying the particle changed if (m_onceOff) m_onceOffed << qMakePair(d->group, d->index); emit affected(d->curX(), d->curY()); } return; } if (m_onceOff) dt = 1.0; v8::HandleScope handle_scope; v8::Context::Scope scope(QQmlEnginePrivate::getV8Engine(qmlEngine(this))->context()); v8::Handle<v8::Array> array = v8::Array::New(toAffect.size()); for (int i=0; i<toAffect.size(); i++) array->Set(i, toAffect[i]->v8Value().toHandle()); if (dt >= simulationCutoff || dt <= simulationDelta) { affectProperties(toAffect, dt); emit affectParticles(QQmlV8Handle::fromHandle(array), dt); } else { int realTime = m_system->timeInt; m_system->timeInt -= dt * 1000.0; while (dt > simulationDelta) { m_system->timeInt += simulationDelta * 1000.0; dt -= simulationDelta; affectProperties(toAffect, simulationDelta); emit affectParticles(QQmlV8Handle::fromHandle(array), simulationDelta); } m_system->timeInt = realTime; if (dt > 0.0) { affectProperties(toAffect, dt); emit affectParticles(QQmlV8Handle::fromHandle(array), dt); } } foreach (QQuickParticleData* d, toAffect) if (d->update == 1.0) postAffect(d); }
void EventWidget::updateConfig() { KConfig *config; config = kapp->getConfig(); config->setGroup("Fonts"); setFont(config->readFontEntry("Schedule Font")); config->setGroup( "Colors" ); selectedHandle = config->readColorEntry( "AptSelected" ); inactiveHandle = config->readColorEntry( "AptUnselected" ); activeHandle = config->readColorEntry( "AptActive" ); QColorGroup normalGroup( black, //kapp->windowColor, // foreground, used for the edge //kapp->windowColor, config->readColorEntry( "AptBackground" ), // background, used for non text area in textbox green, //config->readColorEntry( "AptUnselected" ),// light red, // dark red, // mid config->readColorEntry( "AptText" ), // text //kapp->windowColor config->readColorEntry( "AptBackground" ) // base used for background behind text ); // for displaying currently happening event ... QColorGroup activeGroup( selectedHandle, // for the edge config->readColorEntry( "AptBackground" ), green, // light red, // dark red, // mid config->readColorEntry( "AptText" ), // text config->readColorEntry( "AptBackground" ) ); QColorGroup disabledGroup( black, //kapp->windowColor, // foreground, used for the edge //kapp->windowColor, config->readColorEntry( "AptBackground" ).dark(120), // background, used for non text area in textbox green, //config->readColorEntry( "AptUnselected" ),// light red, // dark red, // mid config->readColorEntry( "AptText" ), // text //kapp->windowColor config->readColorEntry( "AptBackground" ).dark(120) // base used for background behind text ); QPalette myPalette; myPalette.setNormal( normalGroup ); myPalette.setActive( activeGroup ); myPalette.setDisabled(disabledGroup); setPalette(myPalette); // we don't want the hilite border for other widgets except // the main widget, so set the active color group to normalGroup. myPalette.setActive(normalGroup); textBox->setPalette( myPalette ); iconBox->setPalette( myPalette ); setSelected( widgetSelected ); // to set handle color }