mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-01-23 04:14:35 +08:00
udpate
This commit is contained in:
parent
4f202831b8
commit
5f6745b630
@ -73,12 +73,7 @@ void FluFrameless::componentComplete() {
|
|||||||
int w = window()->width();
|
int w = window()->width();
|
||||||
int h = window()->height();
|
int h = window()->height();
|
||||||
_current = window()->winId();
|
_current = window()->winId();
|
||||||
window()->setFlags((window()->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::FramelessWindowHint);
|
window()->setFlags((window()->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint);
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
if (QQuickWindow::sceneGraphBackend() == "software") {
|
|
||||||
window()->setFlag(Qt::FramelessWindowHint, false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (!_fixSize) {
|
if (!_fixSize) {
|
||||||
window()->setFlag(Qt::WindowMaximizeButtonHint);
|
window()->setFlag(Qt::WindowMaximizeButtonHint);
|
||||||
}
|
}
|
||||||
@ -97,14 +92,14 @@ 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) {
|
||||||
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);
|
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_CAPTION);
|
||||||
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 {
|
||||||
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME);
|
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_CAPTION);
|
||||||
}
|
}
|
||||||
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] {
|
||||||
@ -151,29 +146,22 @@ void FluFrameless::componentComplete() {
|
|||||||
return false;
|
return false;
|
||||||
} 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]);
|
||||||
|
bool isMaximum = ::IsZoomed(hwnd);
|
||||||
|
if (!isMaximum){
|
||||||
|
if (clientRect->top != 0)
|
||||||
|
{
|
||||||
|
clientRect->top -= 1;
|
||||||
|
clientRect->bottom -= 1;
|
||||||
|
}
|
||||||
|
} else{
|
||||||
const LONG originalTop = clientRect->top;
|
const LONG originalTop = clientRect->top;
|
||||||
const LONG originalLeft = clientRect->left;
|
|
||||||
const LONG originalRight = clientRect->right;
|
|
||||||
const LONG originalBottom = clientRect->bottom;
|
|
||||||
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 = static_cast<QT_NATIVE_EVENT_RESULT_TYPE>(hitTestResult);
|
*result = static_cast<QT_NATIVE_EVENT_RESULT_TYPE>(hitTestResult);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int offsetSize;
|
clientRect->top = originalTop-originalTop;
|
||||||
bool isMaximum = ::IsZoomed(hwnd);
|
|
||||||
if (isMaximum || _isFullScreen()) {
|
|
||||||
offsetSize = 0;
|
|
||||||
} else {
|
|
||||||
offsetSize = 1;
|
|
||||||
}
|
}
|
||||||
if (!isCompositionEnabled()) {
|
|
||||||
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,6 +218,18 @@ void FluFrameless::componentComplete() {
|
|||||||
}
|
}
|
||||||
*result = HTCLIENT;
|
*result = HTCLIENT;
|
||||||
return true;
|
return true;
|
||||||
|
} else if (uMsg == WM_NCPAINT) {
|
||||||
|
if(isCompositionEnabled()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*result = FALSE;
|
||||||
|
return true;
|
||||||
|
} else if (uMsg == WM_NCACTIVATE) {
|
||||||
|
if(isCompositionEnabled()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*result = TRUE;
|
||||||
|
return true;
|
||||||
} else if (_isWindows11OrGreater && (uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN)) {
|
} else if (_isWindows11OrGreater && (uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN)) {
|
||||||
if (_hitMaximizeButton()) {
|
if (_hitMaximizeButton()) {
|
||||||
QMouseEvent event = QMouseEvent(QEvent::MouseButtonPress, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
QMouseEvent event = QMouseEvent(QEvent::MouseButtonPress, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
||||||
@ -244,23 +244,8 @@ void FluFrameless::componentComplete() {
|
|||||||
_setMaximizePressed(false);
|
_setMaximizePressed(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (uMsg == WM_NCPAINT) {
|
} else if (uMsg == WM_ERASEBKGND) {
|
||||||
*result = FALSE;
|
|
||||||
return true;
|
return true;
|
||||||
} else if (uMsg == WM_NCACTIVATE) {
|
|
||||||
*result = static_cast<QT_NATIVE_EVENT_RESULT_TYPE>(::DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1));
|
|
||||||
return true;
|
|
||||||
} else if (uMsg == WM_GETMINMAXINFO) {
|
|
||||||
auto *minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
|
|
||||||
auto pixelRatio = window()->devicePixelRatio();
|
|
||||||
auto geometry = window()->screen()->availableGeometry();
|
|
||||||
RECT rect;
|
|
||||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
|
|
||||||
minmaxInfo->ptMaxPosition.x = rect.left;
|
|
||||||
minmaxInfo->ptMaxPosition.y = rect.top;
|
|
||||||
minmaxInfo->ptMaxSize.x = qRound(geometry.width() * pixelRatio);
|
|
||||||
minmaxInfo->ptMaxSize.y = qRound(geometry.height() * pixelRatio);
|
|
||||||
return false;
|
|
||||||
} else if (uMsg == WM_NCRBUTTONDOWN) {
|
} else if (uMsg == WM_NCRBUTTONDOWN) {
|
||||||
if (wParam == HTCAPTION) {
|
if (wParam == HTCAPTION) {
|
||||||
_showSystemMenu(QCursor::pos());
|
_showSystemMenu(QCursor::pos());
|
||||||
|
@ -279,13 +279,7 @@ Window {
|
|||||||
id:loader_border
|
id:loader_border
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
sourceComponent: {
|
sourceComponent: {
|
||||||
if(window.useSystemAppBar){
|
if(window.useSystemAppBar || FluTools.isWin() || window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
if(FluTools.isWindows10OrGreater()){
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
if(window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
|
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
return com_border
|
return com_border
|
||||||
|
@ -278,13 +278,7 @@ Window {
|
|||||||
id:loader_border
|
id:loader_border
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
sourceComponent: {
|
sourceComponent: {
|
||||||
if(window.useSystemAppBar){
|
if(window.useSystemAppBar || FluTools.isWin() || window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
if(FluTools.isWindows10OrGreater()){
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
if(window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
|
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
return com_border
|
return com_border
|
||||||
|
Loading…
Reference in New Issue
Block a user