diff --git a/example/T_Awesome.qml b/example/T_Awesome.qml index 13e26bf..e3e23fa 100644 --- a/example/T_Awesome.qml +++ b/example/T_Awesome.qml @@ -47,7 +47,7 @@ FluContentPage { height: 80 FluIconButton{ id:item_icon - icon:modelData.icon + iconSource:modelData.icon anchors.horizontalCenter: parent.horizontalCenter onClicked: { var text ="FluentIcons."+modelData.name; diff --git a/example/T_Buttons.qml b/example/T_Buttons.qml index 6b1ac2c..fe6eaa6 100644 --- a/example/T_Buttons.qml +++ b/example/T_Buttons.qml @@ -10,8 +10,8 @@ FluScrollablePage{ spacing: 20 FluText{ - Layout.topMargin: 20 - text:"支持Tab键切换焦点,Enter键执行点击事件" + Layout.topMargin: 20 + text:"支持Tab键切换焦点,空格键执行点击事件" } FluArea{ @@ -21,6 +21,7 @@ FluScrollablePage{ FluButton{ disabled:button_switch.checked + text:"Standard Button" onClicked: { showInfo("点击StandardButton") } @@ -53,8 +54,9 @@ FluScrollablePage{ FluFilledButton{ disabled:filled_button_switch.checked + text:"Filled Button" onClicked: { - showWarning("点击FilledButton") + showWarning("点击FilledButton") } anchors{ verticalCenter: parent.verticalCenter @@ -85,7 +87,7 @@ FluScrollablePage{ paddings: 10 FluIconButton{ - icon:FluentIcons.ChromeCloseContrast + iconSource:FluentIcons.ChromeCloseContrast disabled:icon_button_switch.checked iconSize: 15 anchors{ @@ -129,7 +131,7 @@ FluScrollablePage{ property int selecIndex : 0 model: 3 delegate: FluRadioButton{ - checked : repeater.selecIndex===index + selected : repeater.selecIndex===index disabled:radio_button_switch.checked text:"Radio Button_"+index onClicked:{ @@ -164,6 +166,7 @@ FluScrollablePage{ FluCheckBox{ disabled:icon_button_check.checked + text:"Check Box" anchors{ verticalCenter: parent.verticalCenter left: parent.left diff --git a/example/T_Expander.qml b/example/T_Expander.qml index cb39e47..4db8714 100644 --- a/example/T_Expander.qml +++ b/example/T_Expander.qml @@ -26,7 +26,7 @@ FluScrollablePage{ property int selecIndex : 0 model: 3 delegate: FluRadioButton{ - checked : repeater.selecIndex===index + selected : repeater.selecIndex===index text:"Radio Button_"+index onClicked:{ repeater.selecIndex = index diff --git a/example/T_Theme.qml b/example/T_Theme.qml index 5dd0363..ffa75a2 100644 --- a/example/T_Theme.qml +++ b/example/T_Theme.qml @@ -20,7 +20,7 @@ FluScrollablePage{ color: mouse_item.containsMouse ? Qt.lighter(modelData.normal,1.1) : modelData.normal FluIcon { anchors.centerIn: parent - icon: FluentIcons.AcceptMedium + iconSource: FluentIcons.AcceptMedium iconSize: 15 visible: modelData === FluTheme.primaryColor color: FluTheme.isDark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1) @@ -42,8 +42,8 @@ FluScrollablePage{ } FluToggleSwitch{ checked: FluTheme.isDark - onClickFunc:function(){ - FluTheme.isDark = !FluTheme.isDark + onCheckedChanged:{ + FluTheme.isDark = checked } } FluText{ @@ -52,8 +52,8 @@ FluScrollablePage{ } FluToggleSwitch{ checked: FluTheme.isFrameless - onClickFunc:function(){ - FluTheme.isFrameless = !FluTheme.isFrameless + onCheckedChanged:{ + FluTheme.isFrameless = isFrameless } } FluText{ @@ -62,8 +62,8 @@ FluScrollablePage{ } FluToggleSwitch{ checked: FluTheme.isNativeText - onClickFunc:function(){ - FluTheme.isNativeText = !FluTheme.isNativeText + onCheckedChanged:{ + FluTheme.isNativeText = isNativeText } } } diff --git a/src/controls/FluAppBar.qml b/src/controls/FluAppBar.qml index edb5d11..53af7aa 100644 --- a/src/controls/FluAppBar.qml +++ b/src/controls/FluAppBar.qml @@ -94,14 +94,14 @@ Rectangle{ } FluToggleSwitch{ checked: FluTheme.isDark - onClickFunc:function(){ - FluTheme.isDark = !FluTheme.isDark + onCheckedChanged:{ + FluTheme.isDark = checked } } } FluIconButton{ - icon : FluentIcons.ChromeMinimizeContrast + iconSource : FluentIcons.ChromeMinimizeContrast Layout.alignment: Qt.AlignVCenter iconSize: 15 text:"最小化" @@ -117,7 +117,7 @@ Rectangle{ return false return Window.Maximized === window.visibility } - icon : isRestore ? FluentIcons.ChromeRestoreContrast : FluentIcons.ChromeMaximizeContrast + iconSource : isRestore ? FluentIcons.ChromeRestoreContrast : FluentIcons.ChromeMaximizeContrast color:hovered ? "#20000000" : "#00000000" Layout.alignment: Qt.AlignVCenter visible: resizable @@ -129,7 +129,7 @@ Rectangle{ } } FluIconButton{ - icon : FluentIcons.ChromeCloseContrast + iconSource : FluentIcons.ChromeCloseContrast Layout.alignment: Qt.AlignVCenter text:"关闭" iconSize: 13 diff --git a/src/controls/FluAutoSuggestBox.qml b/src/controls/FluAutoSuggestBox.qml index 0dc106e..6712c59 100644 --- a/src/controls/FluAutoSuggestBox.qml +++ b/src/controls/FluAutoSuggestBox.qml @@ -7,7 +7,7 @@ TextField{ property var values:[] property int fontStyle: FluText.Body property int pixelSize : FluTheme.textSize - property int icon: -1 + property int iconSource: -1 signal itemClicked(string data) id:input @@ -91,7 +91,7 @@ TextField{ inputItem: input FluIconButton{ - icon:FluentIcons.ChromeClose + iconSource:FluentIcons.ChromeClose iconSize: 10 width: 20 height: 20 @@ -109,10 +109,10 @@ TextField{ FluIcon{ id:icon_right - icon: input.icon + iconSource: input.iconSource iconSize: 15 opacity: 0.5 - visible: input.icon != -1 + visible: input.iconSource != -1 anchors{ verticalCenter: parent.verticalCenter right: parent.right diff --git a/src/controls/FluButton.qml b/src/controls/FluButton.qml index 7c15023..b346a39 100644 --- a/src/controls/FluButton.qml +++ b/src/controls/FluButton.qml @@ -2,39 +2,19 @@ import QtQuick.Controls 2.15 import FluentUI 1.0 -Control { +Button { id: control - property string text: "Standard Button" property bool disabled: false - - property color normalColor: FluTheme.isDark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1) property color hoverColor: FluTheme.isDark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1) property color disableColor: FluTheme.isDark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1) - signal clicked - topPadding:5 bottomPadding:5 leftPadding:15 rightPadding:15 - - focusPolicy:Qt.TabFocus - Keys.onEnterPressed:(visualFocus&&handleClick()) - Keys.onReturnPressed:(visualFocus&&handleClick()) - - MouseArea { - anchors.fill: parent - onClicked: handleClick() - } - - function handleClick(){ - if(disabled){ - return - } - control.clicked() - } + enabled: !disabled background: Rectangle{ border.color: FluTheme.isDark ? "#505050" : "#DFDFDF" @@ -71,5 +51,4 @@ Control { } } } - } diff --git a/src/controls/FluCheckBox.qml b/src/controls/FluCheckBox.qml index e52544a..0e9d638 100644 --- a/src/controls/FluCheckBox.qml +++ b/src/controls/FluCheckBox.qml @@ -3,49 +3,45 @@ import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 import FluentUI 1.0 -Control { +Button { id:control - property bool checked: false - property string text: "Check Box" - property var checkClicked + property bool selected: false + + property var clickFunc property bool disabled: false + padding:0 + property color borderNormalColor: FluTheme.isDark ? Qt.rgba(160/255,160/255,160/255,1) : Qt.rgba(136/255,136/255,136/255,1) - property color borderCheckedColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark + property color borderSelectedColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark property color borderHoverColor: FluTheme.isDark ? Qt.rgba(167/255,167/255,167/255,1) : Qt.rgba(135/255,135/255,135/255,1) property color borderDisableColor: FluTheme.isDark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1) property color normalColor: FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(247/255,247/255,247/255,1) - property color checkedColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark + property color selectedColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark property color hoverColor: FluTheme.isDark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(244/255,244/255,244/255,1) - property color checkedHoverColor: FluTheme.isDark ? Qt.darker(checkedColor,1.1) : Qt.lighter(checkedColor,1.1) + property color selectedHoverColor: FluTheme.isDark ? Qt.darker(selectedColor,1.1) : Qt.lighter(selectedColor,1.1) - property color checkedDisableColor: FluTheme.isDark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1) + property color selectedDisableColor: FluTheme.isDark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1) property color disableColor: FluTheme.isDark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(253/255,253/255,253/255,1) + enabled: !disabled - focusPolicy:Qt.TabFocus - Keys.onEnterPressed:(visualFocus&&handleClick()) - Keys.onReturnPressed:(visualFocus&&handleClick()) - MouseArea { - anchors.fill: parent - onClicked: handleClick() - } - - function handleClick(){ + onClicked: { if(disabled){ return } - if(checkClicked){ - checkClicked() + if(clickFunc){ + clickFunc() return } - checked = !checked + selected = !selected } + background: Item{ FluFocusRectangle{ visible: control.visualFocus @@ -62,8 +58,8 @@ Control { if(disabled){ return borderDisableColor } - if(checked){ - return borderCheckedColor + if(selected){ + return borderSelectedColor } if(hovered){ return borderHoverColor @@ -72,14 +68,14 @@ Control { } border.width: 1 color: { - if(checked){ + if(selected){ if(disabled){ - return checkedDisableColor + return selectedDisableColor } if(hovered){ - return checkedHoverColor + return selectedHoverColor } - return checkedColor + return selectedColor } if(hovered){ return hoverColor @@ -89,9 +85,9 @@ Control { FluIcon { anchors.centerIn: parent - icon: FluentIcons.AcceptMedium + iconSource: FluentIcons.AcceptMedium iconSize: 15 - visible: checked + visible: selected color: FluTheme.isDark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1) } } diff --git a/src/controls/FluExpander.qml b/src/controls/FluExpander.qml index 2309800..18f60d8 100644 --- a/src/controls/FluExpander.qml +++ b/src/controls/FluExpander.qml @@ -56,7 +56,7 @@ Item { return FluTheme.isDark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(254/255,254/255,254/255,1) } iconSize: 15 - icon: expand ? FluentIcons.ChevronUp : FluentIcons.ChevronDown + iconSource: expand ? FluentIcons.ChevronUp : FluentIcons.ChevronDown onClicked: { expand = !expand } diff --git a/src/controls/FluFilledButton.qml b/src/controls/FluFilledButton.qml index ba978a3..49c2a4b 100644 --- a/src/controls/FluFilledButton.qml +++ b/src/controls/FluFilledButton.qml @@ -2,34 +2,19 @@ import QtQuick.Controls 2.15 import FluentUI 1.0 -Control { +Button { id: control - property string text: "Filled Button" property bool disabled: false property color normalColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark property color hoverColor: FluTheme.isDark ? Qt.darker(normalColor,1.1) : Qt.lighter(normalColor,1.1) property color disableColor: FluTheme.isDark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1) - signal clicked + enabled: !disabled topPadding:5 bottomPadding:5 leftPadding:15 rightPadding:15 - focusPolicy:Qt.TabFocus - Keys.onEnterPressed:(visualFocus&&handleClick()) - Keys.onReturnPressed:(visualFocus&&handleClick()) - - MouseArea { - anchors.fill: parent - onClicked: handleClick() - } - - function handleClick(){ - if(disabled) - return - control.clicked() - } background: Rectangle{ radius: 4 diff --git a/src/controls/FluIcon.qml b/src/controls/FluIcon.qml index 9937c27..1943c06 100644 --- a/src/controls/FluIcon.qml +++ b/src/controls/FluIcon.qml @@ -2,7 +2,7 @@ Text { - property int icon + property int iconSource property int iconSize: 20 property color iconColor: FluTheme.isDark ? "#FFFFFF" : "#000000" @@ -12,5 +12,5 @@ Text { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter color: iconColor - text: (String.fromCharCode(icon).toString(16)); + text: (String.fromCharCode(iconSource).toString(16)); } diff --git a/src/controls/FluIconButton.qml b/src/controls/FluIconButton.qml index bd3d99f..f6f35bc 100644 --- a/src/controls/FluIconButton.qml +++ b/src/controls/FluIconButton.qml @@ -2,18 +2,26 @@ import QtQuick.Controls 2.15 import FluentUI 1.0 -Control { +Button { id:control + + width: 30 height: 30 + implicitWidth: width + implicitHeight: height + + padding: 0 property int iconSize: 20 - property int icon - property alias text: tool_tip.text - signal clicked + property int iconSource + + property bool disabled: false + enabled: !disabled + property color hoverColor: FluTheme.isDark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(0,0,0,0.03) property color normalColor: FluTheme.isDark ? Qt.rgba(0,0,0,0) : Qt.rgba(0,0,0,0) property color disableColor: FluTheme.isDark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(0,0,0,0) @@ -39,22 +47,6 @@ Control { } } - focusPolicy:Qt.TabFocus - Keys.onEnterPressed:(visualFocus&&handleClick()) - Keys.onReturnPressed:(visualFocus&&handleClick()) - - MouseArea { - anchors.fill: parent - onClicked: handleClick() - } - - function handleClick(){ - if(disabled){ - return - } - control.clicked() - } - background: Rectangle{ radius: 4 color:control.color @@ -68,11 +60,13 @@ Control { id:text_icon font.family: "Segoe Fluent Icons" font.pixelSize: iconSize + width: iconSize + height: iconSize horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter anchors.centerIn: parent color:control.textColor - text: (String.fromCharCode(icon).toString(16)); + text: (String.fromCharCode(iconSource).toString(16)); } FluTooltip{ @@ -83,6 +77,7 @@ Control { } return hovered } + text:control.text delay: 1000 } } diff --git a/src/controls/FluInfoBar.qml b/src/controls/FluInfoBar.qml index df60f88..edb8660 100644 --- a/src/controls/FluInfoBar.qml +++ b/src/controls/FluInfoBar.qml @@ -190,7 +190,7 @@ FluObject { spacing: 10 FluIcon{ - icon:{ + iconSource:{ switch(_super.type){ case mcontrol.const_success: return FluentIcons.CompletedSolid; case mcontrol.const_warning: return FluentIcons.InfoSolid; diff --git a/src/controls/FluNavigationView.qml b/src/controls/FluNavigationView.qml index f724dab..af39518 100644 --- a/src/controls/FluNavigationView.qml +++ b/src/controls/FluNavigationView.qml @@ -145,7 +145,7 @@ Item { height:parent.height spacing: 0 FluIconButton{ - icon: FluentIcons.ChromeBack + iconSource: FluentIcons.ChromeBack Layout.leftMargin: 5 Layout.alignment: Qt.AlignVCenter disabled: nav_swipe.depth === 1 @@ -160,7 +160,7 @@ Item { } } FluIconButton{ - icon: FluentIcons.GlobalNavButton + iconSource: FluentIcons.GlobalNavButton Layout.leftMargin: 5 iconSize: 15 visible: displayMode === FluNavigationView.Minimal @@ -185,8 +185,8 @@ Item { } FluToggleSwitch{ checked: FluTheme.isDark - onClickFunc:function(){ - FluTheme.isDark = !FluTheme.isDark + onCheckedChanged:{ + FluTheme.isDark = checked } } } @@ -269,7 +269,7 @@ Item { FluAutoSuggestBox{ width: 280 anchors.centerIn: parent - icon: FluentIcons.Zoom + iconSource: FluentIcons.Zoom values: { var arr = [] if(items==null) diff --git a/src/controls/FluRadioButton.qml b/src/controls/FluRadioButton.qml index dd09511..f97b792 100644 --- a/src/controls/FluRadioButton.qml +++ b/src/controls/FluRadioButton.qml @@ -4,38 +4,19 @@ import QtQuick.Layouts 1.15 import FluentUI 1.0 -Control { +Button { - id:control - property bool checked: false - property string text: "RodioButton" - signal clicked + property bool selected: false property bool disabled: false - focusPolicy:Qt.TabFocus - Keys.onEnterPressed:(visualFocus&&handleClick()) - Keys.onReturnPressed:(visualFocus&&handleClick()) - - MouseArea { - anchors.fill: parent - onClicked: handleClick() - } - - function handleClick(){ - if(disabled){ - return - } - - control.clicked() - } - - + id:control + enabled: !disabled + padding:0 background: Item{ FluFocusRectangle{ visible: control.visualFocus } } - contentItem: RowLayout{ Rectangle{ id:rect_check @@ -46,22 +27,22 @@ Control { layer.enabled: true layer.smooth: true border.width: { - if(checked&&disabled){ + if(selected&&disabled){ return 3 } if(hovered){ - if(checked){ + if(selected){ return 5 } return 1 } if(hovered){ - if(checked){ + if(selected){ return 3 } return 1 } - return checked ? 5 : 1 + return selected ? 5 : 1 } Behavior on border.width { NumberAnimation{ @@ -76,7 +57,7 @@ Control { return Qt.rgba(198/255,198/255,198/255,1) } } - if(checked){ + if(selected){ if(FluTheme.isDark){ return FluTheme.primaryColor.lighter }else{ @@ -93,7 +74,7 @@ Control { } } color:{ - if(disabled&&checked){ + if(disabled&&selected){ return Qt.rgba(159/255,159/255,159/255,1) } if(FluTheme.isDark){ @@ -103,7 +84,7 @@ Control { return Qt.rgba(50/255,50/255,50/255,1) }else{ if(hovered){ - if(checked){ + if(selected){ return Qt.rgba(1,1,1,1) } return Qt.rgba(222/255,222/255,222/255,1) diff --git a/src/controls/FluToggleSwitch.qml b/src/controls/FluToggleSwitch.qml index 7884db5..202ca93 100644 --- a/src/controls/FluToggleSwitch.qml +++ b/src/controls/FluToggleSwitch.qml @@ -2,76 +2,53 @@ import QtQuick.Controls 2.0 import FluentUI 1.0 -Switch { +Button { id: root - property var onClickFunc width: 40 implicitWidth: 40 height: 20 implicitHeight: 20 - checkable: false - - background:FluFocusRectangle{ - visible: root.visualFocus - radius: 20 - } - - Keys.onEnterPressed:(visualFocus&&handleClick()) - Keys.onReturnPressed:(visualFocus&&handleClick()) - - indicator: Rectangle { + checkable: true + background : Rectangle { width: root.width height: root.height radius: height / 2 + FluFocusRectangle{ + visible: root.visualFocus + radius: 20 + } color: { if(FluTheme.isDark){ - if(root.checked){ + if(checked){ return FluTheme.primaryColor.dark } - if(switch_mouse.containsMouse){ + if(hovered){ return "#3E3E3C" } return "#323232" }else{ - if(root.checked){ + if(checked){ return FluTheme.primaryColor.dark } - if(switch_mouse.containsMouse){ + if(hovered){ return "#F4F4F4" } return "#FFFFFF" } } border.width: 1 - border.color: root.checked ? Qt.lighter(FluTheme.primaryColor.dark,1.2) : "#666666" - + border.color: checked ? Qt.lighter(FluTheme.primaryColor.dark,1.2) : "#666666" Rectangle { - x: root.checked ? root.implicitWidth - width - 4 : 4 + x: checked ? root.implicitWidth - width - 4 : 4 width: root.height - 8 height: root.height - 8 radius: width / 2 - scale: switch_mouse.containsMouse ? 1.2 : 1.0 + scale: hovered ? 1.2 : 1.0 anchors.verticalCenter: parent.verticalCenter - color: root.checked ? "#FFFFFF" : "#666666" - // border.color: "#D5D5D5" + color: checked ? "#FFFFFF" : "#666666" Behavior on x { NumberAnimation { duration: 200 } } } } - MouseArea{ - id:switch_mouse - anchors.fill: parent - hoverEnabled: true - onClicked: handleClick() - } - - function handleClick(){ - if(root.onClickFunc){ - root.onClickFunc() - }else{ - root.checked = !root.checked - } - } - } diff --git a/src/controls/FluTreeView.qml b/src/controls/FluTreeView.qml index 3881c13..667baf5 100644 --- a/src/controls/FluTreeView.qml +++ b/src/controls/FluTreeView.qml @@ -163,7 +163,7 @@ Item { FluCheckBox{ id:item_layout_checkbox text:"" - checked: itemModel.multipSelected + selected: itemModel.multipSelected visible: selectionMode === FluTreeView.Multiple Layout.leftMargin: 5 @@ -199,7 +199,7 @@ Item { } } - checkClicked:function(){ + clickFunc:function(){ if(hasChild){ const stack = [itemModel]; while (stack.length > 0) { @@ -222,7 +222,7 @@ Item { FluIconButton{ id:item_layout_expanded color:"#00000000" - icon:item_layout.expanded?FluentIcons.ChevronDown:FluentIcons.ChevronRight + iconSource:item_layout.expanded?FluentIcons.ChevronDown:FluentIcons.ChevronRight opacity: item_layout.hasChild iconSize: 15 onClicked: {