Compare commits

...

8 Commits
1.5.7 ... 1.5.8

Author SHA1 Message Date
af74f35e43 update 2023-09-13 21:24:02 +08:00
3b61985cfe update 2023-09-13 18:12:58 +08:00
eb96cf5b47 update 2023-09-13 17:27:09 +08:00
d48ad16ae3 update 2023-09-13 16:08:54 +08:00
39fb4d1b1a update 2023-09-13 15:43:31 +08:00
674de3f881 update 2023-09-13 15:26:21 +08:00
0c2b3173eb update 2023-09-13 15:21:07 +08:00
b2471bcf0d update 2023-09-13 15:11:22 +08:00
63 changed files with 365 additions and 448 deletions

85
.github/workflows/windows-qt5.yml vendored Normal file
View File

@ -0,0 +1,85 @@
name: Windows Qt5.15.2
on:
push:
paths:
- '*.txt'
- 'src/**'
- 'example/**'
- 'scripts/**'
- '.github/workflows/windows_qt5.yml'
pull_request:
paths:
- '*.txt'
- 'example/**'
- 'src/**'
- 'scripts/**'
- '.github/workflows/windows_qt5.yml'
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2019]
include:
- qt_ver: 5.15.2
qt_arch: win32_msvc2019
msvc_arch: x86
qt_arch_install: msvc2019
env:
targetName: example.exe
fileName: example
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt_ver }}
arch: ${{ matrix.qt_arch }}
cache: ${{steps.cache-qt.outputs.cache-hit}}
- name: msvc-build
id: build
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.msvc_arch }}
mkdir build
cd build
cmake -DCMAKE_MESSAGE_LOG_LEVEL=STATUS -DCMAKE_PREFIX_PATH=D:\a\FluentUI\Qt\5.15.2\msvc2019 -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release -GNinja ..
cmake --build . --target all --config Release --parallel
echo winSdkDir=%WindowsSdkDir% >> %GITHUB_ENV%
echo winSdkVer=%WindowsSdkVersion% >> %GITHUB_ENV%
echo vcToolsInstallDir=%VCToolsInstallDir% >> %GITHUB_ENV%
echo vcToolsRedistDir=%VCToolsRedistDir% >> %GITHUB_ENV%
- name: package
id: package
env:
archiveName: ${{ env.fileName }}-${{ matrix.qt_arch }}-${{ matrix.qt_ver }}
msvcArch: ${{ matrix.msvc_arch }}
shell: pwsh
run: |
& scripts\windows-publish.ps1 ${env:archiveName} ${env:targetName}
# 记录packageName给后续step
$name = ${env:archiveName}
echo "::set-output name=packageName::$name"
- uses: actions/upload-artifact@v2
with:
name: ${{ steps.package.outputs.packageName }}
path: ${{ steps.package.outputs.packageName }}
- name: uploadRelease
if: startsWith(github.event.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.package.outputs.packageName }}.zip
asset_name: ${{ env.fileName }}_${{ github.ref_name }}_${{ matrix.qt_arch }}_Qt${{ matrix.qt_ver }}.zip
tag: ${{ github.ref }}
overwrite: true

View File

@ -26,7 +26,7 @@ jobs:
- qt_ver: 6.5.0
qt_arch: win64_msvc2019_64
msvc_arch: x64
qt_arch_install: msvc2019_64
qt_arch_install: msvc2019_64
env:
targetName: example.exe
fileName: example

BIN
3rdparty/Win_x86/mingw/libcrypto-1_1.dll vendored Normal file

Binary file not shown.

BIN
3rdparty/Win_x86/mingw/libssl-1_1.dll vendored Normal file

Binary file not shown.

BIN
3rdparty/Win_x86/msvc/libcrypto-1_1.dll vendored Normal file

Binary file not shown.

BIN
3rdparty/Win_x86/msvc/libssl-1_1.dll vendored Normal file

Binary file not shown.

View File

