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

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") if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
#遍历所有qml文件 #遍历所有qml文件
file(GLOB_RECURSE QML_PATHS *.qml qmldir) file(GLOB_RECURSE QML_PATHS *.qml)
foreach(filepath ${QML_PATHS}) foreach(filepath ${QML_PATHS})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath}) string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
if(${filepath} MATCHES "Qt${QT_VERSION_MAJOR}/") if(${filepath} MATCHES "Qt${QT_VERSION_MAJOR}/")
@ -64,7 +64,7 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
endforeach(filepath) 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}) foreach(filepath ${RES_PATHS})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath}) string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
list(APPEND resource_files ${filename}) list(APPEND resource_files ${filename})
@ -93,12 +93,17 @@ else ()
) )
endif () endif ()
#复制动态库到可执行文件同级目录下
if(WIN32) 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") if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(DLLPATH ${CMAKE_SOURCE_DIR}/3rdparty/msvc/*.dll) set(DLLPATH ${3RDPARTY_ARCH_DIR}/msvc/*.dll)
else() else()
set(DLLPATH ${CMAKE_SOURCE_DIR}/3rdparty/mingw/*.dll) set(DLLPATH ${3RDPARTY_ARCH_DIR}/mingw/*.dll)
endif() endif()
string(REPLACE "/" ${PATH_SEPARATOR} DLLPATH "${DLLPATH}") string(REPLACE "/" ${PATH_SEPARATOR} DLLPATH "${DLLPATH}")
file(GLOB DLL_FILES ${DLLPATH}) file(GLOB DLL_FILES ${DLLPATH})

View File

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

View File

@ -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{
} }
} }
} }
} }

View File

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

View File

@ -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{
} }
} }
} }
} }

View File

@ -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){

View File

@ -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;
}; };

View File

@ -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;
} }

View File

@ -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

View File

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

View File

@ -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");

View File

@ -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

View File

@ -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);
} }

View File

@ -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

View File

@ -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);

View File

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

View File

@ -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

View File

@ -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("");

View File

@ -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);

View File

@ -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

View File

@ -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)))

View File

@ -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

View File

@ -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());
} }

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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();
} }

View File

@ -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

View File

@ -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;
} }

View File

@ -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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,5 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import FluentUI 1.0 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 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 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 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 property bool cleanEnabled: true
id:control id:control
padding: 8 padding: 7
leftPadding: padding+2 leftPadding: padding+4
enabled: !disabled enabled: !disabled
color: { color: {
if(!enabled){ if(!enabled){
@ -25,7 +26,7 @@ TextField{
} }
font:FluTextStyle.Body font:FluTextStyle.Body
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering 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 selectedTextColor: color
placeholderTextColor: { placeholderTextColor: {
if(!enabled){ if(!enabled){
@ -41,18 +42,6 @@ TextField{
background: FluTextBoxBackground{ background: FluTextBoxBackground{
inputItem: control inputItem: control
implicitWidth: 240 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.onEnterPressed: (event)=> d.handleCommit(event)
Keys.onReturnPressed:(event)=> d.handleCommit(event) Keys.onReturnPressed:(event)=> d.handleCommit(event)
@ -68,11 +57,20 @@ TextField{
acceptedButtons: Qt.RightButton acceptedButtons: Qt.RightButton
onClicked: control.echoMode !== TextInput.Password && menu.popup() onClicked: control.echoMode !== TextInput.Password && menu.popup()
} }
RowLayout{
height: parent.height
anchors{
right: parent.right
rightMargin: 5
}
spacing: 4
FluIconButton{ FluIconButton{
iconSource:FluentIcons.ChromeClose iconSource: FluentIcons.Cancel
iconSize: 10 iconSize: 12
width: 20 Layout.preferredWidth: 30
height: 20 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 verticalPadding: 0
horizontalPadding: 0 horizontalPadding: 0
visible: { visible: {
@ -83,19 +81,23 @@ TextField{
return false return false
return control.text !== "" return control.text !== ""
} }
anchors{ contentDescription:"Clean"
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: control.iconRightMargin
}
contentDescription:"清空"
onClicked:{ onClicked:{
control.text = "" 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{ FluTextBoxMenu{
id:menu id:menu
inputItem: control inputItem: control
} }
} }

View File

@ -36,14 +36,14 @@ Rectangle{
} }
Rectangle{ Rectangle{
width: parent.width width: parent.width
height: inputItem.activeFocus ? 3 : 1 height: inputItem.activeFocus ? 2 : 1
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
visible: !inputItem.disabled visible: !inputItem.disabled
color: { color: {
if(FluTheme.dark){ 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{ }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{ Behavior on height{

View File

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

View File

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

View File

@ -21,11 +21,11 @@ TextField{
return normalColor return normalColor
} }
font:FluTextStyle.Body font:FluTextStyle.Body
padding: 8 padding: 7
leftPadding: padding+2 leftPadding: padding+4
echoMode:btn_reveal.pressed ? TextField.Normal : TextField.Password echoMode:btn_reveal.pressed ? TextField.Normal : TextField.Password
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering 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 selectedTextColor: color
placeholderTextColor: { placeholderTextColor: {
if(!enabled){ if(!enabled){
@ -37,22 +37,9 @@ TextField{
return placeholderNormalColor return placeholderNormalColor
} }
selectByMouse: true selectByMouse: true
rightPadding: icon_end.visible ? 50 : 30
background: FluTextBoxBackground{ background: FluTextBoxBackground{
inputItem: control inputItem: control
implicitWidth: 240 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.onEnterPressed: (event)=> d.handleCommit(event)
Keys.onReturnPressed:(event)=> d.handleCommit(event) Keys.onReturnPressed:(event)=> d.handleCommit(event)
@ -66,16 +53,16 @@ TextField{
id:btn_reveal id:btn_reveal
iconSource:FluentIcons.RevealPasswordMedium iconSource:FluentIcons.RevealPasswordMedium
iconSize: 10 iconSize: 10
width: 20 width: 30
height: 20 height: 20
verticalPadding: 0 verticalPadding: 0
horizontalPadding: 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 !== "" visible: control.text !== ""
anchors{ anchors{
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
right: parent.right right: parent.right
rightMargin: icon_end.visible ? 25 : 5 rightMargin: 5
} }
} }
FluTextBoxMenu{ FluTextBoxMenu{

View File

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

View File

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

View File

@ -1,5 +1,6 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Controls.Basic import QtQuick.Controls.Basic
import FluentUI 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 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 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 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 property bool cleanEnabled: true
id:control id:control
padding: 8 padding: 7
leftPadding: padding+2 leftPadding: padding+4
enabled: !disabled enabled: !disabled
color: { color: {
if(!enabled){ if(!enabled){
@ -26,7 +27,7 @@ TextField{
} }
font:FluTextStyle.Body font:FluTextStyle.Body
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering 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 selectedTextColor: color
placeholderTextColor: { placeholderTextColor: {
if(!enabled){ if(!enabled){
@ -42,18 +43,6 @@ TextField{
background: FluTextBoxBackground{ background: FluTextBoxBackground{
inputItem: control inputItem: control
implicitWidth: 240 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.onEnterPressed: (event)=> d.handleCommit(event)
Keys.onReturnPressed:(event)=> d.handleCommit(event) Keys.onReturnPressed:(event)=> d.handleCommit(event)
@ -69,11 +58,20 @@ TextField{
acceptedButtons: Qt.RightButton acceptedButtons: Qt.RightButton
onClicked: control.echoMode !== TextInput.Password && menu.popup() onClicked: control.echoMode !== TextInput.Password && menu.popup()
} }
RowLayout{
height: parent.height
anchors{
right: parent.right
rightMargin: 5
}
spacing: 4
FluIconButton{ FluIconButton{
iconSource:FluentIcons.ChromeClose iconSource: FluentIcons.Cancel
iconSize: 10 iconSize: 12
width: 20 Layout.preferredWidth: 30
height: 20 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 verticalPadding: 0
horizontalPadding: 0 horizontalPadding: 0
visible: { visible: {
@ -84,19 +82,23 @@ TextField{
return false return false
return control.text !== "" return control.text !== ""
} }
anchors{ contentDescription:"Clean"
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: control.iconRightMargin
}
contentDescription:"清空"
onClicked:{ onClicked:{
control.text = "" 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{ FluTextBoxMenu{
id:menu id:menu
inputItem: control inputItem: control
} }
} }

View File

@ -36,14 +36,14 @@ Rectangle{
} }
Rectangle{ Rectangle{
width: parent.width width: parent.width
height: inputItem.activeFocus ? 3 : 1 height: inputItem.activeFocus ? 2 : 1
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
visible: !inputItem.disabled visible: !inputItem.disabled
color: { color: {
if(FluTheme.dark){ 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{ }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{ Behavior on height{

View File

@ -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);

View File

@ -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;
}; };

View File

@ -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){

View File

@ -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
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