mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-29 22:55:56 +08:00
update
This commit is contained in:
parent
af6e39d8c0
commit
38ea91964e
@ -117,7 +117,7 @@ void FluFrameless::updateCursor(int edges){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool FluFrameless::eventFilter(QObject *obj, QEvent *ev){
|
bool FluFrameless::eventFilter(QObject *obj, QEvent *ev){
|
||||||
if (!_window.isNull()) {
|
if (!_window.isNull() && _window->flags() & Qt::FramelessWindowHint) {
|
||||||
|
|
||||||
static int edges = 0;
|
static int edges = 0;
|
||||||
const int margin = 8;
|
const int margin = 8;
|
||||||
@ -183,6 +183,7 @@ void FluFrameless::componentComplete(){
|
|||||||
o = o->parent();
|
o = o->parent();
|
||||||
}
|
}
|
||||||
if(!_window.isNull()){
|
if(!_window.isNull()){
|
||||||
|
_window->setFlag(Qt::FramelessWindowHint,true);
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
_nativeEvent =new FramelessEventFilter(_window);
|
_nativeEvent =new FramelessEventFilter(_window);
|
||||||
qApp->installNativeEventFilter(_nativeEvent);
|
qApp->installNativeEventFilter(_nativeEvent);
|
||||||
@ -190,12 +191,10 @@ void FluFrameless::componentComplete(){
|
|||||||
ULONG_PTR cNewStyle = GetClassLongPtr(hwnd, GCL_STYLE) | CS_DROPSHADOW;
|
ULONG_PTR cNewStyle = GetClassLongPtr(hwnd, GCL_STYLE) | CS_DROPSHADOW;
|
||||||
SetClassLongPtr(hwnd, GCL_STYLE, cNewStyle);
|
SetClassLongPtr(hwnd, GCL_STYLE, cNewStyle);
|
||||||
DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
|
DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
|
||||||
SetWindowLongPtr(hwnd,GWL_STYLE,style &~ WS_SYSMENU);
|
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION &~ WS_SYSMENU);
|
||||||
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE |SWP_FRAMECHANGED);
|
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE |SWP_FRAMECHANGED);
|
||||||
_stayTop = QQmlProperty(_window,"stayTop");
|
_stayTop = QQmlProperty(_window,"stayTop");
|
||||||
_stayTop.connectNotifySignal(this,SLOT(_stayTopChange()));
|
_stayTop.connectNotifySignal(this,SLOT(_stayTopChange()));
|
||||||
#else
|
|
||||||
_window->setFlag(Qt::FramelessWindowHint,true);
|
|
||||||
#endif
|
#endif
|
||||||
_window->installEventFilter(this);
|
_window->installEventFilter(this);
|
||||||
}
|
}
|
||||||
@ -205,17 +204,16 @@ void FluFrameless::_stayTopChange(){
|
|||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
HWND hwnd = reinterpret_cast<HWND>(_window->winId());
|
HWND hwnd = reinterpret_cast<HWND>(_window->winId());
|
||||||
DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
|
DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
|
||||||
SetWindowLongPtr(hwnd,GWL_STYLE,style &~ WS_SYSMENU);
|
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION &~ WS_SYSMENU);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
FluFrameless::~FluFrameless(){
|
FluFrameless::~FluFrameless(){
|
||||||
if (!_window.isNull()) {
|
if (!_window.isNull()) {
|
||||||
_window->removeEventFilter(this);
|
_window->setFlag(Qt::FramelessWindowHint,false);
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
qApp->removeNativeEventFilter(_nativeEvent);
|
qApp->removeNativeEventFilter(_nativeEvent);
|
||||||
#else
|
|
||||||
_window->setFlag(Qt::FramelessWindowHint,false);
|
|
||||||
#endif
|
#endif
|
||||||
|
_window->removeEventFilter(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user