@ -53,7 +53,7 @@ endforeach(filepath)
if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
#遍历所有qml文件
file(GLOB_RECURSE QML_PATHS *.qml qmldir)
file(GLOB_RECURSE QML_PATHS *.qml)
foreach(filepath ${QML_PATHS})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
if(${filepath} MATCHES "Qt${QT_VERSION_MAJOR}/")
@ -64,7 +64,7 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
endforeach(filepath)
#遍历所有资源文件
file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp)
file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp qmldir)
foreach(filepath ${RES_PATHS})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
list(APPEND resource_files ${filename})
@ -93,12 +93,17 @@ else ()
)
endif ()
#复制动态库到可执行文件同级目录下
if(WIN32)
#复制动态库到可执行文件同级目录下
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(3RDPARTY_ARCH_DIR ${CMAKE_SOURCE_DIR}/3rdparty/Win_x86)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(3RDPARTY_ARCH_DIR ${CMAKE_SOURCE_DIR}/3rdparty/Win_x64)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(DLLPATH ${CMAKE_SOURCE_DIR}/3rdparty/msvc/*.dll)
set(DLLPATH ${3RDPARTY_ARCH_DIR}/msvc/*.dll)
else()
set(DLLPATH ${CMAKE_SOURCE_DIR}/3rdparty/mingw/*.dll)
set(DLLPATH ${3RDPARTY_ARCH_DIR}/mingw/*.dll)
endif()
string(REPLACE "/" ${PATH_SEPARATOR} DLLPATH "${DLLPATH}")
file(GLOB DLL_FILES ${DLLPATH})

View File

@ -28,6 +28,7 @@ Window {
FluApp.init(app)
FluTheme.darkMode = FluThemeType.System
FluTheme.enableAnimation = true
FluTheme.nativeText = true
FluApp.routes = {
"/":"qrc:/example/qml/window/MainWindow.qml",
"/about":"qrc:/example/qml/window/AboutWindow.qml",

View File

@ -9,10 +9,10 @@ FluScrollablePage{
title:"Captcha"
FluCaptcha{
id:captcha
Layout.topMargin: 20
ignoreCase:switch_case.checked
MouseArea{
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
@ -30,6 +30,13 @@ FluScrollablePage{
}
}
FluToggleSwitch{
id:switch_case
text:"Ignore Case"
checked: true
Layout.topMargin: 10
}
RowLayout{
spacing: 10
Layout.topMargin: 10
@ -49,6 +56,4 @@ FluScrollablePage{
}
}
}
}

View File

@ -28,6 +28,7 @@ Window {
FluApp.init(app)
FluTheme.darkMode = FluThemeType.System
FluTheme.enableAnimation = true
FluTheme.nativeText = true
FluApp.routes = {
"/":"qrc:/example/qml/window/MainWindow.qml",
"/about":"qrc:/example/qml/window/AboutWindow.qml",

View File

@ -10,10 +10,10 @@ FluScrollablePage{
title:"Captcha"
FluCaptcha{
id:captcha
Layout.topMargin: 20
ignoreCase:switch_case.checked
MouseArea{
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
@ -31,6 +31,13 @@ FluScrollablePage{
}
}
FluToggleSwitch{
id:switch_case
text:"Ignore Case"
checked: true
Layout.topMargin: 10
}
RowLayout{
spacing: 10
Layout.topMargin: 10
@ -50,6 +57,4 @@ FluScrollablePage{
}
}
}
}

View File

@ -10,19 +10,7 @@
#include <QClipboard>
#include "Def.h"
FluApp* FluApp::m_instance = nullptr;
FluApp *FluApp::getInstance()
{
if(FluApp::m_instance == nullptr){
FluApp::m_instance = new FluApp;
}
return FluApp::m_instance;
}
FluApp::FluApp(QObject *parent)
: QObject{parent}
{
FluApp::FluApp(QObject *parent):QObject{parent}{
httpInterceptor(nullptr);
}
@ -83,8 +71,7 @@ void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegist
view->setColor(QColor(Qt::transparent));
}
QJsonArray FluApp::awesomelist(const QString& keyword)
{
QJsonArray FluApp::awesomelist(const QString& keyword){
QJsonArray arr;
QMetaEnum enumType = Fluent_Awesome::staticMetaObject.enumerator(Fluent_Awesome::staticMetaObject.indexOfEnumerator("Fluent_AwesomeType"));
for(int i=0; i < enumType.keyCount(); ++i){

View File

@ -11,6 +11,7 @@
#include "FluRegister.h"
#include "FluHttpInterceptor.h"
#include "stdafx.h"
#include "singleton.h"
/**
* @brief The FluApp class
@ -25,13 +26,10 @@ class FluApp : public QObject
QML_SINGLETON
private:
explicit FluApp(QObject *parent = nullptr);
public:
~FluApp();
static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
{
return getInstance();
}
static FluApp *getInstance();
public:
SINGLETONG(FluApp)
static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
Q_INVOKABLE void run();
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluRegister* fluRegister = nullptr);
Q_INVOKABLE void init(QQuickWindow *window);
@ -41,7 +39,6 @@ public:
public:
QMap<quint64, QQuickWindow*> wnds;
private:
static FluApp* m_instance;
QWindow *appWindow;
};

View File

@ -5,9 +5,8 @@
#include <QRandomGenerator>
#include <qmath.h>
FluCaptcha::FluCaptcha(QQuickItem *parent)
: QQuickPaintedItem(parent)
{
FluCaptcha::FluCaptcha(QQuickItem *parent):QQuickPaintedItem(parent){
ignoreCase(true);
QFont fontStype;
fontStype.setPixelSize(28);
fontStype.setBold(true);
@ -17,8 +16,7 @@ FluCaptcha::FluCaptcha(QQuickItem *parent)
refresh();
}
void FluCaptcha::paint(QPainter* painter)
{
void FluCaptcha::paint(QPainter* painter){
painter->save();
painter->fillRect(boundingRect().toRect(),QColor(255,255,255,255));
QPen pen;
@ -72,5 +70,8 @@ void FluCaptcha::refresh(){
}
bool FluCaptcha::verify(const QString& code){
if(_ignoreCase){
return this->_code.toUpper() == code.toUpper();
}
return this->_code == code;
}

View File

@ -10,15 +10,17 @@ class FluCaptcha : public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY_AUTO(QFont,font);
Q_PROPERTY_AUTO(bool,ignoreCase);
QML_NAMED_ELEMENT(FluCaptcha)
private:
int _generaNumber(int number);
QString _code;
public:
explicit FluCaptcha(QQuickItem *parent = nullptr);
void paint(QPainter* painter) override;
Q_INVOKABLE void refresh();
Q_INVOKABLE bool verify(const QString& code);
private:
QString _code;
};
#endif // FLUCAPTCHA_H

View File

@ -1,7 +1,4 @@
#include "FluColorSet.h"
FluColorSet::FluColorSet(QObject *parent)
: QObject{parent}
{
FluColorSet::FluColorSet(QObject *parent):QObject{parent}{
}

View File

@ -1,18 +1,6 @@
#include "FluColors.h"
FluColors* FluColors::m_instance = nullptr;
FluColors *FluColors::getInstance()
{
if(FluColors::m_instance == nullptr){
FluColors::m_instance = new FluColors;
}
return FluColors::m_instance;
}
FluColors::FluColors(QObject *parent)
: QObject{parent}
{
FluColors::FluColors(QObject *parent):QObject{parent}{
Transparent("#00000000");
Black("#000000");
White("#ffffff");

View File

@ -5,6 +5,7 @@
#include <QtQml/qqml.h>
#include "FluColorSet.h"
#include "stdafx.h"
#include "singleton.h"
/**
* @brief The FluColors class
@ -49,13 +50,9 @@ class FluColors : public QObject
QML_SINGLETON
private:
explicit FluColors(QObject *parent = nullptr);
static FluColors* m_instance;
public:
static FluColors *getInstance();
static FluColors *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
{
return getInstance();
}
SINGLETONG(FluColors)
static FluColors *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
};
#endif // FLUCOLORS_H

View File

@ -1,38 +1,21 @@
#include "FluEventBus.h"
FluEventBus* FluEventBus::m_instance = nullptr;
FluEvent::FluEvent(QObject *parent)
: QObject{parent}
{
FluEvent::FluEvent(QObject *parent):QObject{parent}{
}
FluEventBus *FluEventBus::getInstance()
{
if(FluEventBus::m_instance == nullptr){
FluEventBus::m_instance = new FluEventBus;
}
return FluEventBus::m_instance;
}
FluEventBus::FluEventBus(QObject *parent)
: QObject{parent}
{
FluEventBus::FluEventBus(QObject *parent):QObject{parent}{
}
void FluEventBus::registerEvent(FluEvent* event){
eventData.append(event);
_eventData.append(event);
}
void FluEventBus::unRegisterEvent(FluEvent* event){
eventData.removeOne(event);
_eventData.removeOne(event);
}
void FluEventBus::post(const QString& name,const QMap<QString, QVariant>& data){
foreach (auto event, eventData) {
foreach (auto event, _eventData) {
if(event->name()==name){
Q_EMIT event->triggered(data);
}

View File

@ -4,6 +4,7 @@
#include <QObject>
#include <QtQml/qqml.h>
#include "stdafx.h"
#include "singleton.h"
class FluEvent : public QObject{
Q_OBJECT
@ -20,19 +21,15 @@ class FluEventBus : public QObject
QML_NAMED_ELEMENT(FluEventBus)
QML_SINGLETON
private:
static FluEventBus* m_instance;
explicit FluEventBus(QObject *parent = nullptr);
public:
static FluEventBus *getInstance();
static FluEventBus *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
{
return getInstance();
}
SINGLETONG(FluEventBus)
static FluEventBus *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
Q_INVOKABLE void registerEvent(FluEvent* event);
Q_INVOKABLE void unRegisterEvent(FluEvent* event);
Q_INVOKABLE void post(const QString& name,const QMap<QString, QVariant>& params = {});
private:
QList<FluEvent*> eventData;
QList<FluEvent*> _eventData;
};
#endif // FLUEVENTBUS_H

View File

@ -14,9 +14,7 @@
#include "FluApp.h"
#include "FluTools.h"
HttpRequest::HttpRequest(QObject *parent)
: QObject{parent}
{
HttpRequest::HttpRequest(QObject *parent):QObject{parent}{
}
QMap<QString, QVariant> HttpRequest::toMap(){
@ -55,14 +53,10 @@ QString HttpRequest::httpId(){
return FluTools::getInstance()->sha256(QJsonDocument::fromVariant(QVariant(toMap())).toJson(QJsonDocument::Compact));
}
HttpCallable::HttpCallable(QObject *parent)
: QObject{parent}
{
HttpCallable::HttpCallable(QObject *parent):QObject{parent}{
}
FluHttp::FluHttp(QObject *parent)
: QObject{parent}
{
FluHttp::FluHttp(QObject *parent):QObject{parent}{
retry(3);
timeout(15000);
cacheMode(FluHttpType::CacheMode::NoCache);

View File

@ -1,7 +1,4 @@
#include "FluHttpInterceptor.h"
FluHttpInterceptor::FluHttpInterceptor(QObject *parent)
: QObject{parent}
{
FluHttpInterceptor::FluHttpInterceptor(QObject *parent):QObject{parent}{
}

View File

@ -10,9 +10,6 @@ class FluHttpInterceptor : public QObject
QML_NAMED_ELEMENT(FluHttpInterceptor)
public:
explicit FluHttpInterceptor(QObject *parent = nullptr);
signals:
};
#endif // FLUHTTPINTERCEPTOR_H

View File

@ -3,9 +3,7 @@
#include "FluApp.h"
#include <QCoreApplication>
FluRegister::FluRegister(QObject *parent)
: QObject{parent}
{
FluRegister::FluRegister(QObject *parent):QObject{parent}{
from(nullptr);
to(nullptr);
path("");

View File

@ -1,19 +1,6 @@
#include "FluTextStyle.h"
FluTextStyle* FluTextStyle::m_instance = nullptr;
FluTextStyle *FluTextStyle::getInstance()
{
if(FluTextStyle::m_instance == nullptr){
FluTextStyle::m_instance = new FluTextStyle;
}
return FluTextStyle::m_instance;
}
FluTextStyle::FluTextStyle(QObject *parent)
: QObject{parent}
{
FluTextStyle::FluTextStyle(QObject *parent):QObject{parent}{
QFont caption;
caption.setPixelSize(12);
Caption(caption);

View File

@ -5,6 +5,7 @@
#include <QtQml/qqml.h>
#include <QFont>
#include "stdafx.h"
#include "singleton.h"
class FluTextStyle : public QObject
{
@ -21,13 +22,9 @@ public:
QML_SINGLETON
private:
explicit FluTextStyle(QObject *parent = nullptr);
static FluTextStyle* m_instance;
public:
static FluTextStyle *getInstance();
static FluTextStyle *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
{
return getInstance();
}
SINGLETONG(FluTextStyle)
static FluTextStyle *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
};
#endif // FLUTEXTSTYLE_H

View File

@ -1,7 +1,6 @@
#include "FluTheme.h"
#include "Def.h"
#include "FluColors.h"
#include <QGuiApplication>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
#include <QStyleHints>
#elif ((QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)))
@ -10,22 +9,10 @@
#else
#include <QPalette>
#endif
#include "Def.h"
#include "FluColors.h"
#include <QGuiApplication>
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}
{
FluTheme::FluTheme(QObject *parent):QObject{parent}{
connect(this,&FluTheme::darkModeChanged,this,[=]{
Q_EMIT darkChanged();
});
@ -37,8 +24,7 @@ FluTheme::FluTheme(QObject *parent)
qApp->installEventFilter(this);
}
bool FluTheme::eventFilter(QObject *obj, QEvent *event)
{
bool FluTheme::eventFilter(QObject *obj, QEvent *event){
Q_UNUSED(obj);
if (event->type() == QEvent::ApplicationPaletteChange || event->type() == QEvent::ThemeChange)
{
@ -50,8 +36,7 @@ bool FluTheme::eventFilter(QObject *obj, QEvent *event)
return false;
}
bool FluTheme::systemDark()
{
bool FluTheme::systemDark(){
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
return (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark);
#elif ((QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)))

View File

@ -5,6 +5,7 @@
#include <QtQml/qqml.h>
#include "FluColorSet.h"
#include "stdafx.h"
#include "singleton.h"
/**
* @brief The FluTheme class
@ -20,21 +21,17 @@ class FluTheme : public QObject
QML_NAMED_ELEMENT(FluTheme)
QML_SINGLETON
private:
static FluTheme* m_instance;
explicit FluTheme(QObject *parent = nullptr);
bool eventFilter(QObject *obj, QEvent *event);
bool systemDark();
public:
static FluTheme *getInstance();
static FluTheme *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
{
return getInstance();
}
SINGLETONG(FluTheme)
static FluTheme *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
bool dark();
Q_SIGNAL void darkChanged();
private:
bool _dark;
bool _systemDark;
bool eventFilter(QObject *obj, QEvent *event);
bool systemDark();
};
#endif // FLUTHEME_H

View File

@ -1,4 +1,5 @@
#include "FluTools.h"
#include <QGuiApplication>
#include <QClipboard>
#include <QUuid>
@ -11,21 +12,7 @@
#include <QCryptographicHash>
#include <QTextDocument>
FluTools* FluTools::m_instance = nullptr;
FluTools *FluTools::getInstance()
{
if(FluTools::m_instance == nullptr){
FluTools::m_instance = new FluTools;
}
return FluTools::m_instance;
}
FluTools::FluTools(QObject *parent)
: QObject{parent}
{
FluTools::FluTools(QObject *parent):QObject{parent}{
}
void FluTools::clipText(const QString& text){
@ -36,8 +23,7 @@ QString FluTools::uuid(){
return QUuid::createUuid().toString();
}
QString FluTools::readFile(const QString &fileName)
{
QString FluTools::readFile(const QString &fileName){
QString content;
QFile file(fileName);
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);
}
QString FluTools::md5(QString text)
{
QString FluTools::md5(QString text){
return QCryptographicHash::hash(text.toUtf8(), QCryptographicHash::Md5).toHex();
}
QString FluTools::toBase64(QString text)
{
QString FluTools::toBase64(QString text){
return text.toUtf8().toBase64();
}
QString FluTools::fromBase64(QString text)
{
QString FluTools::fromBase64(QString text){
return QByteArray::fromBase64(text.toUtf8());
}

View File

@ -5,6 +5,7 @@
#include <QFile>
#include <QColor>
#include <QtQml/qqml.h>
#include "singleton.h"
/**
* @brief The FluTools class
@ -12,71 +13,39 @@
class FluTools : public QObject
{
Q_OBJECT
QML_NAMED_ELEMENT(FluTools)
QML_SINGLETON
private:
explicit FluTools(QObject *parent = nullptr);
static FluTools* m_instance;
public:
static FluTools *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
{
return getInstance();
}
static FluTools *getInstance();
SINGLETONG(FluTools)
static FluTools *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
Q_INVOKABLE int qtMajor();
Q_INVOKABLE int qtMinor();
Q_INVOKABLE bool isMacos();
Q_INVOKABLE bool isLinux();
Q_INVOKABLE bool isWin();
Q_INVOKABLE void clipText(const QString& text);
Q_INVOKABLE QString uuid();
Q_INVOKABLE QString readFile(const QString& fileName);
Q_INVOKABLE void setQuitOnLastWindowClosed(bool val);
Q_INVOKABLE void setOverrideCursor(Qt::CursorShape shape);
Q_INVOKABLE void restoreOverrideCursor();
Q_INVOKABLE QString html2PlantText(const QString& html);
Q_INVOKABLE QString toLocalPath(const QUrl& url);
Q_INVOKABLE void deleteItem(QObject *p);
Q_INVOKABLE QString getFileNameByUrl(const QUrl& url);
Q_INVOKABLE QRect getVirtualGeometry();
Q_INVOKABLE QString getApplicationDirPath();
Q_INVOKABLE QUrl getUrlByFilePath(const QString& path);
Q_INVOKABLE QColor colorAlpha(const QColor&,qreal alpha);
Q_INVOKABLE QString md5(QString text);
Q_INVOKABLE QString sha256(QString text);
Q_INVOKABLE QString toBase64(QString text);
Q_INVOKABLE QString fromBase64(QString text);
Q_INVOKABLE bool removeDir(QString dirPath);
Q_INVOKABLE bool removeFile(QString filePath);
Q_INVOKABLE void showFileInFolder(QString path);
};
#endif // FLUTOOLS_H

View File

@ -3,63 +3,44 @@
#include <QQuickItem>
#include "Def.h"
ViewModelManager* ViewModelManager::m_instance = nullptr;
ViewModelManager *ViewModelManager::getInstance()
{
if(ViewModelManager::m_instance == nullptr){
ViewModelManager::m_instance = new ViewModelManager;
}
return ViewModelManager::m_instance;
Model::Model(QObject *parent):QObject{parent}{
}
Model::Model(QObject *parent)
: QObject{parent}
{
Model::~Model(){
}
Model::~Model()
{
}
ViewModelManager::ViewModelManager(QObject *parent)
: QObject{parent}
{
ViewModelManager::ViewModelManager(QObject *parent): QObject{parent}{
}
void ViewModelManager::insertViewModel(FluViewModel* value){
m_viewmodel.append(value);
_viewmodel.append(value);
}
void ViewModelManager::deleteViewModel(FluViewModel* value){
m_viewmodel.removeOne(value);
_viewmodel.removeOne(value);
}
QObject* ViewModelManager::getModel(const QString& key){
return m_data.value(key);
return _data.value(key);
}
void ViewModelManager::insert(const QString& key,QObject* value){
m_data.insert(key,value);
_data.insert(key,value);
}
bool ViewModelManager::exist(const QString& key){
return m_data.contains(key);
return _data.contains(key);
}
void ViewModelManager::refreshViewModel(FluViewModel* viewModel,QString key,QVariant value){
foreach (auto item, m_viewmodel) {
foreach (auto item, _viewmodel) {
if(item->getKey() == viewModel->getKey()){
item->setProperty(key.toStdString().c_str(),value);
}
}
}
PropertyObserver::PropertyObserver(QString name,QObject* model,QObject *parent)
: QObject{parent}
{
PropertyObserver::PropertyObserver(QString name,QObject* model,QObject *parent):QObject{parent}{
_name = name;
_model = model;
_property = QQmlProperty(parent,_name);
@ -75,9 +56,7 @@ void PropertyObserver::_propertyChange(){
ViewModelManager::getInstance()->refreshViewModel((FluViewModel*)parent(),_name,value);
}
FluViewModel::FluViewModel(QObject *parent)
: QObject{parent}
{
FluViewModel::FluViewModel(QObject *parent):QObject{parent}{
ViewModelManager::getInstance()->insertViewModel(this);
scope(FluViewModelType::Scope::Window);
}
@ -86,12 +65,10 @@ FluViewModel::~FluViewModel(){
ViewModelManager::getInstance()->deleteViewModel(this);
}
void FluViewModel::classBegin()
{
void FluViewModel::classBegin(){
}
void FluViewModel::componentComplete()
{
void FluViewModel::componentComplete(){
auto o = parent();
while (nullptr != o) {
_window = o;

View File

@ -6,6 +6,7 @@
#include <QQuickWindow>
#include <QQmlProperty>
#include "stdafx.h"
#include "singleton.h"
class Model : public QObject{
Q_OBJECT
@ -52,7 +53,7 @@ class ViewModelManager:public QObject{
private:
explicit ViewModelManager(QObject *parent = nullptr);
public:
static ViewModelManager *getInstance();
SINGLETONG(ViewModelManager)
bool exist(const QString& key);
void insert(const QString& key,QObject* value);
QObject* getModel(const QString& key);
@ -60,9 +61,8 @@ public:
void deleteViewModel(FluViewModel* value);
void refreshViewModel(FluViewModel* viewModel,QString key,QVariant value);
private:
static ViewModelManager* m_instance;
QMap<QString,QObject*> m_data;
QList<FluViewModel*> m_viewmodel;
QMap<QString,QObject*> _data;
QList<FluViewModel*> _viewmodel;
};
#endif // FLUVIEWMODEL_H

View File

@ -1,7 +1,6 @@
#include "FluWatermark.h"
FluWatermark::FluWatermark(QQuickItem* parent) : QQuickPaintedItem(parent)
{
FluWatermark::FluWatermark(QQuickItem* parent) : QQuickPaintedItem(parent){
gap(QPoint(100,100));
offset(QPoint(_gap.x()/2,_gap.y()/2));
rotate(22);
@ -16,8 +15,7 @@ FluWatermark::FluWatermark(QQuickItem* parent) : QQuickPaintedItem(parent)
connect(this,&FluWatermark::textSizeChanged,this,[=]{update();});
}
void FluWatermark::paint(QPainter* painter)
{
void FluWatermark::paint(QPainter* painter){
QFont font;
font.setPixelSize(_textSize);
painter->setFont(font);

View File

@ -2,17 +2,13 @@
#include <QGuiApplication>
#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) {
mainThread->deleteLater();
});
}
MainThread::MainThread(QObject* bindObject)
: mBindObject(bindObject)
, mIgnoreNullObject(bindObject == nullptr)
{
MainThread::MainThread(QObject* bindObject): _bindObject(bindObject), _ignoreNullObject(bindObject == nullptr){
qRegisterMetaType<std::function<void()>>("std::function<void()>");
auto mainUIThread = qApp->thread();
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));
}
void MainThread::mainThreadSlot(std::function<void()> func)
{
if ((mIgnoreNullObject || mBindObject) && func)
void MainThread::mainThreadSlot(std::function<void()> func){
if ((_ignoreNullObject || _bindObject) && func)
{
func();
}

View File

@ -9,7 +9,6 @@ class MainThread : public QObject
{
Q_OBJECT
public:
static void post(std::function<void()> func);
~MainThread();
private:
@ -18,7 +17,7 @@ private slots:
void mainThreadSlot(std::function<void()> func);
private:
MainThread(QObject* bindObject = nullptr);
QPointer<QObject> mBindObject;
bool mIgnoreNullObject{ false };
QPointer<QObject> _bindObject;
bool _ignoreNullObject{ false };
};
#endif // MAINTHREAD_H

View File

@ -6,8 +6,7 @@
using namespace ZXing;
QRCode::QRCode(QQuickItem* parent) : QQuickPaintedItem(parent)
{
QRCode::QRCode(QQuickItem* parent):QQuickPaintedItem(parent){
color(QColor(0,0,0,255));
bgColor(QColor(255,255,255,255));
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()){
return;
}

View File

@ -17,7 +17,6 @@ class QRCode : public QQuickPaintedItem
public:
explicit QRCode(QQuickItem *parent = nullptr);
void paint(QPainter* painter) override;
};
#endif // QRCODE_H

View File

@ -38,7 +38,6 @@ FluPopup {
right: parent.right
}
}
Flickable{
id:sroll_message
contentWidth: width
@ -47,11 +46,10 @@ FluPopup {
left: parent.left
right: parent.right
}
boundsBehavior:Flickable.StopAtBounds
contentHeight: text_message.height
clip: true
height: Math.min(text_message.height,300)
ScrollBar.vertical: FluScrollBar {}
FluText{
id:text_message
font: FluTextStyle.Body
@ -63,9 +61,7 @@ FluPopup {
rightPadding: 20
bottomPadding: 14
}
}
Rectangle{
id:layout_actions
height: 68
@ -140,4 +136,3 @@ FluPopup {
}
}
}

View File

@ -20,8 +20,8 @@ TextArea{
}
font:FluTextStyle.Body
wrapMode: Text.WrapAnywhere
padding: 8
leftPadding: padding+2
padding: 7
leftPadding: padding+4
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
selectedTextColor: color
selectionColor: FluTools.colorAlpha(FluTheme.primaryColor.lightest,0.6)

View File

@ -20,8 +20,8 @@ TextField{
return normalColor
}
font:FluTextStyle.Body
padding: 8
leftPadding: padding+2
padding: 7
leftPadding: padding+4
echoMode:btn_reveal.pressed ? TextField.Normal : TextField.Password
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
selectionColor: FluTools.colorAlpha(FluTheme.primaryColor.lightest,0.6)
@ -36,22 +36,9 @@ TextField{
return placeholderNormalColor
}
selectByMouse: true
rightPadding: icon_end.visible ? 50 : 30
background: FluTextBoxBackground{
inputItem: control
implicitWidth: 240
FluIcon{
id:icon_end
iconSource: control.iconSource
iconSize: 15
opacity: 0.5
visible: control.iconSource != 0
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: 5
}
}
}
Keys.onEnterPressed: (event)=> d.handleCommit(event)
Keys.onReturnPressed:(event)=> d.handleCommit(event)
@ -65,16 +52,16 @@ TextField{
id:btn_reveal
iconSource:FluentIcons.RevealPasswordMedium
iconSize: 10
width: 20
width: 30
height: 20
verticalPadding: 0
horizontalPadding: 0
opacity: 0.5
iconColor: FluTheme.dark ? Qt.rgba(222/255,222/255,222/255,1) : Qt.rgba(97/255,97/255,97/255,1)
visible: control.text !== ""
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: icon_end.visible ? 25 : 5
rightMargin: 5
}
}
FluTextBoxMenu{

View File

@ -48,7 +48,7 @@ T.SpinBox {
inputMethodHints: control.inputMethodHints
Rectangle{
width: parent.width
height: contentItem.activeFocus ? 3 : 1
height: contentItem.activeFocus ? 2 : 1
anchors.bottom: parent.bottom
visible: contentItem.enabled
color: {

View File

@ -142,7 +142,10 @@ Rectangle {
id:item_text
text: itemData
anchors.fill: parent
anchors.margins: 10
leftPadding: 11
rightPadding: 11
topPadding: 6
bottomPadding: 6
elide: Text.ElideRight
wrapMode: Text.WrapAnywhere
verticalAlignment: Text.AlignVCenter

View File

@ -1,4 +1,5 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import FluentUI 1.0
@ -11,11 +12,11 @@ TextField{
property color placeholderNormalColor: FluTheme.dark ? Qt.rgba(210/255,210/255,210/255,1) : Qt.rgba(96/255,96/255,96/255,1)
property color placeholderFocusColor: FluTheme.dark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1)
property color placeholderDisableColor: FluTheme.dark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
property int iconRightMargin: icon_end.visible ? 25 : 5
property int iconRightMargin: icon_end.visible ? 40 : 5
property bool cleanEnabled: true
id:control
padding: 8
leftPadding: padding+2
padding: 7
leftPadding: padding+4
enabled: !disabled
color: {
if(!enabled){
@ -25,7 +26,7 @@ TextField{
}
font:FluTextStyle.Body
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
selectionColor:FluTools.colorAlpha(FluTheme.primaryColor.lightest,0.6)
selectionColor: FluTools.colorAlpha(FluTheme.primaryColor.lightest,0.6)
selectedTextColor: color
placeholderTextColor: {
if(!enabled){
@ -41,18 +42,6 @@ TextField{
background: FluTextBoxBackground{
inputItem: control
implicitWidth: 240
FluIcon{
id:icon_end
iconSource: control.iconSource
iconSize: 15
opacity: 0.5
visible: control.iconSource != 0
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: 5
}
}
}
Keys.onEnterPressed: (event)=> d.handleCommit(event)
Keys.onReturnPressed:(event)=> d.handleCommit(event)
@ -68,29 +57,43 @@ TextField{
acceptedButtons: Qt.RightButton
onClicked: control.echoMode !== TextInput.Password && menu.popup()
}
FluIconButton{
iconSource:FluentIcons.ChromeClose
iconSize: 10
width: 20
height: 20
verticalPadding: 0
horizontalPadding: 0
visible: {
if(control.cleanEnabled === false){
return false
}
if(control.readOnly)
return false
return control.text !== ""
}
RowLayout{
height: parent.height
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: control.iconRightMargin
rightMargin: 5
}
contentDescription:"清空"
onClicked:{
control.text = ""
spacing: 4
FluIconButton{
iconSource: FluentIcons.Cancel
iconSize: 12
Layout.preferredWidth: 30
Layout.preferredHeight: 20
Layout.alignment: Qt.AlignVCenter
iconColor: FluTheme.dark ? Qt.rgba(222/255,222/255,222/255,1) : Qt.rgba(97/255,97/255,97/255,1)
verticalPadding: 0
horizontalPadding: 0
visible: {
if(control.cleanEnabled === false){
return false
}
if(control.readOnly)
return false
return control.text !== ""
}
contentDescription:"Clean"
onClicked:{
control.text = ""
}
}
FluIcon{
id:icon_end
iconSource: control.iconSource
iconSize: 12
Layout.alignment: Qt.AlignVCenter
Layout.rightMargin: 10
iconColor: FluTheme.dark ? Qt.rgba(222/255,222/255,222/255,1) : Qt.rgba(97/255,97/255,97/255,1)
visible: control.iconSource != 0
}
}
FluTextBoxMenu{
@ -98,4 +101,3 @@ TextField{
inputItem: control
}
}

View File

@ -36,14 +36,14 @@ Rectangle{
}
Rectangle{
width: parent.width
height: inputItem.activeFocus ? 3 : 1
height: inputItem.activeFocus ? 2 : 1
anchors.bottom: parent.bottom
visible: !inputItem.disabled
color: {
if(FluTheme.dark){
inputItem.activeFocus ? FluTheme.primaryColor.lighter : Qt.rgba(166/255,166/255,166/255,1)
return inputItem.activeFocus ? FluTheme.primaryColor.lighter : Qt.rgba(166/255,166/255,166/255,1)
}else{
return inputItem.activeFocus ? FluTheme.primaryColor.dark : Qt.rgba(183/255,183/255,183/255,1)
return inputItem.activeFocus ? FluTheme.primaryColor.dark : Qt.rgba(134/255,134/255,134/255,1)
}
}
Behavior on height{

View File

@ -38,7 +38,6 @@ FluPopup {
right: parent.right
}
}
Flickable{
id:sroll_message
contentWidth: width
@ -47,11 +46,10 @@ FluPopup {
left: parent.left
right: parent.right
}
boundsBehavior:Flickable.StopAtBounds
contentHeight: text_message.height
clip: true
height: Math.min(text_message.height,300)
ScrollBar.vertical: FluScrollBar {}
FluText{
id:text_message
font: FluTextStyle.Body
@ -63,9 +61,7 @@ FluPopup {
rightPadding: 20
bottomPadding: 14
}
}
Rectangle{
id:layout_actions
height: 68

View File

@ -22,7 +22,7 @@ TextArea{
font:FluTextStyle.Body
wrapMode: Text.WrapAnywhere
padding: 8
leftPadding: padding+2
leftPadding: padding+4
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
selectedTextColor: color
selectionColor: Qt.alpha(FluTheme.primaryColor.lightest,0.6)

View File

@ -21,11 +21,11 @@ TextField{
return normalColor
}
font:FluTextStyle.Body
padding: 8
leftPadding: padding+2
padding: 7
leftPadding: padding+4
echoMode:btn_reveal.pressed ? TextField.Normal : TextField.Password
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
selectionColor: Qt.alpha(FluTheme.primaryColor.lightest,0.6)
selectionColor: FluTools.colorAlpha(FluTheme.primaryColor.lightest,0.6)
selectedTextColor: color
placeholderTextColor: {
if(!enabled){
@ -37,22 +37,9 @@ TextField{
return placeholderNormalColor
}
selectByMouse: true
rightPadding: icon_end.visible ? 50 : 30
background: FluTextBoxBackground{
inputItem: control
implicitWidth: 240
FluIcon{
id:icon_end
iconSource: control.iconSource
iconSize: 15
opacity: 0.5
visible: control.iconSource != 0
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: 5
}
}
}
Keys.onEnterPressed: (event)=> d.handleCommit(event)
Keys.onReturnPressed:(event)=> d.handleCommit(event)
@ -66,16 +53,16 @@ TextField{
id:btn_reveal
iconSource:FluentIcons.RevealPasswordMedium
iconSize: 10
width: 20
width: 30
height: 20
verticalPadding: 0
horizontalPadding: 0
opacity: 0.5
iconColor: FluTheme.dark ? Qt.rgba(222/255,222/255,222/255,1) : Qt.rgba(97/255,97/255,97/255,1)
visible: control.text !== ""
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: icon_end.visible ? 25 : 5
rightMargin: 5
}
}
FluTextBoxMenu{

View File

@ -49,7 +49,7 @@ T.SpinBox {
inputMethodHints: control.inputMethodHints
Rectangle{
width: parent.width
height: contentItem.activeFocus ? 3 : 1
height: contentItem.activeFocus ? 2 : 1
anchors.bottom: parent.bottom
visible: contentItem.enabled
color: {

View File

@ -144,9 +144,12 @@ Rectangle {
id:item_text
text: itemData
anchors.fill: parent
anchors.margins: 10
elide: Text.ElideRight
wrapMode: Text.WrapAnywhere
leftPadding: 11
rightPadding: 11
topPadding: 6
bottomPadding: 6
verticalAlignment: Text.AlignVCenter
HoverHandler{
id: hover_handler
@ -230,7 +233,7 @@ Rectangle {
clip: true
delegate: Rectangle {
id:item_table
property var position: Qt.point(column,row)
property point position: Qt.point(column,row)
required property bool selected
color: (row%2!==0) ? control.color : (FluTheme.dark ? Qt.rgba(1,1,1,0.06) : Qt.rgba(0,0,0,0.06))
implicitHeight: 40
@ -283,7 +286,7 @@ Rectangle {
property var itemData: display
property var tableView: table_view
property var tableModel: table_model
property var position: item_table.position
property point position: item_table.position
property int row: position.y
property int column: position.x
anchors.fill: parent

View File

@ -1,5 +1,6 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Controls.Basic
import FluentUI
@ -12,11 +13,11 @@ TextField{
property color placeholderNormalColor: FluTheme.dark ? Qt.rgba(210/255,210/255,210/255,1) : Qt.rgba(96/255,96/255,96/255,1)
property color placeholderFocusColor: FluTheme.dark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1)
property color placeholderDisableColor: FluTheme.dark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
property int iconRightMargin: icon_end.visible ? 25 : 5
property int iconRightMargin: icon_end.visible ? 40 : 5
property bool cleanEnabled: true
id:control
padding: 8
leftPadding: padding+2
padding: 7
leftPadding: padding+4
enabled: !disabled
color: {
if(!enabled){
@ -26,7 +27,7 @@ TextField{
}
font:FluTextStyle.Body
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
selectionColor: Qt.alpha(FluTheme.primaryColor.lightest,0.6)
selectionColor: FluTools.colorAlpha(FluTheme.primaryColor.lightest,0.6)
selectedTextColor: color
placeholderTextColor: {
if(!enabled){
@ -42,18 +43,6 @@ TextField{
background: FluTextBoxBackground{
inputItem: control
implicitWidth: 240
FluIcon{
id:icon_end
iconSource: control.iconSource
iconSize: 15
opacity: 0.5
visible: control.iconSource != 0
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: 5
}
}
}
Keys.onEnterPressed: (event)=> d.handleCommit(event)
Keys.onReturnPressed:(event)=> d.handleCommit(event)
@ -69,29 +58,43 @@ TextField{
acceptedButtons: Qt.RightButton
onClicked: control.echoMode !== TextInput.Password && menu.popup()
}
FluIconButton{
iconSource:FluentIcons.ChromeClose
iconSize: 10
width: 20
height: 20
verticalPadding: 0
horizontalPadding: 0
visible: {
if(control.cleanEnabled === false){
return false
}
if(control.readOnly)
return false
return control.text !== ""
}
RowLayout{
height: parent.height
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: control.iconRightMargin
rightMargin: 5
}
contentDescription:"清空"
onClicked:{
control.text = ""
spacing: 4
FluIconButton{
iconSource: FluentIcons.Cancel
iconSize: 12
Layout.preferredWidth: 30
Layout.preferredHeight: 20
Layout.alignment: Qt.AlignVCenter
iconColor: FluTheme.dark ? Qt.rgba(222/255,222/255,222/255,1) : Qt.rgba(97/255,97/255,97/255,1)
verticalPadding: 0
horizontalPadding: 0
visible: {
if(control.cleanEnabled === false){
return false
}
if(control.readOnly)
return false
return control.text !== ""
}
contentDescription:"Clean"
onClicked:{
control.text = ""
}
}
FluIcon{
id:icon_end
iconSource: control.iconSource
iconSize: 12
Layout.alignment: Qt.AlignVCenter
Layout.rightMargin: 10
iconColor: FluTheme.dark ? Qt.rgba(222/255,222/255,222/255,1) : Qt.rgba(97/255,97/255,97/255,1)
visible: control.iconSource != 0
}
}
FluTextBoxMenu{
@ -99,4 +102,3 @@ TextField{
inputItem: control
}
}

View File

@ -36,14 +36,14 @@ Rectangle{
}
Rectangle{
width: parent.width
height: inputItem.activeFocus ? 3 : 1
height: inputItem.activeFocus ? 2 : 1
anchors.bottom: parent.bottom
visible: !inputItem.disabled
color: {
if(FluTheme.dark){
inputItem.activeFocus ? FluTheme.primaryColor.lighter : Qt.rgba(166/255,166/255,166/255,1)
return inputItem.activeFocus ? FluTheme.primaryColor.lighter : Qt.rgba(166/255,166/255,166/255,1)
}else{
return inputItem.activeFocus ? FluTheme.primaryColor.dark : Qt.rgba(183/255,183/255,183/255,1)
return inputItem.activeFocus ? FluTheme.primaryColor.dark : Qt.rgba(134/255,134/255,134/255,1)
}
}
Behavior on height{

View File

@ -6,12 +6,9 @@
#include <QtMath>
#include <QDateTime>
#include <QThreadPool>
#include "Def.h"
Screenshot::Screenshot(QQuickItem* parent) : QQuickPaintedItem(parent)
{
Screenshot::Screenshot(QQuickItem* parent):QQuickPaintedItem(parent){
_desktopGeometry = qApp->primaryScreen()->virtualGeometry();
maskColor(QColor(0,0,0,150));
start(QPoint(0,0));
@ -20,8 +17,7 @@ Screenshot::Screenshot(QQuickItem* parent) : QQuickPaintedItem(parent)
connect(this,&Screenshot::endChanged,this,[=]{update();});
}
void Screenshot::paint(QPainter* painter)
{
void Screenshot::paint(QPainter* painter){
painter->save();
painter->fillRect(_desktopGeometry,_maskColor);
painter->setCompositionMode(QPainter::CompositionMode_Clear);
@ -29,8 +25,7 @@ void Screenshot::paint(QPainter* painter)
painter->restore();
}
ScreenshotBackground::ScreenshotBackground(QQuickItem* parent) : QQuickPaintedItem(parent)
{
ScreenshotBackground::ScreenshotBackground(QQuickItem* parent) : QQuickPaintedItem(parent){
_devicePixelRatio = qApp->primaryScreen()->devicePixelRatio();
_desktopGeometry = qApp->primaryScreen()->virtualGeometry();
_desktopPixmap = qApp->primaryScreen()->grabWindow(0, _desktopGeometry.x(), _desktopGeometry.y(), _desktopGeometry.width(), _desktopGeometry.height());
@ -45,8 +40,7 @@ ScreenshotBackground::ScreenshotBackground(QQuickItem* parent) : QQuickPaintedIt
setHeight(h);
}
void ScreenshotBackground::paint(QPainter* painter)
{
void ScreenshotBackground::paint(QPainter* painter){
painter->save();
_sourcePixmap = _desktopPixmap.copy();
painter->drawPixmap(_desktopGeometry,_sourcePixmap);

View File

@ -29,7 +29,6 @@ private:
QRect _captureRect;
};
class Screenshot : public QQuickPaintedItem
{
Q_OBJECT
@ -40,7 +39,6 @@ class Screenshot : public QQuickPaintedItem
public:
Screenshot(QQuickItem* parent = nullptr);
void paint(QPainter* painter) override;
private:
QRect _desktopGeometry;
};

View File

@ -2,10 +2,7 @@
#include "FluRegister.h"
WindowHelper::WindowHelper(QObject *parent)
: QObject{parent}
{
WindowHelper::WindowHelper(QObject *parent):QObject{parent}{
}
void WindowHelper::initWindow(QQuickWindow* window){

View File

@ -17,21 +17,8 @@ class WindowHelper : public QObject
QML_NAMED_ELEMENT(WindowHelper)
public:
explicit WindowHelper(QObject *parent = nullptr);
/**
* @brief initWindow FluWindow中初始化调用
* @param 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);
private:
QQuickWindow* window;
};

47
src/singleton.h Normal file
View 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