2023-05-22 16:17:51 +08:00
|
|
|
|
#ifndef FLUTOOLS_H
|
2023-04-27 17:29:39 +08:00
|
|
|
|
#define FLUTOOLS_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
2023-05-12 19:26:49 +08:00
|
|
|
|
#include <QFile>
|
2023-04-27 17:29:39 +08:00
|
|
|
|
#include <QtQml/qqml.h>
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief The FluTools class
|
|
|
|
|
*/
|
|
|
|
|
class FluTools : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
QML_NAMED_ELEMENT(FluTools)
|
|
|
|
|
QML_SINGLETON
|
2023-05-11 18:24:58 +08:00
|
|
|
|
private:
|
2023-04-27 17:29:39 +08:00
|
|
|
|
explicit FluTools(QObject *parent = nullptr);
|
2023-05-11 18:24:58 +08:00
|
|
|
|
static FluTools* m_instance;
|
|
|
|
|
public:
|
|
|
|
|
static FluTools *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
|
|
|
|
|
{
|
|
|
|
|
return getInstance();
|
|
|
|
|
}
|
|
|
|
|
static FluTools *getInstance();
|
2023-07-24 18:23:26 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief qtMajor Qt Major版本
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
Q_INVOKABLE int qtMajor();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief qtMajor Qt Minor版本
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
Q_INVOKABLE int qtMinor();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief isMacos 是否是Macos系统
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
Q_INVOKABLE bool isMacos();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief isLinux 是否是Linux系统
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
Q_INVOKABLE bool isLinux();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief isWin 是否是Windows系统
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
Q_INVOKABLE bool isWin();
|
|
|
|
|
|
2023-04-27 17:29:39 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief clipText 将字符串添加到剪切板
|
|
|
|
|
* @param text
|
|
|
|
|
*/
|
|
|
|
|
Q_INVOKABLE void clipText(const QString& text);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief uuid 获取uuid
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
Q_INVOKABLE QString uuid();
|
|
|
|
|
|
2023-05-12 19:26:49 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief readFile 读取文件内容
|
|
|
|
|
* @param fileName
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-07-24 18:23:26 +08:00
|
|
|
|
Q_INVOKABLE QString readFile(const QString& fileName);
|
2023-05-18 20:57:57 +08:00
|
|
|
|
|
2023-07-24 18:23:26 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief setQuitOnLastWindowClosed 设置关闭最后一个窗口是否退出程序
|
|
|
|
|
* @param val
|
|
|
|
|
*/
|
2023-05-31 15:39:59 +08:00
|
|
|
|
Q_INVOKABLE void setQuitOnLastWindowClosed(bool val);
|
|
|
|
|
|
2023-07-24 18:23:26 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief setOverrideCursor 设置全局鼠标样式
|
|
|
|
|
* @param shape
|
|
|
|
|
*/
|
2023-06-26 18:12:58 +08:00
|
|
|
|
Q_INVOKABLE void setOverrideCursor(Qt::CursorShape shape);
|
|
|
|
|
|
2023-07-24 18:23:26 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief restoreOverrideCursor 还原全局鼠标样式
|
|
|
|
|
*/
|
2023-06-26 18:12:58 +08:00
|
|
|
|
Q_INVOKABLE void restoreOverrideCursor();
|
|
|
|
|
|
2023-07-24 18:23:26 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief toLocalPath 获取文件路径,可以去掉windows系统下的file:///,macos下的file://
|
|
|
|
|
* @param url
|
|
|
|
|
* @return 返回文件路径
|
|
|
|
|
*/
|
|
|
|
|
Q_INVOKABLE QString toLocalPath(const QUrl& url);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief deleteItem 销毁Item对象
|
|
|
|
|
* @param p
|
|
|
|
|
*/
|
2023-06-28 02:28:34 +08:00
|
|
|
|
Q_INVOKABLE void deleteItem(QObject *p);
|
2023-07-24 18:23:26 +08:00
|
|
|
|
|
|
|
|
|
|
2023-04-27 17:29:39 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // FLUTOOLS_H
|