Compare commits

...

4 Commits

Author SHA1 Message Date
朱子楚\zhuzi
fa14f5824d update 2024-06-14 17:44:31 +08:00
朱子楚\zhuzi
c05222bd81 Merge branch 'temp' 2024-06-14 17:28:37 +08:00
朱子楚\zhuzi
2b528a7072 update 2024-06-14 17:28:31 +08:00
朱子楚\zhuzi
436ae3f8df update 2024-06-14 16:53:48 +08:00
3 changed files with 42 additions and 6 deletions

View File

@ -105,14 +105,22 @@ void FluFrameless::componentComplete() {
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
if (_fixSize) {
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);;
#else
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);
#endif
for (int i = 0; i <= QGuiApplication::screens().count() - 1; ++i) {
connect(QGuiApplication::screens().at(i), &QScreen::logicalDotsPerInchChanged, this, [=] {
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED);
});
}
} else {
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME);
#else
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION);
#endif
}
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
connect(window(), &QQuickWindow::screenChanged, this, [hwnd] {
@ -175,10 +183,28 @@ void FluFrameless::componentComplete() {
*result = static_cast<QT_NATIVE_EVENT_RESULT_TYPE>(hitTestResult);
return true;
}
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
clientRect->top = originalTop;
clientRect->bottom = originalBottom;
clientRect->left = originalLeft;
clientRect->right = originalRight;
#else
bool isMaximum = ::IsZoomed(hwnd);
if (isMaximum) {
auto geometry = window()->screen()->geometry();
auto offsetX = qAbs(geometry.left() - originalLeft);
auto offsetY = qAbs(geometry.top() - originalTop);
clientRect->top = originalTop + offsetY;
clientRect->bottom = originalBottom - offsetY;
clientRect->left = originalLeft + offsetX;
clientRect->right = originalRight - offsetX;
} else {
clientRect->top = originalTop;
clientRect->bottom = originalBottom;
clientRect->left = originalLeft;
clientRect->right = originalRight;
}
#endif
_setMaximizeHovered(false);
*result = WVR_REDRAW;
return true;
@ -236,12 +262,21 @@ void FluFrameless::componentComplete() {
*result = HTCLIENT;
return true;
} else if (uMsg == WM_NCPAINT) {
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
*result = FALSE;
return true;
#else
if (isCompositionEnabled()) {
return false;
}
*result = FALSE;
return true;
#endif
} else if (uMsg == WM_NCACTIVATE) {
*result = TRUE;
return true;
} else if (uMsg == WM_GETMINMAXINFO) {
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
auto *minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
auto pixelRatio = window()->devicePixelRatio();
auto geometry = window()->screen()->availableGeometry();
@ -251,6 +286,7 @@ void FluFrameless::componentComplete() {
minmaxInfo->ptMaxPosition.y = rect.top;
minmaxInfo->ptMaxSize.x = qRound(geometry.width() * pixelRatio);
minmaxInfo->ptMaxSize.y = qRound(geometry.height() * pixelRatio);
#endif
return false;
} else if (_isWindows11OrGreater && (uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN)) {
if (_hitMaximizeButton()) {

View File

@ -43,12 +43,12 @@ Rectangle{
property alias layoutStandardbuttons: layout_standard_buttons
property var maxClickListener : function(){
if(FluTools.isMacos()){
if (d.win.visibility === Window.FullScreen)
if (d.win.visibility === Window.FullScreen || d.win.visibility === Window.Maximized)
d.win.showNormal()
else
d.win.showFullScreen()
}else{
if (d.win.visibility === Window.Maximized)
if (d.win.visibility === Window.Maximized || d.win.visibility === Window.FullScreen)
d.win.showNormal()
else
d.win.showMaximized()
@ -93,7 +93,7 @@ Rectangle{
}
return false
}
property bool isRestore: win && Window.Maximized === win.visibility
property bool isRestore: win && (Window.Maximized === win.visibility || Window.FullScreen === win.visibility)
property bool resizable: win && !(win.height === win.maximumHeight && win.height === win.minimumHeight && win.width === win.maximumWidth && win.width === win.minimumWidth)
function containsPointToItem(point,item){
var pos = item.mapToGlobal(0,0)

View File

@ -43,12 +43,12 @@ Rectangle{
property alias layoutStandardbuttons: layout_standard_buttons
property var maxClickListener : function(){
if(FluTools.isMacos()){
if (d.win.visibility === Window.FullScreen)
if (d.win.visibility === Window.FullScreen || d.win.visibility === Window.Maximized)
d.win.showNormal()
else
d.win.showFullScreen()
}else{
if (d.win.visibility === Window.Maximized)
if (d.win.visibility === Window.Maximized || d.win.visibility === Window.FullScreen)
d.win.showNormal()
else
d.win.showMaximized()
@ -93,7 +93,7 @@ Rectangle{
}
return false
}
property bool isRestore: win && Window.Maximized === win.visibility
property bool isRestore: win && (Window.Maximized === win.visibility || Window.FullScreen === win.visibility)
property bool resizable: win && !(win.height === win.maximumHeight && win.height === win.minimumHeight && win.width === win.maximumWidth && win.width === win.minimumWidth)
function containsPointToItem(point,item){
var pos = item.mapToGlobal(0,0)