2023-05-22 16:17:51 +08:00
|
|
|
#include "FluTools.h"
|
2023-04-27 17:29:39 +08:00
|
|
|
#include <QGuiApplication>
|
|
|
|
#include <QClipboard>
|
|
|
|
#include <QUuid>
|
|
|
|
|
2023-05-11 18:24:58 +08:00
|
|
|
FluTools* FluTools::m_instance = nullptr;
|
|
|
|
|
|
|
|
FluTools *FluTools::getInstance()
|
|
|
|
{
|
|
|
|
if(FluTools::m_instance == nullptr){
|
|
|
|
FluTools::m_instance = new FluTools;
|
|
|
|
}
|
|
|
|
return FluTools::m_instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-04-27 17:29:39 +08:00
|
|
|
FluTools::FluTools(QObject *parent)
|
|
|
|
: QObject{parent}
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void FluTools::clipText(const QString& text){
|
|
|
|
QGuiApplication::clipboard()->setText(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString FluTools::uuid(){
|
|
|
|
return QUuid::createUuid().toString();
|
|
|
|
}
|
2023-05-12 19:26:49 +08:00
|
|
|
|
|
|
|
QString FluTools::readFile(const QString &fileName)
|
|
|
|
{
|
|
|
|
QString content;
|
|
|
|
QFile file(fileName);
|
|
|
|
if (file.open(QIODevice::ReadOnly)) {
|
|
|
|
QTextStream stream(&file);
|
|
|
|
content = stream.readAll();
|
|
|
|
}
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
|
2023-05-18 20:57:57 +08:00
|
|
|
bool FluTools::isMacos(){
|
|
|
|
#if defined(Q_OS_MACOS)
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FluTools::isLinux(){
|
|
|
|
#if defined(Q_OS_LINUX)
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FluTools::isWin(){
|
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
2023-05-12 19:26:49 +08:00
|
|
|
|
2023-05-31 15:39:59 +08:00
|
|
|
void FluTools::setQuitOnLastWindowClosed(bool val){
|
|
|
|
qApp->setQuitOnLastWindowClosed(val);
|
|
|
|
}
|