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
@ -626,27 +617,27 @@ void FluFrameless::_setMaximizeHovered(bool val) {
void FluFrameless::_updateCursor(int edges) { void FluFrameless::_updateCursor(int edges) {
switch (edges) { switch (edges) {
case 0: case 0:
window()->setCursor(Qt::ArrowCursor); window()->setCursor(Qt::ArrowCursor);
break; break;
case Qt::LeftEdge: case Qt::LeftEdge:
case Qt::RightEdge: case Qt::RightEdge:
window()->setCursor(Qt::SizeHorCursor); window()->setCursor(Qt::SizeHorCursor);
break; break;
case Qt::TopEdge: case Qt::TopEdge:
case Qt::BottomEdge: case Qt::BottomEdge:
window()->setCursor(Qt::SizeVerCursor); window()->setCursor(Qt::SizeVerCursor);
break; break;
case Qt::LeftEdge | Qt::TopEdge: case Qt::LeftEdge | Qt::TopEdge:
case Qt::RightEdge | Qt::BottomEdge: case Qt::RightEdge | Qt::BottomEdge:
window()->setCursor(Qt::SizeFDiagCursor); window()->setCursor(Qt::SizeFDiagCursor);
break; break;
case Qt::RightEdge | Qt::TopEdge: case Qt::RightEdge | Qt::TopEdge:
case Qt::LeftEdge | Qt::BottomEdge: case Qt::LeftEdge | Qt::BottomEdge:
window()->setCursor(Qt::SizeBDiagCursor); window()->setCursor(Qt::SizeBDiagCursor);
break; break;
default: default:
break; break;
} }
} }
@ -698,72 +689,72 @@ void FluFrameless::_setWindowTopmost(bool topmost) {
bool FluFrameless::eventFilter(QObject *obj, QEvent *ev) { bool FluFrameless::eventFilter(QObject *obj, QEvent *ev) {
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
switch (ev->type()) { switch (ev->type()) {
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
if(_edges!=0){ if(_edges!=0){
QMouseEvent *event = static_cast<QMouseEvent*>(ev); QMouseEvent *event = static_cast<QMouseEvent*>(ev);
if(event->button() == Qt::LeftButton){ if(event->button() == Qt::LeftButton){
_updateCursor(_edges); _updateCursor(_edges);
window()->startSystemResize(Qt::Edges(_edges)); window()->startSystemResize(Qt::Edges(_edges));
} }
}else{ }else{
if(_hitAppBar()){ if(_hitAppBar()){
qint64 clickTimer = QDateTime::currentMSecsSinceEpoch(); qint64 clickTimer = QDateTime::currentMSecsSinceEpoch();
qint64 offset = clickTimer - this->_clickTimer; qint64 offset = clickTimer - this->_clickTimer;
this->_clickTimer = clickTimer; this->_clickTimer = clickTimer;
if(offset<300){ if(offset<300){
if(_isMaximized()){ if(_isMaximized()){
showNormal(); showNormal();
}else{
showMaximized();
}
}else{ }else{
showMaximized(); window()->startSystemMove();
} }
}else{
window()->startSystemMove();
} }
} }
}
break;
case QEvent::MouseButtonRelease:
_edges = 0;
break;
case QEvent::MouseMove: {
if(_isMaximized() || _isFullScreen()){
break; break;
} case QEvent::MouseButtonRelease:
if(_fixSize){ _edges = 0;
break; break;
} case QEvent::MouseMove: {
QMouseEvent *event = static_cast<QMouseEvent*>(ev); if(_isMaximized() || _isFullScreen()){
QPoint p = break;
#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);
} }
if(_fixSize){
break;
}
QMouseEvent *event = static_cast<QMouseEvent*>(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; break;
} }
_edges = 0; default:
if ( p.x() < _margins ) { break;
_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;
} }
#endif #endif
return QObject::eventFilter(obj, ev); return QObject::eventFilter(obj, ev);

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)