File indexing completed on 2024-12-01 08:07:47

0001 /*
0002     SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef LATTECORETOOLS_H
0007 #define LATTECORETOOLS_H
0008 
0009 // Qt
0010 #include <QObject>
0011 #include <QColor>
0012 #include <QQmlEngine>
0013 #include <QJSEngine>
0014 
0015 
0016 namespace Latte{
0017 
0018 class Tools final: public QObject
0019 {
0020     Q_OBJECT
0021 
0022 public:
0023     explicit Tools(QObject *parent = nullptr);
0024 
0025 public slots:
0026     Q_INVOKABLE float colorBrightness(QColor color);
0027     Q_INVOKABLE float colorLumina(QColor color);
0028 
0029 private:
0030     float colorBrightness(QRgb rgb);
0031     float colorBrightness(float r, float g, float b);
0032 
0033     float colorLumina(QRgb rgb);
0034     float colorLumina(float r, float g, float b);
0035 };
0036 
0037 static QObject *tools_qobject_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
0038 {
0039     Q_UNUSED(engine)
0040     Q_UNUSED(scriptEngine)
0041 
0042 // NOTE: QML engine is the owner of this resource
0043     return new Tools;
0044 }
0045 
0046 }
0047 
0048 #endif