mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-01-23 04:14:35 +08:00
update
This commit is contained in:
parent
79a7c97fe8
commit
b2471bcf0d
@ -9,10 +9,10 @@ FluScrollablePage{
|
|||||||
|
|
||||||
title:"Captcha"
|
title:"Captcha"
|
||||||
|
|
||||||
|
|
||||||
FluCaptcha{
|
FluCaptcha{
|
||||||
id:captcha
|
id:captcha
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
|
ignoreCase:switch_case.checked
|
||||||
MouseArea{
|
MouseArea{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
@ -30,6 +30,13 @@ FluScrollablePage{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FluToggleSwitch{
|
||||||
|
id:switch_case
|
||||||
|
text:"Ignore Case"
|
||||||
|
checked: true
|
||||||
|
Layout.topMargin: 10
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout{
|
RowLayout{
|
||||||
spacing: 10
|
spacing: 10
|
||||||
Layout.topMargin: 10
|
Layout.topMargin: 10
|
||||||
@ -49,6 +56,4 @@ FluScrollablePage{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,10 @@ FluScrollablePage{
|
|||||||
|
|
||||||
title:"Captcha"
|
title:"Captcha"
|
||||||
|
|
||||||
|
|
||||||
FluCaptcha{
|
FluCaptcha{
|
||||||
id:captcha
|
id:captcha
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
|
ignoreCase:switch_case.checked
|
||||||
MouseArea{
|
MouseArea{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
@ -31,6 +31,13 @@ FluScrollablePage{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FluToggleSwitch{
|
||||||
|
id:switch_case
|
||||||
|
text:"Ignore Case"
|
||||||
|
checked: true
|
||||||
|
Layout.topMargin: 10
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout{
|
RowLayout{
|
||||||
spacing: 10
|
spacing: 10
|
||||||
Layout.topMargin: 10
|
Layout.topMargin: 10
|
||||||
@ -50,6 +57,4 @@ FluScrollablePage{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,19 +10,7 @@
|
|||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include "Def.h"
|
#include "Def.h"
|
||||||
|
|
||||||
FluApp* FluApp::m_instance = nullptr;
|
FluApp::FluApp(QObject *parent):QObject{parent}{
|
||||||
|
|
||||||
FluApp *FluApp::getInstance()
|
|
||||||
{
|
|
||||||
if(FluApp::m_instance == nullptr){
|
|
||||||
FluApp::m_instance = new FluApp;
|
|
||||||
}
|
|
||||||
return FluApp::m_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
FluApp::FluApp(QObject *parent)
|
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
httpInterceptor(nullptr);
|
httpInterceptor(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,8 +71,7 @@ void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegist
|
|||||||
view->setColor(QColor(Qt::transparent));
|
view->setColor(QColor(Qt::transparent));
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray FluApp::awesomelist(const QString& keyword)
|
QJsonArray FluApp::awesomelist(const QString& keyword){
|
||||||
{
|
|
||||||
QJsonArray arr;
|
QJsonArray arr;
|
||||||
QMetaEnum enumType = Fluent_Awesome::staticMetaObject.enumerator(Fluent_Awesome::staticMetaObject.indexOfEnumerator("Fluent_AwesomeType"));
|
QMetaEnum enumType = Fluent_Awesome::staticMetaObject.enumerator(Fluent_Awesome::staticMetaObject.indexOfEnumerator("Fluent_AwesomeType"));
|
||||||
for(int i=0; i < enumType.keyCount(); ++i){
|
for(int i=0; i < enumType.keyCount(); ++i){
|
||||||
|
11
src/FluApp.h
11
src/FluApp.h
@ -11,6 +11,7 @@
|
|||||||
#include "FluRegister.h"
|
#include "FluRegister.h"
|
||||||
#include "FluHttpInterceptor.h"
|
#include "FluHttpInterceptor.h"
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "singleton.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The FluApp class
|
* @brief The FluApp class
|
||||||
@ -25,13 +26,10 @@ class FluApp : public QObject
|
|||||||
QML_SINGLETON
|
QML_SINGLETON
|
||||||
private:
|
private:
|
||||||
explicit FluApp(QObject *parent = nullptr);
|
explicit FluApp(QObject *parent = nullptr);
|
||||||
public:
|
|
||||||
~FluApp();
|
~FluApp();
|
||||||
static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
|
public:
|
||||||
{
|
SINGLETONG(FluApp)
|
||||||
return getInstance();
|
static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||||
}
|
|
||||||
static FluApp *getInstance();
|
|
||||||
Q_INVOKABLE void run();
|
Q_INVOKABLE void run();
|
||||||
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluRegister* fluRegister = nullptr);
|
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluRegister* fluRegister = nullptr);
|
||||||
Q_INVOKABLE void init(QQuickWindow *window);
|
Q_INVOKABLE void init(QQuickWindow *window);
|
||||||
@ -41,7 +39,6 @@ public:
|
|||||||
public:
|
public:
|
||||||
QMap<quint64, QQuickWindow*> wnds;
|
QMap<quint64, QQuickWindow*> wnds;
|
||||||
private:
|
private:
|
||||||
static FluApp* m_instance;
|
|
||||||
QWindow *appWindow;
|
QWindow *appWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,9 +5,8 @@
|
|||||||
#include <QRandomGenerator>
|
#include <QRandomGenerator>
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
|
|
||||||
FluCaptcha::FluCaptcha(QQuickItem *parent)
|
FluCaptcha::FluCaptcha(QQuickItem *parent):QQuickPaintedItem(parent){
|
||||||
: QQuickPaintedItem(parent)
|
ignoreCase(true);
|
||||||
{
|
|
||||||
QFont fontStype;
|
QFont fontStype;
|
||||||
fontStype.setPixelSize(28);
|
fontStype.setPixelSize(28);
|
||||||
fontStype.setBold(true);
|
fontStype.setBold(true);
|
||||||
@ -17,8 +16,7 @@ FluCaptcha::FluCaptcha(QQuickItem *parent)
|
|||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluCaptcha::paint(QPainter* painter)
|
void FluCaptcha::paint(QPainter* painter){
|
||||||
{
|
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->fillRect(boundingRect().toRect(),QColor(255,255,255,255));
|
painter->fillRect(boundingRect().toRect(),QColor(255,255,255,255));
|
||||||
QPen pen;
|
QPen pen;
|
||||||
@ -72,5 +70,8 @@ void FluCaptcha::refresh(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool FluCaptcha::verify(const QString& code){
|
bool FluCaptcha::verify(const QString& code){
|
||||||
|
if(_ignoreCase){
|
||||||
|
return this->_code.toUpper() == code.toUpper();
|
||||||
|
}
|
||||||
return this->_code == code;
|
return this->_code == code;
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,17 @@ class FluCaptcha : public QQuickPaintedItem
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY_AUTO(QFont,font);
|
Q_PROPERTY_AUTO(QFont,font);
|
||||||
|
Q_PROPERTY_AUTO(bool,ignoreCase);
|
||||||
QML_NAMED_ELEMENT(FluCaptcha)
|
QML_NAMED_ELEMENT(FluCaptcha)
|
||||||
private:
|
private:
|
||||||
int _generaNumber(int number);
|
int _generaNumber(int number);
|
||||||
QString _code;
|
|
||||||
public:
|
public:
|
||||||
explicit FluCaptcha(QQuickItem *parent = nullptr);
|
explicit FluCaptcha(QQuickItem *parent = nullptr);
|
||||||
void paint(QPainter* painter) override;
|
void paint(QPainter* painter) override;
|
||||||
Q_INVOKABLE void refresh();
|
Q_INVOKABLE void refresh();
|
||||||
Q_INVOKABLE bool verify(const QString& code);
|
Q_INVOKABLE bool verify(const QString& code);
|
||||||
|
private:
|
||||||
|
QString _code;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLUCAPTCHA_H
|
#endif // FLUCAPTCHA_H
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
#include "FluColorSet.h"
|
#include "FluColorSet.h"
|
||||||
|
|
||||||
FluColorSet::FluColorSet(QObject *parent)
|
FluColorSet::FluColorSet(QObject *parent):QObject{parent}{
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,6 @@
|
|||||||
#include "FluColors.h"
|
#include "FluColors.h"
|
||||||
|
|
||||||
FluColors* FluColors::m_instance = nullptr;
|
FluColors::FluColors(QObject *parent):QObject{parent}{
|
||||||
|
|
||||||
FluColors *FluColors::getInstance()
|
|
||||||
{
|
|
||||||
if(FluColors::m_instance == nullptr){
|
|
||||||
FluColors::m_instance = new FluColors;
|
|
||||||
}
|
|
||||||
return FluColors::m_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
FluColors::FluColors(QObject *parent)
|
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
Transparent("#00000000");
|
Transparent("#00000000");
|
||||||
Black("#000000");
|
Black("#000000");
|
||||||
White("#ffffff");
|
White("#ffffff");
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QtQml/qqml.h>
|
#include <QtQml/qqml.h>
|
||||||
#include "FluColorSet.h"
|
#include "FluColorSet.h"
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "singleton.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The FluColors class
|
* @brief The FluColors class
|
||||||
@ -49,13 +50,9 @@ class FluColors : public QObject
|
|||||||
QML_SINGLETON
|
QML_SINGLETON
|
||||||
private:
|
private:
|
||||||
explicit FluColors(QObject *parent = nullptr);
|
explicit FluColors(QObject *parent = nullptr);
|
||||||
static FluColors* m_instance;
|
|
||||||
public:
|
public:
|
||||||
static FluColors *getInstance();
|
SINGLETONG(FluColors)
|
||||||
static FluColors *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
|
static FluColors *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||||
{
|
|
||||||
return getInstance();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLUCOLORS_H
|
#endif // FLUCOLORS_H
|
||||||
|
@ -1,38 +1,21 @@
|
|||||||
#include "FluEventBus.h"
|
#include "FluEventBus.h"
|
||||||
|
|
||||||
FluEventBus* FluEventBus::m_instance = nullptr;
|
FluEvent::FluEvent(QObject *parent):QObject{parent}{
|
||||||
|
|
||||||
FluEvent::FluEvent(QObject *parent)
|
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FluEventBus *FluEventBus::getInstance()
|
FluEventBus::FluEventBus(QObject *parent):QObject{parent}{
|
||||||
{
|
|
||||||
if(FluEventBus::m_instance == nullptr){
|
|
||||||
FluEventBus::m_instance = new FluEventBus;
|
|
||||||
}
|
|
||||||
return FluEventBus::m_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
FluEventBus::FluEventBus(QObject *parent)
|
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluEventBus::registerEvent(FluEvent* event){
|
void FluEventBus::registerEvent(FluEvent* event){
|
||||||
eventData.append(event);
|
_eventData.append(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FluEventBus::unRegisterEvent(FluEvent* event){
|
void FluEventBus::unRegisterEvent(FluEvent* event){
|
||||||
eventData.removeOne(event);
|
_eventData.removeOne(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluEventBus::post(const QString& name,const QMap<QString, QVariant>& data){
|
void FluEventBus::post(const QString& name,const QMap<QString, QVariant>& data){
|
||||||
foreach (auto event, eventData) {
|
foreach (auto event, _eventData) {
|
||||||
if(event->name()==name){
|
if(event->name()==name){
|
||||||
Q_EMIT event->triggered(data);
|
Q_EMIT event->triggered(data);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtQml/qqml.h>
|
#include <QtQml/qqml.h>
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "singleton.h"
|
||||||
|
|
||||||
class FluEvent : public QObject{
|
class FluEvent : public QObject{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -20,19 +21,15 @@ class FluEventBus : public QObject
|
|||||||
QML_NAMED_ELEMENT(FluEventBus)
|
QML_NAMED_ELEMENT(FluEventBus)
|
||||||
QML_SINGLETON
|
QML_SINGLETON
|
||||||
private:
|
private:
|
||||||
static FluEventBus* m_instance;
|
|
||||||
explicit FluEventBus(QObject *parent = nullptr);
|
explicit FluEventBus(QObject *parent = nullptr);
|
||||||
public:
|
public:
|
||||||
static FluEventBus *getInstance();
|
SINGLETONG(FluEventBus)
|
||||||
static FluEventBus *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
|
static FluEventBus *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||||
{
|
|
||||||
return getInstance();
|
|
||||||
}
|
|
||||||
Q_INVOKABLE void registerEvent(FluEvent* event);
|
Q_INVOKABLE void registerEvent(FluEvent* event);
|
||||||
Q_INVOKABLE void unRegisterEvent(FluEvent* event);
|
Q_INVOKABLE void unRegisterEvent(FluEvent* event);
|
||||||
Q_INVOKABLE void post(const QString& name,const QMap<QString, QVariant>& params = {});
|
Q_INVOKABLE void post(const QString& name,const QMap<QString, QVariant>& params = {});
|
||||||
private:
|
private:
|
||||||
QList<FluEvent*> eventData;
|
QList<FluEvent*> _eventData;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLUEVENTBUS_H
|
#endif // FLUEVENTBUS_H
|
||||||
|
@ -14,9 +14,7 @@
|
|||||||
#include "FluApp.h"
|
#include "FluApp.h"
|
||||||
#include "FluTools.h"
|
#include "FluTools.h"
|
||||||
|
|
||||||
HttpRequest::HttpRequest(QObject *parent)
|
HttpRequest::HttpRequest(QObject *parent):QObject{parent}{
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QVariant> HttpRequest::toMap(){
|
QMap<QString, QVariant> HttpRequest::toMap(){
|
||||||
@ -55,14 +53,10 @@ QString HttpRequest::httpId(){
|
|||||||
return FluTools::getInstance()->sha256(QJsonDocument::fromVariant(QVariant(toMap())).toJson(QJsonDocument::Compact));
|
return FluTools::getInstance()->sha256(QJsonDocument::fromVariant(QVariant(toMap())).toJson(QJsonDocument::Compact));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpCallable::HttpCallable(QObject *parent)
|
HttpCallable::HttpCallable(QObject *parent):QObject{parent}{
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FluHttp::FluHttp(QObject *parent)
|
FluHttp::FluHttp(QObject *parent):QObject{parent}{
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
retry(3);
|
retry(3);
|
||||||
timeout(15000);
|
timeout(15000);
|
||||||
cacheMode(FluHttpType::CacheMode::NoCache);
|
cacheMode(FluHttpType::CacheMode::NoCache);
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
#include "FluHttpInterceptor.h"
|
#include "FluHttpInterceptor.h"
|
||||||
|
|
||||||
FluHttpInterceptor::FluHttpInterceptor(QObject *parent)
|
FluHttpInterceptor::FluHttpInterceptor(QObject *parent):QObject{parent}{
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,6 @@ class FluHttpInterceptor : public QObject
|
|||||||
QML_NAMED_ELEMENT(FluHttpInterceptor)
|
QML_NAMED_ELEMENT(FluHttpInterceptor)
|
||||||
public:
|
public:
|
||||||
explicit FluHttpInterceptor(QObject *parent = nullptr);
|
explicit FluHttpInterceptor(QObject *parent = nullptr);
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLUHTTPINTERCEPTOR_H
|
#endif // FLUHTTPINTERCEPTOR_H
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
#include "FluApp.h"
|
#include "FluApp.h"
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
FluRegister::FluRegister(QObject *parent)
|
FluRegister::FluRegister(QObject *parent):QObject{parent}{
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
from(nullptr);
|
from(nullptr);
|
||||||
to(nullptr);
|
to(nullptr);
|
||||||
path("");
|
path("");
|
||||||
|
@ -1,19 +1,6 @@
|
|||||||
#include "FluTextStyle.h"
|
#include "FluTextStyle.h"
|
||||||
|
|
||||||
FluTextStyle* FluTextStyle::m_instance = nullptr;
|
FluTextStyle::FluTextStyle(QObject *parent):QObject{parent}{
|
||||||
|
|
||||||
FluTextStyle *FluTextStyle::getInstance()
|
|
||||||
{
|
|
||||||
if(FluTextStyle::m_instance == nullptr){
|
|
||||||
FluTextStyle::m_instance = new FluTextStyle;
|
|
||||||
}
|
|
||||||
return FluTextStyle::m_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FluTextStyle::FluTextStyle(QObject *parent)
|
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
QFont caption;
|
QFont caption;
|
||||||
caption.setPixelSize(12);
|
caption.setPixelSize(12);
|
||||||
Caption(caption);
|
Caption(caption);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QtQml/qqml.h>
|
#include <QtQml/qqml.h>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "singleton.h"
|
||||||
|
|
||||||
class FluTextStyle : public QObject
|
class FluTextStyle : public QObject
|
||||||
{
|
{
|
||||||
@ -21,13 +22,9 @@ public:
|
|||||||
QML_SINGLETON
|
QML_SINGLETON
|
||||||
private:
|
private:
|
||||||
explicit FluTextStyle(QObject *parent = nullptr);
|
explicit FluTextStyle(QObject *parent = nullptr);
|
||||||
static FluTextStyle* m_instance;
|
|
||||||
public:
|
public:
|
||||||
static FluTextStyle *getInstance();
|
SINGLETONG(FluTextStyle)
|
||||||
static FluTextStyle *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
|
static FluTextStyle *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||||
{
|
|
||||||
return getInstance();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLUTEXTSTYLE_H
|
#endif // FLUTEXTSTYLE_H
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "FluTheme.h"
|
#include "FluTheme.h"
|
||||||
|
|
||||||
#include "Def.h"
|
#include <QGuiApplication>
|
||||||
#include "FluColors.h"
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
|
||||||
#include <QStyleHints>
|
#include <QStyleHints>
|
||||||
#elif ((QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)))
|
#elif ((QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)))
|
||||||
@ -10,22 +9,10 @@
|
|||||||
#else
|
#else
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#endif
|
#endif
|
||||||
|
#include "Def.h"
|
||||||
|
#include "FluColors.h"
|
||||||
|
|
||||||
#include <QGuiApplication>
|
FluTheme::FluTheme(QObject *parent):QObject{parent}{
|
||||||
|
|
||||||
FluTheme* FluTheme::m_instance = nullptr;
|
|
||||||
|
|
||||||
FluTheme *FluTheme::getInstance()
|
|
||||||
{
|
|
||||||
if(FluTheme::m_instance == nullptr){
|
|
||||||
FluTheme::m_instance = new FluTheme;
|
|
||||||
}
|
|
||||||
return FluTheme::m_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
FluTheme::FluTheme(QObject *parent)
|
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
connect(this,&FluTheme::darkModeChanged,this,[=]{
|
connect(this,&FluTheme::darkModeChanged,this,[=]{
|
||||||
Q_EMIT darkChanged();
|
Q_EMIT darkChanged();
|
||||||
});
|
});
|
||||||
@ -37,8 +24,7 @@ FluTheme::FluTheme(QObject *parent)
|
|||||||
qApp->installEventFilter(this);
|
qApp->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FluTheme::eventFilter(QObject *obj, QEvent *event)
|
bool FluTheme::eventFilter(QObject *obj, QEvent *event){
|
||||||
{
|
|
||||||
Q_UNUSED(obj);
|
Q_UNUSED(obj);
|
||||||
if (event->type() == QEvent::ApplicationPaletteChange || event->type() == QEvent::ThemeChange)
|
if (event->type() == QEvent::ApplicationPaletteChange || event->type() == QEvent::ThemeChange)
|
||||||
{
|
{
|
||||||
@ -50,8 +36,7 @@ bool FluTheme::eventFilter(QObject *obj, QEvent *event)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FluTheme::systemDark()
|
bool FluTheme::systemDark(){
|
||||||
{
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
|
||||||
return (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark);
|
return (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark);
|
||||||
#elif ((QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)))
|
#elif ((QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)))
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QtQml/qqml.h>
|
#include <QtQml/qqml.h>
|
||||||
#include "FluColorSet.h"
|
#include "FluColorSet.h"
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "singleton.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The FluTheme class
|
* @brief The FluTheme class
|
||||||
@ -20,21 +21,17 @@ class FluTheme : public QObject
|
|||||||
QML_NAMED_ELEMENT(FluTheme)
|
QML_NAMED_ELEMENT(FluTheme)
|
||||||
QML_SINGLETON
|
QML_SINGLETON
|
||||||
private:
|
private:
|
||||||
static FluTheme* m_instance;
|
|
||||||
explicit FluTheme(QObject *parent = nullptr);
|
explicit FluTheme(QObject *parent = nullptr);
|
||||||
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
|
bool systemDark();
|
||||||
public:
|
public:
|
||||||
static FluTheme *getInstance();
|
SINGLETONG(FluTheme)
|
||||||
static FluTheme *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
|
static FluTheme *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||||
{
|
|
||||||
return getInstance();
|
|
||||||
}
|
|
||||||
bool dark();
|
bool dark();
|
||||||
Q_SIGNAL void darkChanged();
|
Q_SIGNAL void darkChanged();
|
||||||
private:
|
private:
|
||||||
bool _dark;
|
bool _dark;
|
||||||
bool _systemDark;
|
bool _systemDark;
|
||||||
bool eventFilter(QObject *obj, QEvent *event);
|
|
||||||
bool systemDark();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLUTHEME_H
|
#endif // FLUTHEME_H
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "FluTools.h"
|
#include "FluTools.h"
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
@ -11,21 +12,7 @@
|
|||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
|
|
||||||
FluTools* FluTools::m_instance = nullptr;
|
FluTools::FluTools(QObject *parent):QObject{parent}{
|
||||||
|
|
||||||
FluTools *FluTools::getInstance()
|
|
||||||
{
|
|
||||||
if(FluTools::m_instance == nullptr){
|
|
||||||
FluTools::m_instance = new FluTools;
|
|
||||||
}
|
|
||||||
return FluTools::m_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FluTools::FluTools(QObject *parent)
|
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluTools::clipText(const QString& text){
|
void FluTools::clipText(const QString& text){
|
||||||
@ -36,8 +23,7 @@ QString FluTools::uuid(){
|
|||||||
return QUuid::createUuid().toString();
|
return QUuid::createUuid().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FluTools::readFile(const QString &fileName)
|
QString FluTools::readFile(const QString &fileName){
|
||||||
{
|
|
||||||
QString content;
|
QString content;
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if (file.open(QIODevice::ReadOnly)) {
|
if (file.open(QIODevice::ReadOnly)) {
|
||||||
@ -132,18 +118,15 @@ QColor FluTools::colorAlpha(const QColor& color,qreal alpha){
|
|||||||
return QColor(color.red(),color.green(),color.blue(),255*alpha);
|
return QColor(color.red(),color.green(),color.blue(),255*alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FluTools::md5(QString text)
|
QString FluTools::md5(QString text){
|
||||||
{
|
|
||||||
return QCryptographicHash::hash(text.toUtf8(), QCryptographicHash::Md5).toHex();
|
return QCryptographicHash::hash(text.toUtf8(), QCryptographicHash::Md5).toHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FluTools::toBase64(QString text)
|
QString FluTools::toBase64(QString text){
|
||||||
{
|
|
||||||
return text.toUtf8().toBase64();
|
return text.toUtf8().toBase64();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FluTools::fromBase64(QString text)
|
QString FluTools::fromBase64(QString text){
|
||||||
{
|
|
||||||
return QByteArray::fromBase64(text.toUtf8());
|
return QByteArray::fromBase64(text.toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QtQml/qqml.h>
|
#include <QtQml/qqml.h>
|
||||||
|
#include "singleton.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The FluTools class
|
* @brief The FluTools class
|
||||||
@ -12,71 +13,39 @@
|
|||||||
class FluTools : public QObject
|
class FluTools : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QML_NAMED_ELEMENT(FluTools)
|
QML_NAMED_ELEMENT(FluTools)
|
||||||
QML_SINGLETON
|
QML_SINGLETON
|
||||||
private:
|
private:
|
||||||
explicit FluTools(QObject *parent = nullptr);
|
explicit FluTools(QObject *parent = nullptr);
|
||||||
static FluTools* m_instance;
|
|
||||||
public:
|
public:
|
||||||
static FluTools *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
|
SINGLETONG(FluTools)
|
||||||
{
|
static FluTools *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||||
return getInstance();
|
|
||||||
}
|
|
||||||
static FluTools *getInstance();
|
|
||||||
|
|
||||||
Q_INVOKABLE int qtMajor();
|
Q_INVOKABLE int qtMajor();
|
||||||
|
|
||||||
Q_INVOKABLE int qtMinor();
|
Q_INVOKABLE int qtMinor();
|
||||||
|
|
||||||
Q_INVOKABLE bool isMacos();
|
Q_INVOKABLE bool isMacos();
|
||||||
|
|
||||||
Q_INVOKABLE bool isLinux();
|
Q_INVOKABLE bool isLinux();
|
||||||
|
|
||||||
Q_INVOKABLE bool isWin();
|
Q_INVOKABLE bool isWin();
|
||||||
|
|
||||||
Q_INVOKABLE void clipText(const QString& text);
|
Q_INVOKABLE void clipText(const QString& text);
|
||||||
|
|
||||||
Q_INVOKABLE QString uuid();
|
Q_INVOKABLE QString uuid();
|
||||||
|
|
||||||
Q_INVOKABLE QString readFile(const QString& fileName);
|
Q_INVOKABLE QString readFile(const QString& fileName);
|
||||||
|
|
||||||
Q_INVOKABLE void setQuitOnLastWindowClosed(bool val);
|
Q_INVOKABLE void setQuitOnLastWindowClosed(bool val);
|
||||||
|
|
||||||
Q_INVOKABLE void setOverrideCursor(Qt::CursorShape shape);
|
Q_INVOKABLE void setOverrideCursor(Qt::CursorShape shape);
|
||||||
|
|
||||||
Q_INVOKABLE void restoreOverrideCursor();
|
Q_INVOKABLE void restoreOverrideCursor();
|
||||||
|
|
||||||
Q_INVOKABLE QString html2PlantText(const QString& html);
|
Q_INVOKABLE QString html2PlantText(const QString& html);
|
||||||
|
|
||||||
Q_INVOKABLE QString toLocalPath(const QUrl& url);
|
Q_INVOKABLE QString toLocalPath(const QUrl& url);
|
||||||
|
|
||||||
Q_INVOKABLE void deleteItem(QObject *p);
|
Q_INVOKABLE void deleteItem(QObject *p);
|
||||||
|
|
||||||
Q_INVOKABLE QString getFileNameByUrl(const QUrl& url);
|
Q_INVOKABLE QString getFileNameByUrl(const QUrl& url);
|
||||||
|
|
||||||
Q_INVOKABLE QRect getVirtualGeometry();
|
Q_INVOKABLE QRect getVirtualGeometry();
|
||||||
|
|
||||||
Q_INVOKABLE QString getApplicationDirPath();
|
Q_INVOKABLE QString getApplicationDirPath();
|
||||||
|
|
||||||
Q_INVOKABLE QUrl getUrlByFilePath(const QString& path);
|
Q_INVOKABLE QUrl getUrlByFilePath(const QString& path);
|
||||||
|
|
||||||
Q_INVOKABLE QColor colorAlpha(const QColor&,qreal alpha);
|
Q_INVOKABLE QColor colorAlpha(const QColor&,qreal alpha);
|
||||||
|
|
||||||
Q_INVOKABLE QString md5(QString text);
|
Q_INVOKABLE QString md5(QString text);
|
||||||
|
|
||||||
Q_INVOKABLE QString sha256(QString text);
|
Q_INVOKABLE QString sha256(QString text);
|
||||||
|
|
||||||
Q_INVOKABLE QString toBase64(QString text);
|
Q_INVOKABLE QString toBase64(QString text);
|
||||||
|
|
||||||
Q_INVOKABLE QString fromBase64(QString text);
|
Q_INVOKABLE QString fromBase64(QString text);
|
||||||
|
|
||||||
Q_INVOKABLE bool removeDir(QString dirPath);
|
Q_INVOKABLE bool removeDir(QString dirPath);
|
||||||
|
|
||||||
Q_INVOKABLE bool removeFile(QString filePath);
|
Q_INVOKABLE bool removeFile(QString filePath);
|
||||||
|
|
||||||
Q_INVOKABLE void showFileInFolder(QString path);
|
Q_INVOKABLE void showFileInFolder(QString path);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLUTOOLS_H
|
#endif // FLUTOOLS_H
|
||||||
|
@ -3,63 +3,44 @@
|
|||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
#include "Def.h"
|
#include "Def.h"
|
||||||
|
|
||||||
ViewModelManager* ViewModelManager::m_instance = nullptr;
|
Model::Model(QObject *parent):QObject{parent}{
|
||||||
|
|
||||||
ViewModelManager *ViewModelManager::getInstance()
|
|
||||||
{
|
|
||||||
if(ViewModelManager::m_instance == nullptr){
|
|
||||||
ViewModelManager::m_instance = new ViewModelManager;
|
|
||||||
}
|
|
||||||
return ViewModelManager::m_instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Model::Model(QObject *parent)
|
Model::~Model(){
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Model::~Model()
|
ViewModelManager::ViewModelManager(QObject *parent): QObject{parent}{
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewModelManager::ViewModelManager(QObject *parent)
|
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewModelManager::insertViewModel(FluViewModel* value){
|
void ViewModelManager::insertViewModel(FluViewModel* value){
|
||||||
m_viewmodel.append(value);
|
_viewmodel.append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewModelManager::deleteViewModel(FluViewModel* value){
|
void ViewModelManager::deleteViewModel(FluViewModel* value){
|
||||||
m_viewmodel.removeOne(value);
|
_viewmodel.removeOne(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject* ViewModelManager::getModel(const QString& key){
|
QObject* ViewModelManager::getModel(const QString& key){
|
||||||
return m_data.value(key);
|
return _data.value(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewModelManager::insert(const QString& key,QObject* value){
|
void ViewModelManager::insert(const QString& key,QObject* value){
|
||||||
m_data.insert(key,value);
|
_data.insert(key,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ViewModelManager::exist(const QString& key){
|
bool ViewModelManager::exist(const QString& key){
|
||||||
return m_data.contains(key);
|
return _data.contains(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewModelManager::refreshViewModel(FluViewModel* viewModel,QString key,QVariant value){
|
void ViewModelManager::refreshViewModel(FluViewModel* viewModel,QString key,QVariant value){
|
||||||
foreach (auto item, m_viewmodel) {
|
foreach (auto item, _viewmodel) {
|
||||||
if(item->getKey() == viewModel->getKey()){
|
if(item->getKey() == viewModel->getKey()){
|
||||||
item->setProperty(key.toStdString().c_str(),value);
|
item->setProperty(key.toStdString().c_str(),value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyObserver::PropertyObserver(QString name,QObject* model,QObject *parent)
|
PropertyObserver::PropertyObserver(QString name,QObject* model,QObject *parent):QObject{parent}{
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
_name = name;
|
_name = name;
|
||||||
_model = model;
|
_model = model;
|
||||||
_property = QQmlProperty(parent,_name);
|
_property = QQmlProperty(parent,_name);
|
||||||
@ -75,9 +56,7 @@ void PropertyObserver::_propertyChange(){
|
|||||||
ViewModelManager::getInstance()->refreshViewModel((FluViewModel*)parent(),_name,value);
|
ViewModelManager::getInstance()->refreshViewModel((FluViewModel*)parent(),_name,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
FluViewModel::FluViewModel(QObject *parent)
|
FluViewModel::FluViewModel(QObject *parent):QObject{parent}{
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
ViewModelManager::getInstance()->insertViewModel(this);
|
ViewModelManager::getInstance()->insertViewModel(this);
|
||||||
scope(FluViewModelType::Scope::Window);
|
scope(FluViewModelType::Scope::Window);
|
||||||
}
|
}
|
||||||
@ -86,12 +65,10 @@ FluViewModel::~FluViewModel(){
|
|||||||
ViewModelManager::getInstance()->deleteViewModel(this);
|
ViewModelManager::getInstance()->deleteViewModel(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluViewModel::classBegin()
|
void FluViewModel::classBegin(){
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluViewModel::componentComplete()
|
void FluViewModel::componentComplete(){
|
||||||
{
|
|
||||||
auto o = parent();
|
auto o = parent();
|
||||||
while (nullptr != o) {
|
while (nullptr != o) {
|
||||||
_window = o;
|
_window = o;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <QQmlProperty>
|
#include <QQmlProperty>
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "singleton.h"
|
||||||
|
|
||||||
class Model : public QObject{
|
class Model : public QObject{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -52,7 +53,7 @@ class ViewModelManager:public QObject{
|
|||||||
private:
|
private:
|
||||||
explicit ViewModelManager(QObject *parent = nullptr);
|
explicit ViewModelManager(QObject *parent = nullptr);
|
||||||
public:
|
public:
|
||||||
static ViewModelManager *getInstance();
|
SINGLETONG(ViewModelManager)
|
||||||
bool exist(const QString& key);
|
bool exist(const QString& key);
|
||||||
void insert(const QString& key,QObject* value);
|
void insert(const QString& key,QObject* value);
|
||||||
QObject* getModel(const QString& key);
|
QObject* getModel(const QString& key);
|
||||||
@ -60,9 +61,8 @@ public:
|
|||||||
void deleteViewModel(FluViewModel* value);
|
void deleteViewModel(FluViewModel* value);
|
||||||
void refreshViewModel(FluViewModel* viewModel,QString key,QVariant value);
|
void refreshViewModel(FluViewModel* viewModel,QString key,QVariant value);
|
||||||
private:
|
private:
|
||||||
static ViewModelManager* m_instance;
|
QMap<QString,QObject*> _data;
|
||||||
QMap<QString,QObject*> m_data;
|
QList<FluViewModel*> _viewmodel;
|
||||||
QList<FluViewModel*> m_viewmodel;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLUVIEWMODEL_H
|
#endif // FLUVIEWMODEL_H
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "FluWatermark.h"
|
#include "FluWatermark.h"
|
||||||
|
|
||||||
FluWatermark::FluWatermark(QQuickItem* parent) : QQuickPaintedItem(parent)
|
FluWatermark::FluWatermark(QQuickItem* parent) : QQuickPaintedItem(parent){
|
||||||
{
|
|
||||||
gap(QPoint(100,100));
|
gap(QPoint(100,100));
|
||||||
offset(QPoint(_gap.x()/2,_gap.y()/2));
|
offset(QPoint(_gap.x()/2,_gap.y()/2));
|
||||||
rotate(22);
|
rotate(22);
|
||||||
@ -16,8 +15,7 @@ FluWatermark::FluWatermark(QQuickItem* parent) : QQuickPaintedItem(parent)
|
|||||||
connect(this,&FluWatermark::textSizeChanged,this,[=]{update();});
|
connect(this,&FluWatermark::textSizeChanged,this,[=]{update();});
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluWatermark::paint(QPainter* painter)
|
void FluWatermark::paint(QPainter* painter){
|
||||||
{
|
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setPixelSize(_textSize);
|
font.setPixelSize(_textSize);
|
||||||
painter->setFont(font);
|
painter->setFont(font);
|
||||||
|
@ -2,17 +2,13 @@
|
|||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QMetaMethod>
|
#include <QMetaMethod>
|
||||||
|
|
||||||
std::shared_ptr<MainThread> MainThread::createShared(QObject* bindObject)
|
std::shared_ptr<MainThread> MainThread::createShared(QObject* bindObject){
|
||||||
{
|
|
||||||
return std::shared_ptr<MainThread>(new MainThread(bindObject), [=](QObject* mainThread) {
|
return std::shared_ptr<MainThread>(new MainThread(bindObject), [=](QObject* mainThread) {
|
||||||
mainThread->deleteLater();
|
mainThread->deleteLater();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
MainThread::MainThread(QObject* bindObject)
|
MainThread::MainThread(QObject* bindObject): _bindObject(bindObject), _ignoreNullObject(bindObject == nullptr){
|
||||||
: mBindObject(bindObject)
|
|
||||||
, mIgnoreNullObject(bindObject == nullptr)
|
|
||||||
{
|
|
||||||
qRegisterMetaType<std::function<void()>>("std::function<void()>");
|
qRegisterMetaType<std::function<void()>>("std::function<void()>");
|
||||||
auto mainUIThread = qApp->thread();
|
auto mainUIThread = qApp->thread();
|
||||||
if (this->thread() != mainUIThread)
|
if (this->thread() != mainUIThread)
|
||||||
@ -21,18 +17,15 @@ MainThread::MainThread(QObject* bindObject)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MainThread::~MainThread()
|
MainThread::~MainThread(){
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainThread::post(std::function<void()> func)
|
void MainThread::post(std::function<void()> func){
|
||||||
{
|
|
||||||
QMetaObject::invokeMethod(createShared().get(), "mainThreadSlot", Q_ARG(std::function<void()>, func));
|
QMetaObject::invokeMethod(createShared().get(), "mainThreadSlot", Q_ARG(std::function<void()>, func));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainThread::mainThreadSlot(std::function<void()> func)
|
void MainThread::mainThreadSlot(std::function<void()> func){
|
||||||
{
|
if ((_ignoreNullObject || _bindObject) && func)
|
||||||
if ((mIgnoreNullObject || mBindObject) && func)
|
|
||||||
{
|
{
|
||||||
func();
|
func();
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ class MainThread : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void post(std::function<void()> func);
|
static void post(std::function<void()> func);
|
||||||
~MainThread();
|
~MainThread();
|
||||||
private:
|
private:
|
||||||
@ -18,7 +17,7 @@ private slots:
|
|||||||
void mainThreadSlot(std::function<void()> func);
|
void mainThreadSlot(std::function<void()> func);
|
||||||
private:
|
private:
|
||||||
MainThread(QObject* bindObject = nullptr);
|
MainThread(QObject* bindObject = nullptr);
|
||||||
QPointer<QObject> mBindObject;
|
QPointer<QObject> _bindObject;
|
||||||
bool mIgnoreNullObject{ false };
|
bool _ignoreNullObject{ false };
|
||||||
};
|
};
|
||||||
#endif // MAINTHREAD_H
|
#endif // MAINTHREAD_H
|
||||||
|
@ -6,8 +6,7 @@
|
|||||||
|
|
||||||
using namespace ZXing;
|
using namespace ZXing;
|
||||||
|
|
||||||
QRCode::QRCode(QQuickItem* parent) : QQuickPaintedItem(parent)
|
QRCode::QRCode(QQuickItem* parent):QQuickPaintedItem(parent){
|
||||||
{
|
|
||||||
color(QColor(0,0,0,255));
|
color(QColor(0,0,0,255));
|
||||||
bgColor(QColor(255,255,255,255));
|
bgColor(QColor(255,255,255,255));
|
||||||
size(100);
|
size(100);
|
||||||
@ -24,8 +23,7 @@ QRCode::QRCode(QQuickItem* parent) : QQuickPaintedItem(parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QRCode::paint(QPainter* painter)
|
void QRCode::paint(QPainter* painter){
|
||||||
{
|
|
||||||
if(_text.isEmpty()){
|
if(_text.isEmpty()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ class QRCode : public QQuickPaintedItem
|
|||||||
public:
|
public:
|
||||||
explicit QRCode(QQuickItem *parent = nullptr);
|
explicit QRCode(QQuickItem *parent = nullptr);
|
||||||
void paint(QPainter* painter) override;
|
void paint(QPainter* painter) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QRCODE_H
|
#endif // QRCODE_H
|
||||||
|
@ -6,12 +6,9 @@
|
|||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
|
|
||||||
#include "Def.h"
|
#include "Def.h"
|
||||||
|
|
||||||
|
Screenshot::Screenshot(QQuickItem* parent):QQuickPaintedItem(parent){
|
||||||
Screenshot::Screenshot(QQuickItem* parent) : QQuickPaintedItem(parent)
|
|
||||||
{
|
|
||||||
_desktopGeometry = qApp->primaryScreen()->virtualGeometry();
|
_desktopGeometry = qApp->primaryScreen()->virtualGeometry();
|
||||||
maskColor(QColor(0,0,0,150));
|
maskColor(QColor(0,0,0,150));
|
||||||
start(QPoint(0,0));
|
start(QPoint(0,0));
|
||||||
@ -20,8 +17,7 @@ Screenshot::Screenshot(QQuickItem* parent) : QQuickPaintedItem(parent)
|
|||||||
connect(this,&Screenshot::endChanged,this,[=]{update();});
|
connect(this,&Screenshot::endChanged,this,[=]{update();});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screenshot::paint(QPainter* painter)
|
void Screenshot::paint(QPainter* painter){
|
||||||
{
|
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->fillRect(_desktopGeometry,_maskColor);
|
painter->fillRect(_desktopGeometry,_maskColor);
|
||||||
painter->setCompositionMode(QPainter::CompositionMode_Clear);
|
painter->setCompositionMode(QPainter::CompositionMode_Clear);
|
||||||
@ -29,8 +25,7 @@ void Screenshot::paint(QPainter* painter)
|
|||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenshotBackground::ScreenshotBackground(QQuickItem* parent) : QQuickPaintedItem(parent)
|
ScreenshotBackground::ScreenshotBackground(QQuickItem* parent) : QQuickPaintedItem(parent){
|
||||||
{
|
|
||||||
_devicePixelRatio = qApp->primaryScreen()->devicePixelRatio();
|
_devicePixelRatio = qApp->primaryScreen()->devicePixelRatio();
|
||||||
_desktopGeometry = qApp->primaryScreen()->virtualGeometry();
|
_desktopGeometry = qApp->primaryScreen()->virtualGeometry();
|
||||||
_desktopPixmap = qApp->primaryScreen()->grabWindow(0, _desktopGeometry.x(), _desktopGeometry.y(), _desktopGeometry.width(), _desktopGeometry.height());
|
_desktopPixmap = qApp->primaryScreen()->grabWindow(0, _desktopGeometry.x(), _desktopGeometry.y(), _desktopGeometry.width(), _desktopGeometry.height());
|
||||||
@ -45,8 +40,7 @@ ScreenshotBackground::ScreenshotBackground(QQuickItem* parent) : QQuickPaintedIt
|
|||||||
setHeight(h);
|
setHeight(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenshotBackground::paint(QPainter* painter)
|
void ScreenshotBackground::paint(QPainter* painter){
|
||||||
{
|
|
||||||
painter->save();
|
painter->save();
|
||||||
_sourcePixmap = _desktopPixmap.copy();
|
_sourcePixmap = _desktopPixmap.copy();
|
||||||
painter->drawPixmap(_desktopGeometry,_sourcePixmap);
|
painter->drawPixmap(_desktopGeometry,_sourcePixmap);
|
||||||
|
@ -29,7 +29,6 @@ private:
|
|||||||
QRect _captureRect;
|
QRect _captureRect;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Screenshot : public QQuickPaintedItem
|
class Screenshot : public QQuickPaintedItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -40,7 +39,6 @@ class Screenshot : public QQuickPaintedItem
|
|||||||
public:
|
public:
|
||||||
Screenshot(QQuickItem* parent = nullptr);
|
Screenshot(QQuickItem* parent = nullptr);
|
||||||
void paint(QPainter* painter) override;
|
void paint(QPainter* painter) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QRect _desktopGeometry;
|
QRect _desktopGeometry;
|
||||||
};
|
};
|
||||||
|
@ -2,10 +2,7 @@
|
|||||||
|
|
||||||
#include "FluRegister.h"
|
#include "FluRegister.h"
|
||||||
|
|
||||||
WindowHelper::WindowHelper(QObject *parent)
|
WindowHelper::WindowHelper(QObject *parent):QObject{parent}{
|
||||||
: QObject{parent}
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowHelper::initWindow(QQuickWindow* window){
|
void WindowHelper::initWindow(QQuickWindow* window){
|
||||||
|
@ -17,21 +17,8 @@ class WindowHelper : public QObject
|
|||||||
QML_NAMED_ELEMENT(WindowHelper)
|
QML_NAMED_ELEMENT(WindowHelper)
|
||||||
public:
|
public:
|
||||||
explicit WindowHelper(QObject *parent = nullptr);
|
explicit WindowHelper(QObject *parent = nullptr);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief initWindow FluWindow中初始化调用
|
|
||||||
* @param window
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void initWindow(QQuickWindow* window);
|
Q_INVOKABLE void initWindow(QQuickWindow* window);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief createRegister 创建一个FluRegsiter对象,在FluWindow中registerForWindowResult方法调用
|
|
||||||
* @param window
|
|
||||||
* @param path
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE QVariant createRegister(QQuickWindow* window,const QString& path);
|
Q_INVOKABLE QVariant createRegister(QQuickWindow* window,const QString& path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QQuickWindow* window;
|
QQuickWindow* window;
|
||||||
};
|
};
|
||||||
|
47
src/singleton.h
Normal file
47
src/singleton.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#ifndef SINGLETON_H
|
||||||
|
#define SINGLETON_H
|
||||||
|
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class Singleton {
|
||||||
|
public:
|
||||||
|
static T* getInstance();
|
||||||
|
|
||||||
|
Singleton(const Singleton& other) = delete;
|
||||||
|
Singleton<T>& operator=(const Singleton& other) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::mutex mutex;
|
||||||
|
static T* instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::mutex Singleton<T>::mutex;
|
||||||
|
template <typename T>
|
||||||
|
T* Singleton<T>::instance;
|
||||||
|
template <typename T>
|
||||||
|
T* Singleton<T>::getInstance() {
|
||||||
|
if (instance == nullptr) {
|
||||||
|
std::lock_guard<std::mutex> locker(mutex);
|
||||||
|
if (instance == nullptr) {
|
||||||
|
instance = new T();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SINGLETONG(Class) \
|
||||||
|
private: \
|
||||||
|
friend class Singleton<Class>; \
|
||||||
|
friend struct QScopedPointerDeleter<Class>; \
|
||||||
|
\
|
||||||
|
public: \
|
||||||
|
static Class* getInstance() { \
|
||||||
|
return Singleton<Class>::getInstance(); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SINGLETON_H
|
Loading…
Reference in New Issue
Block a user