mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-10-30 15:57:37 +08:00
update
This commit is contained in:
parent
c05222bd81
commit
fa14f5824d
@ -35,6 +35,19 @@ static inline bool isCompositionEnabled() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void setShadow(HWND hwnd) {
|
||||||
|
const MARGINS shadow = {1, 0, 0, 0};
|
||||||
|
typedef HRESULT (WINAPI *DwmExtendFrameIntoClientAreaPtr)(HWND hWnd, const MARGINS *pMarInset);
|
||||||
|
HMODULE module = LoadLibraryW(L"dwmapi.dll");
|
||||||
|
if (module) {
|
||||||
|
DwmExtendFrameIntoClientAreaPtr dwm_extendframe_into_client_area_;
|
||||||
|
dwm_extendframe_into_client_area_ = reinterpret_cast<DwmExtendFrameIntoClientAreaPtr>(GetProcAddress(module, "DwmExtendFrameIntoClientArea"));
|
||||||
|
if (dwm_extendframe_into_client_area_) {
|
||||||
|
dwm_extendframe_into_client_area_(hwnd, &shadow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool containsCursorToItem(QQuickItem *item) {
|
bool containsCursorToItem(QQuickItem *item) {
|
||||||
@ -92,20 +105,31 @@ void FluFrameless::componentComplete() {
|
|||||||
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);
|
||||||
if (_fixSize) {
|
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);;
|
::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) {
|
for (int i = 0; i <= QGuiApplication::screens().count() - 1; ++i) {
|
||||||
connect(QGuiApplication::screens().at(i), &QScreen::logicalDotsPerInchChanged, this, [=] {
|
connect(QGuiApplication::screens().at(i), &QScreen::logicalDotsPerInchChanged, this, [=] {
|
||||||
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED);
|
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
::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);
|
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
||||||
connect(window(), &QQuickWindow::screenChanged, this, [hwnd] {
|
connect(window(), &QQuickWindow::screenChanged, this, [hwnd] {
|
||||||
::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER);
|
::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER);
|
||||||
::RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
|
::RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
|
||||||
});
|
});
|
||||||
|
if (!window()->property("_hideShadow").toBool()) {
|
||||||
|
setShadow(hwnd);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
auto appBarHeight = _appbar->height();
|
auto appBarHeight = _appbar->height();
|
||||||
h = qRound(h + appBarHeight);
|
h = qRound(h + appBarHeight);
|
||||||
@ -149,30 +173,38 @@ void FluFrameless::componentComplete() {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else if (uMsg == WM_NCCALCSIZE && wParam == TRUE) {
|
} else if (uMsg == WM_NCCALCSIZE && wParam == TRUE) {
|
||||||
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
|
const auto clientRect = &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0];
|
||||||
const LONG originalTop = clientRect->top;
|
const LONG originalTop = clientRect->top;
|
||||||
const LONG originalLeft = clientRect->left;
|
const LONG originalLeft = clientRect->left;
|
||||||
const LONG originalRight = clientRect->right;
|
|
||||||
const LONG originalBottom = clientRect->bottom;
|
const LONG originalBottom = clientRect->bottom;
|
||||||
|
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 = static_cast<QT_NATIVE_EVENT_RESULT_TYPE>(hitTestResult);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int offsetSize;
|
#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);
|
bool isMaximum = ::IsZoomed(hwnd);
|
||||||
if (isMaximum || _isFullScreen()) {
|
if (isMaximum) {
|
||||||
offsetSize = 0;
|
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 {
|
} else {
|
||||||
offsetSize = 1;
|
clientRect->top = originalTop;
|
||||||
|
clientRect->bottom = originalBottom;
|
||||||
|
clientRect->left = originalLeft;
|
||||||
|
clientRect->right = originalRight;
|
||||||
}
|
}
|
||||||
if (!isCompositionEnabled()) {
|
#endif
|
||||||
offsetSize = 0;
|
|
||||||
}
|
|
||||||
clientRect->top = originalTop + offsetSize;
|
|
||||||
clientRect->bottom = originalBottom - offsetSize;
|
|
||||||
clientRect->left = originalLeft + offsetSize;
|
|
||||||
clientRect->right = originalRight - offsetSize;
|
|
||||||
_setMaximizeHovered(false);
|
_setMaximizeHovered(false);
|
||||||
*result = WVR_REDRAW;
|
*result = WVR_REDRAW;
|
||||||
return true;
|
return true;
|
||||||
@ -230,12 +262,21 @@ void FluFrameless::componentComplete() {
|
|||||||
*result = HTCLIENT;
|
*result = HTCLIENT;
|
||||||
return true;
|
return true;
|
||||||
} else if (uMsg == WM_NCPAINT) {
|
} else if (uMsg == WM_NCPAINT) {
|
||||||
|
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
|
||||||
*result = FALSE;
|
*result = FALSE;
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
if (isCompositionEnabled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*result = FALSE;
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
} else if (uMsg == WM_NCACTIVATE) {
|
} else if (uMsg == WM_NCACTIVATE) {
|
||||||
*result = TRUE;
|
*result = TRUE;
|
||||||
return true;
|
return true;
|
||||||
} else if (uMsg == WM_GETMINMAXINFO) {
|
} 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 *minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
|
||||||
auto pixelRatio = window()->devicePixelRatio();
|
auto pixelRatio = window()->devicePixelRatio();
|
||||||
auto geometry = window()->screen()->availableGeometry();
|
auto geometry = window()->screen()->availableGeometry();
|
||||||
@ -245,6 +286,7 @@ void FluFrameless::componentComplete() {
|
|||||||
minmaxInfo->ptMaxPosition.y = rect.top;
|
minmaxInfo->ptMaxPosition.y = rect.top;
|
||||||
minmaxInfo->ptMaxSize.x = qRound(geometry.width() * pixelRatio);
|
minmaxInfo->ptMaxSize.x = qRound(geometry.width() * pixelRatio);
|
||||||
minmaxInfo->ptMaxSize.y = qRound(geometry.height() * pixelRatio);
|
minmaxInfo->ptMaxSize.y = qRound(geometry.height() * pixelRatio);
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
} else if (_isWindows11OrGreater && (uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN)) {
|
} else if (_isWindows11OrGreater && (uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN)) {
|
||||||
if (_hitMaximizeButton()) {
|
if (_hitMaximizeButton()) {
|
||||||
|
@ -43,12 +43,12 @@ Rectangle{
|
|||||||
property alias layoutStandardbuttons: layout_standard_buttons
|
property alias layoutStandardbuttons: layout_standard_buttons
|
||||||
property var maxClickListener : function(){
|
property var maxClickListener : function(){
|
||||||
if(FluTools.isMacos()){
|
if(FluTools.isMacos()){
|
||||||
if (d.win.visibility === Window.FullScreen)
|
if (d.win.visibility === Window.FullScreen || d.win.visibility === Window.Maximized)
|
||||||
d.win.showNormal()
|
d.win.showNormal()
|
||||||
else
|
else
|
||||||
d.win.showFullScreen()
|
d.win.showFullScreen()
|
||||||
}else{
|
}else{
|
||||||
if (d.win.visibility === Window.Maximized)
|
if (d.win.visibility === Window.Maximized || d.win.visibility === Window.FullScreen)
|
||||||
d.win.showNormal()
|
d.win.showNormal()
|
||||||
else
|
else
|
||||||
d.win.showMaximized()
|
d.win.showMaximized()
|
||||||
@ -93,7 +93,7 @@ Rectangle{
|
|||||||
}
|
}
|
||||||
return false
|
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)
|
property bool resizable: win && !(win.height === win.maximumHeight && win.height === win.minimumHeight && win.width === win.maximumWidth && win.width === win.minimumWidth)
|
||||||
function containsPointToItem(point,item){
|
function containsPointToItem(point,item){
|
||||||
var pos = item.mapToGlobal(0,0)
|
var pos = item.mapToGlobal(0,0)
|
||||||
|
Loading…
Reference in New Issue
Block a user