void MDeclarativeScreenPrivate::_q_updateOrientationAngle() { if (orientationLocked) return; #ifdef HAVE_CONTEXTSUBSCRIBER MDeclarativeScreen::Orientation newOrientation = MDeclarativeScreen::Portrait; QString edge = topEdgeProperty.value().toString(); bool open = keyboardOpenProperty.value().toBool(); if (open) { newOrientation = MDeclarativeScreen::Landscape; } else if (edge == "top") { newOrientation = MDeclarativeScreen::Landscape; } else if (edge == "left") { newOrientation = MDeclarativeScreen::Portrait; } else if (edge == "right") { newOrientation = MDeclarativeScreen::PortraitInverted; } else if (edge == "bottom") { newOrientation = MDeclarativeScreen::LandscapeInverted; } if (open != keyboardOpen) { keyboardOpen = open; emit q->keyboardOpenChanged(); } if (newOrientation != orientation) { orientation = newOrientation; _q_setOrientationHelper(); emit q->orientationChanged(); } #endif }
void BatteryTest::valueChanged() { ContextProperty *prop = qobject_cast<ContextProperty*>(sender()); if(!prop) return; qDebug()<<"new value: "<<prop->value().toBool(); }
BatteryTest::BatteryTest(QObject *parent) : QObject(parent) { ContextProperty *property = new ContextProperty("Battery.OnBattery",this); property->subscribe(); property->waitForSubscription(); connect(property,SIGNAL(valueChanged()),this,SLOT(valueChanged())); qDebug()<<"initial value: "<<property->value().toBool(); }
void MDeclarativeScreenPrivate::_q_isCoveredChanged() { #ifdef HAVE_CONTEXTSUBSCRIBER bool covered = isCoveredProperty.value().toBool(); if (isCovered != covered) { qDebug() << "MDeclarativeScreenPrivate" << "Covered:" << covered; isCovered = covered; emit q->coveredChanged(); } #endif }
void MDeclarativeScreenPrivate::initContextSubscriber() { #ifdef HAVE_CONTEXTSUBSCRIBER //waiting for properties to synchronize topEdgeProperty.waitForSubscription(); isCoveredProperty.waitForSubscription(); keyboardOpenProperty.waitForSubscription(); QObject::connect(&topEdgeProperty, SIGNAL(valueChanged()), q, SLOT(_q_updateOrientationAngle())); QObject::connect(&isCoveredProperty, SIGNAL(valueChanged()), q, SLOT(_q_isCoveredChanged())); QObject::connect(&keyboardOpenProperty, SIGNAL(valueChanged()), q, SLOT(_q_updateOrientationAngle())); //initiating the variables to current orientation _q_updateOrientationAngle(); if (orientation == MDeclarativeScreen::Portrait) // make sure we notify the input method _q_setOrientationHelper(); _q_isCoveredChanged(); #endif }