diff --git a/example/example_en_US.ts b/example/example_en_US.ts
index c7b29f45..d95df3a9 100644
--- a/example/example_en_US.ts
+++ b/example/example_en_US.ts
@@ -2261,21 +2261,26 @@ Some contents...
+
+
+
+
+
-
+
-
+
-
+
diff --git a/example/example_zh_CN.ts b/example/example_zh_CN.ts
index cf53d737..28aaae56 100644
--- a/example/example_zh_CN.ts
+++ b/example/example_zh_CN.ts
@@ -2443,21 +2443,26 @@ Some contents...
+
+
+
+
+
-
+
-
+
-
+
diff --git a/example/qml/page/T_Theme.qml b/example/qml/page/T_Theme.qml
index 8576750c..fc587066 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 8c946884..e67d0fe7 100644
--- a/src/FluFrameless.cpp
+++ b/src/FluFrameless.cpp
@@ -1,5 +1,4 @@
#include "FluFrameless.h"
-#include "FluTheme.h"
#include
#include
@@ -181,8 +180,6 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en
pDwmSetWindowAttribute(hwnd, 1029, &enable, sizeof(enable));
}
}
- BOOL isDark = FluTheme::getInstance()->dark();
- setWindowDarkMode(hwnd, isDark);
return true;
}
@@ -198,8 +195,6 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en
const DWORD backdropType = _DWMSBT_AUTO;
pDwmSetWindowAttribute(hwnd, 38, &backdropType, sizeof(backdropType));
}
- BOOL isDark = FluTheme::getInstance()->dark();
- setWindowDarkMode(hwnd, isDark);
return true;
}
@@ -215,8 +210,6 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en
const DWORD backdropType = _DWMSBT_AUTO;
pDwmSetWindowAttribute(hwnd, 38, &backdropType, sizeof(backdropType));
}
- BOOL isDark = FluTheme::getInstance()->dark();
- setWindowDarkMode(hwnd, isDark);
return true;
}
@@ -224,8 +217,6 @@ static inline bool setWindowEffect(HWND hwnd, const QString &key, const bool &en
if ((isWin7Only() && !isCompositionEnabled()) || !initializeFunctionPointers()) {
return false;
}
- BOOL isDark = FluTheme::getInstance()->dark();
- setWindowDarkMode(hwnd, isDark && enable);
if (enable) {
if (isWin8OrGreater()) {
ACCENT_POLICY policy{};
@@ -295,8 +286,6 @@ 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() {
@@ -307,7 +296,7 @@ void FluFrameless::componentComplete() {
} else {
availableEffects({"dwm-blur","normal"});
}
- if (!_effect.isEmpty()) {
+ if (!_effect.isEmpty() && _useSystemEffect) {
effective(setWindowEffect(hwnd, _effect, true));
if (effective()) {
_currentEffect = effect();
@@ -323,19 +312,21 @@ void FluFrameless::componentComplete() {
effective(setWindowEffect(hwnd, effect(), true));
if (effective()) {
_currentEffect = effect();
+ _useSystemEffect = true;
} else {
_effect = "normal";
_currentEffect = "normal";
+ _useSystemEffect = false;
}
});
- connect(FluTheme::getInstance(), &FluTheme::blurBehindWindowEnabledChanged, this, [this] {
- if (FluTheme::getInstance()->blurBehindWindowEnabled()) {
+ connect(this, &FluFrameless::useSystemEffectChanged, this, [this] {
+ if (!_useSystemEffect) {
effect("normal");
}
});
- connect(FluTheme::getInstance(), &FluTheme::darkChanged, this, [hwnd, this] {
+ connect(this, &FluFrameless::isDarkModeChanged, this, [hwnd, this] {
if (effective() && !_currentEffect.isEmpty() && _currentEffect != "normal") {
- setWindowDarkMode(hwnd, FluTheme::getInstance()->dark());
+ setWindowDarkMode(hwnd, _isDarkMode);
}
});
#endif
@@ -626,27 +617,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;
}
}
@@ -698,72 +689,72 @@ void FluFrameless::_setWindowTopmost(bool topmost) {
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();
+ 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{
- showMaximized();
+ 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..27f622e4 100644
--- a/src/FluFrameless.h
+++ b/src/FluFrameless.h
@@ -117,6 +117,8 @@ class FluFrameless : public QQuickItem, QAbstractNativeEventFilter {
Q_PROPERTY_AUTO(QString, effect)
Q_PROPERTY_READONLY_AUTO(bool, effective)
Q_PROPERTY_READONLY_AUTO(QStringList, availableEffects)
+ Q_PROPERTY_AUTO(bool, isDarkMode)
+ Q_PROPERTY_AUTO(bool, useSystemEffect)
QML_NAMED_ELEMENT(FluFrameless)
public:
explicit FluFrameless(QQuickItem *parent = nullptr);
@@ -162,6 +164,7 @@ private:
void _setMaximizeHovered(bool val);
+
private:
quint64 _current = 0;
int _edges = 0;
diff --git a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml
index 9ab23dab..0cf189a7 100644
--- a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml
+++ b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml
@@ -114,6 +114,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)