fix long pressed event
This commit is contained in:
parent
9e0afd600a
commit
575203aeaf
@ -80,6 +80,7 @@ Device::DeviceSetupStatus DevicePluginSenic::setupDevice(Device *device)
|
|||||||
connect(nuimo, &Nuimo::rotationValueChanged, this, &DevicePluginSenic::onRotationValueChanged);
|
connect(nuimo, &Nuimo::rotationValueChanged, this, &DevicePluginSenic::onRotationValueChanged);
|
||||||
connect(nuimo, &Nuimo::connectedChanged, this, &DevicePluginSenic::onConnectedChanged);
|
connect(nuimo, &Nuimo::connectedChanged, this, &DevicePluginSenic::onConnectedChanged);
|
||||||
connect(nuimo, &Nuimo::deviceInformationChanged, this, &DevicePluginSenic::onDeviceInformationChanged);
|
connect(nuimo, &Nuimo::deviceInformationChanged, this, &DevicePluginSenic::onDeviceInformationChanged);
|
||||||
|
connect(nuimo, &Nuimo::batteryValueChanged, this, &DevicePluginSenic::onBatteryValueChanged);
|
||||||
|
|
||||||
m_nuimos.insert(nuimo, device);
|
m_nuimos.insert(nuimo, device);
|
||||||
nuimo->bluetoothDevice()->connectDevice();
|
nuimo->bluetoothDevice()->connectDevice();
|
||||||
|
|||||||
@ -290,11 +290,7 @@ void Nuimo::printService(QLowEnergyService *service)
|
|||||||
|
|
||||||
void Nuimo::onLongPressTimer()
|
void Nuimo::onLongPressTimer()
|
||||||
{
|
{
|
||||||
if (m_buttonPressed) {
|
emit buttonLongPressed();
|
||||||
emit buttonLongPressed();
|
|
||||||
} else {
|
|
||||||
emit buttonPressed();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -503,15 +499,16 @@ void Nuimo::onInputServiceStateChanged(const QLowEnergyService::ServiceState &st
|
|||||||
void Nuimo::onInputCharacteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &value)
|
void Nuimo::onInputCharacteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &value)
|
||||||
{
|
{
|
||||||
if (characteristic.uuid() == m_inputButtonCharacteristic.uuid()) {
|
if (characteristic.uuid() == m_inputButtonCharacteristic.uuid()) {
|
||||||
m_buttonPressed = (bool)value.toHex().toUInt(nullptr, 16);
|
bool pressed = (bool)value.toHex().toUInt(nullptr, 16);
|
||||||
qCDebug(dcSenic()) << "Button:" << (m_buttonPressed ? "pressed": "released");
|
qCDebug(dcSenic()) << "Button:" << (pressed ? "pressed": "released");
|
||||||
if (m_buttonPressed) {
|
if (pressed) {
|
||||||
//emit buttonPressed();
|
|
||||||
m_longPressTimer->start(m_longPressTime);
|
m_longPressTimer->start(m_longPressTime);
|
||||||
} else {
|
} else {
|
||||||
if (!m_longPressTimer->isActive())
|
if (m_longPressTimer->isActive()) {
|
||||||
m_longPressTimer->stop();
|
m_longPressTimer->stop();
|
||||||
emit buttonLongPressed();
|
emit buttonPressed();
|
||||||
|
}
|
||||||
|
// else the time run out and has the long pressed event emittted
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,7 +82,6 @@ private:
|
|||||||
uint m_rotationValue;
|
uint m_rotationValue;
|
||||||
QTimer *m_longPressTimer = nullptr;
|
QTimer *m_longPressTimer = nullptr;
|
||||||
int m_longPressTime = 250;
|
int m_longPressTime = 250;
|
||||||
bool m_buttonPressed = false;
|
|
||||||
|
|
||||||
void showMatrix(const QByteArray &matrix, const int &seconds);
|
void showMatrix(const QByteArray &matrix, const int &seconds);
|
||||||
void printService(QLowEnergyService *service);
|
void printService(QLowEnergyService *service);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user