mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-23 03:10:10 +08:00
update
This commit is contained in:
parent
00e028be07
commit
0cad207359
@ -113,7 +113,9 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
|
|||||||
}else if(uMsg == WM_NCCALCSIZE){
|
}else if(uMsg == WM_NCCALCSIZE){
|
||||||
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
|
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
|
||||||
const LONG originalTop = clientRect->top;
|
const LONG originalTop = clientRect->top;
|
||||||
|
const LONG originalBottom = clientRect->bottom;
|
||||||
const LONG originalLeft = clientRect->left;
|
const LONG originalLeft = clientRect->left;
|
||||||
|
const LONG originalRight= clientRect->right;
|
||||||
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
|
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
|
||||||
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
|
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
|
||||||
*result = hitTestResult;
|
*result = hitTestResult;
|
||||||
@ -127,7 +129,7 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
|
|||||||
}else{
|
}else{
|
||||||
_helper->setOriginalPos({});
|
_helper->setOriginalPos({});
|
||||||
}
|
}
|
||||||
clientRect->top = originalTop;
|
clientRect->top = originalTop + 1;
|
||||||
*result = WVR_REDRAW;
|
*result = WVR_REDRAW;
|
||||||
return true;
|
return true;
|
||||||
}if(uMsg == WM_NCHITTEST){
|
}if(uMsg == WM_NCHITTEST){
|
||||||
@ -151,6 +153,8 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
|
|||||||
QGuiApplication::sendEvent(_helper->maximizeButton(),&event);
|
QGuiApplication::sendEvent(_helper->maximizeButton(),&event);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
}else if(uMsg == WM_NCPAINT){
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
@ -264,21 +268,20 @@ void FluFramelessHelper::componentComplete(){
|
|||||||
_screen = QQmlProperty(window,"screen");
|
_screen = QQmlProperty(window,"screen");
|
||||||
_fixSize = QQmlProperty(window,"fixSize");
|
_fixSize = QQmlProperty(window,"fixSize");
|
||||||
_originalPos = QQmlProperty(window,"_originalPos");
|
_originalPos = QQmlProperty(window,"_originalPos");
|
||||||
_accentColor = QQmlProperty(window,"_accentColor");
|
|
||||||
_realHeight = QQmlProperty(window,"_realHeight");
|
_realHeight = QQmlProperty(window,"_realHeight");
|
||||||
_realWidth = QQmlProperty(window,"_realWidth");
|
_realWidth = QQmlProperty(window,"_realWidth");
|
||||||
_appBarHeight = QQmlProperty(window,"_appBarHeight");
|
_appBarHeight = QQmlProperty(window,"_appBarHeight");
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if(isCompositionEnabled()){
|
if(isCompositionEnabled()){
|
||||||
_accentColor.write(getAccentColor());
|
window->setFlag(Qt::CustomizeWindowHint,true);
|
||||||
_nativeEvent =new FramelessEventFilter(this);
|
_nativeEvent =new FramelessEventFilter(this);
|
||||||
qApp->installNativeEventFilter(_nativeEvent);
|
qApp->installNativeEventFilter(_nativeEvent);
|
||||||
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
||||||
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
|
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
|
||||||
if(resizeable()){
|
if(resizeable()){
|
||||||
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION);
|
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME);
|
||||||
}else{
|
}else{
|
||||||
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);
|
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);
|
||||||
}
|
}
|
||||||
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);
|
||||||
}else{
|
}else{
|
||||||
|
@ -57,7 +57,6 @@ private:
|
|||||||
QQmlProperty _screen;
|
QQmlProperty _screen;
|
||||||
QQmlProperty _originalPos;
|
QQmlProperty _originalPos;
|
||||||
QQmlProperty _fixSize;
|
QQmlProperty _fixSize;
|
||||||
QQmlProperty _accentColor;
|
|
||||||
QQmlProperty _realHeight;
|
QQmlProperty _realHeight;
|
||||||
QQmlProperty _realWidth;
|
QQmlProperty _realWidth;
|
||||||
QQmlProperty _appBarHeight;
|
QQmlProperty _appBarHeight;
|
||||||
|
@ -87,7 +87,7 @@ Window {
|
|||||||
on_OriginalPosChanged: {
|
on_OriginalPosChanged: {
|
||||||
if(_originalPos){
|
if(_originalPos){
|
||||||
var dx = (_originalPos.x - screen.virtualX)/screen.devicePixelRatio
|
var dx = (_originalPos.x - screen.virtualX)/screen.devicePixelRatio
|
||||||
var dy = _originalPos.y - screen.virtualY/screen.devicePixelRatio
|
var dy = (_originalPos.y - screen.virtualY)/screen.devicePixelRatio
|
||||||
if(dx<0 && dy<0){
|
if(dx<0 && dy<0){
|
||||||
_offsetXY = Qt.point(Math.abs(dx),Math.abs(dy))
|
_offsetXY = Qt.point(Math.abs(dx),Math.abs(dy))
|
||||||
}else{
|
}else{
|
||||||
@ -270,20 +270,6 @@ Window {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rectangle{
|
|
||||||
height: 1
|
|
||||||
width: parent.width
|
|
||||||
color: window.resizeBorderColor
|
|
||||||
visible: {
|
|
||||||
if(window.useSystemAppBar || !FluTools.isWin()){
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
function destoryOnClose(){
|
function destoryOnClose(){
|
||||||
lifecycle.onDestoryOnClose()
|
lifecycle.onDestoryOnClose()
|
||||||
|
@ -86,7 +86,7 @@ Window {
|
|||||||
on_OriginalPosChanged: {
|
on_OriginalPosChanged: {
|
||||||
if(_originalPos){
|
if(_originalPos){
|
||||||
var dx = (_originalPos.x - screen.virtualX)/screen.devicePixelRatio
|
var dx = (_originalPos.x - screen.virtualX)/screen.devicePixelRatio
|
||||||
var dy = _originalPos.y - screen.virtualY/screen.devicePixelRatio
|
var dy = (_originalPos.y - screen.virtualY)/screen.devicePixelRatio
|
||||||
if(dx<0 && dy<0){
|
if(dx<0 && dy<0){
|
||||||
_offsetXY = Qt.point(Math.abs(dx),Math.abs(dy))
|
_offsetXY = Qt.point(Math.abs(dx),Math.abs(dy))
|
||||||
}else{
|
}else{
|
||||||
@ -269,20 +269,6 @@ Window {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rectangle{
|
|
||||||
height: 1
|
|
||||||
width: parent.width
|
|
||||||
color: window.resizeBorderColor
|
|
||||||
visible: {
|
|
||||||
if(window.useSystemAppBar || !FluTools.isWin()){
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
function destoryOnClose(){
|
function destoryOnClose(){
|
||||||
lifecycle.onDestoryOnClose()
|
lifecycle.onDestoryOnClose()
|
||||||
|
Loading…
Reference in New Issue
Block a user