From 76f40a6265cf82f542c17ce068ffb6ac2e8759db Mon Sep 17 00:00:00 2001 From: jeffrey0326 <547913081@qq.com> Date: Wed, 21 Aug 2024 22:07:20 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwin11=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E5=B4=A9=E6=BA=83=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/qml/page/New_TableView.qml | 263 +++++++++++++++++++++++++++++ src/FluFrameless.cpp | 21 +++ 2 files changed, 284 insertions(+) create mode 100644 example/qml/page/New_TableView.qml diff --git a/example/qml/page/New_TableView.qml b/example/qml/page/New_TableView.qml new file mode 100644 index 00000000..0bef204a --- /dev/null +++ b/example/qml/page/New_TableView.qml @@ -0,0 +1,263 @@ +import QtQuick 2.15 +import FluentUI 1.0 +import "../component" + +FluPage{ + title:"表格测试" + TableView{ + columnSource: [ + { + title: "全选", + dataIndex: 'patientsex', + width:60, + readOnly:true, + position: 0, + delegate: com_checkbox, + headerDelegate: com_header_checkbox, + frozen: true + }, + + { + title: "检测日期", + dataIndex: 'testdate', + readOnly:true, + // width:150, + // delegate: com_action + }, + { + title: "条码号", + dataIndex: 'barcode', + width:80, + readOnly:true, + position: 0, + movable: false, + frozen: true + // delegate: com_checkbox, + // headerDelegate: com_header_checkbox + }, + { + title: "样本号", + dataIndex: 'sampleid', + width:100, + position: 1, + minimumWidth:100, + maximumWidth:100, + }, + { + title: "姓名", + dataIndex: 'patientname', + width:220, + minimumWidth:100, + maximumWidth:250 + }, + { + title:"操作", + dataIndex:"", + delegate:com_action, + frozen: true, + width: 250 + }, + { + title: "头像", + dataIndex: 'imageurl', + width:120, + minimumWidth:80, + maximumWidth:250, + delegate:com_avatar, + frozen: true + }, + { + title: "性别", + dataIndex: 'patientsex', + width:130, + minimumWidth:50, + maximumWidth:250, + // delegate:com_avatar + }, + + { + title: "年龄", + dataIndex: 'patientage', + width:100, + minimumWidth:80, + maximumWidth:330 + }, + { + title: "电话", + dataIndex: 'patienttel', + width:200, + minimumWidth:100, + maximumWidth:300, + editMultiline: true + }, + { + title: "身份证号", + dataIndex: 'patientidenno', + width:120, + minimumWidth:100, + maximumWidth:250 + }, + { + title: "检测项目", + dataIndex: 'hisitemnamelist', + width:120, + minimumWidth:100, + maximumWidth:250 + }, + { + title: "开单科室", + dataIndex: 'deptname', + width:150, + minimumWidth:100, + maximumWidth:250 + }, + { + title: "开单医生", + dataIndex: 'doctorname', + width:140, + minimumWidth:100, + maximumWidth:250 + } + , + { + title: "接收时间", + dataIndex: 'incepttime', + width:120, + minimumWidth:100, + maximumWidth:250 + }, + { + title: "核收时间", + dataIndex: 'accepttime', + width:220, + minimumWidth:100, + maximumWidth:250 + } + ] + model: ListModel{ + id: customModel + } + } + Component.onCompleted: { + // generateTestData(1000) // 生成100条测试数据 + for (var i = 0; i < 100000; i++) { + customModel.append(generateTestData(i)) + } + // uvRecord.setProperty() + } + Component{ + id:com_avatar + Item{ + anchors.fill: parent + FluClip{ + anchors.centerIn: parent + width: Math.min(parent.width,parent.height) + height: width + radius: [width/2,width/2,width/2,width/2] + Image{ + anchors.fill: parent + source: display + sourceSize: Qt.size(80,80) + fillMode: Image.PreserveAspectFit + } + } + } + } + Component { + id: com_checkbox + Item{ + FluCheckBox { + width: 15 + height: 15 + anchors.centerIn: parent + } + } + } + Component { + id: com_header_checkbox + Item{ + FluCheckBox { + width: 15 + height: 15 + anchors.centerIn: parent + } + } + } + Component{ + id: com_action + Item{ + Row{ + anchors.centerIn: parent + FluTextButton{ + text:"插入" + onClicked: { + // uvRecord.insertRecord(row) + uvRecord.insert(row,generateTestData(row)) + } + } + FluTextButton{ + text:"上移" + onClicked:{ + if (row > 0) { + uvRecord.move(row, row - 1, 1) + } + } + } + FluTextButton{ + text:"下移" + onClicked:{ + if (row < uvRecord.rowCount() - 1) { + uvRecord.move(row, row + 2, 1) // 注意这里是 row + 2 + } + } + } + FluTextButton{ + text:"查看" + onClicked: { + showSuccess(JSON.stringify(control.model.get(row))) + } + } + FluTextButton{ + text:"删除" + onClicked: { + uvRecord.remove(row) + } + } + } + } + } + + function generateTestData(i) { + var sexes = ["男", "女"] + var departments = ["内科", "外科", "儿科", "妇科", "眼科"] + var doctors = ["张医生", "李医生", "王医生", "刘医生", "陈医生"] + var images = [ + "qrc:/res/image/pages/exchange.png", + "qrc:/res/image/pages/nuclear.png", + "qrc:/res/image/pages/ocr.png", + "qrc:/res/image/pages/room-temperature.png", + "qrc:/res/image/pages/rt-pcr-machine.png" + ] + return { + testdate: new Date().toLocaleDateString(), + barcode: "BC" + (1000000 + i).toString(), + sampleid: "S" + (100000 + i).toString(), + patientname: "患者" + (i + 1), + patientsex: sexes[Math.floor(Math.random() * sexes.length)], + patientage: Math.floor(Math.random() * 80 + 1) + "岁", + patienttel: "1" + Math.floor(Math.random() * 9000000000 + 1000000000), + patientidenno: (310000000000000000 + i).toString(), + hisitemnamelist: "项目1,项目2,项目3", + deptname: departments[Math.floor(Math.random() * departments.length)], + doctorname: doctors[Math.floor(Math.random() * doctors.length)], + incepttime: new Date().toLocaleString(), + accepttime: new Date().toLocaleString(), + imageurl: images[Math.floor(Math.random() * images.length)], + _minimumHeight: 42, + _maximumHeight: 800, + height: 42 + } + + } + +} diff --git a/src/FluFrameless.cpp b/src/FluFrameless.cpp index 165f7212..bed322c7 100644 --- a/src/FluFrameless.cpp +++ b/src/FluFrameless.cpp @@ -136,6 +136,13 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en if (!isWin11OrGreater()) { return false; } + if(module && !pDwmSetWindowAttribute){ + pDwmSetWindowAttribute = reinterpret_cast( + GetProcAddress(module, "DwmSetWindowAttribute")); + if (!pDwmSetWindowAttribute) { + return false; + } + } if (enable) { pDwmExtendFrameIntoClientArea(hwnd, &extendedMargins); if (isWin1122H2OrGreater()) { @@ -163,6 +170,13 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en if (!isWin1122H2OrGreater()) { return false; } + if(module && !pDwmSetWindowAttribute){ + pDwmSetWindowAttribute = reinterpret_cast( + GetProcAddress(module, "DwmSetWindowAttribute")); + if (!pDwmSetWindowAttribute) { + return false; + } + } if (enable) { pDwmExtendFrameIntoClientArea(hwnd, &extendedMargins); const DWORD backdropType = _DWMSBT_TABBEDWINDOW; @@ -180,6 +194,13 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en if (!isWin11OrGreater()) { return false; } + if(module && !pDwmSetWindowAttribute){ + pDwmSetWindowAttribute = reinterpret_cast( + GetProcAddress(module, "DwmSetWindowAttribute")); + if (!pDwmSetWindowAttribute) { + return false; + } + } if (enable) { MARGINS margins{-1, -1, -1, -1}; pDwmExtendFrameIntoClientArea(hwnd, &margins); From f2eca9a2b9a800f7ff86557378dcf2e974e3d77b Mon Sep 17 00:00:00 2001 From: jeffrey0326 <547913081@qq.com> Date: Wed, 21 Aug 2024 22:08:13 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwin11=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E5=B4=A9=E6=BA=83=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/qml/page/New_TableView.qml | 263 ----------------------------- 1 file changed, 263 deletions(-) delete mode 100644 example/qml/page/New_TableView.qml diff --git a/example/qml/page/New_TableView.qml b/example/qml/page/New_TableView.qml deleted file mode 100644 index 0bef204a..00000000 --- a/example/qml/page/New_TableView.qml +++ /dev/null @@ -1,263 +0,0 @@ -import QtQuick 2.15 -import FluentUI 1.0 -import "../component" - -FluPage{ - title:"表格测试" - TableView{ - columnSource: [ - { - title: "全选", - dataIndex: 'patientsex', - width:60, - readOnly:true, - position: 0, - delegate: com_checkbox, - headerDelegate: com_header_checkbox, - frozen: true - }, - - { - title: "检测日期", - dataIndex: 'testdate', - readOnly:true, - // width:150, - // delegate: com_action - }, - { - title: "条码号", - dataIndex: 'barcode', - width:80, - readOnly:true, - position: 0, - movable: false, - frozen: true - // delegate: com_checkbox, - // headerDelegate: com_header_checkbox - }, - { - title: "样本号", - dataIndex: 'sampleid', - width:100, - position: 1, - minimumWidth:100, - maximumWidth:100, - }, - { - title: "姓名", - dataIndex: 'patientname', - width:220, - minimumWidth:100, - maximumWidth:250 - }, - { - title:"操作", - dataIndex:"", - delegate:com_action, - frozen: true, - width: 250 - }, - { - title: "头像", - dataIndex: 'imageurl', - width:120, - minimumWidth:80, - maximumWidth:250, - delegate:com_avatar, - frozen: true - }, - { - title: "性别", - dataIndex: 'patientsex', - width:130, - minimumWidth:50, - maximumWidth:250, - // delegate:com_avatar - }, - - { - title: "年龄", - dataIndex: 'patientage', - width:100, - minimumWidth:80, - maximumWidth:330 - }, - { - title: "电话", - dataIndex: 'patienttel', - width:200, - minimumWidth:100, - maximumWidth:300, - editMultiline: true - }, - { - title: "身份证号", - dataIndex: 'patientidenno', - width:120, - minimumWidth:100, - maximumWidth:250 - }, - { - title: "检测项目", - dataIndex: 'hisitemnamelist', - width:120, - minimumWidth:100, - maximumWidth:250 - }, - { - title: "开单科室", - dataIndex: 'deptname', - width:150, - minimumWidth:100, - maximumWidth:250 - }, - { - title: "开单医生", - dataIndex: 'doctorname', - width:140, - minimumWidth:100, - maximumWidth:250 - } - , - { - title: "接收时间", - dataIndex: 'incepttime', - width:120, - minimumWidth:100, - maximumWidth:250 - }, - { - title: "核收时间", - dataIndex: 'accepttime', - width:220, - minimumWidth:100, - maximumWidth:250 - } - ] - model: ListModel{ - id: customModel - } - } - Component.onCompleted: { - // generateTestData(1000) // 生成100条测试数据 - for (var i = 0; i < 100000; i++) { - customModel.append(generateTestData(i)) - } - // uvRecord.setProperty() - } - Component{ - id:com_avatar - Item{ - anchors.fill: parent - FluClip{ - anchors.centerIn: parent - width: Math.min(parent.width,parent.height) - height: width - radius: [width/2,width/2,width/2,width/2] - Image{ - anchors.fill: parent - source: display - sourceSize: Qt.size(80,80) - fillMode: Image.PreserveAspectFit - } - } - } - } - Component { - id: com_checkbox - Item{ - FluCheckBox { - width: 15 - height: 15 - anchors.centerIn: parent - } - } - } - Component { - id: com_header_checkbox - Item{ - FluCheckBox { - width: 15 - height: 15 - anchors.centerIn: parent - } - } - } - Component{ - id: com_action - Item{ - Row{ - anchors.centerIn: parent - FluTextButton{ - text:"插入" - onClicked: { - // uvRecord.insertRecord(row) - uvRecord.insert(row,generateTestData(row)) - } - } - FluTextButton{ - text:"上移" - onClicked:{ - if (row > 0) { - uvRecord.move(row, row - 1, 1) - } - } - } - FluTextButton{ - text:"下移" - onClicked:{ - if (row < uvRecord.rowCount() - 1) { - uvRecord.move(row, row + 2, 1) // 注意这里是 row + 2 - } - } - } - FluTextButton{ - text:"查看" - onClicked: { - showSuccess(JSON.stringify(control.model.get(row))) - } - } - FluTextButton{ - text:"删除" - onClicked: { - uvRecord.remove(row) - } - } - } - } - } - - function generateTestData(i) { - var sexes = ["男", "女"] - var departments = ["内科", "外科", "儿科", "妇科", "眼科"] - var doctors = ["张医生", "李医生", "王医生", "刘医生", "陈医生"] - var images = [ - "qrc:/res/image/pages/exchange.png", - "qrc:/res/image/pages/nuclear.png", - "qrc:/res/image/pages/ocr.png", - "qrc:/res/image/pages/room-temperature.png", - "qrc:/res/image/pages/rt-pcr-machine.png" - ] - return { - testdate: new Date().toLocaleDateString(), - barcode: "BC" + (1000000 + i).toString(), - sampleid: "S" + (100000 + i).toString(), - patientname: "患者" + (i + 1), - patientsex: sexes[Math.floor(Math.random() * sexes.length)], - patientage: Math.floor(Math.random() * 80 + 1) + "岁", - patienttel: "1" + Math.floor(Math.random() * 9000000000 + 1000000000), - patientidenno: (310000000000000000 + i).toString(), - hisitemnamelist: "项目1,项目2,项目3", - deptname: departments[Math.floor(Math.random() * departments.length)], - doctorname: doctors[Math.floor(Math.random() * doctors.length)], - incepttime: new Date().toLocaleString(), - accepttime: new Date().toLocaleString(), - imageurl: images[Math.floor(Math.random() * images.length)], - _minimumHeight: 42, - _maximumHeight: 800, - height: 42 - } - - } - -} From 50b89e7eb2dd44814891dd535a24bae5e2c1ed55 Mon Sep 17 00:00:00 2001 From: jeffrey0326 <547913081@qq.com> Date: Wed, 21 Aug 2024 22:50:43 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8Dwin11=E8=AE=BE=E7=BD=AE=E6=95=88?= =?UTF-8?q?=E6=9E=9C=E5=B4=A9=E6=BA=83=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/FluFrameless.cpp | 141 ++++++++++++++++++------------------------- 1 file changed, 58 insertions(+), 83 deletions(-) diff --git a/src/FluFrameless.cpp b/src/FluFrameless.cpp index bed322c7..be2f239d 100644 --- a/src/FluFrameless.cpp +++ b/src/FluFrameless.cpp @@ -84,14 +84,57 @@ static inline QByteArray qtNativeEventType() { return result; } -static inline bool isCompositionEnabled() { - HMODULE module = ::LoadLibraryW(L"dwmapi.dll"); +static inline bool initializeFunctionPointers() { + HMODULE module = LoadLibraryW(L"dwmapi.dll"); if (module) { - BOOL composition_enabled = false; - pDwmIsCompositionEnabled = reinterpret_cast(::GetProcAddress(module, "DwmIsCompositionEnabled")); - if (pDwmIsCompositionEnabled) { - pDwmIsCompositionEnabled(&composition_enabled); + if (!pDwmSetWindowAttribute) { + pDwmSetWindowAttribute = reinterpret_cast( + GetProcAddress(module, "DwmSetWindowAttribute")); + if (!pDwmSetWindowAttribute) { + return false; + } } + if (!pDwmExtendFrameIntoClientArea) { + pDwmExtendFrameIntoClientArea = reinterpret_cast( + GetProcAddress(module, "DwmExtendFrameIntoClientArea")); + if (!pDwmExtendFrameIntoClientArea) { + return false; + } + } + if (!pDwmIsCompositionEnabled) { + pDwmIsCompositionEnabled = reinterpret_cast( + ::GetProcAddress(module, "DwmIsCompositionEnabled")); + if (!pDwmIsCompositionEnabled) { + return false; + } + } + if (!pDwmEnableBlurBehindWindow) { + pDwmEnableBlurBehindWindow = + reinterpret_cast( + GetProcAddress(module, "DwmEnableBlurBehindWindow")); + if (!pDwmEnableBlurBehindWindow) { + return false; + } + } + if (!pSetWindowCompositionAttribute) { + HMODULE user32 = LoadLibraryW(L"user32.dll"); + if (!user32) { + return false; + } + pSetWindowCompositionAttribute = reinterpret_cast( + GetProcAddress(user32, "SetWindowCompositionAttribute")); + if (!pSetWindowCompositionAttribute) { + return false; + } + } + } + return true; +} + +static inline bool isCompositionEnabled() { + if(initializeFunctionPointers()){ + BOOL composition_enabled = false; + pDwmIsCompositionEnabled(&composition_enabled); return composition_enabled; } return false; @@ -99,50 +142,24 @@ static inline bool isCompositionEnabled() { static inline void setShadow(HWND hwnd) { const MARGINS shadow = {1, 0, 0, 0}; - HMODULE module = LoadLibraryW(L"dwmapi.dll"); - if (module) { - pDwmExtendFrameIntoClientArea = reinterpret_cast(GetProcAddress(module, "DwmExtendFrameIntoClientArea")); - if (pDwmExtendFrameIntoClientArea) { - pDwmExtendFrameIntoClientArea(hwnd, &shadow); - } + if (initializeFunctionPointers()) { + pDwmExtendFrameIntoClientArea(hwnd, &shadow); } } static inline bool setWindowDarkMode(HWND hwnd, const BOOL enable) { - if (!pDwmSetWindowAttribute) { - HMODULE module = LoadLibraryW(L"dwmapi.dll"); - if (module) { - pDwmSetWindowAttribute = reinterpret_cast( - GetProcAddress(module, "DwmSetWindowAttribute")); - } - if (!pDwmSetWindowAttribute) { - return false; - } + if (!initializeFunctionPointers()) { + return false; } return bool(pDwmSetWindowAttribute(hwnd, 20, &enable, sizeof(BOOL))); } static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &enable) { static constexpr const MARGINS extendedMargins = {-1, -1, -1, -1}; - HMODULE module = LoadLibraryW(L"dwmapi.dll"); - if (module) { - pDwmExtendFrameIntoClientArea = reinterpret_cast( - GetProcAddress(module, "DwmExtendFrameIntoClientArea")); - if (!pDwmExtendFrameIntoClientArea) { - return false; - } - } if (key == QStringLiteral("mica")) { - if (!isWin11OrGreater()) { + if (!isWin11OrGreater() || !initializeFunctionPointers()) { return false; } - if(module && !pDwmSetWindowAttribute){ - pDwmSetWindowAttribute = reinterpret_cast( - GetProcAddress(module, "DwmSetWindowAttribute")); - if (!pDwmSetWindowAttribute) { - return false; - } - } if (enable) { pDwmExtendFrameIntoClientArea(hwnd, &extendedMargins); if (isWin1122H2OrGreater()) { @@ -167,16 +184,9 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en } if (key == QStringLiteral("mica-alt")) { - if (!isWin1122H2OrGreater()) { + if (!isWin1122H2OrGreater() || !initializeFunctionPointers()) { return false; } - if(module && !pDwmSetWindowAttribute){ - pDwmSetWindowAttribute = reinterpret_cast( - GetProcAddress(module, "DwmSetWindowAttribute")); - if (!pDwmSetWindowAttribute) { - return false; - } - } if (enable) { pDwmExtendFrameIntoClientArea(hwnd, &extendedMargins); const DWORD backdropType = _DWMSBT_TABBEDWINDOW; @@ -191,19 +201,11 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en } if (key == QStringLiteral("acrylic")) { - if (!isWin11OrGreater()) { + if (!isWin11OrGreater() || !initializeFunctionPointers()) { return false; } - if(module && !pDwmSetWindowAttribute){ - pDwmSetWindowAttribute = reinterpret_cast( - GetProcAddress(module, "DwmSetWindowAttribute")); - if (!pDwmSetWindowAttribute) { - return false; - } - } if (enable) { - MARGINS margins{-1, -1, -1, -1}; - pDwmExtendFrameIntoClientArea(hwnd, &margins); + pDwmExtendFrameIntoClientArea(hwnd, &extendedMargins); DWORD system_backdrop_type = _DWMSBT_TRANSIENTWINDOW; pDwmSetWindowAttribute(hwnd, 38, &system_backdrop_type, sizeof(DWORD)); } else { @@ -216,19 +218,11 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en } if (key == QStringLiteral("dwm-blur")) { - if (isWin7Only() && !isCompositionEnabled()) { + if ((isWin7Only() && !isCompositionEnabled()) || !initializeFunctionPointers()) { return false; } BOOL isDark = FluTheme::getInstance()->dark(); setWindowDarkMode(hwnd, isDark && enable); - if (isWin8OrGreater() && !pSetWindowCompositionAttribute) { - HMODULE module = LoadLibraryW(L"user32.dll"); - pSetWindowCompositionAttribute = reinterpret_cast( - GetProcAddress(module, "SetWindowCompositionAttribute")); - if (!pSetWindowCompositionAttribute) { - return false; - } - } if (enable) { if (isWin8OrGreater()) { ACCENT_POLICY policy{}; @@ -243,15 +237,6 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en DWM_BLURBEHIND bb{}; bb.fEnable = TRUE; bb.dwFlags = DWM_BB_ENABLE; - if (!pDwmEnableBlurBehindWindow) { - HMODULE module = LoadLibraryW(L"user32.dll"); - pDwmEnableBlurBehindWindow = - reinterpret_cast( - GetProcAddress(module, "DwmEnableBlurBehindWindowFunc")); - if (!pDwmEnableBlurBehindWindow) { - return false; - } - } pDwmEnableBlurBehindWindow(hwnd, &bb); } } else { @@ -268,21 +253,11 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en DWM_BLURBEHIND bb{}; bb.fEnable = FALSE; bb.dwFlags = DWM_BB_ENABLE; - if (!pDwmEnableBlurBehindWindow) { - HMODULE module = LoadLibraryW(L"user32.dll"); - pDwmEnableBlurBehindWindow = - reinterpret_cast( - GetProcAddress(module, "DwmEnableBlurBehindWindowFunc")); - if (!pDwmEnableBlurBehindWindow) { - return false; - } - } pDwmEnableBlurBehindWindow(hwnd, &bb); } } return true; } - return false; } From 4b49fb1340aa2c2de77f203170ce663917dcc290 Mon Sep 17 00:00:00 2001 From: jeffrey0326 <547913081@qq.com> Date: Sat, 24 Aug 2024 19:22:42 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=80=82=E5=BA=94?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=A0=87=E9=A2=98=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/FluFrameless.cpp | 112 ++++++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 50 deletions(-) diff --git a/src/FluFrameless.cpp b/src/FluFrameless.cpp index be2f239d..2bf490f6 100644 --- a/src/FluFrameless.cpp +++ b/src/FluFrameless.cpp @@ -284,6 +284,7 @@ FluFrameless::FluFrameless(QQuickItem *parent) : QQuickItem{parent} { _topmost = false; _disabled = false; _effect = "normal"; + _effective = false; _isWindows11OrGreater = FluTools::getInstance()->isWindows11OrGreater(); } @@ -294,58 +295,12 @@ FluFrameless::~FluFrameless() = default; } void FluFrameless::componentComplete() { - if (_disabled) { - return; - } - int w = window()->width(); - int h = window()->height(); - _current = window()->winId(); - window()->setFlags((window()->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint); - if (!_fixSize) { - window()->setFlag(Qt::WindowMaximizeButtonHint); - } - window()->installEventFilter(this); - QGuiApplication::instance()->installNativeEventFilter(this); - if (_maximizeButton) { - setHitTestVisible(_maximizeButton); - } - if (_minimizedButton) { - setHitTestVisible(_minimizedButton); - } - if (_closeButton) { - setHitTestVisible(_closeButton); - } -#ifdef Q_OS_WIN -#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3)) - qWarning()<<"Qt's own frameless bug, currently only exist in 6.5.3, please use other versions"; -#endif HWND hwnd = reinterpret_cast(window()->winId()); - DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE); -# if (QT_VERSION == QT_VERSION_CHECK(6, 7, 2)) - style &= ~(WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU); -# endif - if (_fixSize) { - ::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);; - for (int i = 0; i <= QGuiApplication::screens().count() - 1; ++i) { - connect(QGuiApplication::screens().at(i), &QScreen::logicalDotsPerInchChanged, this, [=] { - SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED); - }); - } - } else { - ::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION); - } - SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - connect(window(), &QQuickWindow::screenChanged, this, [hwnd] { - ::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER); - ::RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW); - }); - if (!window()->property("_hideShadow").toBool()) { - setShadow(hwnd); - } +#ifdef Q_OS_WIN if (isWin11OrGreater()) { availableEffects({"mica", "mica-alt", "acrylic", "dwm-blur", "normal"}); } else if (isWin7Only()) { - availableEffects({"dwm-blur","normal"}); + availableEffects({"dwm-blur", "normal"}); } if (!_effect.isEmpty()) { effective(setWindowEffect(hwnd, _effect, true)); @@ -378,7 +333,64 @@ void FluFrameless::componentComplete() { setWindowDarkMode(hwnd, FluTheme::getInstance()->dark()); } }); + if (_disabled) { + return; + } +# if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3)) + qWarning() + << "Qt's own frameless bug, currently only exist in 6.5.3, please use other versions"; +# endif + DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE); +# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + style &= ~(WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU); +# endif + if (_fixSize) { + ::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION); + ; + for (int i = 0; i <= QGuiApplication::screens().count() - 1; ++i) { + connect( + QGuiApplication::screens().at(i), &QScreen::logicalDotsPerInchChanged, this, [=] { + SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, + SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED); + }); + } + } else { + ::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION); + } + SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, + SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); + connect(window(), &QQuickWindow::screenChanged, this, [hwnd] { + ::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | + SWP_NOOWNERZORDER); + ::RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW); + }); + if (!window()->property("_hideShadow").toBool()) { + setShadow(hwnd); + } #endif + if (_disabled) { + return; + } + int w = window()->width(); + int h = window()->height(); + _current = window()->winId(); + window()->setFlags((window()->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint); + if (!_fixSize) { + window()->setFlag(Qt::WindowMaximizeButtonHint); + } + window()->installEventFilter(this); + QGuiApplication::instance()->installNativeEventFilter(this); + if (_maximizeButton) { + setHitTestVisible(_maximizeButton); + } + if (_minimizedButton) { + setHitTestVisible(_minimizedButton); + } + if (_closeButton) { + setHitTestVisible(_closeButton); + } + auto appBarHeight = _appbar->height(); h = qRound(h + appBarHeight); if (_fixSize) { @@ -393,6 +405,8 @@ void FluFrameless::componentComplete() { _setWindowTopmost(topmost()); }); _setWindowTopmost(topmost()); + _setMaximizeHovered(false); + _setMaximizePressed(false); } [[maybe_unused]] bool FluFrameless::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) { @@ -439,8 +453,6 @@ void FluFrameless::componentComplete() { _setMaximizeHovered(true); return true; } - _setMaximizeHovered(false); - _setMaximizePressed(false); } *result = 0; POINT nativeGlobalPos{GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; From a26f643ba37c8e55688de74d55b846000c0d358a Mon Sep 17 00:00:00 2001 From: jeffrey0326 <547913081@qq.com> Date: Sat, 24 Aug 2024 19:27:54 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=80=82=E5=BA=94?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=A0=87=E9=A2=98=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/FluFrameless.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FluFrameless.cpp b/src/FluFrameless.cpp index 2bf490f6..5b66dc21 100644 --- a/src/FluFrameless.cpp +++ b/src/FluFrameless.cpp @@ -295,8 +295,8 @@ FluFrameless::~FluFrameless() = default; } void FluFrameless::componentComplete() { - HWND hwnd = reinterpret_cast(window()->winId()); #ifdef Q_OS_WIN + HWND hwnd = reinterpret_cast(window()->winId()); if (isWin11OrGreater()) { availableEffects({"mica", "mica-alt", "acrylic", "dwm-blur", "normal"}); } else if (isWin7Only()) { From 5ea71e2c1af5d7d06f4342eec45d35648b1b3342 Mon Sep 17 00:00:00 2001 From: jeffrey0326 <547913081@qq.com> Date: Tue, 27 Aug 2024 17:27:17 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E5=88=87=E6=8D=A2=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E4=BC=9A=E9=97=AA=E4=B8=80=E4=B8=8B=E8=BE=B9=E6=A1=86=EF=BC=8C?= =?UTF-8?q?=E9=9C=80=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/example_en_US.ts | 11 +- example/example_zh_CN.ts | 11 +- example/qml/page/T_Theme.qml | 11 ++ src/FluFrameless.cpp | 230 +++++++++++++++++++---------------- src/FluFrameless.h | 1 + 5 files changed, 155 insertions(+), 109 deletions(-) diff --git a/example/example_en_US.ts b/example/example_en_US.ts index 70fa49cb..d95df3a9 100644 --- a/example/example_en_US.ts +++ b/example/example_en_US.ts @@ -2261,21 +2261,26 @@ Some contents... + Rounded Window + + + + Open Blur Window - + window tintOpacity - + window blurRadius - + window effect diff --git a/example/example_zh_CN.ts b/example/example_zh_CN.ts index 6214065e..28aaae56 100644 --- a/example/example_zh_CN.ts +++ b/example/example_zh_CN.ts @@ -2443,21 +2443,26 @@ Some contents... + Rounded Window + + + + Open Blur Window - + window tintOpacity - + window blurRadius - + window effect diff --git a/example/qml/page/T_Theme.qml b/example/qml/page/T_Theme.qml index 9a01f989..2398ef53 100644 --- a/example/qml/page/T_Theme.qml +++ b/example/qml/page/T_Theme.qml @@ -119,6 +119,17 @@ FluScrollablePage{ FluTheme.animationEnabled = !FluTheme.animationEnabled } } + FluText{ + text: qsTr("Rounded Window") + Layout.topMargin: 20 + } + FluToggleSwitch{ + Layout.topMargin: 5 + checked: window.roundCornerEnable + onClicked: { + window.roundCornerEnable = !window.roundCornerEnable + } + } FluText{ text: qsTr("Open Blur Window") Layout.topMargin: 20 diff --git a/src/FluFrameless.cpp b/src/FluFrameless.cpp index 5b66dc21..94bc49a5 100644 --- a/src/FluFrameless.cpp +++ b/src/FluFrameless.cpp @@ -76,7 +76,7 @@ static inline bool isWin10Only() { static inline bool isWin7Only() { RTL_OSVERSIONINFOW rovi = GetRealOSVersion(); - return rovi.dwMajorVersion = 7; + return rovi.dwMajorVersion == 7; } static inline QByteArray qtNativeEventType() { @@ -109,9 +109,8 @@ static inline bool initializeFunctionPointers() { } } if (!pDwmEnableBlurBehindWindow) { - pDwmEnableBlurBehindWindow = - reinterpret_cast( - GetProcAddress(module, "DwmEnableBlurBehindWindow")); + pDwmEnableBlurBehindWindow = reinterpret_cast( + GetProcAddress(module, "DwmEnableBlurBehindWindow")); if (!pDwmEnableBlurBehindWindow) { return false; } @@ -132,7 +131,7 @@ static inline bool initializeFunctionPointers() { } static inline bool isCompositionEnabled() { - if(initializeFunctionPointers()){ + if (initializeFunctionPointers()) { BOOL composition_enabled = false; pDwmIsCompositionEnabled(&composition_enabled); return composition_enabled; @@ -145,6 +144,25 @@ static inline void setShadow(HWND hwnd) { if (initializeFunctionPointers()) { pDwmExtendFrameIntoClientArea(hwnd, &shadow); } + if(isWin7Only()){ + SetClassLong(hwnd, GCL_STYLE, GetClassLong(hwnd, GCL_STYLE) | CS_DROPSHADOW); + } +} + +static void setWindowRoundCorners(HWND hwnd) { + const MARGINS shadow = {-15}; + if (initializeFunctionPointers()) { + pDwmExtendFrameIntoClientArea(hwnd, &shadow); + } + RECT rect; + GetWindowRect(hwnd, &rect); + int width = rect.right - rect.left; + int height = rect.bottom - rect.top; + const int radius = 15; + HRGN hRgn = CreateRoundRectRgn(0, 0, width + 1, height + 1, radius, radius); + SetWindowRgn(hwnd, hRgn, TRUE); + SetClassLong(hwnd, GCL_STYLE, GetClassLong(hwnd, GCL_STYLE) | CS_DROPSHADOW); + DeleteObject(hRgn); } static inline bool setWindowDarkMode(HWND hwnd, const BOOL enable) { @@ -375,7 +393,8 @@ void FluFrameless::componentComplete() { int w = window()->width(); int h = window()->height(); _current = window()->winId(); - window()->setFlags((window()->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint); + window()->setFlags((window()->flags()) | Qt::CustomizeWindowHint | + Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint); if (!_fixSize) { window()->setFlag(Qt::WindowMaximizeButtonHint); } @@ -390,7 +409,6 @@ void FluFrameless::componentComplete() { if (_closeButton) { setHitTestVisible(_closeButton); } - auto appBarHeight = _appbar->height(); h = qRound(h + appBarHeight); if (_fixSize) { @@ -401,15 +419,14 @@ void FluFrameless::componentComplete() { window()->setMaximumHeight(window()->maximumHeight() + appBarHeight); } window()->resize(QSize(w, h)); - connect(this, &FluFrameless::topmostChanged, this, [this] { - _setWindowTopmost(topmost()); - }); + connect(this, &FluFrameless::topmostChanged, this, [this] { _setWindowTopmost(topmost()); }); _setWindowTopmost(topmost()); - _setMaximizeHovered(false); - _setMaximizePressed(false); + _setMaximizeHovered(false); + _setMaximizePressed(false); } -[[maybe_unused]] bool FluFrameless::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) { +[[maybe_unused]] bool FluFrameless::nativeEventFilter(const QByteArray &eventType, void *message, + QT_NATIVE_EVENT_RESULT_TYPE *result) { #ifdef Q_OS_WIN if ((eventType != qtNativeEventType()) || !message) { return false; @@ -430,16 +447,17 @@ void FluFrameless::componentComplete() { auto *wp = reinterpret_cast(lParam); if (wp != nullptr && (wp->flags & SWP_NOSIZE) == 0) { wp->flags |= SWP_NOCOPYBITS; - *result = static_cast(::DefWindowProcW(hwnd, uMsg, wParam, lParam)); + *result = static_cast( + ::DefWindowProcW(hwnd, uMsg, wParam, lParam)); return true; } return false; } else if (uMsg == WM_NCCALCSIZE && wParam == TRUE) { bool isMaximum = ::IsZoomed(hwnd); if (isMaximum) { - window()->setProperty("__margins",7); - }else{ - window()->setProperty("__margins",0); + window()->setProperty("__margins", 7); + } else { + window()->setProperty("__margins", 0); } _setMaximizeHovered(false); *result = WVR_REDRAW; @@ -499,21 +517,23 @@ void FluFrameless::componentComplete() { *result = FALSE; return false; } else if (uMsg == WM_NCACTIVATE) { - if (effective() || (!effect().isEmpty() && _currentEffect!="normal")) { + if (effective() || (!effect().isEmpty() && effect() != "normal")) { return false; } *result = TRUE; return true; } else if (_isWindows11OrGreater && (uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN)) { if (_hitMaximizeButton()) { - QMouseEvent event = QMouseEvent(QEvent::MouseButtonPress, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + QMouseEvent event = QMouseEvent(QEvent::MouseButtonPress, QPoint(), QPoint(), + Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QGuiApplication::sendEvent(_maximizeButton, &event); _setMaximizePressed(true); return true; } } else if (_isWindows11OrGreater && (uMsg == WM_NCLBUTTONUP || uMsg == WM_NCRBUTTONUP)) { if (_hitMaximizeButton()) { - QMouseEvent event = QMouseEvent(QEvent::MouseButtonRelease, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + QMouseEvent event = QMouseEvent(QEvent::MouseButtonRelease, QPoint(), QPoint(), + Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QGuiApplication::sendEvent(_maximizeButton, &event); _setMaximizePressed(false); return true; @@ -568,7 +588,8 @@ void FluFrameless::_showSystemMenu(QPoint point) { return; } const QPoint origin = screen->geometry().topLeft(); - auto nativePos = QPointF(QPointF(point - origin) * window()->devicePixelRatio()).toPoint() + origin; + auto nativePos = + QPointF(QPointF(point - origin) * window()->devicePixelRatio()).toPoint() + origin; HWND hwnd = reinterpret_cast(window()->winId()); auto hMenu = ::GetSystemMenu(hwnd, FALSE); if (_isMaximized() || _isFullScreen()) { @@ -585,8 +606,10 @@ void FluFrameless::_showSystemMenu(QPoint point) { ::EnableMenuItem(hMenu, SC_SIZE, MFS_DISABLED); ::EnableMenuItem(hMenu, SC_MAXIMIZE, MFS_DISABLED); } - const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), nativePos.x(), - nativePos.y(), 0, hwnd, nullptr); + const int result = ::TrackPopupMenu( + hMenu, + (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), + nativePos.x(), nativePos.y(), 0, hwnd, nullptr); if (result) { ::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0); } @@ -627,27 +650,27 @@ void FluFrameless::_setMaximizeHovered(bool val) { void FluFrameless::_updateCursor(int edges) { switch (edges) { - case 0: - window()->setCursor(Qt::ArrowCursor); - break; - case Qt::LeftEdge: - case Qt::RightEdge: - window()->setCursor(Qt::SizeHorCursor); - break; - case Qt::TopEdge: - case Qt::BottomEdge: - window()->setCursor(Qt::SizeVerCursor); - break; - case Qt::LeftEdge | Qt::TopEdge: - case Qt::RightEdge | Qt::BottomEdge: - window()->setCursor(Qt::SizeFDiagCursor); - break; - case Qt::RightEdge | Qt::TopEdge: - case Qt::LeftEdge | Qt::BottomEdge: - window()->setCursor(Qt::SizeBDiagCursor); - break; - default: - break; + case 0: + window()->setCursor(Qt::ArrowCursor); + break; + case Qt::LeftEdge: + case Qt::RightEdge: + window()->setCursor(Qt::SizeHorCursor); + break; + case Qt::TopEdge: + case Qt::BottomEdge: + window()->setCursor(Qt::SizeVerCursor); + break; + case Qt::LeftEdge | Qt::TopEdge: + case Qt::RightEdge | Qt::BottomEdge: + window()->setCursor(Qt::SizeFDiagCursor); + break; + case Qt::RightEdge | Qt::TopEdge: + case Qt::LeftEdge | Qt::BottomEdge: + window()->setCursor(Qt::SizeBDiagCursor); + break; + default: + break; } } @@ -692,79 +715,80 @@ void FluFrameless::_setWindowTopmost(bool topmost) { ::SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } #else - window()->setFlag(Qt::WindowStaysOnTopHint,topmost); + window()->setFlag(Qt::WindowStaysOnTopHint, topmost); #endif } bool FluFrameless::eventFilter(QObject *obj, QEvent *ev) { #ifndef Q_OS_WIN switch (ev->type()) { - case QEvent::MouseButtonPress: - if(_edges!=0){ - QMouseEvent *event = static_cast(ev); - if(event->button() == Qt::LeftButton){ - _updateCursor(_edges); - window()->startSystemResize(Qt::Edges(_edges)); - } - }else{ - if(_hitAppBar()){ - qint64 clickTimer = QDateTime::currentMSecsSinceEpoch(); - qint64 offset = clickTimer - this->_clickTimer; - this->_clickTimer = clickTimer; - if(offset<300){ - if(_isMaximized()){ - showNormal(); - }else{ - showMaximized(); + case QEvent::MouseButtonPress: + if (_edges != 0) { + QMouseEvent *event = static_cast(ev); + if (event->button() == Qt::LeftButton) { + _updateCursor(_edges); + window()->startSystemResize(Qt::Edges(_edges)); + } + } else { + if (_hitAppBar()) { + qint64 clickTimer = QDateTime::currentMSecsSinceEpoch(); + qint64 offset = clickTimer - this->_clickTimer; + this->_clickTimer = clickTimer; + if (offset < 300) { + if (_isMaximized()) { + showNormal(); + } else { + showMaximized(); + } + } else { + window()->startSystemMove(); } - }else{ - window()->startSystemMove(); } } - } - break; - case QEvent::MouseButtonRelease: - _edges = 0; - break; - case QEvent::MouseMove: { - if(_isMaximized() || _isFullScreen()){ break; - } - if(_fixSize){ + case QEvent::MouseButtonRelease: + _edges = 0; break; - } - QMouseEvent *event = static_cast(ev); - QPoint p = -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) - event->pos(); -#else - event->position().toPoint(); -#endif - if(p.x() >= _margins && p.x() <= (window()->width() - _margins) && p.y() >= _margins && p.y() <= (window()->height() - _margins)){ - if(_edges != 0){ - _edges = 0; - _updateCursor(_edges); + case QEvent::MouseMove: { + if (_isMaximized() || _isFullScreen()) { + break; } + if (_fixSize) { + break; + } + QMouseEvent *event = static_cast(ev); + QPoint p = +# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + event->pos(); +# else + event->position().toPoint(); +# endif + if (p.x() >= _margins && p.x() <= (window()->width() - _margins) && p.y() >= _margins && + p.y() <= (window()->height() - _margins)) { + if (_edges != 0) { + _edges = 0; + _updateCursor(_edges); + } + break; + } + _edges = 0; + if (p.x() < _margins) { + _edges |= Qt::LeftEdge; + } + if (p.x() > (window()->width() - _margins)) { + _edges |= Qt::RightEdge; + } + if (p.y() < _margins) { + _edges |= Qt::TopEdge; + } + if (p.y() > (window()->height() - _margins)) { + _edges |= Qt::BottomEdge; + } + _updateCursor(_edges); break; } - _edges = 0; - if ( p.x() < _margins ) { - _edges |= Qt::LeftEdge; - } - if ( p.x() > (window()->width() - _margins) ) { - _edges |= Qt::RightEdge; - } - if ( p.y() < _margins ) { - _edges |= Qt::TopEdge; - } - if ( p.y() > (window()->height() - _margins) ) { - _edges |= Qt::BottomEdge; - } - _updateCursor(_edges); - break; - } - default: - break; + default: + break; } #endif return QObject::eventFilter(obj, ev); diff --git a/src/FluFrameless.h b/src/FluFrameless.h index 80897270..5e4047d5 100644 --- a/src/FluFrameless.h +++ b/src/FluFrameless.h @@ -162,6 +162,7 @@ private: void _setMaximizeHovered(bool val); + private: quint64 _current = 0; int _edges = 0; From 12300ef08124b0c8328c631df4a1948d0941bbc6 Mon Sep 17 00:00:00 2001 From: jeffrey0326 <547913081@qq.com> Date: Wed, 28 Aug 2024 14:04:50 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=B3=BB=E7=BB=9F=E6=A0=87=E9=A2=98=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/example_en_US.ts | 6 +- example/example_zh_CN.ts | 6 +- example/qml/page/T_Theme.qml | 44 +++++++------- src/FluFrameless.cpp | 107 +++++++++++++++++++---------------- 4 files changed, 87 insertions(+), 76 deletions(-) diff --git a/example/example_en_US.ts b/example/example_en_US.ts index 70fa49cb..c7b29f45 100644 --- a/example/example_en_US.ts +++ b/example/example_en_US.ts @@ -2265,17 +2265,17 @@ Some contents... - + window tintOpacity - + window blurRadius - + window effect diff --git a/example/example_zh_CN.ts b/example/example_zh_CN.ts index 6214065e..cf53d737 100644 --- a/example/example_zh_CN.ts +++ b/example/example_zh_CN.ts @@ -2447,17 +2447,17 @@ Some contents... - + window tintOpacity - + window blurRadius - + window effect diff --git a/example/qml/page/T_Theme.qml b/example/qml/page/T_Theme.qml index 9a01f989..8576750c 100644 --- a/example/qml/page/T_Theme.qml +++ b/example/qml/page/T_Theme.qml @@ -131,6 +131,28 @@ FluScrollablePage{ FluTheme.blurBehindWindowEnabled = !FluTheme.blurBehindWindowEnabled } } + FluText{ + text: qsTr("window effect") + Layout.topMargin: 20 + } + Row{ + spacing: 10 + Repeater{ + model: window.availableEffects + delegate: FluRadioButton{ + checked: window.effect === modelData + text: qsTr(`${modelData}`) + clickListener:function(){ + window.effect = modelData + if(window.effective){ + FluTheme.blurBehindWindowEnabled = false + toggle_blur.checked = Qt.binding( function() {return FluTheme.blurBehindWindowEnabled}) + } + } + } + + } + } FluText{ visible: FluTheme.blurBehindWindowEnabled || window.effect === "dwm-blur" text: qsTr("window tintOpacity") @@ -165,28 +187,6 @@ FluScrollablePage{ value = window.blurRadius } } - FluText{ - text: qsTr("window effect") - Layout.topMargin: 20 - } - Row{ - spacing: 10 - Repeater{ - model: window.availableEffects - delegate: FluRadioButton{ - checked: window.effect === modelData - text: qsTr(`${modelData}`) - clickListener:function(){ - window.effect = modelData - if(window.effective){ - FluTheme.blurBehindWindowEnabled = false - toggle_blur.checked = Qt.binding( function() {return FluTheme.blurBehindWindowEnabled}) - } - } - } - - } - } } } CodeExpander{ diff --git a/src/FluFrameless.cpp b/src/FluFrameless.cpp index be2f239d..0b23ff0b 100644 --- a/src/FluFrameless.cpp +++ b/src/FluFrameless.cpp @@ -76,7 +76,7 @@ static inline bool isWin10Only() { static inline bool isWin7Only() { RTL_OSVERSIONINFOW rovi = GetRealOSVersion(); - return rovi.dwMajorVersion = 7; + return rovi.dwMajorVersion == 7; } static inline QByteArray qtNativeEventType() { @@ -145,6 +145,9 @@ static inline void setShadow(HWND hwnd) { if (initializeFunctionPointers()) { pDwmExtendFrameIntoClientArea(hwnd, &shadow); } + if(isWin7Only()){ + SetClassLong(hwnd, GCL_STYLE, GetClassLong(hwnd, GCL_STYLE) | CS_DROPSHADOW); + } } static inline bool setWindowDarkMode(HWND hwnd, const BOOL enable) { @@ -284,6 +287,7 @@ FluFrameless::FluFrameless(QQuickItem *parent) : QQuickItem{parent} { _topmost = false; _disabled = false; _effect = "normal"; + _effective = false; _isWindows11OrGreater = FluTools::getInstance()->isWindows11OrGreater(); } @@ -291,60 +295,16 @@ FluFrameless::~FluFrameless() = default; [[maybe_unused]] void FluFrameless::onDestruction() { QGuiApplication::instance()->removeNativeEventFilter(this); + disconnect(FluTheme::getInstance(), &FluTheme::darkChanged, this, nullptr); + disconnect(window(), &QQuickWindow::screenChanged, this, nullptr); } void FluFrameless::componentComplete() { - if (_disabled) { - return; - } - int w = window()->width(); - int h = window()->height(); - _current = window()->winId(); - window()->setFlags((window()->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint); - if (!_fixSize) { - window()->setFlag(Qt::WindowMaximizeButtonHint); - } - window()->installEventFilter(this); - QGuiApplication::instance()->installNativeEventFilter(this); - if (_maximizeButton) { - setHitTestVisible(_maximizeButton); - } - if (_minimizedButton) { - setHitTestVisible(_minimizedButton); - } - if (_closeButton) { - setHitTestVisible(_closeButton); - } #ifdef Q_OS_WIN -#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3)) - qWarning()<<"Qt's own frameless bug, currently only exist in 6.5.3, please use other versions"; -#endif HWND hwnd = reinterpret_cast(window()->winId()); - DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE); -# if (QT_VERSION == QT_VERSION_CHECK(6, 7, 2)) - style &= ~(WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU); -# endif - if (_fixSize) { - ::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);; - for (int i = 0; i <= QGuiApplication::screens().count() - 1; ++i) { - connect(QGuiApplication::screens().at(i), &QScreen::logicalDotsPerInchChanged, this, [=] { - SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED); - }); - } - } else { - ::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION); - } - SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - connect(window(), &QQuickWindow::screenChanged, this, [hwnd] { - ::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER); - ::RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW); - }); - if (!window()->property("_hideShadow").toBool()) { - setShadow(hwnd); - } if (isWin11OrGreater()) { availableEffects({"mica", "mica-alt", "acrylic", "dwm-blur", "normal"}); - } else if (isWin7Only()) { + } else { availableEffects({"dwm-blur","normal"}); } if (!_effect.isEmpty()) { @@ -378,6 +338,57 @@ void FluFrameless::componentComplete() { setWindowDarkMode(hwnd, FluTheme::getInstance()->dark()); } }); +#endif + if (_disabled) { + return; + } + int w = window()->width(); + int h = window()->height(); + _current = window()->winId(); + window()->setFlags((window()->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint); + if (!_fixSize) { + window()->setFlag(Qt::WindowMaximizeButtonHint); + } + window()->installEventFilter(this); + QGuiApplication::instance()->installNativeEventFilter(this); + if (_maximizeButton) { + setHitTestVisible(_maximizeButton); + } + if (_minimizedButton) { + setHitTestVisible(_minimizedButton); + } + if (_closeButton) { + setHitTestVisible(_closeButton); + } +#ifdef Q_OS_WIN +#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3)) + qWarning()<<"Qt's own frameless bug, currently only exist in 6.5.3, please use other versions"; +#endif + if(!hwnd){ + hwnd = reinterpret_cast(window()->winId()); + } + DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE); +# if (QT_VERSION == QT_VERSION_CHECK(6, 7, 2)) + style &= ~(WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU); +# endif + if (_fixSize) { + ::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);; + for (int i = 0; i <= QGuiApplication::screens().count() - 1; ++i) { + connect(QGuiApplication::screens().at(i), &QScreen::logicalDotsPerInchChanged, this, [=] { + SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED); + }); + } + } else { + ::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION); + } + SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); + connect(window(), &QQuickWindow::screenChanged, this, [hwnd] { + ::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER); + ::RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW); + }); + if (!window()->property("_hideShadow").toBool()) { + setShadow(hwnd); + } #endif auto appBarHeight = _appbar->height(); h = qRound(h + appBarHeight); From 8f8a1a6124f6a1cf7b06fe32fe8aca3fe4c436e6 Mon Sep 17 00:00:00 2001 From: jeffrey0326 <547913081@qq.com> Date: Fri, 30 Aug 2024 23:34:01 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dgenerate-qmltypes?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=A9=BA=E7=99=BD=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CMakeLists.txt | 2 +- src/FluFrameless.cpp | 2 +- src/FluentUI.cpp | 60 +++-- src/Qt5/imports/FluentUI/plugins.qmltypes | 303 +++++++++++++++++++--- 4 files changed, 305 insertions(+), 62 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6440d12b..5cc51946 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -227,7 +227,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE if ((${QT_VERSION_MAJOR} LESS_EQUAL 6) AND (CMAKE_BUILD_TYPE MATCHES "Release")) find_program(QML_PLUGIN_DUMP NAMES qmlplugindump) add_custom_target(Script-Generate-QmlTypes - COMMAND ${QML_PLUGIN_DUMP} -nonrelocatable FluentUI 1.0 ${CMAKE_CURRENT_BINARY_DIR} > ${CMAKE_CURRENT_SOURCE_DIR}/Qt5/imports/FluentUI/plugins.qmltypes + COMMAND ${QML_PLUGIN_DUMP} -nonrelocatable -noinstantiate FluentUI 1.0 ${CMAKE_CURRENT_BINARY_DIR} > ${CMAKE_CURRENT_SOURCE_DIR}/Qt5/imports/FluentUI/plugins.qmltypes COMMENT "Generate qmltypes........." SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Qt5/imports/FluentUI/plugins.qmltypes WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/src/FluFrameless.cpp b/src/FluFrameless.cpp index 0b23ff0b..8c946884 100644 --- a/src/FluFrameless.cpp +++ b/src/FluFrameless.cpp @@ -498,10 +498,10 @@ void FluFrameless::componentComplete() { *result = FALSE; return false; } else if (uMsg == WM_NCACTIVATE) { + *result = TRUE; if (effective() || (!effect().isEmpty() && _currentEffect!="normal")) { return false; } - *result = TRUE; return true; } else if (_isWindows11OrGreater && (uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN)) { if (_hitMaximizeButton()) { diff --git a/src/FluentUI.cpp b/src/FluentUI.cpp index 00c6804d..de5569b4 100644 --- a/src/FluentUI.cpp +++ b/src/FluentUI.cpp @@ -162,31 +162,41 @@ void FluentUI::registerTypes(const char *uri) const { qmlRegisterUncreatableMetaObject(FluTimelineType::staticMetaObject, uri, major, minor, "FluTimelineType", "Access to enums & flags only"); qmlRegisterUncreatableMetaObject(FluSheetType::staticMetaObject, uri, major, minor, "FluSheetType", "Access to enums & flags only"); - qmlRegisterSingletonType(uri, major, minor, "FluApp", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QJSValue { - Q_UNUSED(engine) - return scriptEngine->newQObject(FluApp::getInstance()); - }); - qmlRegisterSingletonType(uri, major, minor, "FluColors", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QJSValue { - Q_UNUSED(engine) - return scriptEngine->newQObject(FluColors::getInstance()); - }); - qmlRegisterSingletonType(uri, major, minor, "FluTheme", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QJSValue { - Q_UNUSED(engine) - return scriptEngine->newQObject(FluTheme::getInstance()); - }); - qmlRegisterSingletonType(uri, major, minor, "FluTools", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QJSValue { - Q_UNUSED(engine) - return scriptEngine->newQObject(FluTools::getInstance()); - }); - qmlRegisterSingletonType(uri, major, minor, "FluTextStyle", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QJSValue { - Q_UNUSED(engine) - return scriptEngine->newQObject(FluTextStyle::getInstance()); - }); -// qmlRegisterSingletonInstance(uri, major, minor, "FluApp", FluApp::getInstance()); -// qmlRegisterSingletonInstance(uri, major, minor, "FluColors", FluColors::getInstance()); -// qmlRegisterSingletonInstance(uri, major, minor, "FluTheme", FluTheme::getInstance()); -// qmlRegisterSingletonInstance(uri, major, minor, "FluTools", FluTools::getInstance()); -// qmlRegisterSingletonInstance(uri, major, minor, "FluTextStyle", FluTextStyle::getInstance()); + qmlRegisterSingletonType(uri, major, minor, "FluApp", + [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { + Q_UNUSED(scriptEngine) + QObject *instance = FluApp::getInstance(); + engine->setObjectOwnership(instance, QQmlEngine::CppOwnership); + return instance; + }); + qmlRegisterSingletonType(uri, major, minor, "FluColors", + [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { + Q_UNUSED(scriptEngine) + QObject *instance = FluColors::getInstance(); + engine->setObjectOwnership(instance, QQmlEngine::CppOwnership); + return instance; + }); + qmlRegisterSingletonType(uri, major, minor, "FluTheme", + [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { + Q_UNUSED(scriptEngine) + QObject *instance = FluTheme::getInstance(); + engine->setObjectOwnership(instance, QQmlEngine::CppOwnership); + return instance; + }); + qmlRegisterSingletonType(uri, major, minor, "FluTools", + [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { + Q_UNUSED(scriptEngine) + QObject *instance = FluTools::getInstance(); + engine->setObjectOwnership(instance, QQmlEngine::CppOwnership); + return instance; + }); + qmlRegisterSingletonType(uri, major, minor, "FluTextStyle", + [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { + Q_UNUSED(scriptEngine) + QObject *instance = FluTextStyle::getInstance(); + engine->setObjectOwnership(instance, QQmlEngine::CppOwnership); + return instance; + }); qmlRegisterModule(uri, major, minor); #endif } diff --git a/src/Qt5/imports/FluentUI/plugins.qmltypes b/src/Qt5/imports/FluentUI/plugins.qmltypes index 5390b832..4dbcf477 100644 --- a/src/Qt5/imports/FluentUI/plugins.qmltypes +++ b/src/Qt5/imports/FluentUI/plugins.qmltypes @@ -4,7 +4,7 @@ import QtQuick.tooling 1.2 // It is used for QML tooling purposes only. // // This file was auto-generated by: -// 'qmlplugindump -nonrelocatable FluentUI 1.0 D:/QtProjects/build-FluentUI-Desktop_Qt_5_15_2_MSVC2019_64bit-Release/src' +// 'qmlplugindump -nonrelocatable -noinstantiate FluentUI 1.0 F:/FluentUI/build/Desktop_Qt_5_15_2_MSVC2019_32bit-Release/src' Module { dependencies: ["QtQuick 2.0"] @@ -151,8 +151,8 @@ Module { Property { name: "disabled"; type: "bool" } Property { name: "fixSize"; type: "bool" } Property { name: "effect"; type: "string" } - Property { name: "effective"; type: "bool" } - Property {name: "availableEffects"; type: "QVariant"} + Property { name: "effective"; type: "bool"; isReadonly: true } + Property { name: "availableEffects"; type: "QStringList"; isReadonly: true } Method { name: "showFullScreen" } Method { name: "showMaximized" } Method { name: "showMinimized" } @@ -399,7 +399,6 @@ Module { Property { name: "nativeText"; type: "bool" } Property { name: "animationEnabled"; type: "bool" } Property { name: "blurBehindWindowEnabled"; type: "bool" } - Property { name: "micaBackgroundColor"; type: "QColor" } } Component { name: "FluThemeType" @@ -673,12 +672,12 @@ Module { } } Component { - name: "Fluent_Icons" + name: "FluentIcons" exports: ["FluentUI/FluentIcons 1.0"] isCreatable: false exportMetaObjectRevisions: [0] Enum { - name: "Fluent_IconType" + name: "Type" values: { "GlobalNavButton": 59136, "Wifi": 59137, @@ -2453,6 +2452,240 @@ Module { Method { name: "clear" } Method { name: "invalidate" } } + Component { + name: "QmlQCustomPlot::Axis" + prototype: "QObject" + exports: ["FluentUI/Axis 1.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + Enum { + name: "TickerType" + values: { + "Fixed": 0, + "Log": 1, + "Pi": 2, + "Text": 3, + "DateTime": 4, + "Time": 5 + } + } + Property { name: "visible"; type: "bool" } + Property { name: "label"; type: "string" } + Property { name: "upper"; type: "float" } + Property { name: "lower"; type: "float" } + Property { name: "grid"; type: "QmlQCustomPlot::Grid"; isReadonly: true; isPointer: true } + Property { name: "ticker"; type: "QmlQCustomPlot::Ticker"; isReadonly: true; isPointer: true } + Signal { + name: "visibleChanged" + Parameter { type: "bool" } + } + Signal { + name: "labelChanged" + Parameter { type: "string" } + } + Signal { + name: "upperChanged" + Parameter { type: "float" } + } + Signal { + name: "lowerChanged" + Parameter { type: "float" } + } + Signal { + name: "gridChanged" + Parameter { type: "QmlQCustomPlot::Grid"; isPointer: true } + } + Signal { + name: "tickerChanged" + Parameter { type: "QmlQCustomPlot::Ticker"; isPointer: true } + } + Method { + name: "setTickerType" + Parameter { name: "type"; type: "TickerType" } + } + Method { + name: "setRange" + Parameter { name: "position"; type: "float" } + Parameter { name: "size"; type: "float" } + Parameter { name: "align"; type: "Qt::AlignmentFlag" } + } + Method { + name: "setRange" + Parameter { name: "lower"; type: "float" } + Parameter { name: "upper"; type: "float" } + } + } + Component { + name: "QmlQCustomPlot::BasePlot" + defaultProperty: "data" + prototype: "QQuickPaintedItem" + exports: ["FluentUI/BasePlot 1.0"] + exportMetaObjectRevisions: [0] + Property { name: "backgroundColor"; type: "QColor" } + Property { name: "xAxis"; type: "QmlQCustomPlot::Axis"; isReadonly: true; isPointer: true } + Property { name: "x1Axis"; type: "QmlQCustomPlot::Axis"; isReadonly: true; isPointer: true } + Property { name: "yAxis"; type: "QmlQCustomPlot::Axis"; isReadonly: true; isPointer: true } + Property { name: "y1Axis"; type: "QmlQCustomPlot::Axis"; isReadonly: true; isPointer: true } + Property { name: "graphs"; type: "QVariantMap"; isReadonly: true } + Signal { + name: "backgroundColorChanged" + Parameter { type: "QColor" } + } + Signal { + name: "xAxisChanged" + Parameter { type: "QmlQCustomPlot::Axis"; isPointer: true } + } + Signal { + name: "x1AxisChanged" + Parameter { type: "QmlQCustomPlot::Axis"; isPointer: true } + } + Signal { + name: "yAxisChanged" + Parameter { type: "QmlQCustomPlot::Axis"; isPointer: true } + } + Signal { + name: "y1AxisChanged" + Parameter { type: "QmlQCustomPlot::Axis"; isPointer: true } + } + Method { + name: "addGraph" + Parameter { name: "key"; type: "string" } + } + Method { + name: "removeGraph" + Parameter { name: "key"; type: "string" } + } + Method { + name: "rescaleAxes" + Parameter { name: "onlyVisiblePlottables"; type: "bool" } + } + Method { name: "rescaleAxes" } + } + Component { + name: "QmlQCustomPlot::Grid" + prototype: "QObject" + exports: ["FluentUI/PlotGrid 1.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + Enum { + name: "LineType" + values: { + "NoPen": 0, + "SolidLine": 1, + "DashLine": 2, + "DotLine": 3, + "DashDotLine": 4, + "DashDotDotLine": 5 + } + } + Property { name: "visible"; type: "bool" } + Property { name: "subVisible"; type: "bool" } + Property { name: "lineWidth"; type: "int" } + Property { name: "lineColor"; type: "QColor" } + Property { name: "lineType"; type: "LineType" } + Property { name: "subLineWidth"; type: "int" } + Property { name: "subLineColor"; type: "QColor" } + Property { name: "subLineType"; type: "LineType" } + Signal { + name: "visibleChanged" + Parameter { type: "bool" } + } + Signal { + name: "subVisibleChanged" + Parameter { type: "bool" } + } + Signal { + name: "lineWidthChanged" + Parameter { type: "int" } + } + Signal { + name: "lineColorChanged" + Parameter { type: "QColor" } + } + Signal { + name: "lineTypeChanged" + Parameter { type: "LineType" } + } + Signal { + name: "subLineWidthChanged" + Parameter { type: "int" } + } + Signal { + name: "subLineColorChanged" + Parameter { type: "QColor" } + } + Signal { + name: "subLineTypeChanged" + Parameter { type: "LineType" } + } + } + Component { + name: "QmlQCustomPlot::Ticker" + prototype: "QObject" + exports: ["FluentUI/Ticker 1.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + Property { name: "ticks"; type: "bool" } + Property { name: "subTicks"; type: "bool" } + Property { name: "tickCount"; type: "int" } + Property { name: "baseWidth"; type: "int" } + Property { name: "baseColor"; type: "QColor" } + Property { name: "tickColor"; type: "QColor" } + Property { name: "subTickColor"; type: "QColor" } + Signal { + name: "ticksChanged" + Parameter { type: "bool" } + } + Signal { + name: "subTicksChanged" + Parameter { type: "bool" } + } + Signal { + name: "tickCountChanged" + Parameter { type: "int" } + } + Signal { + name: "baseWidthChanged" + Parameter { type: "int" } + } + Signal { + name: "baseColorChanged" + Parameter { type: "QColor" } + } + Signal { + name: "tickColorChanged" + Parameter { type: "QColor" } + } + Signal { + name: "subTickColorChanged" + Parameter { type: "QColor" } + } + } + Component { + name: "QmlQCustomPlot::TimePlot" + defaultProperty: "data" + prototype: "QmlQCustomPlot::BasePlot" + exports: ["FluentUI/TimePlot 1.0"] + exportMetaObjectRevisions: [0] + Property { name: "plotTimeRangeInMilliseconds"; type: "int" } + Signal { + name: "plotTimeRangeInMillisecondsChanged" + Parameter { type: "int" } + } + Method { + name: "setTimeFormat" + Parameter { name: "format"; type: "string" } + } + Method { + name: "addCurrentTimeValue" + Parameter { name: "name"; type: "string" } + Parameter { name: "value"; type: "double" } + } + Method { + name: "addCurrentTimeValues" + Parameter { name: "values"; type: "QVariantMap" } + } + } Component { prototype: "QQuickItem" name: "FluentUI/FluAcrylic 1.0" @@ -2511,37 +2744,37 @@ Module { Property { name: "darkClickListener"; type: "QVariant" } Property { name: "buttonStayTop" - type: "FluIconButton_QMLTYPE_18" + type: "FluIconButton_QMLTYPE_19" isReadonly: true isPointer: true } Property { name: "buttonMinimize" - type: "FluIconButton_QMLTYPE_18" + type: "FluIconButton_QMLTYPE_19" isReadonly: true isPointer: true } Property { name: "buttonMaximize" - type: "FluIconButton_QMLTYPE_18" + type: "FluIconButton_QMLTYPE_19" isReadonly: true isPointer: true } Property { name: "buttonClose" - type: "FluIconButton_QMLTYPE_18" + type: "FluIconButton_QMLTYPE_19" isReadonly: true isPointer: true } Property { name: "buttonDark" - type: "FluIconButton_QMLTYPE_18" + type: "FluIconButton_QMLTYPE_19" isReadonly: true isPointer: true } Property { name: "layoutMacosButtons" - type: "FluLoader_QMLTYPE_16" + type: "FluLoader_QMLTYPE_18" isReadonly: true isPointer: true } @@ -3234,15 +3467,15 @@ Module { defaultProperty: "data" Property { name: "logo"; type: "QUrl" } Property { name: "title"; type: "string" } - Property { name: "items"; type: "FluObject_QMLTYPE_164"; isPointer: true } - Property { name: "footerItems"; type: "FluObject_QMLTYPE_164"; isPointer: true } + Property { name: "items"; type: "FluObject_QMLTYPE_130"; isPointer: true } + Property { name: "footerItems"; type: "FluObject_QMLTYPE_130"; isPointer: true } Property { name: "displayMode"; type: "int" } Property { name: "autoSuggestBox"; type: "QQmlComponent"; isPointer: true } Property { name: "actionItem"; type: "QQmlComponent"; isPointer: true } Property { name: "topPadding"; type: "int" } Property { name: "pageMode"; type: "int" } - Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_36"; isPointer: true } - Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_36"; isPointer: true } + Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_40"; isPointer: true } + Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_40"; isPointer: true } Property { name: "navCompactWidth"; type: "int" } Property { name: "navTopMargin"; type: "int" } Property { name: "cellHeight"; type: "int" } @@ -3250,13 +3483,13 @@ Module { Property { name: "hideNavAppBar"; type: "bool" } Property { name: "buttonMenu" - type: "FluIconButton_QMLTYPE_18" + type: "FluIconButton_QMLTYPE_19" isReadonly: true isPointer: true } Property { name: "buttonBack" - type: "FluIconButton_QMLTYPE_18" + type: "FluIconButton_QMLTYPE_19" isReadonly: true isPointer: true } @@ -3624,7 +3857,7 @@ Module { Method { name: "removeWindow" type: "QVariant" - Parameter { name: "window"; type: "QVariant" } + Parameter { name: "win"; type: "QVariant" } } Method { name: "exit" @@ -4142,6 +4375,9 @@ Module { Property { name: "fixSize"; type: "bool" } Property { name: "loadingItem"; type: "QQmlComponent"; isPointer: true } Property { name: "fitsAppBarWindows"; type: "bool" } + Property { name: "tintOpacity"; type: "QVariant" } + Property { name: "blurRadius"; type: "int" } + Property { name: "availableEffects"; type: "QVariant"; isReadonly: true } Property { name: "appBar"; type: "QQuickItem"; isPointer: true } Property { name: "backgroundColor"; type: "QColor" } Property { name: "stayTop"; type: "bool" } @@ -4154,13 +4390,8 @@ Module { Property { name: "autoVisible"; type: "bool" } Property { name: "autoCenter"; type: "bool" } Property { name: "autoDestroy"; type: "bool" } - - Property { name: "effect"; type: "string" } - Property { name: "effective"; type: "bool" } - Property { name: "blurRadius"; type: "int" } - Property { name: "tintOpacity"; type: "QVariant" } - Property { name: "useSystemAppBar"; type: "bool" } + Property { name: "__margins"; type: "int" } Property { name: "resizeBorderColor"; type: "QColor" } Property { name: "resizeBorderWidth"; type: "int" } Property { name: "closeListener"; type: "QVariant" } @@ -4168,6 +4399,8 @@ Module { Property { name: "_route"; type: "string" } Property { name: "_hideShadow"; type: "bool" } Property { name: "contentData"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "effect"; type: "string" } + Property { name: "effective"; type: "bool"; isReadonly: true } Signal { name: "initArgument" Parameter { name: "argument"; type: "QVariant" } @@ -4205,11 +4438,6 @@ Module { Method { name: "clearAllInfo"; type: "QVariant" } Method { name: "moveWindowToDesktopCenter"; type: "QVariant" } Method { name: "fixWindowSize"; type: "QVariant" } - Method { - name: "registerForWindowResult" - type: "QVariant" - Parameter { name: "path"; type: "QVariant" } - } Method { name: "setResult" type: "QVariant" @@ -4229,6 +4457,8 @@ Module { type: "QVariant" Parameter { name: "val"; type: "QVariant" } } + Method { name: "deleteLater"; type: "QVariant" } + Method { name: "containerItem"; type: "QVariant" } } Component { prototype: "QQuickWindowQmlImpl" @@ -4251,6 +4481,9 @@ Module { Property { name: "fixSize"; type: "bool" } Property { name: "loadingItem"; type: "QQmlComponent"; isPointer: true } Property { name: "fitsAppBarWindows"; type: "bool" } + Property { name: "tintOpacity"; type: "QVariant" } + Property { name: "blurRadius"; type: "int" } + Property { name: "availableEffects"; type: "QVariant"; isReadonly: true } Property { name: "appBar"; type: "QQuickItem"; isPointer: true } Property { name: "backgroundColor"; type: "QColor" } Property { name: "stayTop"; type: "bool" } @@ -4264,6 +4497,7 @@ Module { Property { name: "autoCenter"; type: "bool" } Property { name: "autoDestroy"; type: "bool" } Property { name: "useSystemAppBar"; type: "bool" } + Property { name: "__margins"; type: "int" } Property { name: "resizeBorderColor"; type: "QColor" } Property { name: "resizeBorderWidth"; type: "int" } Property { name: "closeListener"; type: "QVariant" } @@ -4271,6 +4505,8 @@ Module { Property { name: "_route"; type: "string" } Property { name: "_hideShadow"; type: "bool" } Property { name: "contentData"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "effect"; type: "string" } + Property { name: "effective"; type: "bool"; isReadonly: true } Signal { name: "initArgument" Parameter { name: "argument"; type: "QVariant" } @@ -4308,11 +4544,6 @@ Module { Method { name: "clearAllInfo"; type: "QVariant" } Method { name: "moveWindowToDesktopCenter"; type: "QVariant" } Method { name: "fixWindowSize"; type: "QVariant" } - Method { - name: "registerForWindowResult" - type: "QVariant" - Parameter { name: "path"; type: "QVariant" } - } Method { name: "setResult" type: "QVariant" @@ -4332,6 +4563,8 @@ Module { type: "QVariant" Parameter { name: "val"; type: "QVariant" } } + Method { name: "deleteLater"; type: "QVariant" } + Method { name: "containerItem"; type: "QVariant" } } Component { prototype: "QQuickItem" From dbde052d4adcfd3b36bf14a7a36331b69024cd48 Mon Sep 17 00:00:00 2001 From: jeffrey0326 <547913081@qq.com> Date: Fri, 30 Aug 2024 23:41:06 +0800 Subject: [PATCH 09/12] update --- example/example_en_US.ts | 6 +++--- example/example_zh_CN.ts | 6 +++--- src/Qt5/imports/FluentUI/plugins.qmltypes | 12 +++++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/example/example_en_US.ts b/example/example_en_US.ts index d95df3a9..2ed0bd6b 100644 --- a/example/example_en_US.ts +++ b/example/example_en_US.ts @@ -2270,17 +2270,17 @@ Some contents... - + window tintOpacity - + window blurRadius - + window effect diff --git a/example/example_zh_CN.ts b/example/example_zh_CN.ts index 28aaae56..9d48f812 100644 --- a/example/example_zh_CN.ts +++ b/example/example_zh_CN.ts @@ -2452,17 +2452,17 @@ Some contents... - + window tintOpacity - + window blurRadius - + window effect diff --git a/src/Qt5/imports/FluentUI/plugins.qmltypes b/src/Qt5/imports/FluentUI/plugins.qmltypes index 4dbcf477..3981b4aa 100644 --- a/src/Qt5/imports/FluentUI/plugins.qmltypes +++ b/src/Qt5/imports/FluentUI/plugins.qmltypes @@ -153,6 +153,8 @@ Module { Property { name: "effect"; type: "string" } Property { name: "effective"; type: "bool"; isReadonly: true } Property { name: "availableEffects"; type: "QStringList"; isReadonly: true } + Property { name: "isDarkMode"; type: "bool" } + Property { name: "useSystemEffect"; type: "bool" } Method { name: "showFullScreen" } Method { name: "showMaximized" } Method { name: "showMinimized" } @@ -2774,7 +2776,7 @@ Module { } Property { name: "layoutMacosButtons" - type: "FluLoader_QMLTYPE_18" + type: "FluLoader_QMLTYPE_11" isReadonly: true isPointer: true } @@ -3467,15 +3469,15 @@ Module { defaultProperty: "data" Property { name: "logo"; type: "QUrl" } Property { name: "title"; type: "string" } - Property { name: "items"; type: "FluObject_QMLTYPE_130"; isPointer: true } - Property { name: "footerItems"; type: "FluObject_QMLTYPE_130"; isPointer: true } + Property { name: "items"; type: "FluObject_QMLTYPE_176"; isPointer: true } + Property { name: "footerItems"; type: "FluObject_QMLTYPE_176"; isPointer: true } Property { name: "displayMode"; type: "int" } Property { name: "autoSuggestBox"; type: "QQmlComponent"; isPointer: true } Property { name: "actionItem"; type: "QQmlComponent"; isPointer: true } Property { name: "topPadding"; type: "int" } Property { name: "pageMode"; type: "int" } - Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_40"; isPointer: true } - Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_40"; isPointer: true } + Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_48"; isPointer: true } + Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_48"; isPointer: true } Property { name: "navCompactWidth"; type: "int" } Property { name: "navTopMargin"; type: "int" } Property { name: "cellHeight"; type: "int" } From 901ca8077e890a06b1cac6ef6578e48eabad00eb Mon Sep 17 00:00:00 2001 From: jeffrey0326 <547913081@qq.com> Date: Sat, 31 Aug 2024 20:12:01 +0800 Subject: [PATCH 10/12] update --- example/example_en_US.ts | 11 ++++++----- example/example_zh_CN.ts | 11 ++++++----- example/qml/page/T_Theme.qml | 11 ----------- src/Qt5/imports/FluentUI/Controls/FluWindow.qml | 2 +- src/Qt6/imports/FluentUI/Controls/FluWindow.qml | 4 +++- 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/example/example_en_US.ts b/example/example_en_US.ts index 2ed0bd6b..f371cbc4 100644 --- a/example/example_en_US.ts +++ b/example/example_en_US.ts @@ -2261,26 +2261,27 @@ Some contents... - Rounded Window + Open Blur Window + Rounded Window - + Open Blur Window - + window tintOpacity - + window blurRadius - + window effect diff --git a/example/example_zh_CN.ts b/example/example_zh_CN.ts index 9d48f812..182a4b86 100644 --- a/example/example_zh_CN.ts +++ b/example/example_zh_CN.ts @@ -2443,26 +2443,27 @@ Some contents... - Rounded Window + Open Blur Window + Rounded Window - + Open Blur Window - + window tintOpacity - + window blurRadius - + window effect diff --git a/example/qml/page/T_Theme.qml b/example/qml/page/T_Theme.qml index fc587066..8576750c 100644 --- a/example/qml/page/T_Theme.qml +++ b/example/qml/page/T_Theme.qml @@ -119,17 +119,6 @@ FluScrollablePage{ FluTheme.animationEnabled = !FluTheme.animationEnabled } } - FluText{ - text: qsTr("Rounded Window") - Layout.topMargin: 20 - } - FluToggleSwitch{ - Layout.topMargin: 5 - checked: window.roundCornerEnable - onClicked: { - window.roundCornerEnable = !window.roundCornerEnable - } - } FluText{ text: qsTr("Open Blur Window") Layout.topMargin: 20 diff --git a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml index 0cf189a7..da1d6fe2 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml @@ -17,7 +17,7 @@ Window { property int blurRadius: 60 property alias effect: frameless.effect readonly property alias effective: frameless.effective - readonly property var availableEffects: frameless.availableEffects + readonly property alias availableEffects: frameless.availableEffects property Item appBar: FluAppBar { title: window.title height: 30 diff --git a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml index ba9bdf5b..1f04c023 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml @@ -16,7 +16,7 @@ Window { property int blurRadius: 60 property alias effect: frameless.effect readonly property alias effective: frameless.effective - readonly property var availableEffects: frameless.availableEffects + readonly property alias availableEffects: frameless.availableEffects property Item appBar: FluAppBar { title: window.title height: 30 @@ -113,6 +113,8 @@ Window { fixSize: window.fixSize topmost: window.stayTop disabled: FluApp.useSystemAppBar + isDarkMode: FluTheme.dark + useSystemEffect: !FluTheme.blurBehindWindowEnabled Component.onCompleted: { frameless.setHitTestVisible(appBar.layoutMacosButtons) frameless.setHitTestVisible(appBar.layoutStandardbuttons) From 80eadd5d190df750d27d62b3befacb9ef1e3c9c2 Mon Sep 17 00:00:00 2001 From: jeffrey0326 <547913081@qq.com> Date: Sat, 31 Aug 2024 20:51:20 +0800 Subject: [PATCH 11/12] update --- example/example_en_US.ts | 5 ----- example/example_zh_CN.ts | 13 ++++--------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/example/example_en_US.ts b/example/example_en_US.ts index f371cbc4..32e38cae 100644 --- a/example/example_en_US.ts +++ b/example/example_en_US.ts @@ -2265,11 +2265,6 @@ Some contents... Rounded Window - - - Open Blur Window - - window tintOpacity diff --git a/example/example_zh_CN.ts b/example/example_zh_CN.ts index 182a4b86..36b127b7 100644 --- a/example/example_zh_CN.ts +++ b/example/example_zh_CN.ts @@ -2445,27 +2445,22 @@ Some contents... Open Blur Window Rounded Window - - - - - Open Blur Window - + 亚克力背景 window tintOpacity - + 背景透明度 window blurRadius - + 背景模糊度 window effect - + 窗口效果 From fb8c0b79b36428642530e8b7391574bac9f000ac Mon Sep 17 00:00:00 2001 From: jeffrey0326 <547913081@qq.com> Date: Sat, 31 Aug 2024 20:51:20 +0800 Subject: [PATCH 12/12] update --- example/example_en_US.ts | 5 ----- example/example_zh_CN.ts | 13 ++++--------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/example/example_en_US.ts b/example/example_en_US.ts index f371cbc4..32e38cae 100644 --- a/example/example_en_US.ts +++ b/example/example_en_US.ts @@ -2265,11 +2265,6 @@ Some contents... Rounded Window - - - Open Blur Window - - window tintOpacity diff --git a/example/example_zh_CN.ts b/example/example_zh_CN.ts index 182a4b86..36b127b7 100644 --- a/example/example_zh_CN.ts +++ b/example/example_zh_CN.ts @@ -2445,27 +2445,22 @@ Some contents... Open Blur Window Rounded Window - - - - - Open Blur Window - + 亚克力背景 window tintOpacity - + 背景透明度 window blurRadius - + 背景模糊度 window effect - + 窗口效果