From e1c6c04013d946878e0e38677f5b87afbb3a8110 Mon Sep 17 00:00:00 2001 From: zhuzihcu Date: Fri, 12 May 2023 19:26:49 +0800 Subject: [PATCH] update --- example/CMakeLists.txt | 2 +- .../qml/{window/main.qml => TestWindow.qml} | 2 +- example/qml/component/CodeExpander.qml | 3 +- example/qml/global/ItemsOriginal.qml | 6 ++ example/qml/page/T_Acrylic.qml | 60 +++++++++++++++++++ example/qml/window/AboutWindow.qml | 8 +-- example/qml/window/LoginWindow.qml | 6 -- example/qml/window/MainWindow.qml | 8 --- example/qml/window/MediaWindow.qml | 8 +-- example/qml/window/SingleInstanceWindow.qml | 6 -- example/qml/window/SingleTaskWindow.qml | 6 -- example/qml/window/StandardWindow.qml | 6 -- example/src/main.cpp | 2 +- src/CMakeLists.txt | 7 +-- src/FluTools.cpp | 13 ++++ src/FluTools.h | 8 +++ src/imports/FluentUI/Controls/FluAcrylic.qml | 32 ++++++++++ 17 files changed, 129 insertions(+), 54 deletions(-) rename example/qml/{window/main.qml => TestWindow.qml} (92%) create mode 100644 example/qml/page/T_Acrylic.qml create mode 100644 src/imports/FluentUI/Controls/FluAcrylic.qml diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index ea93c06..8b47966 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -20,7 +20,7 @@ endif() file(TO_CMAKE_PATH "/" PATH_SEPARATOR) #设置版本号 -add_definitions(-DVERSION=1,2,9,0) +add_definitions(-DVERSION=1,3,0,0) find_package(Qt6 REQUIRED COMPONENTS Quick REQUIRED) diff --git a/example/qml/window/main.qml b/example/qml/TestWindow.qml similarity index 92% rename from example/qml/window/main.qml rename to example/qml/TestWindow.qml index e466a8e..0f33e73 100644 --- a/example/qml/window/main.qml +++ b/example/qml/TestWindow.qml @@ -1,7 +1,7 @@ import QtQuick import FluentUI -Window { +FluWindow { id:window width: 400 height: 400 diff --git a/example/qml/component/CodeExpander.qml b/example/qml/component/CodeExpander.qml index 6d69d48..0fdc543 100644 --- a/example/qml/component/CodeExpander.qml +++ b/example/qml/component/CodeExpander.qml @@ -121,7 +121,8 @@ FluExpander{ "FluRatingControl", "FluPasswordBox", "FluBreadcrumbBar", - "FluCopyableText" + "FluCopyableText", + "FluAcrylic" ]; code = code.replace(/\n/g, "
"); code = code.replace(/ /g, " "); diff --git a/example/qml/global/ItemsOriginal.qml b/example/qml/global/ItemsOriginal.qml index 499cc55..a7cffad 100644 --- a/example/qml/global/ItemsOriginal.qml +++ b/example/qml/global/ItemsOriginal.qml @@ -246,6 +246,12 @@ FluObject{ FluPaneItemExpander{ title:lang.theming icon:FluentIcons.Brightness + FluPaneItem{ + title:"Acrylic" + onTap:{ + navigationView.push("qrc:/example/qml/page/T_Acrylic.qml") + } + } FluPaneItem{ title:"Theme" onTap:{ diff --git a/example/qml/page/T_Acrylic.qml b/example/qml/page/T_Acrylic.qml new file mode 100644 index 0000000..02be572 --- /dev/null +++ b/example/qml/page/T_Acrylic.qml @@ -0,0 +1,60 @@ +import QtQuick +import QtQuick.Layouts +import QtQuick.Window +import QtQuick.Controls +import FluentUI +import "../component" + +FluScrollablePage{ + + title:"Acrylic" + + FluArea{ + Layout.fillWidth: true + Layout.topMargin: 20 + height: 1439/5+20 + paddings: 10 + + FluRectangle{ + width: 1080/5 + height: 1439/5 + radius:[25,25,25,25] + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 20 + Image { + asynchronous: true + source: "qrc:/example/res/image/image_huoyin.webp" + anchors.fill: parent + sourceSize: Qt.size(width,height) + FluAcrylic { + anchors.centerIn: parent + width: 100 + height: 100 + FluText { + anchors.centerIn: parent + text: "Acrylic" + color: "#FFFFFF" + font.bold: true + } + } + } + } + } + CodeExpander{ + Layout.fillWidth: true + Layout.topMargin: -1 + code:'Image{ + width: 800 + height: 600 + source: "qrc:/example/res/image/image_huoyin.webp" + radius: 8 + FluAcrylic{ + width: 100 + height: 100 + anchors.centerIn: parent + } +}' + } + +} diff --git a/example/qml/window/AboutWindow.qml b/example/qml/window/AboutWindow.qml index fd8f379..7426634 100644 --- a/example/qml/window/AboutWindow.qml +++ b/example/qml/window/AboutWindow.qml @@ -15,15 +15,9 @@ FluWindow { maximumHeight: 600 launchMode: FluWindow.SingleTask - FluAppBar{ - id:appbar - title:"关于" - width:parent.width - } - ColumnLayout{ anchors{ - top: appbar.bottom + top: parent.top left: parent.left right: parent.right } diff --git a/example/qml/window/LoginWindow.qml b/example/qml/window/LoginWindow.qml index 84d8274..41dbc9f 100644 --- a/example/qml/window/LoginWindow.qml +++ b/example/qml/window/LoginWindow.qml @@ -20,12 +20,6 @@ FluWindow { textbox_password.focus = true } - FluAppBar{ - id:appbar - title:"登录" - width:parent.width - } - ColumnLayout{ anchors{ left: parent.left diff --git a/example/qml/window/MainWindow.qml b/example/qml/window/MainWindow.qml index 505a445..4904cee 100644 --- a/example/qml/window/MainWindow.qml +++ b/example/qml/window/MainWindow.qml @@ -31,14 +31,6 @@ FluWindow { } } - FluAppBar{ - id:appbar - z:9 - showDark: true - width:parent.width - darkText: lang.dark_mode - } - SystemTrayIcon { id:system_tray visible: true diff --git a/example/qml/window/MediaWindow.qml b/example/qml/window/MediaWindow.qml index 3f57288..d16956a 100644 --- a/example/qml/window/MediaWindow.qml +++ b/example/qml/window/MediaWindow.qml @@ -16,18 +16,12 @@ FluWindow { player.source = argument.source } - FluAppBar{ - id:appbar - title:"视频播放器" - width:parent.width - } - FluMediaPlayer{ id:player anchors{ left: parent.left right: parent.right - top: appbar.bottom + top: parent.top bottom: parent.bottom } } diff --git a/example/qml/window/SingleInstanceWindow.qml b/example/qml/window/SingleInstanceWindow.qml index caae291..4fad552 100644 --- a/example/qml/window/SingleInstanceWindow.qml +++ b/example/qml/window/SingleInstanceWindow.qml @@ -15,12 +15,6 @@ FluWindow { maximumHeight: 600 launchMode: FluWindow.SingleInstance - FluAppBar{ - id:appbar - title:"SingleInstance" - width:parent.width - } - FluTextBox{ anchors{ top:parent.top diff --git a/example/qml/window/SingleTaskWindow.qml b/example/qml/window/SingleTaskWindow.qml index 70bfa90..510195b 100644 --- a/example/qml/window/SingleTaskWindow.qml +++ b/example/qml/window/SingleTaskWindow.qml @@ -15,12 +15,6 @@ FluWindow { maximumHeight: 600 launchMode: FluWindow.SingleTask - FluAppBar{ - id:appbar - title:"SingleTask" - width:parent.width - } - FluText{ anchors.centerIn: parent text:"我是一个SingleTask模式的窗口,如果我存在,我就激活窗口" diff --git a/example/qml/window/StandardWindow.qml b/example/qml/window/StandardWindow.qml index f5f3508..5fe6f79 100644 --- a/example/qml/window/StandardWindow.qml +++ b/example/qml/window/StandardWindow.qml @@ -15,12 +15,6 @@ FluWindow { maximumHeight: 600 launchMode: FluWindow.Standard - FluAppBar{ - id:appbar - title:"Standard" - width:parent.width - } - FluText{ anchors.centerIn: parent text:"我是一个Standard模式的窗口,每次我都会创建一个新的窗口" diff --git a/example/src/main.cpp b/example/src/main.cpp index 8663e40..e7bf88f 100644 --- a/example/src/main.cpp +++ b/example/src/main.cpp @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) }); context->setContextProperty("appInfo",appInfo); const QUrl url(QStringLiteral("qrc:/example/qml/App.qml")); -// const QUrl url(QStringLiteral("qrc:/example/qml/window/main.qml")); +// const QUrl url(QStringLiteral("qrc:/example/qml/TestWindow.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2491f79..45a4064 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,9 +13,9 @@ endif() set(QML_PLUGIN_DIRECTORY ${CMAKE_PREFIX_PATH}/qml/FluentUI) #设置版本号 -add_definitions(-DVERSION=1,2,9,0) +add_definitions(-DVERSION=1,3,0,0) -find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml) +find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml ShaderTools) #遍历所有Cpp文件 file(GLOB_RECURSE CPP_FILES *.cpp *.h) @@ -32,7 +32,7 @@ foreach(filepath ${QML_PATHS}) endforeach(filepath) #遍历所有资源文件 -file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp *.metainfo) +file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp *.qsb *.metainfo) foreach(filepath ${RES_PATHS}) string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath}) list(APPEND resource_files ${filename}) @@ -59,7 +59,6 @@ qt_add_qml_module(fluentuiplugin DESIGNER_SUPPORTED ) - #链接库 target_link_libraries(fluentuiplugin PUBLIC Qt::Core diff --git a/src/FluTools.cpp b/src/FluTools.cpp index 8307a63..837605b 100644 --- a/src/FluTools.cpp +++ b/src/FluTools.cpp @@ -27,3 +27,16 @@ void FluTools::clipText(const QString& text){ QString FluTools::uuid(){ return QUuid::createUuid().toString(); } + +QString FluTools::readFile(const QString &fileName) +{ + QString content; + QFile file(fileName); + if (file.open(QIODevice::ReadOnly)) { + QTextStream stream(&file); + content = stream.readAll(); + } + return content; +} + + diff --git a/src/FluTools.h b/src/FluTools.h index 5264a86..0033d23 100644 --- a/src/FluTools.h +++ b/src/FluTools.h @@ -2,6 +2,7 @@ #define FLUTOOLS_H #include +#include #include /** @@ -34,6 +35,13 @@ public: */ Q_INVOKABLE QString uuid(); + /** + * @brief readFile 读取文件内容 + * @param fileName + * @return + */ + Q_INVOKABLE QString readFile(const QString &fileName); + }; #endif // FLUTOOLS_H diff --git a/src/imports/FluentUI/Controls/FluAcrylic.qml b/src/imports/FluentUI/Controls/FluAcrylic.qml new file mode 100644 index 0000000..4006289 --- /dev/null +++ b/src/imports/FluentUI/Controls/FluAcrylic.qml @@ -0,0 +1,32 @@ +import QtQuick +import Qt5Compat.GraphicalEffects +import FluentUI + +Item { + id: control + + property alias color: rect.color + property alias acrylicOpacity: rect.opacity + + Rectangle { + id: rect + anchors.fill: parent + color: "white" + opacity: 0.05 + } + + ShaderEffectSource { + id: effect_source + anchors.fill: parent + sourceItem: control.parent + sourceRect: Qt.rect(control.x, control.y, control.width, control.height) + } + + GaussianBlur { + radius: 20 + anchors.fill: effect_source + source: effect_source + samples: 1 + radius * 2 + } + +}