From 5f2f1276231eb6c6fc1ff3d9219e538f0d958d39 Mon Sep 17 00:00:00 2001 From: zhuzihcu Date: Wed, 31 May 2023 15:39:59 +0800 Subject: [PATCH] update --- example/qml/page/T_Settings.qml | 19 +- src/FluTools.cpp | 4 +- src/FluTools.h | 2 + src/imports/FluentUI/Controls/FluButton.qml | 39 +-- .../FluentUI/Controls/FluDropDownButton.qml | 39 +-- .../FluentUI/Controls/FluFilledButton.qml | 21 +- .../FluentUI/Controls/FluNavigationView.qml | 11 +- .../FluentUI/Controls/FluRadioButton.qml | 6 +- .../FluentUI/Controls/FluTableView2.qml | 235 ------------------ .../FluentUI/Controls/FluTextButton.qml | 22 +- 10 files changed, 88 insertions(+), 310 deletions(-) delete mode 100644 src/imports/FluentUI/Controls/FluTableView2.qml diff --git a/example/qml/page/T_Settings.qml b/example/qml/page/T_Settings.qml index fce3a20..74a6e7d 100644 --- a/example/qml/page/T_Settings.qml +++ b/example/qml/page/T_Settings.qml @@ -30,17 +30,14 @@ FluScrollablePage{ Repeater{ model: [{title:"System",mode:FluDarkMode.System},{title:"Light",mode:FluDarkMode.Light},{title:"Dark",mode:FluDarkMode.Dark}] delegate: FluRadioButton{ - selected : FluTheme.darkMode === modelData.mode + checked : FluTheme.darkMode === modelData.mode text:modelData.title - onClicked:{ + clickListener:function(){ FluTheme.darkMode = modelData.mode } } } - - } - } FluArea{ @@ -63,10 +60,10 @@ FluScrollablePage{ } Repeater{ model: [{title:"Open",mode:FluNavigationView.Open},{title:"Compact",mode:FluNavigationView.Compact},{title:"Minimal",mode:FluNavigationView.Minimal},{title:"Auto",mode:FluNavigationView.Auto}] - delegate: FluRadioButton{ - selected : MainEvent.displayMode===modelData.mode + delegate: FluRadioButton{ + checked : MainEvent.displayMode===modelData.mode text:modelData.title - onClicked:{ + clickListener:function(){ MainEvent.displayMode = modelData.mode } } @@ -97,10 +94,10 @@ FluScrollablePage{ spacing: 5 Repeater{ model: ["Zh","En"] - delegate: FluRadioButton{ - selected : appInfo.lang.objectName === modelData + delegate: FluRadioButton{ + checked: appInfo.lang.objectName === modelData text:modelData - onClicked:{ + clickListener:function(){ appInfo.changeLang(modelData) } } diff --git a/src/FluTools.cpp b/src/FluTools.cpp index af633ea..04a77af 100644 --- a/src/FluTools.cpp +++ b/src/FluTools.cpp @@ -63,4 +63,6 @@ bool FluTools::isWin(){ #endif } - +void FluTools::setQuitOnLastWindowClosed(bool val){ + qApp->setQuitOnLastWindowClosed(val); +} diff --git a/src/FluTools.h b/src/FluTools.h index 80ed187..f5c7f9f 100644 --- a/src/FluTools.h +++ b/src/FluTools.h @@ -48,6 +48,8 @@ public: Q_INVOKABLE bool isWin(); + Q_INVOKABLE void setQuitOnLastWindowClosed(bool val); + }; #endif // FLUTOOLS_H diff --git a/src/imports/FluentUI/Controls/FluButton.qml b/src/imports/FluentUI/Controls/FluButton.qml index b069ef1..286f149 100644 --- a/src/imports/FluentUI/Controls/FluButton.qml +++ b/src/imports/FluentUI/Controls/FluButton.qml @@ -8,6 +8,25 @@ Button { property color normalColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1) property color hoverColor: FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1) property color disableColor: FluTheme.dark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1) + property color textColor: { + if(FluTheme.dark){ + if(disabled){ + return Qt.rgba(131/255,131/255,131/255,1) + } + if(pressed){ + return Qt.rgba(162/255,162/255,162/255,1) + } + return Qt.rgba(1,1,1,1) + }else{ + if(disabled){ + return Qt.rgba(160/255,160/255,160/255,1) + } + if(pressed){ + return Qt.rgba(96/255,96/255,96/255,1) + } + return Qt.rgba(0,0,0,1) + } + } id: control enabled: !disabled focusPolicy:Qt.TabFocus @@ -36,24 +55,6 @@ Button { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter font: control.font - color: { - if(FluTheme.dark){ - if(disabled){ - return Qt.rgba(131/255,131/255,131/255,1) - } - if(pressed){ - return Qt.rgba(162/255,162/255,162/255,1) - } - return Qt.rgba(1,1,1,1) - }else{ - if(disabled){ - return Qt.rgba(160/255,160/255,160/255,1) - } - if(pressed){ - return Qt.rgba(96/255,96/255,96/255,1) - } - return Qt.rgba(0,0,0,1) - } - } + color: control.textColor } } diff --git a/src/imports/FluentUI/Controls/FluDropDownButton.qml b/src/imports/FluentUI/Controls/FluDropDownButton.qml index 79aebf4..cd3a634 100644 --- a/src/imports/FluentUI/Controls/FluDropDownButton.qml +++ b/src/imports/FluentUI/Controls/FluDropDownButton.qml @@ -9,6 +9,25 @@ Button { property color normalColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1) property color hoverColor: FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1) property color disableColor: FluTheme.dark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1) + property color textColor: { + if(FluTheme.dark){ + if(disabled){ + return Qt.rgba(131/255,131/255,131/255,1) + } + if(pressed){ + return Qt.rgba(162/255,162/255,162/255,1) + } + return Qt.rgba(1,1,1,1) + }else{ + if(disabled){ + return Qt.rgba(160/255,160/255,160/255,1) + } + if(pressed){ + return Qt.rgba(96/255,96/255,96/255,1) + } + return Qt.rgba(0,0,0,1) + } + } property var window : Window.window property alias items: menu.content id: control @@ -49,25 +68,7 @@ Button { text: control.text horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - color: { - if(FluTheme.dark){ - if(disabled){ - return Qt.rgba(131/255,131/255,131/255,1) - } - if(pressed){ - return Qt.rgba(162/255,162/255,162/255,1) - } - return Qt.rgba(1,1,1,1) - }else{ - if(disabled){ - return Qt.rgba(160/255,160/255,160/255,1) - } - if(pressed){ - return Qt.rgba(96/255,96/255,96/255,1) - } - return Qt.rgba(0,0,0,1) - } - } + color: control.textColor } onClicked: { if(items && menu.getContainerCount()!==0){ diff --git a/src/imports/FluentUI/Controls/FluFilledButton.qml b/src/imports/FluentUI/Controls/FluFilledButton.qml index b221276..ff9574b 100644 --- a/src/imports/FluentUI/Controls/FluFilledButton.qml +++ b/src/imports/FluentUI/Controls/FluFilledButton.qml @@ -9,6 +9,16 @@ Button { property color hoverColor: FluTheme.dark ? Qt.darker(normalColor,1.1) : Qt.lighter(normalColor,1.1) property color disableColor: FluTheme.dark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1) property color pressedColor: FluTheme.dark ? Qt.darker(normalColor,1.2) : Qt.lighter(normalColor,1.2) + property color textColor: { + if(FluTheme.dark){ + if(disabled){ + return Qt.rgba(173/255,173/255,173/255,1) + } + return Qt.rgba(0,0,0,1) + }else{ + return Qt.rgba(1,1,1,1) + } + } id: control enabled: !disabled Keys.onSpacePressed: control.visualFocus&&clicked() @@ -38,15 +48,6 @@ Button { font: control.font horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - color: { - if(FluTheme.dark){ - if(disabled){ - return Qt.rgba(173/255,173/255,173/255,1) - } - return Qt.rgba(0,0,0,1) - }else{ - return Qt.rgba(1,1,1,1) - } - } + color: control.textColor } } diff --git a/src/imports/FluentUI/Controls/FluNavigationView.qml b/src/imports/FluentUI/Controls/FluNavigationView.qml index c4e7461..49b8c84 100644 --- a/src/imports/FluentUI/Controls/FluNavigationView.qml +++ b/src/imports/FluentUI/Controls/FluNavigationView.qml @@ -352,8 +352,6 @@ Item { if(model.tapFunc){ model.tapFunc() }else{ - model.tap() - d.stackItems.push(model) nav_list.currentIndex = nav_list.count-layout_footer.count+idx layout_footer.currentIndex = idx if(d.isMinimal || d.isCompact){ @@ -769,6 +767,15 @@ Item { return footerItems.children } } + onCurrentIndexChanged: { + if(d.enableStack){ + var item = model[currentIndex] + if(item instanceof FluPaneItem){ + item.tap() + d.stackItems.push(item) + } + } + } highlightMoveDuration: 150 highlight: Item{ clip: true diff --git a/src/imports/FluentUI/Controls/FluRadioButton.qml b/src/imports/FluentUI/Controls/FluRadioButton.qml index 4fa514f..12c819e 100644 --- a/src/imports/FluentUI/Controls/FluRadioButton.qml +++ b/src/imports/FluentUI/Controls/FluRadioButton.qml @@ -11,6 +11,7 @@ Button { property color normalColor: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(1,1,1,1) property color hoverColor: checked ? FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(1,1,1,1) : FluTheme.dark ? Qt.rgba(43/255,43/255,43/255,1) : Qt.rgba(222/255,222/255,222/255,1) property color disableColor: checked ? FluTheme.dark ? Qt.rgba(159/255,159/255,159/255,1) : Qt.rgba(159/255,159/255,159/255,1) : FluTheme.dark ? Qt.rgba(43/255,43/255,43/255,1) : Qt.rgba(222/255,222/255,222/255,1) + property alias textColor: btn_text.textColor property var clickListener : function(){ checked = !checked } @@ -34,7 +35,7 @@ Button { radius: 10 border.width: { if(checked&&disabled){ - return 3 + return 4 } if(pressed){ if(checked){ @@ -44,7 +45,7 @@ Button { } if(hovered){ if(checked){ - return 3 + return 4 } return 1 } @@ -74,6 +75,7 @@ Button { } } FluText{ + id:btn_text text: control.text Layout.alignment: Qt.AlignVCenter font: control.font diff --git a/src/imports/FluentUI/Controls/FluTableView2.qml b/src/imports/FluentUI/Controls/FluTableView2.qml deleted file mode 100644 index f2512bd..0000000 --- a/src/imports/FluentUI/Controls/FluTableView2.qml +++ /dev/null @@ -1,235 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Controls.Basic -import QtQuick.Layouts -import FluentUI - -Item { - property var columns : [] - property var dataSource : [] - property int pageCurrent: 1 - property int itemCount: 1000 - property int pageCount: 10 - property int itemHeight: 56 - property bool pageVisible: true - signal requestPage(int page,int count) - id:control - implicitHeight: layout_table.height - QtObject{ - id:d - property int coumnsWidth: parent.width - } - MouseArea{ - anchors.fill: parent - preventStealing: true - } - ListModel{ - id:model_coumns - } - ListModel{ - id:model_data_source - } - onColumnsChanged: { - model_coumns.clear() - model_coumns.append(columns) - var w = 0 - for(var i=0;i { - control.requestPage(page,count) - } - anchors{ - top: parent.top - right: parent.right - } - Connections{ - target: control - function onPageCurrentChanged(){ - if (control.pageCurrent!==pagination.pageCurrent) - { - pagination.calcNewPage(control.pageCurrent) - } - } - } - } - } - model:model_data_source - delegate: Control{ - id:item_control - height: table_row.maxHeight - width: layout_table.width - property var model_values : getObjectValues(index) - property var itemObject: getObject(index) - property var listModel: model - Rectangle{ - anchors.fill: parent - color: { - if(item_control.hovered){ - return FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1) - } - return FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(1,1,1,1) - } - } - Row{ - id: table_row - spacing: 0 - anchors.fill: parent - property int maxHeight: itemHeight - Repeater{ - model: model_values - delegate:Item{ - height: table_row.maxHeight - width: modelData.width - Loader{ - property var model : modelData - property var dataModel : listModel - property var dataObject : itemObject - anchors.fill: parent - sourceComponent: { - if(model.itemData instanceof Component){ - return model.itemData - } - return com_text - } - onHeightChanged: - { - table_row.maxHeight = Math.max(table_row.maxHeight,height,itemHeight) - parent.height = table_row.maxHeight - table_row.parent.height = table_row.maxHeight - } - } - } - } - } - FluDivider{ - width: parent.width - height: 1 - anchors.right: parent.right - anchors.bottom: parent.bottom - } - } - } - } - Component{ - id:com_text - Item{ - FluCopyableText{ - id:table_value - text:String(model.itemData) - width: Math.min(parent.width - 14,implicitWidth) - wrapMode: Text.WordWrap - onImplicitHeightChanged: parent.parent.parent.height = Math.max(implicitHeight + 20,itemHeight) - anchors{ - verticalCenter: parent.verticalCenter - left: parent.left - leftMargin: 14 - } - MouseArea{ - id:item_mouse - hoverEnabled: true - anchors.fill: parent - cursorShape: Qt.IBeamCursor - acceptedButtons: Qt.NoButton - } - FluTooltip{ - visible: item_mouse.containsMouse - text:parent.text - delay: 1000 - } - } - } - } - function getObject(index){ - return model_data_source.get(index) - } - function getObjectValues(index) { - var obj = model_data_source.get(index) - if(!obj) - return - var data = [] - for(var i=0;i