Exemplo n.º 1
0
 AppLockPrivate(AppLock *parent)
   : _id(-1),
     _myLock(false),
     _otherLock(false),
     _parent(parent)
 {
   if (_mobilizedDb.isNull()) {
     XSqlQuery q("SELECT EXISTS(SELECT 1"
                 "  FROM pg_class c"
                 "  JOIN pg_namespace n ON (relnamespace = n.oid)"
                 " WHERE relname = 'lock'"
                 "   AND nspname = 'xt') AS mobilized;");
     if (q.first())
       _mobilizedDb = q.value("mobilized");
     else
       (void)ErrorReporter::error(QtCriticalMsg,
                                  qobject_cast<QWidget*>(parent->parent()),
                                  parent->tr("Locking Error"),
                                  q, __FILE__, __LINE__);
   }
   XSqlQuery vq("SELECT compareversion('9.2.0') <= 0 AS isNew;");
   if (vq.first()) {
     _actPidCol = vq.value("isNew").toBool() ? "pid" : "procpid";
   } else {
     (void)ErrorReporter::error(QtCriticalMsg,
                                qobject_cast<QWidget*>(parent->parent()),
                                parent->tr("Locking Error"),
                                vq, __FILE__, __LINE__);
   }
   updateLockStatus();
 }
Exemplo n.º 2
0
void Camera::setCamera(const QCameraInfo& cameraInfo)
{
    // ------------------------------------------------------------------------
    // QCamera
    // ------------------------------------------------------------------------
    m_camera = QSharedPointer<QCamera>(new QCamera(cameraInfo));
    connect(m_camera.data(), &QCamera::stateChanged,
            this, &Camera::updateCameraState);
    // QCamera::error is overloaded.
    // Disambiguate like this:
    void (QCamera::*camera_error)(QCamera::Error) = &QCamera::error;
    connect(m_camera.data(), camera_error,
            this, &Camera::displayCameraError);
    // QCamera::lockStatusChanged is overloaded.
    // Disambiguate like this:
    void (QCamera::*camera_lockstatus)(
                QCamera::LockStatus,
                QCamera::LockChangeReason) = &QCamera::lockStatusChanged;
    connect(m_camera.data(), camera_lockstatus,
            this, &Camera::updateLockStatus);

    // ------------------------------------------------------------------------
    // QCameraImageCapture
    // ------------------------------------------------------------------------
    m_capture = QSharedPointer<QCameraImageCapture>(
                new QCameraImageCapture(m_camera.data()));

    updateCameraState(m_camera->state());

    connect(m_capture.data(), &QCameraImageCapture::readyForCaptureChanged,
            this, &Camera::readyForCapture);
    connect(m_capture.data(), &QCameraImageCapture::imageSaved,
            this, &Camera::imageSaved);
    connect(m_capture.data(), &QCameraImageCapture::imageAvailable,
            this, &Camera::imageAvailable);
    // QCameraImageCapture::error is overloaded.
    // Disambiguate like this:
    void (QCameraImageCapture::*capture_error)(
                int,
                QCameraImageCapture::Error,
                const QString&) = &QCameraImageCapture::error;
    connect(m_capture.data(), capture_error,
            this, &Camera::displayCaptureError);

    bool use_buffer = m_capture->isCaptureDestinationSupported(
                QCameraImageCapture::CaptureToBuffer);
    // use_buffer = false;
    if (use_buffer) {
        qDebug() << Q_FUNC_INFO << "Capturing to buffer";
        m_capture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
    } else {
        qDebug() << Q_FUNC_INFO << "Capturing to file";
        m_capture->setCaptureDestination(QCameraImageCapture::CaptureToFile);
    }

    // ------------------------------------------------------------------------
    // QCameraViewfinder
    // ------------------------------------------------------------------------
    m_camera->setViewfinder(m_viewfinder);

    // ------------------------------------------------------------------------
    // Set up; let's go.
    // ------------------------------------------------------------------------
    if (m_camera->isCaptureModeSupported(QCamera::CaptureStillImage)) {
        m_camera->setCaptureMode(QCamera::CaptureStillImage);
    } else {
        qWarning() << Q_FUNC_INFO
                   << "Camera does not support QCamera::CaptureStillImage";
    }
    updateLockStatus(m_camera->lockStatus(),
                     QCamera::LockChangeReason::UserRequest);
    readyForCapture(m_capture->isReadyForCapture());
    m_camera->start();
}