Compare commits

...

2 Commits

Author SHA1 Message Date
朱子楚\zhuzi cc4e88adbd update 2024-01-02 22:55:17 +08:00
朱子楚\zhuzi 284afed52f update 2024-01-02 22:33:47 +08:00
12 changed files with 80 additions and 56 deletions

View File

@ -67,10 +67,10 @@ FluScrollablePage{
text:"Always" text:"Always"
Layout.preferredWidth: 120 Layout.preferredWidth: 120
FluMenuItem{ FluMenuItem{
text:"Nerver" text:"Never"
onClicked: { onClicked: {
btn_close_button_visibility.text = text btn_close_button_visibility.text = text
tab_view.closeButtonVisibility = FluTabViewType.Nerver tab_view.closeButtonVisibility = FluTabViewType.Never
} }
} }
FluMenuItem{ FluMenuItem{

View File

@ -68,10 +68,10 @@ FluScrollablePage{
text:"Always" text:"Always"
Layout.preferredWidth: 120 Layout.preferredWidth: 120
FluMenuItem{ FluMenuItem{
text:"Nerver" text:"Never"
onClicked: { onClicked: {
btn_close_button_visibility.text = text btn_close_button_visibility.text = text
tab_view.closeButtonVisibility = FluTabViewType.Nerver tab_view.closeButtonVisibility = FluTabViewType.Never
} }
} }
FluMenuItem{ FluMenuItem{

View File

@ -145,7 +145,7 @@ enum TabWidthBehavior {
}; };
Q_ENUM_NS(TabWidthBehavior) Q_ENUM_NS(TabWidthBehavior)
enum CloseButtonVisibility { enum CloseButtonVisibility {
Nerver = 0x0000, Never = 0x0000,
Always = 0x0001, Always = 0x0001,
OnHover = 0x0002 OnHover = 0x0002
}; };

View File

@ -57,21 +57,26 @@ static inline bool isCompositionEnabled(){
} }
return composition_enabled; return composition_enabled;
} }
return false; return true;
} }
static inline void showShadow(HWND hwnd){ static inline void showShadow(HWND hwnd){
const MARGINS shadow = { 0, 0, 1, 0 }; if(isCompositionEnabled()){
typedef HRESULT (WINAPI* DwmExtendFrameIntoClientAreaPtr)(HWND hWnd, const MARGINS *pMarInset); const MARGINS shadow = { 0, 0, 1, 0 };
HMODULE module = LoadLibraryW(L"dwmapi.dll"); typedef HRESULT (WINAPI* DwmExtendFrameIntoClientAreaPtr)(HWND hWnd, const MARGINS *pMarInset);
if (module) 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); 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);
}
} }
}else{
ULONG_PTR cNewStyle = GetClassLongPtr(hwnd, GCL_STYLE) | CS_DROPSHADOW;
SetClassLongPtr(hwnd, GCL_STYLE, cNewStyle);
} }
} }
@ -111,7 +116,9 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
}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]);
const LONG originalTop = clientRect->top; const LONG originalTop = clientRect->top;
const LONG originalBottom = clientRect->bottom;
const LONG originalLeft = clientRect->left; const LONG originalLeft = clientRect->left;
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 = hitTestResult;
@ -133,7 +140,14 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
offsetTop = 1; offsetTop = 1;
} }
} }
clientRect->top = originalTop+offsetTop; if(isCompositionEnabled()){
clientRect->top = originalTop+offsetTop;
}else{
clientRect->top = originalTop;
clientRect->bottom = originalBottom;
clientRect->left = originalLeft;
clientRect->right = originalRight;
}
*result = WVR_REDRAW; *result = WVR_REDRAW;
return true; return true;
}if(uMsg == WM_NCHITTEST){ }if(uMsg == WM_NCHITTEST){
@ -157,8 +171,8 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
QGuiApplication::sendEvent(_helper->maximizeButton(),&event); QGuiApplication::sendEvent(_helper->maximizeButton(),&event);
} }
return false; return false;
}else if(uMsg == WM_NCPAINT){ }else if(uMsg == WM_NCPAINT || uMsg == 0x00AE || uMsg == 0x00AF){
*result = 0; *result = FALSE;
return true; return true;
}else if(uMsg == WM_NCACTIVATE){ }else if(uMsg == WM_NCACTIVATE){
*result = DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1); *result = DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1);
@ -285,23 +299,21 @@ void FluFramelessHelper::componentComplete(){
_realHeight = QQmlProperty(window,"_realHeight"); _realHeight = QQmlProperty(window,"_realHeight");
_realWidth = QQmlProperty(window,"_realWidth"); _realWidth = QQmlProperty(window,"_realWidth");
_appBarHeight = QQmlProperty(window,"_appBarHeight"); _appBarHeight = QQmlProperty(window,"_appBarHeight");
_enableMarginsBottomLeftRight = QQmlProperty(window,"_enableMarginsBottomLeftRight");
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if(isCompositionEnabled()){ _enableMarginsBottomLeftRight.write(!isCompositionEnabled());
window->setFlag(Qt::CustomizeWindowHint,true); window->setFlag(Qt::CustomizeWindowHint,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());
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE); DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
if(resizeable()){ if(resizeable()){
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_THICKFRAME);
}
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
}else{ }else{
window->setFlags((window->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window); SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);
} }
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
@ -374,10 +386,8 @@ FluFramelessHelper::~FluFramelessHelper(){
if (!window.isNull()) { if (!window.isNull()) {
window->setFlags(Qt::Window); window->setFlags(Qt::Window);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if(isCompositionEnabled()){ qApp->removeNativeEventFilter(_nativeEvent);
qApp->removeNativeEventFilter(_nativeEvent); delete _nativeEvent;
delete _nativeEvent;
}
#endif #endif
window->removeEventFilter(this); window->removeEventFilter(this);
} }

View File

@ -61,6 +61,7 @@ private:
QQmlProperty _realHeight; QQmlProperty _realHeight;
QQmlProperty _realWidth; QQmlProperty _realWidth;
QQmlProperty _appBarHeight; QQmlProperty _appBarHeight;
QQmlProperty _enableMarginsBottomLeftRight;
}; };
#endif // FLUFRAMELESSHELPER_H #endif // FLUFRAMELESSHELPER_H

