This commit is contained in:
朱子楚\zhuzi 2024-03-12 22:59:56 +08:00
parent 80f8f5f01e
commit e11f1a1232
12 changed files with 78 additions and 40 deletions

View File

@ -35,7 +35,7 @@ FluScrollablePage{
height: 42 height: 42
radius: 4 radius: 4
color: mouse_item.containsMouse ? Qt.lighter(modelData.normal,1.1) : modelData.normal color: mouse_item.containsMouse ? Qt.lighter(modelData.normal,1.1) : modelData.normal
border.color: modelData.darkest border.color: modelData.darker
FluIcon { FluIcon {
anchors.centerIn: parent anchors.centerIn: parent
iconSource: FluentIcons.AcceptMedium iconSource: FluentIcons.AcceptMedium

View File

@ -21,7 +21,6 @@ FluWindow {
fitsAppBarWindows: true fitsAppBarWindows: true
appBar: FluAppBar { appBar: FluAppBar {
height: 30 height: 30
darkText: qsTr("Dark Mode")
showDark: true showDark: true
darkClickListener:(button)=>handleDarkChanged(button) darkClickListener:(button)=>handleDarkChanged(button)
closeClickListener: ()=>{dialog_close.open()} closeClickListener: ()=>{dialog_close.open()}

View File

@ -35,7 +35,7 @@ FluScrollablePage{
height: 42 height: 42
radius: 4 radius: 4
color: mouse_item.containsMouse ? Qt.lighter(modelData.normal,1.1) : modelData.normal color: mouse_item.containsMouse ? Qt.lighter(modelData.normal,1.1) : modelData.normal
border.color: modelData.darkest border.color: modelData.darker
FluIcon { FluIcon {
anchors.centerIn: parent anchors.centerIn: parent
iconSource: FluentIcons.AcceptMedium iconSource: FluentIcons.AcceptMedium

View File

@ -21,7 +21,6 @@ FluWindow {
fitsAppBarWindows: true fitsAppBarWindows: true
appBar: FluAppBar { appBar: FluAppBar {
height: 30 height: 30
darkText: qsTr("Dark Mode")
showDark: true showDark: true
darkClickListener:(button)=>handleDarkChanged(button) darkClickListener:(button)=>handleDarkChanged(button)
closeClickListener: ()=>{dialog_close.open()} closeClickListener: ()=>{dialog_close.open()}

View File

@ -182,6 +182,7 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
minmaxInfo->ptMaxSize.x = geometry.width()*pixelRatio + offsetXY.x() * 2; minmaxInfo->ptMaxSize.x = geometry.width()*pixelRatio + offsetXY.x() * 2;
minmaxInfo->ptMaxSize.y = geometry.height()*pixelRatio + offsetXY.y() * 2; minmaxInfo->ptMaxSize.y = geometry.height()*pixelRatio + offsetXY.y() * 2;
#endif #endif
return false;
}else if(uMsg == WM_NCRBUTTONDOWN){ }else if(uMsg == WM_NCRBUTTONDOWN){
if (wParam == HTCAPTION) { if (wParam == HTCAPTION) {
_helper->showSystemMenu(QCursor::pos()); _helper->showSystemMenu(QCursor::pos());

View File

@ -241,6 +241,6 @@ bool FluTools::isWindows10OrGreater(){
} }
} }
int FluTools::getTaskBarHeight(QQuickWindow* window){ QRect FluTools::desktopAvailableGeometry(QQuickWindow* window){
return window->screen()->geometry().height() - window->screen()->availableGeometry().height(); return window->screen()->availableGeometry();
} }

View File

@ -55,7 +55,7 @@ public:
Q_INVOKABLE int windowBuildNumber(); Q_INVOKABLE int windowBuildNumber();
Q_INVOKABLE bool isWindows11OrGreater(); Q_INVOKABLE bool isWindows11OrGreater();
Q_INVOKABLE bool isWindows10OrGreater(); Q_INVOKABLE bool isWindows10OrGreater();
Q_INVOKABLE int getTaskBarHeight(QQuickWindow* window); Q_INVOKABLE QRect desktopAvailableGeometry(QQuickWindow* window);
}; };
#endif // FLUTOOLS_H #endif // FLUTOOLS_H

View File

@ -6,7 +6,8 @@ import FluentUI 1.0
Rectangle{ Rectangle{
property string title: "" property string title: ""
property string darkText : "夜间模式" property string darkText : "深色"
property string lightText : "浅色"
property string minimizeText : "最小化" property string minimizeText : "最小化"
property string restoreText : "向下还原" property string restoreText : "向下还原"
property string maximizeText : "最大化" property string maximizeText : "最大化"
@ -199,24 +200,33 @@ Rectangle{
Component.onCompleted: { Component.onCompleted: {
setHitTestVisible(layout_row) setHitTestVisible(layout_row)
} }
FluToggleSwitch{ FluIconButton{
id:btn_dark id:btn_dark
Layout.preferredWidth: 40
Layout.preferredHeight: 30
padding: 0
verticalPadding: 0
horizontalPadding: 0
rightPadding: 2
iconSource: FluTheme.dark ? FluentIcons.Brightness : FluentIcons.QuietHours
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
Layout.rightMargin: 5 iconSize: 15
visible: showDark visible: showDark
text:darkText text: FluTheme.dark ? control.lightText : control.darkText
textColor:control.textColor radius: 0
checked: FluTheme.dark iconColor:control.textColor
textRight: false onClicked:()=> darkClickListener(btn_dark)
clickListener:()=> darkClickListener(btn_dark)
} }
FluIconButton{ FluIconButton{
id:btn_stay_top id:btn_stay_top
Layout.preferredWidth: 40 Layout.preferredWidth: 40
Layout.preferredHeight: 30 Layout.preferredHeight: 30
padding: 0
verticalPadding: 0
horizontalPadding: 0
iconSource : FluentIcons.Pinned iconSource : FluentIcons.Pinned
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
iconSize: 13 iconSize: 14
visible: { visible: {
if(!(d.win instanceof FluWindow)){ if(!(d.win instanceof FluWindow)){
return false return false
@ -232,6 +242,9 @@ Rectangle{
id:btn_minimize id:btn_minimize
Layout.preferredWidth: 40 Layout.preferredWidth: 40
Layout.preferredHeight: 30 Layout.preferredHeight: 30
padding: 0
verticalPadding: 0
horizontalPadding: 0
iconSource : FluentIcons.ChromeMinimize iconSource : FluentIcons.ChromeMinimize
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
iconSize: 11 iconSize: 11
@ -251,6 +264,9 @@ Rectangle{
id:btn_maximize id:btn_maximize
Layout.preferredWidth: 40 Layout.preferredWidth: 40
Layout.preferredHeight: 30 Layout.preferredHeight: 30
padding: 0
verticalPadding: 0
horizontalPadding: 0
iconSource : d.isRestore ? FluentIcons.ChromeRestore : FluentIcons.ChromeMaximize iconSource : d.isRestore ? FluentIcons.ChromeRestore : FluentIcons.ChromeMaximize
color: { color: {
if(down){ if(down){
@ -271,11 +287,14 @@ Rectangle{
} }
FluIconButton{ FluIconButton{
id:btn_close id:btn_close
Layout.preferredWidth: 40
Layout.preferredHeight: 30
padding: 0
verticalPadding: 0
horizontalPadding: 0
iconSource : FluentIcons.ChromeClose iconSource : FluentIcons.ChromeClose
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
text:closeText text:closeText
Layout.preferredWidth: 40
Layout.preferredHeight: 30
visible: !isMac && showClose visible: !isMac && showClose
radius: 0 radius: 0
iconSize: 10 iconSize: 10

View File

@ -237,7 +237,7 @@ Window {
clip: true clip: true
} }
FluLoader{ FluLoader{
property string loadingText: "加载中..." property string loadingText
property bool cancel: false property bool cancel: false
id:loader_loading id:loader_loading
anchors.fill: parent anchors.fill: parent
@ -290,8 +290,8 @@ Window {
} }
function moveWindowToDesktopCenter(){ function moveWindowToDesktopCenter(){
screen = Qt.application.screens[FluTools.cursorScreenIndex()] screen = Qt.application.screens[FluTools.cursorScreenIndex()]
var taskBarHeight = FluTools.getTaskBarHeight(window) var availableGeometry = FluTools.desktopAvailableGeometry(window)
window.setGeometry((Screen.width-window.width)/2+Screen.virtualX,(Screen.height-window.height-taskBarHeight)/2+Screen.virtualY,window.width,window.height) window.setGeometry((availableGeometry.width-window.width)/2+Screen.virtualX,(availableGeometry.height-window.height)/2+Screen.virtualY,window.width,window.height)
} }
function fixWindowSize(){ function fixWindowSize(){
if(fixSize){ if(fixSize){

View File

@ -2322,6 +2322,7 @@ Module {
defaultProperty: "data" defaultProperty: "data"
Property { name: "title"; type: "string" } Property { name: "title"; type: "string" }
Property { name: "darkText"; type: "string" } Property { name: "darkText"; type: "string" }
Property { name: "lightText"; type: "string" }
Property { name: "minimizeText"; type: "string" } Property { name: "minimizeText"; type: "string" }
Property { name: "restoreText"; type: "string" } Property { name: "restoreText"; type: "string" }
Property { name: "maximizeText"; type: "string" } Property { name: "maximizeText"; type: "string" }
@ -2381,7 +2382,7 @@ Module {
} }
Property { Property {
name: "buttonDark" name: "buttonDark"
type: "FluToggleSwitch_QMLTYPE_22" type: "FluIconButton_QMLTYPE_17"
isReadonly: true isReadonly: true
isPointer: true isPointer: true
} }
@ -3052,15 +3053,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_157"; isPointer: true } Property { name: "items"; type: "FluObject_QMLTYPE_129"; isPointer: true }
Property { name: "footerItems"; type: "FluObject_QMLTYPE_157"; isPointer: true } Property { name: "footerItems"; type: "FluObject_QMLTYPE_129"; 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_47"; isPointer: true } Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_31"; isPointer: true }
Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_47"; isPointer: true } Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_31"; 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" }

View File

@ -6,7 +6,8 @@ import FluentUI
Rectangle{ Rectangle{
property string title: "" property string title: ""
property string darkText : "夜间模式" property string darkText : "深色"
property string lightText : "浅色"
property string minimizeText : "最小化" property string minimizeText : "最小化"
property string restoreText : "向下还原" property string restoreText : "向下还原"
property string maximizeText : "最大化" property string maximizeText : "最大化"
@ -199,24 +200,33 @@ Rectangle{
Component.onCompleted: { Component.onCompleted: {
setHitTestVisible(layout_row) setHitTestVisible(layout_row)
} }
FluToggleSwitch{ FluIconButton{
id:btn_dark id:btn_dark
Layout.preferredWidth: 40
Layout.preferredHeight: 30
padding: 0
verticalPadding: 0
horizontalPadding: 0
rightPadding: 2
iconSource: FluTheme.dark ? FluentIcons.Brightness : FluentIcons.QuietHours
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
Layout.rightMargin: 5 iconSize: 15
visible: showDark visible: showDark
text:darkText text: FluTheme.dark ? control.lightText : control.darkText
textColor:control.textColor radius: 0
checked: FluTheme.dark iconColor:control.textColor
textRight: false onClicked:()=> darkClickListener(btn_dark)
clickListener:()=> darkClickListener(btn_dark)
} }
FluIconButton{ FluIconButton{
id:btn_stay_top id:btn_stay_top
Layout.preferredWidth: 40 Layout.preferredWidth: 40
Layout.preferredHeight: 30 Layout.preferredHeight: 30
padding: 0
verticalPadding: 0
horizontalPadding: 0
iconSource : FluentIcons.Pinned iconSource : FluentIcons.Pinned
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
iconSize: 13 iconSize: 14
visible: { visible: {
if(!(d.win instanceof FluWindow)){ if(!(d.win instanceof FluWindow)){
return false return false
@ -232,6 +242,9 @@ Rectangle{
id:btn_minimize id:btn_minimize
Layout.preferredWidth: 40 Layout.preferredWidth: 40
Layout.preferredHeight: 30 Layout.preferredHeight: 30
padding: 0
verticalPadding: 0
horizontalPadding: 0
iconSource : FluentIcons.ChromeMinimize iconSource : FluentIcons.ChromeMinimize
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
iconSize: 11 iconSize: 11
@ -251,6 +264,9 @@ Rectangle{
id:btn_maximize id:btn_maximize
Layout.preferredWidth: 40 Layout.preferredWidth: 40
Layout.preferredHeight: 30 Layout.preferredHeight: 30
padding: 0
verticalPadding: 0
horizontalPadding: 0
iconSource : d.isRestore ? FluentIcons.ChromeRestore : FluentIcons.ChromeMaximize iconSource : d.isRestore ? FluentIcons.ChromeRestore : FluentIcons.ChromeMaximize
color: { color: {
if(down){ if(down){
@ -271,11 +287,14 @@ Rectangle{
} }
FluIconButton{ FluIconButton{
id:btn_close id:btn_close
Layout.preferredWidth: 40
Layout.preferredHeight: 30
padding: 0
verticalPadding: 0
horizontalPadding: 0
iconSource : FluentIcons.ChromeClose iconSource : FluentIcons.ChromeClose
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
text:closeText text:closeText
Layout.preferredWidth: 40
Layout.preferredHeight: 30
visible: !isMac && showClose visible: !isMac && showClose
radius: 0 radius: 0
iconSize: 10 iconSize: 10

View File

@ -236,7 +236,7 @@ Window {
clip: true clip: true
} }
FluLoader{ FluLoader{
property string loadingText: "加载中..." property string loadingText
property bool cancel: false property bool cancel: false
id:loader_loading id:loader_loading
anchors.fill: parent anchors.fill: parent
@ -289,8 +289,8 @@ Window {
} }
function moveWindowToDesktopCenter(){ function moveWindowToDesktopCenter(){
screen = Qt.application.screens[FluTools.cursorScreenIndex()] screen = Qt.application.screens[FluTools.cursorScreenIndex()]
var taskBarHeight = FluTools.getTaskBarHeight(window) var availableGeometry = FluTools.desktopAvailableGeometry(window)
window.setGeometry((Screen.width-window.width)/2+Screen.virtualX,(Screen.height-window.height-taskBarHeight)/2+Screen.virtualY,window.width,window.height) window.setGeometry((availableGeometry.width-window.width)/2+Screen.virtualX,(availableGeometry.height-window.height)/2+Screen.virtualY,window.width,window.height)
} }
function fixWindowSize(){ function fixWindowSize(){
if(fixSize){ if(fixSize){