/*! This function starts the startBatteryStatusChanged notification. */ void QDeclarativeBatteryInfo::startBatteryStatusChanged(bool on) { monitoringBatteryStatusChanges = on; if(on) { connect(batteryInfo(),SIGNAL(batteryStatusChanged(QSystemBatteryInfo::BatteryStatus)), this,SIGNAL(batteryStatusChanged(QSystemBatteryInfo::BatteryStatus)),Qt::UniqueConnection); } else { disconnect(batteryInfo(),SIGNAL(batteryStatusChanged(QSystemBatteryInfo::BatteryStatus)), this,SIGNAL(batteryStatusChanged(QSystemBatteryInfo::BatteryStatus))); } }
/*! Constructs a QtopiaPowerManager instance. */ QtopiaPowerManager::QtopiaPowerManager() : m_powerConstraint(QtopiaApplication::Enable), m_dimLightEnabled(true), m_lightOffEnabled(true) { g_qtopiaPowerManager = this; if (!m_vso) m_vso = new QValueSpaceObject("/Hardware"); setBacklight(-3); //forced on // Create the screen saver and the associated service. #ifdef Q_WS_QWS QWSServer::setScreenSaver(this); #endif (void)new QtopiaPowerManagerService( this, this ); QtopiaPowerConstraintManager *tsmMonitor = new QtopiaPowerConstraintManager(this); connect( tsmMonitor, SIGNAL(forceSuspend()), this, SLOT(_forceSuspend()) ); QObject::connect(&powerstatus, SIGNAL(wallStatusChanged(QPowerStatus::WallStatus)), this, SLOT(powerStatusChanged())); QObject::connect(&powerstatus, SIGNAL(batteryStatusChanged(QPowerStatus::BatteryStatus)), this, SLOT(powerStatusChanged())); QObject::connect(&powerstatus, SIGNAL(batteryChargingChanged(bool)), this, SLOT(powerStatusChanged())); }
BatteryNotifier::BatteryNotifier(QObject *parent) : QObject(parent), lowBatteryNotifier(0), notificationId(0), touchScreenLockActive(false), batteryInfo(new QtMobility::QSystemBatteryInfo(this)), qmDeviceMode(new MeeGo::QmDeviceMode(this)), qmLed(new MeeGo::QmLED(this)), chargerType(QtMobility::QSystemBatteryInfo::UnknownCharger) { connect(batteryInfo, SIGNAL(batteryStatusChanged(QSystemBatteryInfo::BatteryStatus)), this, SLOT(applyBatteryStatus(QSystemBatteryInfo::BatteryStatus))); connect(batteryInfo, SIGNAL(chargingStateChanged(QSystemBatteryInfo::ChargingState)), this, SLOT(applyChargingState(QSystemBatteryInfo::ChargingState))); connect(batteryInfo, SIGNAL(chargerTypeChanged(QSystemBatteryInfo::ChargerType)), this, SLOT(applyChargerType(QSystemBatteryInfo::ChargerType))); connect(qmDeviceMode, SIGNAL(devicePSMStateChanged(MeeGo::QmDeviceMode::PSMState)), this, SLOT(applyPSMState(MeeGo::QmDeviceMode::PSMState))); // Init battery values delayed... initBattery(); notificationTimer.setInterval(5000); notificationTimer.setSingleShot(true); }
void Monitor::procBattery() { QString value; if ( !fGotBatteryInfo ){ QFile f("/sys/class/power_supply/battery/health"); if (f.open(QFile::ReadOnly)){ QByteArray content = f.readAll(); value = QString(content).replace(QString("\n"), QString("")); f.close(); emit batteryHealthChanged(value); } QFile f1("/sys/class/power_supply/battery/technology"); if (f1.open(QFile::ReadOnly)){ QByteArray content = f1.readAll(); value = QString(content).replace(QString("\n"), QString("")); f1.close(); emit batteryTechnologyChanged(value); } fGotBatteryInfo = true; } QFile f2("/sys/class/power_supply/battery/capacity"); if (f2.open(QFile::ReadOnly)){ QByteArray content = f2.readAll(); int v = QString(content).toInt(); f2.close(); emit batteryLevelChanged(v); } QFile f3("/sys/class/power_supply/battery/status"); if (f3.open(QFile::ReadOnly)){ QByteArray content = f3.readAll(); value = QString(content).replace(QString("\n"), QString("")); f3.close(); emit batteryStatusChanged(value); } }
void Dialog::setupDevice() { delete di; //! [createdi] di = new QSystemDeviceInfo(this); //! [createdi] //! [batteryLevel] batteryLevelBar->setValue(di->batteryLevel()); //! [batteryLevel] //! [sig batteryLevelChanged] connect(di,SIGNAL(batteryLevelChanged(int)), this,SLOT(updateBatteryStatus(int))); //! [sig batteryLevelChanged] connect(di,SIGNAL(batteryStatusChanged(QSystemDeviceInfo::BatteryStatus)), this,SLOT(displayBatteryStatus(QSystemDeviceInfo::BatteryStatus))); connect(di,SIGNAL(powerStateChanged(QSystemDeviceInfo::PowerState)), this,SLOT(updatePowerState(QSystemDeviceInfo::PowerState))); ImeiLabel->setText(di->imei()); imsiLabel->setText(di->imsi()); //! [manuf-id] manufacturerLabel->setText(di->manufacturer()); //! [manuf-id] modelLabel->setText(di->model()); //! [productName] productLabel->setText(di->productName()); //! [productName] deviceLockPushButton->setChecked(di->isDeviceLocked()); updateSimStatus(); updateProfile(); connect(di, SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile)), this, SLOT(updateProfile(QSystemDeviceInfo::Profile))); if(di->currentPowerState() == QSystemDeviceInfo::BatteryPower) { radioButton_2->setChecked(true); } else if(di->currentPowerState() == QSystemDeviceInfo::WallPower) { radioButton_3->setChecked(true); } else if(di->currentPowerState() == QSystemDeviceInfo::WallPowerChargingBattery) { radioButton_4->setChecked(true); } else { radioButton->setChecked(true); } //! [inputMethod flags] QSystemDeviceInfo::InputMethodFlags methods = di->inputMethodType(); QStringList inputs; if((methods & QSystemDeviceInfo::Keys)){ inputs << "Keys"; } if((methods & QSystemDeviceInfo::Keypad)) { inputs << "Keypad"; } //! [inputMethod flags] if((methods & QSystemDeviceInfo::Keyboard)) { inputs << "Keyboard"; } if((methods & QSystemDeviceInfo::SingleTouch)) { inputs << "Touch Screen"; } if((methods & QSystemDeviceInfo::MultiTouch)) { inputs << "Multi touch"; } if((methods & QSystemDeviceInfo::Mouse)){ inputs << "Mouse"; } inputMethodLabel->setText(inputs.join(" ")); }