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
radius: 4
color: mouse_item.containsMouse ? Qt.lighter(modelData.normal,1.1) : modelData.normal
border.color: modelData.darkest
border.color: modelData.darker
FluIcon {
anchors.centerIn: parent
iconSource: FluentIcons.AcceptMedium

View File

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

View File

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

View File

@ -21,7 +21,6 @@ FluWindow {
fitsAppBarWindows: true
appBar: FluAppBar {
height: 30
darkText: qsTr("Dark Mode")
showDark: true
darkClickListener:(button)=>handleDarkChanged(button)
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.y = geometry.height()*pixelRatio + offsetXY.y() * 2;
#endif
return false;
}else if(uMsg == WM_NCRBUTTONDOWN){
if (wParam == HTCAPTION) {
_helper->showSystemMenu(QCursor::pos());

View File

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

View File

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

View File

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

View File

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

View File

@ -2322,6 +2322,7 @@ Module {
defaultProperty: "data"
Property { name: "title"; type: "string" }
Property { name: "darkText"; type: "string" }
Property { name: "lightText"; type: "string" }
Property { name: "minimizeText"; type: "string" }
Property { name: "restoreText"; type: "string" }
Property { name: "maximizeText"; type: "string" }
@ -2381,7 +2382,7 @@ Module {
}
Property {
name: "buttonDark"
type: "FluToggleSwitch_QMLTYPE_22"
type: "FluIconButton_QMLTYPE_17"
isReadonly: true
isPointer: true
}
@ -3052,15 +3053,15 @@ Module {
defaultProperty: "data"
Property { name: "logo"; type: "QUrl" }
Property { name: "title"; type: "string" }
Property { name: "items"; type: "FluObject_QMLTYPE_157"; isPointer: true }
Property { name: "footerItems"; type: "FluObject_QMLTYPE_157"; isPointer: true }
Property { name: "items"; type: "FluObject_QMLTYPE_129"; isPointer: true }
Property { name: "footerItems"; type: "FluObject_QMLTYPE_129"; isPointer: true }
Property { name: "displayMode"; type: "int" }
Property { name: "autoSuggestBox"; type: "QQmlComponent"; isPointer: true }
Property { name: "actionItem"; type: "QQmlComponent"; isPointer: true }
Property { name: "topPadding"; type: "int" }
Property { name: "pageMode"; type: "int" }
Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_47"; isPointer: true }
Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_47"; isPointer: true }
Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_31"; isPointer: true }
Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_31"; isPointer: true }
Property { name: "navCompactWidth"; type: "int" }
Property { name: "navTopMargin"; type: "int" }
Property { name: "cellHeight"; type: "int" }

View File

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

View File

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