FluentUI/src/FluTools.h

100 lines
2.2 KiB
C
Raw Normal View History

2024-04-11 14:51:43 +08:00
#pragma once
2023-04-27 17:29:39 +08:00
#include <QObject>
2023-05-12 19:26:49 +08:00
#include <QFile>
2023-08-24 15:50:37 +08:00
#include <QColor>
2023-04-27 17:29:39 +08:00
#include <QtQml/qqml.h>
2024-01-02 18:27:59 +08:00
#include <QQuickWindow>
2023-09-13 15:11:22 +08:00
#include "singleton.h"
2023-04-27 17:29:39 +08:00
/**
* @brief The FluTools class
*/
2024-04-11 14:51:43 +08:00
class FluTools : public QObject {
Q_OBJECT
2023-04-27 17:29:39 +08:00
QML_NAMED_ELEMENT(FluTools)
QML_SINGLETON
2024-04-11 14:51:43 +08:00
2023-05-11 18:24:58 +08:00
private:
2023-04-27 17:29:39 +08:00
explicit FluTools(QObject *parent = nullptr);
2024-04-11 14:51:43 +08:00
2023-05-11 18:24:58 +08:00
public:
2024-04-11 14:51:43 +08:00
SINGLETON(FluTools)
static FluTools *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
2023-07-24 18:23:26 +08:00
Q_INVOKABLE int qtMajor();
2024-04-11 14:51:43 +08:00
2023-07-24 18:23:26 +08:00
Q_INVOKABLE int qtMinor();
2024-04-11 14:51:43 +08:00
2023-07-24 18:23:26 +08:00
Q_INVOKABLE bool isMacos();
2024-04-11 14:51:43 +08:00
2023-07-24 18:23:26 +08:00
Q_INVOKABLE bool isLinux();
2024-04-11 14:51:43 +08:00
2023-07-24 18:23:26 +08:00
Q_INVOKABLE bool isWin();
2024-04-11 14:51:43 +08:00
Q_INVOKABLE void clipText(const QString &text);
2023-04-27 17:29:39 +08:00
Q_INVOKABLE QString uuid();
2024-04-11 14:51:43 +08:00
Q_INVOKABLE QString readFile(const QString &fileName);
2023-05-31 15:39:59 +08:00
Q_INVOKABLE void setQuitOnLastWindowClosed(bool val);
2024-04-11 14:51:43 +08:00
2023-06-26 18:12:58 +08:00
Q_INVOKABLE void setOverrideCursor(Qt::CursorShape shape);
2024-04-11 14:51:43 +08:00
2023-06-26 18:12:58 +08:00
Q_INVOKABLE void restoreOverrideCursor();
2024-04-11 14:51:43 +08:00
Q_INVOKABLE QString html2PlantText(const QString &html);
Q_INVOKABLE QString toLocalPath(const QUrl &url);
2024-03-27 00:36:56 +08:00
Q_INVOKABLE void deleteLater(QObject *p);
2024-04-11 14:51:43 +08:00
Q_INVOKABLE QString getFileNameByUrl(const QUrl &url);
2023-08-17 17:14:31 +08:00
Q_INVOKABLE QRect getVirtualGeometry();
2024-04-11 14:51:43 +08:00
2023-08-17 23:03:00 +08:00
Q_INVOKABLE QString getApplicationDirPath();
2024-04-11 14:51:43 +08:00
Q_INVOKABLE QUrl getUrlByFilePath(const QString &path);
Q_INVOKABLE QColor withOpacity(const QColor &, qreal alpha);
Q_INVOKABLE QString md5(const QString &text);
Q_INVOKABLE QString sha256(const QString &text);
Q_INVOKABLE QString toBase64(const QString &text);
Q_INVOKABLE QString fromBase64(const QString &text);
Q_INVOKABLE bool removeDir(const QString &dirPath);
Q_INVOKABLE bool removeFile(const QString &filePath);
Q_INVOKABLE void showFileInFolder(const QString &path);
2023-09-17 20:36:33 +08:00
Q_INVOKABLE bool isSoftware();
2024-04-11 14:51:43 +08:00
2023-09-21 18:29:09 +08:00
Q_INVOKABLE qint64 currentTimestamp();
2024-04-11 14:51:43 +08:00
2023-09-19 00:31:49 +08:00
Q_INVOKABLE QPoint cursorPos();
2024-04-11 14:51:43 +08:00
2023-12-13 18:13:35 +08:00
Q_INVOKABLE QIcon windowIcon();
2024-04-11 14:51:43 +08:00
2023-12-20 21:58:59 +08:00
Q_INVOKABLE int cursorScreenIndex();
2024-04-11 14:51:43 +08:00
2023-12-29 23:09:46 +08:00
Q_INVOKABLE int windowBuildNumber();
2024-04-11 14:51:43 +08:00
2023-12-22 12:39:04 +08:00
Q_INVOKABLE bool isWindows11OrGreater();
2024-04-11 14:51:43 +08:00
2023-12-29 23:09:46 +08:00
Q_INVOKABLE bool isWindows10OrGreater();
2024-04-11 14:51:43 +08:00
Q_INVOKABLE QRect desktopAvailableGeometry(QQuickWindow *window);
2024-04-12 16:26:32 +08:00
Q_INVOKABLE QString getWallpaperFilePath();
2024-04-28 20:22:05 +08:00
Q_INVOKABLE QColor imageMainColor(const QImage &image, double bright = 1);
2024-04-12 16:26:32 +08:00
};