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