diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sensors/doc/src/qt6-changes.qdoc | 13 | ||||
-rw-r--r-- | src/sensors/qsensor.h | 2 | ||||
-rw-r--r-- | src/sensors/qsensorbackend.cpp | 18 | ||||
-rw-r--r-- | src/sensors/qsensorbackend.h | 2 | ||||
-rw-r--r-- | src/sensorsquick/qmlsensor.cpp | 1 | ||||
-rw-r--r-- | src/sensorsquick/qmlsensor_p.h | 3 |
6 files changed, 30 insertions, 9 deletions
diff --git a/src/sensors/doc/src/qt6-changes.qdoc b/src/sensors/doc/src/qt6-changes.qdoc index 7baad9f0..f71cde15 100644 --- a/src/sensors/doc/src/qt6-changes.qdoc +++ b/src/sensors/doc/src/qt6-changes.qdoc @@ -66,4 +66,17 @@ The property name is now aligned with the \c frontLidClosed property of the same QML type. + \section2 QSensorBackend::sensorBusy() and QSensor::isBusy() + + The \c QSensor::busy property and its accessor, \c QSensor::isBusy(), can be used + to check if the sensor is busy or not. To allow this property to better reflect the + sensor backend's state, QSensorBackend::sensorBusy() now accepts a boolean parameter. + This \c busy parameter is used to set/unset the backend busy state and notify the + QSensor interface attached to it. + + The default value for the QSensorBackend::sensorBusy() parameter is \e true which + results in the original behavior (except the added signal emission). This means + that in most if not all cases the changes are not mandatory. Instead it is up to the + individual sensor backend implementations to decide if the changes are useful. + */ diff --git a/src/sensors/qsensor.h b/src/sensors/qsensor.h index 9fdaab17..3bc4fd59 100644 --- a/src/sensors/qsensor.h +++ b/src/sensors/qsensor.h @@ -78,7 +78,7 @@ class Q_SENSORS_EXPORT QSensor : public QObject Q_PROPERTY(qrangelist availableDataRates READ availableDataRates) Q_PROPERTY(int dataRate READ dataRate WRITE setDataRate NOTIFY dataRateChanged) Q_PROPERTY(QSensorReading* reading READ reading NOTIFY readingChanged) - Q_PROPERTY(bool busy READ isBusy) + Q_PROPERTY(bool busy READ isBusy NOTIFY busyChanged) Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) Q_PROPERTY(qoutputrangelist outputRanges READ outputRanges) Q_PROPERTY(int outputRange READ outputRange WRITE setOutputRange) diff --git a/src/sensors/qsensorbackend.cpp b/src/sensors/qsensorbackend.cpp index 31e2e811..1e75644b 100644 --- a/src/sensors/qsensorbackend.cpp +++ b/src/sensors/qsensorbackend.cpp @@ -318,21 +318,27 @@ void QSensorBackend::sensorStopped() } /*! - Inform the front end that the sensor is busy. - This implicitly calls sensorStopped() and - is typically called from start(). + Inform the front end of the sensor's busy state according + to the provided \a busy parameter. + + If the sensor is set \e busy this implicitly calls sensorStopped(). + Busy indication is typically done in start(). Note that the front end must call QSensor::isBusy() to see if the sensor is busy. If the sensor has stopped due to an error the sensorError() function should be called to notify the class of the error condition. */ -void QSensorBackend::sensorBusy() +void QSensorBackend::sensorBusy(bool busy) { Q_D(QSensorBackend); QSensorPrivate *sensorPrivate = d->m_sensor->d_func(); - sensorPrivate->active = false; - sensorPrivate->busy = true; + if (sensorPrivate->busy == busy) + return; + if (busy) + sensorPrivate->active = false; + sensorPrivate->busy = busy; + emit d->m_sensor->busyChanged(); } /*! diff --git a/src/sensors/qsensorbackend.h b/src/sensors/qsensorbackend.h index f786a9d9..58097c69 100644 --- a/src/sensors/qsensorbackend.h +++ b/src/sensors/qsensorbackend.h @@ -80,7 +80,7 @@ public: // used by the backend to inform us of events void newReadingAvailable(); void sensorStopped(); - void sensorBusy(); + void sensorBusy(bool busy = true); void sensorError(int error); private: diff --git a/src/sensorsquick/qmlsensor.cpp b/src/sensorsquick/qmlsensor.cpp index 7957a663..14dc21c7 100644 --- a/src/sensorsquick/qmlsensor.cpp +++ b/src/sensorsquick/qmlsensor.cpp @@ -447,6 +447,7 @@ void QmlSensor::componentComplete() connect(sensor(), SIGNAL(bufferSizeChanged(int)), this, SIGNAL(bufferSizeChanged(int))); connect(sensor(), SIGNAL(maxBufferSizeChanged(int)), this, SIGNAL(maxBufferSizeChanged(int))); connect(sensor(), SIGNAL(efficientBufferSizeChanged(int)), this, SIGNAL(efficientBufferSizeChanged(int))); + connect(sensor(), &QSensor::busyChanged, this, &QmlSensor::busyChanged); // We need to set this on the sensor object now sensor()->setIdentifier(m_identifier.toLocal8Bit()); diff --git a/src/sensorsquick/qmlsensor_p.h b/src/sensorsquick/qmlsensor_p.h index 55d4eb42..2b893c99 100644 --- a/src/sensorsquick/qmlsensor_p.h +++ b/src/sensorsquick/qmlsensor_p.h @@ -78,7 +78,7 @@ class Q_SENSORSQUICK_PRIVATE_EXPORT QmlSensor : public QObject, public QQmlParse Q_PROPERTY(QQmlListProperty<QmlSensorRange> availableDataRates READ availableDataRates NOTIFY availableDataRatesChanged) Q_PROPERTY(int dataRate READ dataRate WRITE setDataRate NOTIFY dataRateChanged) Q_PROPERTY(QmlSensorReading* reading READ reading NOTIFY readingChanged) - Q_PROPERTY(bool busy READ isBusy) + Q_PROPERTY(bool busy READ isBusy NOTIFY busyChanged) Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) Q_PROPERTY(QQmlListProperty<QmlSensorOutputRange> outputRanges READ outputRanges NOTIFY outputRangesChanged) Q_PROPERTY(int outputRange READ outputRange WRITE setOutputRange NOTIFY outputRangeChanged) @@ -173,6 +173,7 @@ Q_SIGNALS: void descriptionChanged(); void errorChanged(); void alwaysOnChanged(); + void busyChanged(); Q_REVISION(1) void skipDuplicatesChanged(bool skipDuplicates); Q_REVISION(1) void axesOrientationModeChanged(AxesOrientationMode axesOrientationMode); Q_REVISION(1) void currentOrientationChanged(int currentOrientation); |