This commit is contained in:
朱子楚\zhuzi
2024-06-23 11:45:49 +08:00
parent 155307fe6a
commit 649edbea0d
6 changed files with 168 additions and 169 deletions

View File

@ -108,14 +108,14 @@ void FluFrameless::componentComplete() {
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
if (_fixSize) {
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);;
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);;
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 {
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME);
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION);
}
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
connect(window(), &QQuickWindow::screenChanged, this, [hwnd] {
@ -168,30 +168,11 @@ void FluFrameless::componentComplete() {
}
return false;
} else if (uMsg == WM_NCCALCSIZE && wParam == TRUE) {
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
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);
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
*result = hitTestResult;
return true;
}
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;
window()->setProperty("__margins",7);
}else{
window()->setProperty("__margins",0);
}
_setMaximizeHovered(false);
*result = WVR_REDRAW;
@ -251,7 +232,7 @@ void FluFrameless::componentComplete() {
return true;
} else if (uMsg == WM_NCPAINT) {
*result = FALSE;
return true;
return false;
} else if (uMsg == WM_NCACTIVATE) {
*result = TRUE;
return true;

View File

@ -16,7 +16,6 @@ Window {
property Item appBar: FluAppBar {
title: window.title
height: 30
width: window.width
showDark: window.showDark
showClose: window.showClose
showMinimize: window.showMinimize
@ -41,6 +40,7 @@ Window {
property bool autoCenter: true
property bool autoDestroy: true
property bool useSystemAppBar
property int __margins: 0
property color resizeBorderColor: {
if(window.active){
return FluTheme.dark ? Qt.rgba(51/255,51/255,51/255,1) : Qt.rgba(110/255,110/255,110/255,1)
@ -174,6 +174,11 @@ Window {
id:com_app_bar
Item{
data: window.appBar
Component.onCompleted: {
window.appBar.width = Qt.binding(function(){
return this.parent.width
})
}
}
}
Component{
@ -246,53 +251,59 @@ Window {
border.color: window.resizeBorderColor
}
}
FluLoader{
anchors.fill: parent
sourceComponent: background
}
FluLoader{
id:loader_app_bar
anchors {
top: parent.top
left: parent.left
right: parent.right
}
height: {
if(window.useSystemAppBar){
return 0
}
return window.fitsAppBarWindows ? 0 : window.appBar.height
}
sourceComponent: window.useSystemAppBar ? undefined : com_app_bar
}
Item{
id:layout_content
anchors{
top: loader_app_bar.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
id: layout_container
anchors.fill: parent
anchors.margins: window.__margins
FluLoader{
anchors.fill: parent
sourceComponent: background
}
clip: true
}
FluLoader{
property string loadingText
property bool cancel: false
id:loader_loading
anchors.fill: parent
}
FluInfoBar{
id:info_bar
root: window
}
FluLoader{
id:loader_border
anchors.fill: parent
sourceComponent: {
if(window.useSystemAppBar || FluTools.isWin() || window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
return undefined
FluLoader{
id:loader_app_bar
anchors {
top: parent.top
left: parent.left
right: parent.right
}
height: {
if(window.useSystemAppBar){
return 0
}
return window.fitsAppBarWindows ? 0 : window.appBar.height
}
sourceComponent: window.useSystemAppBar ? undefined : com_app_bar
}
Item{
id:layout_content
anchors{
top: loader_app_bar.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
clip: true
}
FluLoader{
property string loadingText
property bool cancel: false
id:loader_loading
anchors.fill: parent
}
FluInfoBar{
id:info_bar
root: layout_container
}
FluLoader{
id:loader_border
anchors.fill: parent
sourceComponent: {
if(window.useSystemAppBar || FluTools.isWin() || window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
return undefined
}
return com_border
}
return com_border
}
}
function hideLoading(){
@ -325,9 +336,6 @@ Window {
window.minimumHeight = window.height
}
}
function registerForWindowResult(path){
return FluApp.createWindowRegister(window,path)
}
function setResult(data){
if(_windowRegister){
_windowRegister.setResult(data)

View File

@ -15,7 +15,6 @@ Window {
property Item appBar: FluAppBar {
title: window.title
height: 30
width: window.width
showDark: window.showDark
showClose: window.showClose
showMinimize: window.showMinimize
@ -40,6 +39,7 @@ Window {
property bool autoCenter: true
property bool autoDestroy: true
property bool useSystemAppBar
property int __margins: 0
property color resizeBorderColor: {
if(window.active){
return FluTheme.dark ? Qt.rgba(51/255,51/255,51/255,1) : Qt.rgba(110/255,110/255,110/255,1)
@ -173,6 +173,11 @@ Window {
id:com_app_bar
Item{
data: window.appBar
Component.onCompleted: {
window.appBar.width = Qt.binding(function(){
return this.parent.width
})
}
}
}
Component{
@ -245,53 +250,59 @@ Window {
border.color: window.resizeBorderColor
}
}
FluLoader{
anchors.fill: parent
sourceComponent: background
}
FluLoader{
id:loader_app_bar
anchors {
top: parent.top
left: parent.left
right: parent.right
}
height: {
if(window.useSystemAppBar){
return 0
}
return window.fitsAppBarWindows ? 0 : window.appBar.height
}
sourceComponent: window.useSystemAppBar ? undefined : com_app_bar
}
Item{
id:layout_content
anchors{
top: loader_app_bar.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
id: layout_container
anchors.fill: parent
anchors.margins: window.__margins
FluLoader{
anchors.fill: parent
sourceComponent: background
}
clip: true
}
FluLoader{
property string loadingText
property bool cancel: false
id:loader_loading
anchors.fill: parent
}
FluInfoBar{
id:info_bar
root: window
}
FluLoader{
id:loader_border
anchors.fill: parent
sourceComponent: {
if(window.useSystemAppBar || FluTools.isWin() || window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
return undefined
FluLoader{
id:loader_app_bar
anchors {
top: parent.top
left: parent.left
right: parent.right
}
height: {
if(window.useSystemAppBar){
return 0
}
return window.fitsAppBarWindows ? 0 : window.appBar.height
}
sourceComponent: window.useSystemAppBar ? undefined : com_app_bar
}
Item{
id:layout_content
anchors{
top: loader_app_bar.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
clip: true
}
FluLoader{
property string loadingText
property bool cancel: false
id:loader_loading
anchors.fill: parent
}
FluInfoBar{
id:info_bar
root: layout_container
}
FluLoader{
id:loader_border
anchors.fill: parent
sourceComponent: {
if(window.useSystemAppBar || FluTools.isWin() || window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
return undefined
}
return com_border
}
return com_border
}
}
function hideLoading(){