Compare commits

..

21 Commits
1.2.8 ... 1.2.9

Author SHA1 Message Date
eaad0dc565 update 2023-05-06 00:08:04 +08:00
9a494e938c update 2023-05-05 23:54:10 +08:00
ad35ac2588 update 2023-05-05 23:05:07 +08:00
c81910a41f update 2023-05-05 22:46:54 +08:00
cff6aaf6f4 update 2023-05-05 22:45:02 +08:00
a1c8672a5a update 2023-05-05 21:58:39 +08:00
df5e657ad1 update 2023-05-05 21:42:16 +08:00
fb4ed03530 update 2023-05-05 18:51:40 +08:00
7ceb4f27a3 Merge pull request #83 from mentalfl0w/dev
Make the library compile as Universal Library in macOS.
2023-05-04 08:23:58 +08:00
292e96cdfd Make the library compile as Universal Library in macOS. 2023-05-04 00:22:20 +08:00
c925ab79c6 Merge pull request #81 from mentalfl0w/dev
Allow the table to set the maximum height of each row based on the content.
2023-04-30 14:52:01 +08:00
f51d9f960b Allow the table to set the maximum height of each row based on the content. 2023-04-30 13:50:51 +08:00
86fa76edee update 2023-04-28 23:44:32 +08:00
4222597ef0 Merge pull request #76 from mentalfl0w/dev
Added ToolTip for FluTabView's tab.
2023-04-27 18:18:24 +08:00
a3adedf164 Added ToolTip for FluTabView's tab. 2023-04-27 18:06:01 +08:00
a70ddf7087 update 2023-04-27 17:29:39 +08:00
afeb6daea5 update 2023-04-27 15:43:45 +08:00
a258d429c2 Merge branch 'main' of https://github.com/zhuzichu520/FluentUI 2023-04-27 14:30:46 +08:00
7a25a48fdb update 2023-04-27 14:30:10 +08:00
0e434a36e7 Update README.md 2023-04-27 10:25:40 +08:00
36561fd75a Update README.md 2023-04-27 10:24:09 +08:00
39 changed files with 568 additions and 204 deletions

View File

@ -50,7 +50,7 @@ jobs:
cmake --version
mkdir build
cd build
cmake -DCMAKE_MESSAGE_LOG_LEVEL=STATUS -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -GNinja ..
cmake -DCMAKE_MESSAGE_LOG_LEVEL=STATUS -DCMAKE_PREFIX_PATH=/Users/runner/work/FluentUI/Qt/6.4.3/macos -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -GNinja ..
cmake --build . --target all --config Release --parallel
- name: package

View File

@ -55,7 +55,7 @@ jobs:
cmake --version
mkdir build
cd build
cmake -DCMAKE_MESSAGE_LOG_LEVEL=STATUS -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -GNinja ..
cmake -DCMAKE_MESSAGE_LOG_LEVEL=STATUS -DCMAKE_PREFIX_PATH=/home/runner/work/FluentUI/Qt/6.4.3/gcc_64 -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -GNinja ..
cmake --build . --target all --config Release --parallel
- name: install QT linux deploy

View File

@ -62,7 +62,7 @@ jobs:
run: |
mkdir build
cd build
cmake -DCMAKE_MESSAGE_LOG_LEVEL=STATUS -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -GNinja ..
cmake -DCMAKE_MESSAGE_LOG_LEVEL=STATUS -DCMAKE_PREFIX_PATH=D:\a\FluentUI\Qt\6.4.3\mingw_64 -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -GNinja ..
cmake --build . --target all --config Release --parallel
- name: package

View File

@ -51,7 +51,7 @@ jobs:
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_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release -GNinja ..
cmake -DCMAKE_MESSAGE_LOG_LEVEL=STATUS -DCMAKE_PREFIX_PATH=D:\a\FluentUI\Qt\6.4.3\msvc2019_64 -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%

4
.gitignore vendored
View File

@ -34,4 +34,6 @@ CMakeLists.txt.user*
src/build-preset/plugins.qmltypes
bin
.DS_Store
build
build
cmake-build-*
.idea

