This commit is contained in:
朱子楚\zhuzi 2024-04-03 13:24:30 +08:00
parent eb4ec242b1
commit c2b845658d
2 changed files with 14 additions and 4 deletions

View File

@ -3,6 +3,7 @@
#include <QQuickWindow> #include <QQuickWindow>
#include <QGuiApplication> #include <QGuiApplication>
#include <QScreen> #include <QScreen>
#include <QDateTime>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#pragma comment (lib,"user32.lib") #pragma comment (lib,"user32.lib")
@ -62,9 +63,6 @@ void FluFrameless::componentComplete(){
} }
window()->installEventFilter(this); window()->installEventFilter(this);
qApp->installNativeEventFilter(this); qApp->installNativeEventFilter(this);
if(_appbar){
_appbar->installEventFilter(this);
}
if(_maximizeButton){ if(_maximizeButton){
setHitTestVisible(_maximizeButton); setHitTestVisible(_maximizeButton);
} }
@ -425,9 +423,20 @@ bool FluFrameless::eventFilter(QObject *obj, QEvent *ev){
} }
}else{ }else{
if(_hitAppBar()){ 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(); window()->startSystemMove();
} }
} }
}
break; break;
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
_edges = 0; _edges = 0;

View File

@ -54,6 +54,7 @@ private:
qint64 _current; qint64 _current;
int _edges = 0; int _edges = 0;
int _margins = 8; int _margins = 8;
qint64 _clickTimer = 0;
QList<QPointer<QQuickItem>> _hitTestList; QList<QPointer<QQuickItem>> _hitTestList;
}; };