50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
|
|
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
|
|
#pragma once
|
|
|
|
#include <Plasma/Applet>
|
|
|
|
#include <QBluetoothDeviceDiscoveryAgent>
|
|
#include <QBluetoothLocalDevice>
|
|
#include <QLowEnergyController>
|
|
|
|
class DeskControl : public Plasma::Applet
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY(DeskState state READ state NOTIFY stateChanged)
|
|
Q_PROPERTY(qreal height MEMBER m_height NOTIFY heightChanged)
|
|
|
|
public:
|
|
explicit DeskControl(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
|
|
~DeskControl() override;
|
|
|
|
enum DeskState {
|
|
NotFound,
|
|
Searching,
|
|
Connected
|
|
};
|
|
Q_ENUM(DeskState)
|
|
|
|
DeskState state() const;
|
|
|
|
public Q_SLOTS:
|
|
void up() const;
|
|
void down() const;
|
|
void connectToDesk();
|
|
|
|
Q_SIGNALS:
|
|
void stateChanged();
|
|
void heightChanged();
|
|
|
|
private:
|
|
void searchForDesk();
|
|
|
|
QLowEnergyController *m_controller = nullptr;
|
|
QLowEnergyService *m_commandService = nullptr;
|
|
QLowEnergyService *m_positionCommandService = nullptr;
|
|
qreal m_height = 0.0;
|
|
QLowEnergyCharacteristic m_commandCharacteristic;
|
|
QBluetoothDeviceDiscoveryAgent * m_discoveryAgent = nullptr;
|
|
QBluetoothLocalDevice m_localDevice;
|
|
};
|