View File

@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(FluentUI VERSION 0.1 LANGUAGES CXX)
add_subdirectory(src)

View File

@ -2,7 +2,7 @@
## 简介
这是一个漂亮的Fluent组件库使用QML插件开发的。main分支是Qt6.4.3如果需要qt5的请切换至qt5分支<a href="https://github.com/zhuzichu520/FluentUI/wiki/%E6%96%B0%E6%89%8B%E5%85%A5%E9%97%A8" target="_blank">如何使用?</a>
这是一个漂亮的Fluent组件库使用QML插件开发的。main分支是Qt6.4.3<a href="https://github.com/zhuzichu520/FluentUI/wiki/%E6%96%B0%E6%89%8B%E5%85%A5%E9%97%A8" target="_blank">如何使用?</a>如果需要qt5的请切换至qt5分支<a href="https://github.com/zhuzichu520/FluentUI/wiki/%E6%96%B0%E6%89%8B%E5%85%A5%E9%97%A8%EF%BC%881.2.7%E4%BB%A5%E5%8F%8A%E4%B9%8B%E5%89%8D%E7%89%88%E6%9C%AC%EF%BC%89" target="_blank">如何使用?</a>
## 编译状态
| [Windows][win-link]| [Ubuntu][ubuntu-link]|[MacOS][macos-link]|

View File

