This commit is contained in:
朱子楚\zhuzi 2023-12-16 15:25:37 +08:00
parent 5e38493403
commit ecd0f29d30
3 changed files with 105 additions and 130 deletions

View File

@ -1,7 +1,7 @@
#include "FluFrameless.h"
#include <QGuiApplication>
#include <QOperatingSystemVersion>
#ifdef Q_OS_WIN
#pragma comment(lib, "user32.lib")
#include <windows.h>
@ -46,10 +46,11 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
}
return false;
}else if(uMsg == WM_NCCALCSIZE){
NCCALCSIZE_PARAMS* sz = reinterpret_cast<NCCALCSIZE_PARAMS*>(msg->lParam);
*result = WVR_REDRAW;
sz->rgrc[0].top -= 1;
return true;
}else if(uMsg == WM_NCPAINT){
*result = WVR_REDRAW;
return false;
}
return false;
#endif
@ -90,6 +91,7 @@ void FluFrameless::updateCursor(int edges){
bool FluFrameless::eventFilter(QObject *obj, QEvent *ev){
if (!_window.isNull() && _window->flags()& Qt::FramelessWindowHint) {
static int edges = 0;
const int margin = 8;
switch (ev->type()) {
@ -162,13 +164,7 @@ void FluFrameless::componentComplete(){
HWND hwnd = reinterpret_cast<HWND>(_window->winId());
ULONG_PTR cNewStyle = GetClassLongPtr(hwnd, GCL_STYLE) | CS_DROPSHADOW;
SetClassLongPtr(hwnd, GCL_STYLE, cNewStyle);
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE |SWP_FRAMECHANGED);
SetWindowLong(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);
connect(this,&FluFrameless::stayTopChanged,this,[this,hwnd](){
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
SetWindowLong(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);
});
#endif
}
}

View File

@ -197,71 +197,60 @@ Window {
FluLoader{
id:loader_frameless
}
onWidthChanged: {
window.appBar.width = width
}
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
id:container
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: container
}
FluInfoBar{
id:infoBar
root: window
}
WindowLifecycle{
id:lifecycle
}
Rectangle{
anchors.fill: parent
anchors.margins: {
if(FluTools.isWin() && !window.useSystemAppBar){
return window.visibility === Window.Maximized ? 8 : 0
color:"transparent"
border.width: window.resizeBorderWidth
border.color: window.resizeBorderColor
visible: {
if(window.useSystemAppBar){
return false
}
return 0
}
onWidthChanged: {
window.appBar.width = width
}
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:container
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: container
}
FluInfoBar{
id:infoBar
root: window
}
WindowLifecycle{
id:lifecycle
}
Rectangle{
anchors.fill: parent
color:"transparent"
anchors.topMargin: FluTools.isWin() ? 1/Screen.devicePixelRatio : 0
border.width: window.resizeBorderWidth
border.color: window.resizeBorderColor
visible: {
if(window.useSystemAppBar){
return false
}
if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){
return false
}
return true
if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){
return false
}
return true
}
}
function destoryOnClose(){

View File

@ -196,70 +196,60 @@ Window {
FluLoader{
id:loader_frameless
}
onWidthChanged: {
window.appBar.width = width
}
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
id:container
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: container
}
FluInfoBar{
id:infoBar
root: window
}
WindowLifecycle{
id:lifecycle
}
Rectangle{
anchors.fill: parent
anchors.margins: {
if(FluTools.isWin() && !window.useSystemAppBar){
return window.visibility === Window.Maximized ? 8 : 0
color:"transparent"
border.width: window.resizeBorderWidth
border.color: window.resizeBorderColor
visible: {
if(window.useSystemAppBar){
return false
}
return 0
}
onWidthChanged: {
window.appBar.width = width
}
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:container
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: container
}
FluInfoBar{
id:infoBar
root: window
}
WindowLifecycle{
id:lifecycle
}
Rectangle{
anchors.fill: parent
color:"transparent"
border.width: window.resizeBorderWidth
border.color: window.resizeBorderColor
visible: {
if(window.useSystemAppBar){
return false
}
if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){
return false
}
return true
if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){
return false
}
return true
}
}
function destoryOnClose(){