View File

@ -44,6 +44,7 @@ Rectangle{
d.win.visibility = Window.Windowed d.win.visibility = Window.Windowed
else else
d.win.visibility = Window.Maximized d.win.visibility = Window.Maximized
d.hoverMaxBtn = false
} }
} }
property var minClickListener: function(){ property var minClickListener: function(){

View File

@ -236,7 +236,7 @@ Item {
width: visible ? 24 : 0 width: visible ? 24 : 0
height: 24 height: 24
visible: { visible: {
if(closeButtonVisibility === FluTabViewType.Nerver) if(closeButtonVisibility === FluTabViewType.Never)
return false return false
if(closeButtonVisibility === FluTabViewType.OnHover) if(closeButtonVisibility === FluTabViewType.OnHover)
return item_mouse_hove.containsMouse || item_btn_close.hovered return item_mouse_hove.containsMouse || item_btn_close.hovered

View File

@ -64,6 +64,7 @@ Window {
property int _realHeight property int _realHeight
property int _realWidth property int _realWidth
property int _appBarHeight: appBar.height property int _appBarHeight: appBar.height
property bool _enableMarginsBottomLeftRight: false
id:window id:window
color:"transparent" color:"transparent"
Component.onCompleted: { Component.onCompleted: {
@ -209,6 +210,9 @@ Window {
anchors{ anchors{
fill:parent fill:parent
topMargin: _offsetXY.y topMargin: _offsetXY.y
bottomMargin: _enableMarginsBottomLeftRight ? _offsetXY.y : 0
leftMargin: _enableMarginsBottomLeftRight ? _offsetXY.x : 0
rightMargin: _enableMarginsBottomLeftRight ? _offsetXY.x : 0
} }
onWidthChanged: { onWidthChanged: {
window.appBar.width = width window.appBar.width = width

View File

@ -80,6 +80,8 @@ Module {
prototype: "QObject" prototype: "QObject"
exports: ["FluentUI/FluFramelessHelper 1.0"] exports: ["FluentUI/FluFramelessHelper 1.0"]
exportMetaObjectRevisions: [0] exportMetaObjectRevisions: [0]
Signal { name: "loadCompleted" }
Method { name: "showSystemMenu" }
} }
Component { Component {
name: "FluNavigationViewType" name: "FluNavigationViewType"
@ -186,7 +188,7 @@ Module {
Enum { Enum {
name: "CloseButtonVisibility" name: "CloseButtonVisibility"
values: { values: {
"Nerver": 0, "Never": 0,
"Always": 1, "Always": 1,
"OnHover": 2 "OnHover": 2
} }
@ -2341,11 +2343,13 @@ Module {
Property { name: "closeClickListener"; type: "QVariant" } Property { name: "closeClickListener"; type: "QVariant" }
Property { name: "stayTopClickListener"; type: "QVariant" } Property { name: "stayTopClickListener"; type: "QVariant" }
Property { name: "darkClickListener"; type: "QVariant" } Property { name: "darkClickListener"; type: "QVariant" }
Property { name: "systemMenuListener"; type: "QVariant" }
Method { name: "stayTopButton"; type: "QVariant" } Method { name: "stayTopButton"; type: "QVariant" }
Method { name: "minimizeButton"; type: "QVariant" } Method { name: "minimizeButton"; type: "QVariant" }
Method { name: "maximizeButton"; type: "QVariant" } Method { name: "maximizeButton"; type: "QVariant" }
Method { name: "closeButton"; type: "QVariant" } Method { name: "closeButton"; type: "QVariant" }
Method { name: "darkButton"; type: "QVariant" } Method { name: "darkButton"; type: "QVariant" }
Method { name: "maximizeButtonHover"; type: "QVariant" }
} }
Component { Component {
prototype: "QQuickRectangle" prototype: "QQuickRectangle"
@ -3013,15 +3017,15 @@ Module {
defaultProperty: "data" defaultProperty: "data"
Property { name: "logo"; type: "QUrl" } Property { name: "logo"; type: "QUrl" }
Property { name: "title"; type: "string" } Property { name: "title"; type: "string" }
Property { name: "items"; type: "FluObject_QMLTYPE_125"; isPointer: true } Property { name: "items"; type: "FluObject_QMLTYPE_157"; isPointer: true }
Property { name: "footerItems"; type: "FluObject_QMLTYPE_125"; isPointer: true } Property { name: "footerItems"; type: "FluObject_QMLTYPE_157"; isPointer: true }
Property { name: "displayMode"; type: "int" } Property { name: "displayMode"; type: "int" }
Property { name: "autoSuggestBox"; type: "QQmlComponent"; isPointer: true } Property { name: "autoSuggestBox"; type: "QQmlComponent"; isPointer: true }
Property { name: "actionItem"; type: "QQmlComponent"; isPointer: true } Property { name: "actionItem"; type: "QQmlComponent"; isPointer: true }
Property { name: "topPadding"; type: "int" } Property { name: "topPadding"; type: "int" }
Property { name: "pageMode"; type: "int" } Property { name: "pageMode"; type: "int" }
Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_34"; isPointer: true } Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_45"; isPointer: true }
Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_34"; isPointer: true } Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_45"; isPointer: true }
Property { name: "navCompactWidth"; type: "int" } Property { name: "navCompactWidth"; type: "int" }
Property { name: "navTopMargin"; type: "int" } Property { name: "navTopMargin"; type: "int" }
Property { name: "cellHeight"; type: "int" } Property { name: "cellHeight"; type: "int" }
@ -3109,21 +3113,17 @@ Module {
Property { name: "_ext"; type: "QVariant" } Property { name: "_ext"; type: "QVariant" }
Property { name: "_parent"; type: "QVariant" } Property { name: "_parent"; type: "QVariant" }
Property { name: "title"; type: "string" } Property { name: "title"; type: "string" }
Property { name: "order"; type: "int" }
Property { name: "url"; type: "QVariant" } Property { name: "url"; type: "QVariant" }
Property { name: "disabled"; type: "bool" } Property { name: "disabled"; type: "bool" }
Property { name: "icon"; type: "int" } Property { name: "icon"; type: "int" }
Property { name: "iconVisible"; type: "bool" } Property { name: "iconVisible"; type: "bool" }
Property { name: "infoBadge"; type: "QQmlComponent"; isPointer: true } Property { name: "infoBadge"; type: "QQmlComponent"; isPointer: true }
Property { name: "recentlyAdded"; type: "bool" }
Property { name: "recentlyUpdated"; type: "bool" }
Property { name: "desc"; type: "string" }
Property { name: "image"; type: "QVariant" }
Property { name: "count"; type: "int" } Property { name: "count"; type: "int" }
Property { name: "onTapListener"; type: "QVariant" } Property { name: "onTapListener"; type: "QVariant" }
Property { name: "iconDelegate"; type: "QQmlComponent"; isPointer: true } Property { name: "iconDelegate"; type: "QQmlComponent"; isPointer: true }
Property { name: "menuDelegate"; type: "QQmlComponent"; isPointer: true } Property { name: "menuDelegate"; type: "QQmlComponent"; isPointer: true }
Property { name: "editDelegate"; type: "QQmlComponent"; isPointer: true } Property { name: "editDelegate"; type: "QQmlComponent"; isPointer: true }
Property { name: "extra"; type: "QVariant" }
Property { name: "showEdit"; type: "bool" } Property { name: "showEdit"; type: "bool" }
Signal { name: "tap" } Signal { name: "tap" }
} }
@ -3534,13 +3534,6 @@ Module {
} }
Method { name: "count"; type: "QVariant" } Method { name: "count"; type: "QVariant" }
} }
Component {
prototype: "QQmlTableModelColumn"
name: "FluentUI/FluTableModelColumn 1.0"
exports: ["FluentUI/FluTableModelColumn 1.0"]
exportMetaObjectRevisions: [0]
isComposite: true
}
Component { Component {
prototype: "QQuickRectangle" prototype: "QQuickRectangle"
name: "FluentUI/FluTableView 1.0" name: "FluentUI/FluTableView 1.0"
@ -3798,7 +3791,15 @@ Module {
Property { name: "resizeBorderColor"; type: "QColor" } Property { name: "resizeBorderColor"; type: "QColor" }
Property { name: "resizeBorderWidth"; type: "int" } Property { name: "resizeBorderWidth"; type: "int" }
Property { name: "closeListener"; type: "QVariant" } Property { name: "closeListener"; type: "QVariant" }
Property { name: "_offsetXY"; type: "QPointF" }
Property { name: "_originalPos"; type: "QVariant" }
Property { name: "_accentColor"; type: "QColor" }
Property { name: "_realHeight"; type: "int" }
Property { name: "_realWidth"; type: "int" }
Property { name: "_appBarHeight"; type: "int" }
Property { name: "_enableMarginsBottomLeftRight"; type: "bool" }
Property { name: "content"; type: "QObject"; isList: true; isReadonly: true } Property { name: "content"; type: "QObject"; isList: true; isReadonly: true }
Signal { name: "showSystemMenu" }
Signal { Signal {
name: "initArgument" name: "initArgument"
Parameter { name: "argument"; type: "QVariant" } Parameter { name: "argument"; type: "QVariant" }
@ -3846,12 +3847,14 @@ Module {
Parameter { name: "path"; type: "QVariant" } Parameter { name: "path"; type: "QVariant" }
} }
Method { name: "moveWindowToDesktopCenter"; type: "QVariant" } Method { name: "moveWindowToDesktopCenter"; type: "QVariant" }
Method { name: "fixWindowSize"; type: "QVariant" }
Method { Method {
name: "onResult" name: "onResult"
type: "QVariant" type: "QVariant"
Parameter { name: "data"; type: "QVariant" } Parameter { name: "data"; type: "QVariant" }
} }
Method { name: "containerItem"; type: "QVariant" } Method { name: "layoutContainer"; type: "QVariant" }
Method { name: "layoutContent"; type: "QVariant" }
} }
Component { Component {
prototype: "QQuickRow" prototype: "QQuickRow"

View File

@ -44,6 +44,7 @@ Rectangle{
d.win.visibility = Window.Windowed d.win.visibility = Window.Windowed
else else
d.win.visibility = Window.Maximized d.win.visibility = Window.Maximized
d.hoverMaxBtn = false
} }
} }
property var minClickListener: function(){ property var minClickListener: function(){

View File

@ -236,7 +236,7 @@ Item {
width: visible ? 24 : 0 width: visible ? 24 : 0
height: 24 height: 24
visible: { visible: {
if(closeButtonVisibility === FluTabViewType.Nerver) if(closeButtonVisibility === FluTabViewType.Never)
return false return false
if(closeButtonVisibility === FluTabViewType.OnHover) if(closeButtonVisibility === FluTabViewType.OnHover)
return item_mouse_hove.containsMouse || item_btn_close.hovered return item_mouse_hove.containsMouse || item_btn_close.hovered

View File

@ -63,6 +63,7 @@ Window {
property int _realHeight property int _realHeight
property int _realWidth property int _realWidth
property int _appBarHeight: appBar.height property int _appBarHeight: appBar.height
property bool _enableMarginsBottomLeftRight: false
id:window id:window
color:"transparent" color:"transparent"
Component.onCompleted: { Component.onCompleted: {
@ -208,6 +209,9 @@ Window {
anchors{ anchors{
fill:parent fill:parent
topMargin: _offsetXY.y topMargin: _offsetXY.y
bottomMargin: _enableMarginsBottomLeftRight ? _offsetXY.y : 0
leftMargin: _enableMarginsBottomLeftRight ? _offsetXY.x : 0
rightMargin: _enableMarginsBottomLeftRight ? _offsetXY.x : 0
} }
onWidthChanged: { onWidthChanged: {
window.appBar.width = width window.appBar.width = width