@ -2,11 +2,12 @@
project(example VERSION 0.1 LANGUAGES CXX)
#配置通用编译
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#获取文件路径分隔符(解决执行命令的时候有些平台会报错)
file(TO_CMAKE_PATH "/" PATH_SEPARATOR)
if(APPLE)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
endif()
#设置可执行文件输出目录
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
@ -15,6 +16,12 @@ else()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/release)
endif()
#获取文件路径分隔符(解决执行命令的时候有些平台会报错)
file(TO_CMAKE_PATH "/" PATH_SEPARATOR)
#设置版本号
add_definitions(-DVERSION=1,2,9,0)
find_package(Qt6 REQUIRED COMPONENTS Quick REQUIRED)
#遍历所有Cpp文件
@ -32,20 +39,27 @@ foreach(filepath ${QML_PATHS})
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})
endforeach(filepath)
#添加可执行文件
qt_add_executable(example
${sources_files}
)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
qt_add_executable(example
${sources_files}
example.rc
)
else ()
qt_add_executable(example
${sources_files}
)
endif ()
#复制动态库到可执行文件同级目录下
if(WIN32)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(DLLPATH ${CMAKE_SOURCE_DIR}/3rdparty/msvc/*.dll)
else()
set(DLLPATH ${CMAKE_SOURCE_DIR}/3rdparty/mingw/*.dll)
@ -63,7 +77,7 @@ endif()
qt_add_qml_module(example
URI example
VERSION 1.0
QML_FILES ${qml_files} qml/global/qmldir
QML_FILES ${qml_files}
RESOURCES ${resource_files}
)
@ -77,8 +91,9 @@ set_target_properties(example PROPERTIES
)
#链接库
target_link_libraries(example
PRIVATE Qt6::Quick
target_link_libraries(example PRIVATE
Qt6::Quick
fluentui
)
#安装

42
example/example.rc Normal file
View File

@ -0,0 +1,42 @@
#include <windows.h>
IDI_ICON1 ICON "favicon.ico"
#define STR(x) #x
#define VER_JOIN(a,b,c,d) STR(a.b.c.d)
#define VER_JOIN_(x) VER_JOIN x
#define VER_STR VER_JOIN_((VERSION))
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION
PRODUCTVERSION VERSION
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "Built by the FluentUI."
VALUE "CompanyName", "zhuzichu"
VALUE "FileDescription", "example"
VALUE "FileVersion", VER_STR
VALUE "InternalName", ""
VALUE "LegalCopyright", "Copyright (C) 2023"
VALUE "OriginalFilename", ""
VALUE "ProductName", "example"
VALUE "ProductVersion", VER_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

BIN
example/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

View File

@ -36,7 +36,7 @@ FluExpander{
topMargin: 5
}
onClicked:{
FluApp.clipText(content.text)
FluTools.clipText(content.text)
showSuccess("复制成功")
}
}

View File

@ -55,7 +55,7 @@ FluContentPage {
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
var text ="FluentIcons."+modelData.name;
FluApp.clipText(text)
FluTools.clipText(text)
showSuccess("您复制了 "+text)
}
}

View File

@ -83,12 +83,5 @@ FluContentPage {
textSize = value/100*6+FluTheme.textSize
}
}
}
}

View File

@ -4,7 +4,6 @@ import QtQuick.Controls
import QtQuick.Layouts
import Qt.labs.platform
import FluentUI
import example
import "qrc:///example/qml/global/"
FluWindow {

View File

@ -1,11 +1,17 @@
#include "AppInfo.h"
#include "lang/En.h"
#include "lang/Zh.h"
#include <QDebug>
#define STR(x) #x
#define VER_JOIN(a,b,c,d) STR(a.b.c.d)
#define VER_JOIN_(x) VER_JOIN x
#define VER_STR VER_JOIN_((VERSION))
AppInfo::AppInfo(QObject *parent)
: QObject{parent}
{
version("1.2.8");
version(VER_STR);
lang(new En());
}

View File

@ -1,59 +1,71 @@
cmake_minimum_required(VERSION 3.16)
project(fluentui LANGUAGES CXX)
#配置通用编译
set(CMAKE_AUTOMOC ON)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/debug)
else()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/release)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(APPLE)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
endif()
#设置可执行文件输出目录
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/debug)
else()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/release)
endif()
#设置版本号
add_definitions(-DVERSION=1,2,9,0)
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml)
#遍历所有Cpp文件
file(GLOB_RECURSE CPP_FILES *.cpp *.h)
foreach(filepath ${CPP_FILES})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
list(APPEND sources_files ${filename})
endforeach(filepath)
#遍历所有qml文件
file(GLOB_RECURSE QML_PATHS *.qml)
foreach(filepath ${QML_PATHS})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
list(APPEND qml_files ${filename})
endforeach(filepath)
#遍历所有资源文件
file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp)
foreach(filepath ${RES_PATHS})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
list(APPEND resource_files ${filename})
endforeach(filepath)
#修改资源文件导出路径
foreach(filepath IN LISTS qml_files resource_files)
string(REPLACE "imports/FluentUI/" "" filename ${filepath})
set_source_files_properties(${filepath} PROPERTIES QT_RESOURCE_ALIAS ${filename})
endforeach()
#添加qml模块
qt_add_qml_module(fluentui
OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/FluentUI
OUTPUT_DIRECTORY ${CMAKE_PREFIX_PATH}/qml/FluentUI
VERSION 1.0
URI "FluentUI"
SOURCES ${sources_files}
SOURCES ${sources_files} fluentui.rc
QML_FILES ${qml_files}
RESOURCES ${resource_files}
)
set_target_properties(fluentui PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
#链接库
target_link_libraries(fluentui PUBLIC
Qt::Core
Qt::Quick
Qt::Qml
)
#链接库 win32库 不然mingw会编译错误
if(WIN32)
target_link_libraries(fluentui PRIVATE dwmapi user32)
endif()

View File

@ -8,9 +8,7 @@
#include <QUuid>
#include <QFontDatabase>
#include <QClipboard>
#include "FluTheme.h"
#include "Def.h"
#ifdef Q_OS_WIN
#pragma comment(lib, "Dwmapi.lib")
#pragma comment(lib, "User32.lib")
@ -26,18 +24,12 @@ static bool isCompositionEnabled()
#endif
FluApp* FluApp::fluApp = nullptr;
FluTheme* FluApp::fluTheme = nullptr;
FluColors* FluApp::flutColors = nullptr;
void FluApp::setFluApp(FluApp* val){
FluApp::fluApp = val;
}
void FluApp::setFluTheme(FluTheme* val){
FluApp::fluTheme = val;
}
void FluApp::setFluColors(FluColors* val){
FluApp::flutColors = val;
}
FluTheme* FluApp::fluTheme = nullptr;
FluColors* FluApp::fluColors = nullptr;
FluTools* FluApp::fluTools = nullptr;
FluApp::FluApp(QObject *parent)
: QObject{parent}
@ -45,6 +37,29 @@ FluApp::FluApp(QObject *parent)
QFontDatabase::addApplicationFont(":/FluentUI/Font/Segoe_Fluent_Icons.ttf");
}
FluApp::~FluApp(){
if (nativeEvent != Q_NULLPTR) {
delete nativeEvent;
nativeEvent = Q_NULLPTR;
}
}
void FluApp::setFluApp(FluApp* val){
FluApp::fluApp = val;
}
void FluApp::setFluTheme(FluTheme* val){
FluApp::fluTheme = val;
}
void FluApp::setFluColors(FluColors* val){
FluApp::fluColors = val;
}
void FluApp::setFluTools(FluTools* val){
FluApp::fluTools = val;
}
void FluApp::init(QQuickWindow *window){
this->appWindow = window;
QQmlEngine *engine = qmlEngine(appWindow);
@ -133,14 +148,6 @@ QJsonArray FluApp::awesomelist(const QString& keyword)
return arr;
}
void FluApp::clipText(const QString& text){
QGuiApplication::clipboard()->setText(text);
}
QString FluApp::uuid(){
return QUuid::createUuid().toString();
}
void FluApp::closeApp(){
qApp->exit(0);
}

View File

@ -9,45 +9,125 @@
#include <QJsonObject>
#include <QQmlEngine>
#include "FluTheme.h"
#include "FluTools.h"
#include "FluColors.h"
#include "NativeEventFilter.h"
#include "FluRegister.h"
#include "stdafx.h"
/**
* @brief The FluApp class
*/
class FluApp : public QObject
{
Q_OBJECT
/**
* @brief initialRoute 初始路由
*/
Q_PROPERTY_AUTO(QString,initialRoute);
/**
* @brief routes 路由表
*/
Q_PROPERTY_AUTO(QJsonObject,routes);
QML_NAMED_ELEMENT(FluApp)
QML_SINGLETON
public:
static FluApp *getInstance();
explicit FluApp(QObject *parent = nullptr);
~FluApp(){
if (nativeEvent != Q_NULLPTR) {
delete nativeEvent;
nativeEvent = Q_NULLPTR;
}
}
Q_INVOKABLE void run();
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluRegister* fluRegister = nullptr);
Q_INVOKABLE void init(QQuickWindow *window);
Q_INVOKABLE QJsonArray awesomelist(const QString& keyword = "");
Q_INVOKABLE void clipText(const QString& text);
Q_INVOKABLE QString uuid();
Q_INVOKABLE void closeApp();
Q_INVOKABLE void setFluApp(FluApp* val);
Q_INVOKABLE void setFluTheme(FluTheme* val);
Q_INVOKABLE void setFluColors(FluColors* val);
public:
explicit FluApp(QObject *parent = nullptr);
~FluApp();
/**
* @brief run
*/
Q_INVOKABLE void run();
/**
* @brief navigate
* @param route
* @param argument
* @param fluRegister
*/
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluRegister* fluRegister = nullptr);
/**
* @brief init
* @param window
*/
Q_INVOKABLE void init(QQuickWindow *window);
/**
* @brief awesomelist
* @param keyword
* @return
*/
Q_INVOKABLE QJsonArray awesomelist(const QString& keyword = "");
/**
* @brief closeApp
*/
Q_INVOKABLE void closeApp();
/**
* @brief setFluApp 在FluSingleton.qml调用拿到QML中FluApp的单例
* @param val
*/
Q_INVOKABLE void setFluApp(FluApp* val);
/**
* @brief setFluTheme 在FluSingleton.qml调用拿到QML中FluTheme的单例
* @param val
*/
Q_INVOKABLE void setFluTheme(FluTheme* val);
/**
* @brief setFluColors 在FluSingleton.qml调用拿到QML中FluColors的单例
* @param val
*/
Q_INVOKABLE void setFluColors(FluColors* val);
/**
* @brief setFluColors 在FluSingleton.qml调用拿到QML中FluTools的单例
* @param val
*/
Q_INVOKABLE void setFluTools(FluTools* val);
public:
/**
* @brief wnds
*/
QMap<quint64, QQuickWindow*> wnds;
/**
* @brief fluApp
*/
static FluApp* fluApp;
/**
* @brief fluTheme
*/
static FluTheme* fluTheme;
static FluColors* flutColors;
/**
* @brief fluColors
*/
static FluColors* fluColors;
/**
* @brief fluTools
*/
static FluTools* fluTools;
private:
/**
* @brief nativeEvent
*/
NativeEventFilter *nativeEvent = Q_NULLPTR;
/**
* @brief appWindow
*/
QWindow *appWindow;
};

