mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-02-02 19:27:38 +08:00
update
This commit is contained in:
parent
8253fb611f
commit
bf5c722058
@ -22,7 +22,7 @@ static inline bool isWindows11OrGreater() {
|
|||||||
if (dwVersion < 0x80000000)
|
if (dwVersion < 0x80000000)
|
||||||
dwBuild = (DWORD)(HIWORD(dwVersion));
|
dwBuild = (DWORD)(HIWORD(dwVersion));
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
return dwBuild < 22000;
|
return dwBuild >= 22000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ static inline bool isCompositionEnabled(){
|
|||||||
|
|
||||||
static inline void showShadow(HWND hwnd){
|
static inline void showShadow(HWND hwnd){
|
||||||
if(isCompositionEnabled()){
|
if(isCompositionEnabled()){
|
||||||
const MARGINS shadow = { 1, 0, 0, 0 };
|
const MARGINS shadow = { 0, 0, 1, 0 };
|
||||||
typedef HRESULT (WINAPI* DwmExtendFrameIntoClientAreaPtr)(HWND hWnd, const MARGINS *pMarInset);
|
typedef HRESULT (WINAPI* DwmExtendFrameIntoClientAreaPtr)(HWND hWnd, const MARGINS *pMarInset);
|
||||||
HMODULE module = LoadLibraryW(L"dwmapi.dll");
|
HMODULE module = LoadLibraryW(L"dwmapi.dll");
|
||||||
if (module)
|
if (module)
|
||||||
@ -110,20 +110,6 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}else if(uMsg == WM_NCCALCSIZE){
|
}else if(uMsg == WM_NCCALCSIZE){
|
||||||
NCCALCSIZE_PARAMS* sz = reinterpret_cast<NCCALCSIZE_PARAMS*>(lParam);
|
|
||||||
if(IsZoomed(hwnd)){
|
|
||||||
sz->rgrc[0].left += 8;
|
|
||||||
sz->rgrc[0].top += 8;
|
|
||||||
sz->rgrc[0].right -= 8;
|
|
||||||
sz->rgrc[0].bottom -= isTaskbarAutoHide() ? 9 : 8;
|
|
||||||
}else{
|
|
||||||
sz->rgrc[0].top += isWindows11OrGreater() ? 0 : 1;
|
|
||||||
if(isCompositionEnabled()){
|
|
||||||
sz->rgrc[0].right -= 8;
|
|
||||||
sz->rgrc[0].bottom -= 8;
|
|
||||||
sz->rgrc[0].left -= -8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*result = WVR_REDRAW;
|
*result = WVR_REDRAW;
|
||||||
return true;
|
return true;
|
||||||
}else if(uMsg == WM_NCPAINT){
|
}else if(uMsg == WM_NCPAINT){
|
||||||
@ -269,9 +255,7 @@ void FluFramelessHelper::componentComplete(){
|
|||||||
}
|
}
|
||||||
if(!window.isNull()){
|
if(!window.isNull()){
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if(!isCompositionEnabled()){
|
window->setFlags(window->flags() | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);
|
||||||
window->setFlag(Qt::FramelessWindowHint,true);
|
|
||||||
}
|
|
||||||
_nativeEvent =new FramelessEventFilter(this);
|
_nativeEvent =new FramelessEventFilter(this);
|
||||||
qApp->installNativeEventFilter(_nativeEvent);
|
qApp->installNativeEventFilter(_nativeEvent);
|
||||||
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
||||||
@ -282,6 +266,7 @@ void FluFramelessHelper::componentComplete(){
|
|||||||
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);
|
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | 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);
|
||||||
|
showShadow(hwnd);
|
||||||
#else
|
#else
|
||||||
window->setFlags((window->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window);
|
window->setFlags((window->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window);
|
||||||
#endif
|
#endif
|
||||||
|
@ -208,7 +208,7 @@ bool FluTools::isWindows11OrGreater(){
|
|||||||
if (dwVersion < 0x80000000)
|
if (dwVersion < 0x80000000)
|
||||||
dwBuild = (DWORD)(HIWORD(dwVersion));
|
dwBuild = (DWORD)(HIWORD(dwVersion));
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
return dwBuild < 22000;
|
return dwBuild >= 22000;
|
||||||
#endif
|
#endif
|
||||||
var = QVariant::fromValue(false);
|
var = QVariant::fromValue(false);
|
||||||
return false;
|
return false;
|
||||||
|
@ -53,6 +53,7 @@ Window {
|
|||||||
signal showSystemMenu
|
signal showSystemMenu
|
||||||
signal initArgument(var argument)
|
signal initArgument(var argument)
|
||||||
signal firstVisible()
|
signal firstVisible()
|
||||||
|
property point _offsetXY : Qt.point(0,0)
|
||||||
id:window
|
id:window
|
||||||
color:"transparent"
|
color:"transparent"
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
@ -72,6 +73,19 @@ Window {
|
|||||||
Component.onDestruction: {
|
Component.onDestruction: {
|
||||||
lifecycle.onDestruction()
|
lifecycle.onDestruction()
|
||||||
}
|
}
|
||||||
|
onVisibilityChanged: {
|
||||||
|
if(visibility === Window.Maximized || visibility === Window.FullScreen){
|
||||||
|
var dx = window.x-Screen.virtualX
|
||||||
|
var dy = window.y-Screen.virtualY
|
||||||
|
if(dx<0 && dy<0){
|
||||||
|
_offsetXY = Qt.point(Math.abs(dx+1),Math.abs(dy+1))
|
||||||
|
}else{
|
||||||
|
_offsetXY = Qt.point(0,0)
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
_offsetXY = Qt.point(0,0)
|
||||||
|
}
|
||||||
|
}
|
||||||
onShowSystemMenu: {
|
onShowSystemMenu: {
|
||||||
if(loader_frameless_helper.item){
|
if(loader_frameless_helper.item){
|
||||||
loader_frameless_helper.item.showSystemMenu()
|
loader_frameless_helper.item.showSystemMenu()
|
||||||
@ -177,6 +191,10 @@ Window {
|
|||||||
id:layout_container
|
id:layout_container
|
||||||
anchors{
|
anchors{
|
||||||
fill:parent
|
fill:parent
|
||||||
|
leftMargin: _offsetXY.x
|
||||||
|
rightMargin: _offsetXY.x
|
||||||
|
topMargin: _offsetXY.y
|
||||||
|
bottomMargin: _offsetXY.y
|
||||||
}
|
}
|
||||||
onWidthChanged: {
|
onWidthChanged: {
|
||||||
window.appBar.width = width
|
window.appBar.width = width
|
||||||
@ -229,7 +247,7 @@ Window {
|
|||||||
border.width: window.resizeBorderWidth
|
border.width: window.resizeBorderWidth
|
||||||
border.color: window.resizeBorderColor
|
border.color: window.resizeBorderColor
|
||||||
visible: {
|
visible: {
|
||||||
if(window.useSystemAppBar || FluTools.isWin()){
|
if(window.useSystemAppBar){
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){
|
if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){
|
||||||
|
@ -52,6 +52,7 @@ Window {
|
|||||||
signal showSystemMenu
|
signal showSystemMenu
|
||||||
signal initArgument(var argument)
|
signal initArgument(var argument)
|
||||||
signal firstVisible()
|
signal firstVisible()
|
||||||
|
property point _offsetXY : Qt.point(0,0)
|
||||||
id:window
|
id:window
|
||||||
color:"transparent"
|
color:"transparent"
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
@ -71,6 +72,19 @@ Window {
|
|||||||
Component.onDestruction: {
|
Component.onDestruction: {
|
||||||
lifecycle.onDestruction()
|
lifecycle.onDestruction()
|
||||||
}
|
}
|
||||||
|
onVisibilityChanged: {
|
||||||
|
if(visibility === Window.Maximized || visibility === Window.FullScreen){
|
||||||
|
var dx = window.x-Screen.virtualX
|
||||||
|
var dy = window.y-Screen.virtualY
|
||||||
|
if(dx<0 && dy<0){
|
||||||
|
_offsetXY = Qt.point(Math.abs(dx+1),Math.abs(dy+1))
|
||||||
|
}else{
|
||||||
|
_offsetXY = Qt.point(0,0)
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
_offsetXY = Qt.point(0,0)
|
||||||
|
}
|
||||||
|
}
|
||||||
onShowSystemMenu: {
|
onShowSystemMenu: {
|
||||||
if(loader_frameless_helper.item){
|
if(loader_frameless_helper.item){
|
||||||
loader_frameless_helper.item.showSystemMenu()
|
loader_frameless_helper.item.showSystemMenu()
|
||||||
@ -176,6 +190,10 @@ Window {
|
|||||||
id:layout_container
|
id:layout_container
|
||||||
anchors{
|
anchors{
|
||||||
fill:parent
|
fill:parent
|
||||||
|
leftMargin: _offsetXY.x
|
||||||
|
rightMargin: _offsetXY.x
|
||||||
|
topMargin: _offsetXY.y
|
||||||
|
bottomMargin: _offsetXY.y
|
||||||
}
|
}
|
||||||
onWidthChanged: {
|
onWidthChanged: {
|
||||||
window.appBar.width = width
|
window.appBar.width = width
|
||||||
@ -228,7 +246,7 @@ Window {
|
|||||||
border.width: window.resizeBorderWidth
|
border.width: window.resizeBorderWidth
|
||||||
border.color: window.resizeBorderColor
|
border.color: window.resizeBorderColor
|
||||||
visible: {
|
visible: {
|
||||||
if(window.useSystemAppBar || FluTools.isWin()){
|
if(window.useSystemAppBar){
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){
|
if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){
|
||||||
|
Loading…
Reference in New Issue
Block a user