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

View File

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