mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
40 lines
835 B
C++
40 lines
835 B
C++
/*
|
|
* SPDX-FileCopyrightText: 2022 by Devin Lin <devin@kde.org>
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <libudev.h>
|
|
|
|
#include <qqmlregistration.h>
|
|
|
|
class FlashlightUtil : public QObject
|
|
{
|
|
Q_OBJECT
|
|
QML_ELEMENT
|
|
QML_SINGLETON
|
|
Q_PROPERTY(bool torchEnabled READ torchEnabled NOTIFY torchChanged);
|
|
Q_PROPERTY(bool available READ isAvailable CONSTANT);
|
|
|
|
public:
|
|
FlashlightUtil(QObject *parent = nullptr);
|
|
~FlashlightUtil();
|
|
|
|
Q_INVOKABLE void toggleTorch();
|
|
bool torchEnabled() const;
|
|
bool isAvailable() const;
|
|
|
|
Q_SIGNALS:
|
|
void torchChanged(bool value);
|
|
|
|
private:
|
|
struct udev_device *m_device{nullptr};
|
|
const char *m_maxBrightness{nullptr};
|
|
bool m_isAvailable{false};
|
|
bool m_torchEnabled{false};
|
|
|
|
void findTorchDevice();
|
|
};
|