コード例 #1
0
ファイル: light.cpp プロジェクト: Camelek/qtmoko
void LightSettings::powerTypeChanged(int index)
{
    PowerMode *newMode = &batteryMode;

    if(index == 1)
        newMode = &externalMode;
    else if(index == 2)
        newMode = &lockMode;

    /*  store everytime (so we can store from accept)   */
    currentMode->intervalDim = b->interval_dim->value();
    currentMode->intervalLightOff = b->interval_lightoff->value();
    currentMode->intervalSuspend = b->interval_suspend->value();
    currentMode->brightness = b->brightness->value();
    currentMode->dim = (b->interval_dim->value() != b->interval_dim->minimum());
    currentMode->lightoff = (b->interval_lightoff->value() != b->interval_lightoff->minimum());
    currentMode->suspend = (b->interval_suspend->value() != b->interval_suspend->minimum());
    currentMode->networkedsuspend = !b->notnetworkedsuspend->isChecked();

    /*  Radio buttons toggled   */
    if ( newMode != currentMode ) {
        currentMode = newMode;
        applyMode();
    }
}
コード例 #2
0
ファイル: camera.cpp プロジェクト: Nokius/cameraplus
bool Camera::start() {
  if (!m_dev) {
    return false;
  }

  if (!applyMode()) {
    return false;
  }

  return m_dev->start();
}
コード例 #3
0
ファイル: camera.cpp プロジェクト: Nokius/cameraplus
bool Camera::setMode(const Camera::CameraMode& mode) {
  if (m_mode == mode) {
    return true;
  }

  if (!m_dev) {
    return false;
  }

  m_mode = mode;

  if (m_dev->isRunning()) {
    applyMode();
  }

  return true;
}
コード例 #4
0
ファイル: light.cpp プロジェクト: Camelek/qtmoko
LightSettings::LightSettings( QWidget* parent,  Qt::WFlags fl )
    : QDialog( parent, fl), isStatusView( false )
{
    setWindowTitle(tr("Power Management"));
    QVBoxLayout * baseLayout = new QVBoxLayout( this );
    baseLayout->setMargin( 0 );

    QWidget * container = new QWidget();

    QScrollArea *sView = new QScrollArea;
    sView->setFocusPolicy(Qt::NoFocus);
    sView->setFrameStyle(QFrame::NoFrame);
    sView->setWidget( container );
    sView->setWidgetResizable( true );
    sView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    QVBoxLayout *lightLayout = new QVBoxLayout(container);
    lightLayout->setMargin( 0 );
    b = new LightSettingsContainer();
    QtopiaApplication::setInputMethodHint( b->interval_dim, QtopiaApplication::AlwaysOff );
    QtopiaApplication::setInputMethodHint( b->interval_lightoff, QtopiaApplication::AlwaysOff );
    QtopiaApplication::setInputMethodHint( b->interval_suspend, QtopiaApplication::AlwaysOff );

    lightLayout->addWidget(b);

    baseLayout->addWidget(sView);

    // add context menu to push its status to Profiles
    contextMenu = QSoftMenuBar::menuFor( this );
    QAction* actionCapture = new QAction( QIcon( ":icon/Note" ), tr( "Add to current profile" ), this );
    contextMenu->addAction( actionCapture );
    connect( actionCapture, SIGNAL(triggered()), this, SLOT(pushSettingStatus()) );
    connect( qApp, SIGNAL(appMessage(QString,QByteArray)),
        this, SLOT(receive(QString,QByteArray)) );

    connect( b->interval_dim, SIGNAL(valueChanged(int)), this, SLOT(updateLightOffMinValue(int)) );
    connect( b->interval_dim, SIGNAL(valueChanged(int)), this, SLOT(updateSuspendMinValue(int)) );
    connect( b->interval_lightoff, SIGNAL(valueChanged(int)), this, SLOT(updateSuspendMinValue(int)) );

    b->officon->setPixmap(QPixmap(":image/off").scaled(24, 24, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
    b->brighticon->setPixmap(QPixmap(":image/Light").scaled(24, 24, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));

    QSettings hwConfig("Trolltech", "Hardware");
    hwConfig.beginGroup("PowerManagement");
    lockMode.canSuspend = hwConfig.value("CanSuspendLock", false).toBool();    
    batteryMode.canSuspend = hwConfig.value("CanSuspend", false).toBool();
    externalMode.canSuspend = hwConfig.value("CanSuspendAC", false).toBool();
    hwConfig.endGroup();

    b->notnetworkedsuspend->hide();

    if (batteryMode.canSuspend || externalMode.canSuspend || lockMode.canSuspend) {
        b->interval_suspend->setEnabled(true);
    } else {
        b->interval_suspend->hide();
        b->label_suspend->hide();
    }

    QSettings config("Trolltech","qpe");
    
    config.beginGroup("LockPower");
    lockMode.intervalDim = config.value( "Interval_Dim", 20 ).toInt();
    lockMode.intervalLightOff = config.value("Interval_LightOff", 30).toInt();
    lockMode.intervalSuspend = config.value("Interval", 60).toInt();
    lockMode.brightness = config.value("Brightness", 255).toInt();
    lockMode.brightness = qMax(1,lockMode.brightness * qpe_sysBrightnessSteps() / 255);
    lockMode.initBrightness = lockMode.brightness;
    lockMode.dim = config.value("Dim", true).toBool();
    lockMode.lightoff = config.value("LightOff", false).toBool();
    lockMode.suspend = config.value("Suspend", true).toBool();
    lockMode.networkedsuspend = config.value("NetworkedSuspend", true).toBool();
    config.endGroup();

    config.beginGroup("BatteryPower");
    batteryMode.intervalDim = config.value( "Interval_Dim", 20 ).toInt();
    batteryMode.intervalLightOff = config.value("Interval_LightOff", 30).toInt();
    batteryMode.intervalSuspend = config.value("Interval", 60).toInt();
    batteryMode.brightness = config.value("Brightness", 255).toInt();
    batteryMode.brightness = qMax(1,batteryMode.brightness * qpe_sysBrightnessSteps() / 255);
    batteryMode.initBrightness = batteryMode.brightness;
    batteryMode.dim = config.value("Dim", true).toBool();
    batteryMode.lightoff = config.value("LightOff", false).toBool();
    batteryMode.suspend = config.value("Suspend", true).toBool();
    batteryMode.networkedsuspend = config.value("NetworkedSuspend", true).toBool();
    config.endGroup();

    config.beginGroup("ExternalPower");
    externalMode.intervalDim = config.value( "Interval_Dim", 20 ).toInt();
    externalMode.intervalLightOff = config.value("Interval_LightOff", 30).toInt();
    externalMode.intervalSuspend = config.value("Interval", 240).toInt();
    externalMode.brightness = config.value("Brightness", 255).toInt();
    externalMode.brightness = qMax(1,externalMode.brightness * qpe_sysBrightnessSteps() / 255);
    externalMode.initBrightness = externalMode.brightness;
    externalMode.dim = config.value("Dim", true).toBool();
    externalMode.lightoff = config.value("LightOff", false).toBool();   //default to leave on
    externalMode.suspend = config.value("Suspend", true).toBool();
    externalMode.networkedsuspend = config.value("NetworkedSuspend",false).toBool();
    config.endGroup();

    //must set min > 0 the screen will become completely black
    int maxbright = qpe_sysBrightnessSteps();
    b->brightness->setMaximum( maxbright );
    b->brightness->setMinimum( 1 );
    b->brightness->setTickInterval( qMax(1,maxbright/16) );
    b->brightness->setSingleStep( qMax(1,maxbright/16) );
    b->brightness->setPageStep( qMax(1,maxbright/16) );

    currentMode = &batteryMode;
    applyMode();

    connect(b->powerSource, SIGNAL(currentIndexChanged(int)),
            this, SLOT(powerTypeChanged(int)));
    if ( powerStatus.wallStatus() == QPowerStatus::Available ) {
        b->powerSource->setCurrentIndex(1);
    }

    connect(b->brightness, SIGNAL(valueChanged(int)), this, SLOT(applyBrightness()));

    QtopiaChannel *channel = new QtopiaChannel("Qtopia/PowerStatus", this);
    connect(channel, SIGNAL(received(QString,QByteArray)),
            this, SLOT(sysMessage(QString,QByteArray)));
}