FluWindowbug修复,qmltypes生成bug修复

This commit is contained in:
jeffrey0326 2024-08-30 23:39:45 +08:00
commit 9716c3c98c
6 changed files with 117 additions and 100 deletions

View File

@ -2261,21 +2261,26 @@ Some contents...</source>
</message> </message>
<message> <message>
<location filename="qml/page/T_Theme.qml" line="123"/> <location filename="qml/page/T_Theme.qml" line="123"/>
<source>Rounded Window</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_Theme.qml" line="134"/>
<source>Open Blur Window</source> <source>Open Blur Window</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_Theme.qml" line="158"/> <location filename="qml/page/T_Theme.qml" line="147"/>
<source>window tintOpacity</source> <source>window tintOpacity</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_Theme.qml" line="175"/> <location filename="qml/page/T_Theme.qml" line="164"/>
<source>window blurRadius</source> <source>window blurRadius</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_Theme.qml" line="135"/> <location filename="qml/page/T_Theme.qml" line="180"/>
<source>window effect</source> <source>window effect</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -2443,21 +2443,26 @@ Some contents...</source>
</message> </message>
<message> <message>
<location filename="qml/page/T_Theme.qml" line="123"/> <location filename="qml/page/T_Theme.qml" line="123"/>
<source>Rounded Window</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_Theme.qml" line="134"/>
<source>Open Blur Window</source> <source>Open Blur Window</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_Theme.qml" line="158"/> <location filename="qml/page/T_Theme.qml" line="147"/>
<source>window tintOpacity</source> <source>window tintOpacity</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_Theme.qml" line="175"/> <location filename="qml/page/T_Theme.qml" line="164"/>
<source>window blurRadius</source> <source>window blurRadius</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_Theme.qml" line="135"/> <location filename="qml/page/T_Theme.qml" line="180"/>
<source>window effect</source> <source>window effect</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -119,6 +119,17 @@ FluScrollablePage{
FluTheme.animationEnabled = !FluTheme.animationEnabled 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{ FluText{
text: qsTr("Open Blur Window") text: qsTr("Open Blur Window")
Layout.topMargin: 20 Layout.topMargin: 20

View File

@ -1,5 +1,4 @@
#include "FluFrameless.h" #include "FluFrameless.h"
#include "FluTheme.h"
#include <QQuickWindow> #include <QQuickWindow>
#include <QGuiApplication> #include <QGuiApplication>
@ -181,8 +180,6 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en
pDwmSetWindowAttribute(hwnd, 1029, &enable, sizeof(enable)); pDwmSetWindowAttribute(hwnd, 1029, &enable, sizeof(enable));
} }
} }
BOOL isDark = FluTheme::getInstance()->dark();
setWindowDarkMode(hwnd, isDark);
return true; return true;
} }
@ -198,8 +195,6 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en
const DWORD backdropType = _DWMSBT_AUTO; const DWORD backdropType = _DWMSBT_AUTO;
pDwmSetWindowAttribute(hwnd, 38, &backdropType, sizeof(backdropType)); pDwmSetWindowAttribute(hwnd, 38, &backdropType, sizeof(backdropType));
} }
BOOL isDark = FluTheme::getInstance()->dark();
setWindowDarkMode(hwnd, isDark);
return true; return true;
} }
@ -215,8 +210,6 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en
const DWORD backdropType = _DWMSBT_AUTO; const DWORD backdropType = _DWMSBT_AUTO;
pDwmSetWindowAttribute(hwnd, 38, &backdropType, sizeof(backdropType)); pDwmSetWindowAttribute(hwnd, 38, &backdropType, sizeof(backdropType));
} }
BOOL isDark = FluTheme::getInstance()->dark();
setWindowDarkMode(hwnd, isDark);
return true; return true;
} }
@ -224,8 +217,6 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en
if ((isWin7Only() && !isCompositionEnabled()) || !initializeFunctionPointers()) { if ((isWin7Only() && !isCompositionEnabled()) || !initializeFunctionPointers()) {
return false; return false;
} }
BOOL isDark = FluTheme::getInstance()->dark();
setWindowDarkMode(hwnd, isDark && enable);
if (enable) { if (enable) {
if (isWin8OrGreater()) { if (isWin8OrGreater()) {
ACCENT_POLICY policy{}; ACCENT_POLICY policy{};
@ -295,8 +286,6 @@ FluFrameless::~FluFrameless() = default;
[[maybe_unused]] void FluFrameless::onDestruction() { [[maybe_unused]] void FluFrameless::onDestruction() {
QGuiApplication::instance()->removeNativeEventFilter(this); QGuiApplication::instance()->removeNativeEventFilter(this);
disconnect(FluTheme::getInstance(), &FluTheme::darkChanged, this, nullptr);
disconnect(window(), &QQuickWindow::screenChanged, this, nullptr);
} }
void FluFrameless::componentComplete() { void FluFrameless::componentComplete() {
@ -307,7 +296,7 @@ void FluFrameless::componentComplete() {
} else { } else {
availableEffects({"dwm-blur","normal"}); availableEffects({"dwm-blur","normal"});
} }
if (!_effect.isEmpty()) { if (!_effect.isEmpty() && _useSystemEffect) {
effective(setWindowEffect(hwnd, _effect, true)); effective(setWindowEffect(hwnd, _effect, true));
if (effective()) { if (effective()) {
_currentEffect = effect(); _currentEffect = effect();
@ -323,19 +312,21 @@ void FluFrameless::componentComplete() {
effective(setWindowEffect(hwnd, effect(), true)); effective(setWindowEffect(hwnd, effect(), true));
if (effective()) { if (effective()) {
_currentEffect = effect(); _currentEffect = effect();
_useSystemEffect = true;
} else { } else {
_effect = "normal"; _effect = "normal";
_currentEffect = "normal"; _currentEffect = "normal";
_useSystemEffect = false;
} }
}); });
connect(FluTheme::getInstance(), &FluTheme::blurBehindWindowEnabledChanged, this, [this] { connect(this, &FluFrameless::useSystemEffectChanged, this, [this] {
if (FluTheme::getInstance()->blurBehindWindowEnabled()) { if (!_useSystemEffect) {
effect("normal"); effect("normal");
} }
}); });
connect(FluTheme::getInstance(), &FluTheme::darkChanged, this, [hwnd, this] { connect(this, &FluFrameless::isDarkModeChanged, this, [hwnd, this] {
if (effective() && !_currentEffect.isEmpty() && _currentEffect != "normal") { if (effective() && !_currentEffect.isEmpty() && _currentEffect != "normal") {
setWindowDarkMode(hwnd, FluTheme::getInstance()->dark()); setWindowDarkMode(hwnd, _isDarkMode);
} }
}); });
#endif #endif

View File

@ -117,6 +117,8 @@ class FluFrameless : public QQuickItem, QAbstractNativeEventFilter {
Q_PROPERTY_AUTO(QString, effect) Q_PROPERTY_AUTO(QString, effect)
Q_PROPERTY_READONLY_AUTO(bool, effective) Q_PROPERTY_READONLY_AUTO(bool, effective)
Q_PROPERTY_READONLY_AUTO(QStringList, availableEffects) Q_PROPERTY_READONLY_AUTO(QStringList, availableEffects)
Q_PROPERTY_AUTO(bool, isDarkMode)
Q_PROPERTY_AUTO(bool, useSystemEffect)
QML_NAMED_ELEMENT(FluFrameless) QML_NAMED_ELEMENT(FluFrameless)
public: public:
explicit FluFrameless(QQuickItem *parent = nullptr); explicit FluFrameless(QQuickItem *parent = nullptr);
@ -162,6 +164,7 @@ private:
void _setMaximizeHovered(bool val); void _setMaximizeHovered(bool val);
private: private:
quint64 _current = 0; quint64 _current = 0;
int _edges = 0; int _edges = 0;

View File

@ -114,6 +114,8 @@ Window {
fixSize: window.fixSize fixSize: window.fixSize
topmost: window.stayTop topmost: window.stayTop
disabled: FluApp.useSystemAppBar disabled: FluApp.useSystemAppBar
isDarkMode: FluTheme.dark
useSystemEffect: !FluTheme.blurBehindWindowEnabled
Component.onCompleted: { Component.onCompleted: {
frameless.setHitTestVisible(appBar.layoutMacosButtons) frameless.setHitTestVisible(appBar.layoutMacosButtons)
frameless.setHitTestVisible(appBar.layoutStandardbuttons) frameless.setHitTestVisible(appBar.layoutStandardbuttons)