View File

@ -4,9 +4,11 @@
#include <QObject>
#include "stdafx.h"
/**
* @brief The FluColorSet class
*/
class FluColorSet : public QObject
{
Q_OBJECT
Q_PROPERTY_AUTO(QString,darkest)
Q_PROPERTY_AUTO(QString,darker)

View File

@ -6,6 +6,9 @@
#include "FluColorSet.h"
#include "stdafx.h"
/**
* @brief The FluColors class
*/
class FluColors : public QObject
{
Q_OBJECT
@ -33,7 +36,6 @@ class FluColors : public QObject
Q_PROPERTY_AUTO(QString,Grey200);
Q_PROPERTY_AUTO(QString,Grey210);
Q_PROPERTY_AUTO(QString,Grey220);
Q_PROPERTY_AUTO(FluColorSet*,Yellow);
Q_PROPERTY_AUTO(FluColorSet*,Orange);
Q_PROPERTY_AUTO(FluColorSet*,Red);

View File

@ -6,6 +6,9 @@
#include <QJsonObject>
#include "stdafx.h"
/**
* @brief The FluRegister class
*/
class FluRegister : public QObject
{
Q_OBJECT
@ -15,8 +18,22 @@ class FluRegister : public QObject
public:
explicit FluRegister(QObject *parent = nullptr);
/**
* @brief launch 窗口跳转
* @param argument 跳转携带参数
*/
Q_INVOKABLE void launch(const QJsonObject& argument = {});
/**
* @brief onResult 将结果数据回传到上一个窗口
* @param data 结果数据
*/
Q_INVOKABLE void onResult(const QJsonObject& data = {});
/**
* @brief result 收到结果数据的信号
* @param data 结果数据
*/
Q_SIGNAL void result(const QJsonObject& data);
};

View File

@ -11,7 +11,7 @@ FluTheme::FluTheme(QObject *parent)
connect(this,&FluTheme::darkModeChanged,this,[=]{
Q_EMIT darkChanged();
});
primaryColor(FluApp::flutColors->Blue());
primaryColor(FluApp::fluColors->Blue());
textSize(13);
nativeText(false);
frameless(true);

View File

@ -6,15 +6,42 @@
#include "FluColorSet.h"
#include "stdafx.h"
/**
* @brief The FluTheme class
*/
class FluTheme : public QObject
{
Q_OBJECT
/**
* @brief dark 改变窗口夜间样式只读属性可以通过darkMode切换
*/
Q_PROPERTY(bool dark READ dark NOTIFY darkChanged)
/**
* @brief primaryColor 主题颜色
*/
Q_PROPERTY_AUTO(FluColorSet*,primaryColor)
/**
* @brief frameless 是否是无边框窗口只支持windows部分电脑
*/
Q_PROPERTY_AUTO(bool,frameless);
/**
* @brief darkMode 夜间模式支持System=0、Light=1、Dark=2
*/
Q_PROPERTY_AUTO(int,darkMode);
/**
* @brief nativeText 本地渲染文本
*/
Q_PROPERTY_AUTO(bool,nativeText);
/**
* @brief textSize 文字大小
*/
Q_PROPERTY_AUTO(int,textSize);
QML_NAMED_ELEMENT(FluTheme)
QML_SINGLETON
public:

18
src/FluTools.cpp Normal file
View File

@ -0,0 +1,18 @@
#include "FluTools.h"
#include <QGuiApplication>
#include <QClipboard>
#include <QUuid>
FluTools::FluTools(QObject *parent)
: QObject{parent}
{
}
void FluTools::clipText(const QString& text){
QGuiApplication::clipboard()->setText(text);
}
QString FluTools::uuid(){
return QUuid::createUuid().toString();
}

34
src/FluTools.h Normal file
View File

@ -0,0 +1,34 @@
#ifndef FLUTOOLS_H
#define FLUTOOLS_H
#include <QObject>
#include <QtQml/qqml.h>
/**
* @brief The FluTools class
*/
class FluTools : public QObject
{
Q_OBJECT
QML_NAMED_ELEMENT(FluTools)
QML_SINGLETON
public:
explicit FluTools(QObject *parent = nullptr);
/**
* @brief clipText 将字符串添加到剪切板
* @param text
*/
Q_INVOKABLE void clipText(const QString& text);
/**
* @brief uuid 获取uuid
* @return
*/
Q_INVOKABLE QString uuid();
};
#endif // FLUTOOLS_H

View File

@ -4,6 +4,9 @@
#include <QObject>
#include <QAbstractNativeEventFilter>
/**
* @brief The NativeEventFilter class
*/
class NativeEventFilter : public QAbstractNativeEventFilter
{

View File

@ -28,21 +28,17 @@ void WindowHelper::initWindow(QQuickWindow* window){
}
void WindowHelper::firstUpdate(){
if(isFisrt){
#ifdef Q_OS_WIN
if(FluApp::fluTheme->frameless()){
HWND wnd = (HWND)window->winId();
SetWindowLongPtr(wnd, GWL_STYLE, static_cast<LONG>(Style::aero_borderless));
const MARGINS shadow_on = { 1, 1, 1, 1 };
DwmExtendFrameIntoClientArea(wnd, &shadow_on);
SetWindowPos(wnd, Q_NULLPTR, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);
ShowWindow(wnd, SW_SHOW);
window->setFlag(Qt::FramelessWindowHint,false);
}
#endif
isFisrt = false;
if(FluApp::fluTheme->frameless()){
HWND wnd = (HWND)window->winId();
SetWindowLongPtr(wnd, GWL_STYLE, static_cast<LONG>(Style::aero_borderless));
const MARGINS shadow_on = { 1, 1, 1, 1 };
DwmExtendFrameIntoClientArea(wnd, &shadow_on);
SetWindowPos(wnd, Q_NULLPTR, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);
ShowWindow(wnd, SW_SHOW);
window->setFlag(Qt::FramelessWindowHint,false);
}
#endif
}
QVariant WindowHelper::createRegister(QQuickWindow* window,const QString& path){

View File

@ -8,6 +8,9 @@
#include <QWindow>
#include <QJsonObject>
/**
* @brief The WindowHelper class
*/
class WindowHelper : public QObject
{
Q_OBJECT
@ -15,14 +18,32 @@ class WindowHelper : public QObject
public:
explicit WindowHelper(QObject *parent = nullptr);
/**
* @brief initWindow FluWindow中初始化调用
* @param window
*/
Q_INVOKABLE void initWindow(QQuickWindow* window);
/**
* @brief destoryWindow 销毁窗口释放资源QML中的Window close并不会销毁窗口只是把窗口隐藏了
*/
Q_INVOKABLE void destoryWindow();
/**
* @brief createRegister 创建一个FluRegsiter对象在FluWindow中registerForWindowResult方法调用
* @param window
* @param path
* @return
*/
Q_INVOKABLE QVariant createRegister(QQuickWindow* window,const QString& path);
/**
* @brief firstUpdate 窗口创建成功后调用,只调用一次
*/
Q_INVOKABLE void firstUpdate();
private:
QQuickWindow* window;
bool isFisrt=true;
};
#endif // WINDOWHELPER_H

40
src/fluentui.rc Normal file
View File

@ -0,0 +1,40 @@
#include <windows.h>
#define STR(x) #x
#define VER_JOIN(a,b,c,d) STR(a.b.c.d)
#define VER_JOIN_(x) VER_JOIN x
#define VER_STR VER_JOIN_((VERSION))
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION
PRODUCTVERSION VERSION
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "FluentUI for QML."
VALUE "CompanyName", "zhuzichu"
VALUE "FileDescription", "fluentui"
VALUE "FileVersion", VER_STR
VALUE "InternalName", ""
VALUE "LegalCopyright", "Copyright (C) 2023"
VALUE "OriginalFilename", ""
VALUE "ProductName", "fluentui"
VALUE "ProductVersion", VER_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

View File

@ -581,7 +581,7 @@ Item {
MouseArea{
anchors.fill: parent
enabled: d.isMinimalAndPanel||d.isCompactAndPanel
visible: d.isMinimalAndPanel||d.isCompactAndPanel
onClicked: {
d.enableNavigationPanel = false
}

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import FluentUI
QtObject {
readonly property string key : FluApp.uuid()
readonly property string key : FluTools.uuid()
readonly property int flag : 0
property string title
property int order : 0

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import FluentUI
QtObject {
readonly property string key : FluApp.uuid()
readonly property string key : FluTools.uuid()
property var parent
property int idx
}

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import FluentUI
FluObject {
readonly property string key : FluApp.uuid()
readonly property string key : FluTools.uuid()
property string title
property var icon
property Component cusIcon

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import FluentUI
QtObject {
readonly property string key : FluApp.uuid()
readonly property string key : FluTools.uuid()
property string title
property var parent
property int idx

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import FluentUI
QtObject {
readonly property string key : FluApp.uuid()
readonly property string key : FluTools.uuid()
property var parent
property int idx
}

View File

@ -10,6 +10,7 @@ QtObject {
FluApp.setFluApp(FluApp)
FluApp.setFluColors(FluColors)
FluApp.setFluTheme(FluTheme)
FluApp.setFluTools(FluTools)
}
}

View File

@ -133,9 +133,9 @@ Item {
drag.axis: Drag.XAxis
onWheel: (wheel)=>{
if (wheel.angleDelta.y > 0) scroll_nav.decrease()
else scroll_nav.increase()
}
if (wheel.angleDelta.y > 0) scroll_nav.decrease()
else scroll_nav.increase()
}
onPressed: {
d.itemPress = true
@ -264,6 +264,11 @@ Item {
Layout.preferredWidth: visible?item_container.width - 41 - item_btn_close.width:0
elide: Text.ElideRight
Layout.alignment: Qt.AlignVCenter
FluTooltip{
visible: item_mouse_hove.containsMouse
text:item_text.text
delay: 1000
}
}
}

View File

@ -14,7 +14,12 @@ Item {
signal requestPage(int page,int count)
id:control
implicitHeight: layout_coumns.height + layout_table.height
implicitHeight: layout_table.height
QtObject{
id:d
property int coumnsWidth: parent.width
}
MouseArea{
anchors.fill: parent
@ -32,6 +37,12 @@ Item {
onColumnsChanged: {
model_coumns.clear()
model_coumns.append(columns)
var w = 0
for(var i=0;i<model_coumns.count;i++){
var item = model_coumns.get(i)
w=w+item.width
}
d.coumnsWidth = w
}
onDataSourceChanged: {
@ -39,115 +50,137 @@ Item {
model_data_source.append(dataSource)
}
FluRectangle{
id:layout_coumns
height: control.itemHeight
width: parent.width
color:FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
radius: [12,12,0,0]
Row{
id:list_coumns
spacing: 0
anchors.fill: parent
Repeater{
model: model_coumns
delegate: Item{
height: list_coumns.height
width: model.width
FluText{
text:model.title
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 14
}
fontStyle: FluText.BodyStrong
}
FluDivider{
width: 1
height: 40
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
visible: index !== list_coumns.count-1
}
}
}
}
}
Rectangle{
anchors.fill: layout_table
color: FluTheme.dark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1)
}
ListView{
id:layout_table
Flickable{
id:layout_flickable
height: layout_table.height
anchors{
top: layout_coumns.bottom
top: parent.top
left: parent.left
right: parent.right
}
height: contentHeight
clip:true
footer: Item{
height: 50
width: layout_table.width
FluPagination{
id:pagination
height: 40
pageCurrent: control.pageCurrent
itemCount: control.itemCount
pageCount: control.pageCount
onRequestPage:
(page,count)=> {
control.requestPage(page,count)
}
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
}
}
contentWidth: layout_table.width
ScrollBar.horizontal: FluScrollBar {
}
model:model_data_source
delegate: Item{
height: list_coumns.height
width: layout_table.width
property var model_values : getObjectValues(index)
property var itemObject: getObject(index)
property var listModel: model
Row{
spacing: 0
anchors.fill: parent
Repeater{
model: model_values
delegate:Item{
height: list_coumns.height
width: modelData.width
Loader{
property var model : modelData
property var dataModel : listModel
property var dataObject : itemObject
anchors.fill: parent
sourceComponent: {
if(model.itemData instanceof Component){
return model.itemData
Rectangle{
anchors.fill: layout_table
radius: 5
color: FluTheme.dark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1)
}
ListView{
id:layout_table
height: contentHeight
width: Math.max(layout_flickable.width,d.coumnsWidth)
clip:true
interactive: false
header: FluRectangle{
id:layout_coumns
height: control.itemHeight
width: parent.width
color:FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
radius: [5,5,0,0]
Row{
id:list_coumns
spacing: 0
anchors.fill: parent
Repeater{
model: model_coumns
delegate: Item{
height: list_coumns.height
width: model.width
FluText{
text:model.title
wrapMode: Text.WordWrap
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 14
}
return com_text
fontStyle: FluText.BodyStrong
}
FluDivider{
width: 1
height: 40
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
visible: index !== list_coumns.count-1
}
}
}
}
}
FluDivider{
width: parent.width
height: 1
anchors.right: parent.right
anchors.bottom: parent.bottom
footer: Item{
height: 50
width: layout_table.width
FluPagination{
id:pagination
height: 40
pageCurrent: control.pageCurrent
itemCount: control.itemCount
pageCount: control.pageCount
onRequestPage:
(page,count)=> {
control.requestPage(page,count)
}
anchors{
top: parent.top
right: parent.right
}
}
}
model:model_data_source
delegate: Item{
height: table_row.maxHeight
width: layout_table.width
property var model_values : getObjectValues(index)
property var itemObject: getObject(index)
property var listModel: model
Row{
id: table_row
spacing: 0
anchors.fill: parent
property int maxHeight: itemHeight
Repeater{
model: model_values
delegate:Item{
height: table_row.maxHeight
width: modelData.width
Loader{
property var model : modelData
property var dataModel : listModel
property var dataObject : itemObject
anchors.fill: parent
sourceComponent: {
if(model.itemData instanceof Component){
return model.itemData
}
return com_text
}
onHeightChanged:
{
table_row.maxHeight = Math.max(table_row.maxHeight,height,itemHeight)
parent.height = table_row.maxHeight
table_row.parent.height = table_row.maxHeight
}
}
}
}
}
FluDivider{
width: parent.width
height: 1
anchors.right: parent.right
anchors.bottom: parent.bottom
}
}
}
}
Component{
id:com_text
Item{
@ -157,9 +190,11 @@ Item {
anchors.fill: parent
}
FluText{
id:table_value
text:String(model.itemData)
width: parent.width - 14
elide: Text.ElideRight
wrapMode: Text.WordWrap
onImplicitHeightChanged: parent.parent.parent.height = Math.max(implicitHeight + 20,itemHeight)
anchors{
verticalCenter: parent.verticalCenter
left: parent.left

View File

@ -28,6 +28,11 @@ ApplicationWindow {
}
signal initArgument(var argument)
QtObject{
id:d
property bool firstFlag: true
}
id:window
background: Rectangle{
color: {
@ -51,8 +56,9 @@ ApplicationWindow {
}
onActiveChanged: {
if(active){
if(d.firstFlag){
helper.firstUpdate()
d.firstFlag = false
}
}