From 154670f744ba8d0c86b9c864de8fbf7bed926f0b Mon Sep 17 00:00:00 2001 From: zhuzihcu Date: Thu, 8 Jun 2023 13:55:25 +0800 Subject: [PATCH] update --- example/qml/TestWindow.qml | 73 --- example/qml/component/CodeExpander.qml | 10 +- example/src/main.cpp | 1 - src/imports/FluentUI/Controls/FluButton.qml | 17 +- src/imports/FluentUI/Controls/FluCheckBox.qml | 4 +- src/imports/FluentUI/Controls/FluComboBox.qml | 2 +- .../FluentUI/Controls/FluContentDialog.qml | 4 +- src/imports/FluentUI/Controls/FluControl.qml | 22 + .../FluentUI/Controls/FluDropDownButton.qml | 9 +- .../FluentUI/Controls/FluFilledButton.qml | 8 +- .../FluentUI/Controls/FluFocusRectangle.qml | 11 +- .../FluentUI/Controls/FluIconButton.qml | 9 +- .../FluentUI/Controls/FluNavigationView.qml | 520 +++++++++--------- .../FluentUI/Controls/FluNavigationView2.qml | 57 -- .../FluentUI/Controls/FluRadioButton.qml | 9 +- .../FluentUI/Controls/FluTextButton.qml | 13 +- .../FluentUI/Controls/FluToggleButton.qml | 9 +- .../FluentUI/Controls/FluToggleSwitch.qml | 4 +- 18 files changed, 350 insertions(+), 432 deletions(-) delete mode 100644 example/qml/TestWindow.qml create mode 100644 src/imports/FluentUI/Controls/FluControl.qml delete mode 100644 src/imports/FluentUI/Controls/FluNavigationView2.qml diff --git a/example/qml/TestWindow.qml b/example/qml/TestWindow.qml deleted file mode 100644 index 8916fec..0000000 --- a/example/qml/TestWindow.qml +++ /dev/null @@ -1,73 +0,0 @@ -import QtQuick -import QtQuick.Window -import QtQuick.Controls -import QtQuick.Layouts -import Qt.labs.platform -import FluentUI -import "qrc:///example/qml/global/" - -FluWindow { - - id:window - title: "FluentUI" - width: 1000 - height: 640 - closeDestory:false - minimumWidth: 520 - minimumHeight: 460 - launchMode: FluWindow.SingleTask - visible: true - - Component.onCompleted: { -// FluApp.init(window) - } - - FluNavigationView2{ - id:nav_view - anchors.fill: parent - items: ItemsOriginal - footerItems:ItemsFooter - z:11 - displayMode:MainEvent.displayMode - logo: "qrc:/example/res/image/favicon.ico" - title:"FluentUI" - autoSuggestBox:FluAutoSuggestBox{ - width: 280 - anchors.centerIn: parent - iconSource: FluentIcons.Search - items: ItemsOriginal.getSearchData() - placeholderText: lang.search - onItemClicked: - (data)=>{ - ItemsOriginal.startPageByItem(data) - } - } - actionItem:Item{ - height: 40 - width: 148 - RowLayout{ - anchors.centerIn: parent - spacing: 5 - FluText{ - text:lang.dark_mode - } - FluToggleSwitch{ - checked: FluTheme.dark - onClicked: { - if(FluTheme.dark){ - FluTheme.darkMode = FluDarkMode.Light - }else{ - FluTheme.darkMode = FluDarkMode.Dark - } - } - } - } - } - Component.onCompleted: { - ItemsOriginal.navigationView = nav_view - ItemsFooter.navigationView = nav_view -// nav_view.setCurrentIndex(0) - } - } - -} diff --git a/example/qml/component/CodeExpander.qml b/example/qml/component/CodeExpander.qml index fd98792..6e33b98 100644 --- a/example/qml/component/CodeExpander.qml +++ b/example/qml/component/CodeExpander.qml @@ -6,19 +6,20 @@ import FluentUI FluExpander{ + id:control property string code: "" headerText: "Source" contentHeight:content.height + focus: false FluMultilineTextBox{ id:content width:parent.width - readOnly:true text:highlightQmlCode(code) - focus:false textFormat: FluMultilineTextBox.RichText KeyNavigation.priority: KeyNavigation.BeforeItem + enabled: false background:Rectangle{ radius: 4 color:FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1) @@ -40,6 +41,11 @@ FluExpander{ rightMargin: 5 topMargin: 5 } + onActiveFocusChanged: { + if(activeFocus){ + control.expand = true + } + } onClicked:{ FluTools.clipText(content.text) showSuccess("复制成功") diff --git a/example/src/main.cpp b/example/src/main.cpp index 15c9371..009a609 100644 --- a/example/src/main.cpp +++ b/example/src/main.cpp @@ -39,7 +39,6 @@ int main(int argc, char *argv[]) FramelessHelper::Quick::registerTypes(&engine); appInfo->init(&engine); const QUrl url(QStringLiteral("qrc:/example/qml/App.qml")); - // const QUrl url(QStringLiteral("qrc:/example/qml/TestWindow.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) diff --git a/src/imports/FluentUI/Controls/FluButton.qml b/src/imports/FluentUI/Controls/FluButton.qml index 286f149..f8fb439 100644 --- a/src/imports/FluentUI/Controls/FluButton.qml +++ b/src/imports/FluentUI/Controls/FluButton.qml @@ -5,6 +5,7 @@ import FluentUI Button { property bool disabled: false + property string contentDescription: "" 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) @@ -27,11 +28,13 @@ Button { return Qt.rgba(0,0,0,1) } } + Accessible.role: Accessible.Button + Accessible.name: control.text + Accessible.description: contentDescription + Accessible.onPressAction: control.clicked() id: control enabled: !disabled - focusPolicy:Qt.TabFocus horizontalPadding:12 - Keys.onSpacePressed: control.visualFocus&&clicked() font:FluTextStyle.Body background: Rectangle{ implicitWidth: 28 @@ -40,14 +43,8 @@ Button { border.width: 1 radius: 4 FluFocusRectangle{ - visible: control.visualFocus - radius:8 - } - color:{ - if(disabled){ - return disableColor - } - return hovered ? hoverColor :normalColor + visible: control.activeFocus + radius:4 } } contentItem: FluText { diff --git a/src/imports/FluentUI/Controls/FluCheckBox.qml b/src/imports/FluentUI/Controls/FluCheckBox.qml index 2a88824..bdf8731 100644 --- a/src/imports/FluentUI/Controls/FluCheckBox.qml +++ b/src/imports/FluentUI/Controls/FluCheckBox.qml @@ -23,13 +23,11 @@ Button { } id:control enabled: !disabled - focusPolicy:Qt.TabFocus - Keys.onSpacePressed: control.visualFocus&&clicked() padding:0 onClicked: clickListener() background: Item{ FluFocusRectangle{ - visible: control.visualFocus + visible: control.activeFocus } } contentItem: RowLayout{ diff --git a/src/imports/FluentUI/Controls/FluComboBox.qml b/src/imports/FluentUI/Controls/FluComboBox.qml index 39d046d..6cc0b2e 100644 --- a/src/imports/FluentUI/Controls/FluComboBox.qml +++ b/src/imports/FluentUI/Controls/FluComboBox.qml @@ -74,7 +74,7 @@ ComboBox { visible: !control.flat || control.down radius: 4 FluFocusRectangle{ - visible: control.visualFocus + visible: control.activeFocus radius:8 } color:{ diff --git a/src/imports/FluentUI/Controls/FluContentDialog.qml b/src/imports/FluentUI/Controls/FluContentDialog.qml index 171a973..384bdb6 100644 --- a/src/imports/FluentUI/Controls/FluContentDialog.qml +++ b/src/imports/FluentUI/Controls/FluContentDialog.qml @@ -1,4 +1,4 @@ -import QtQuick +import QtQuick import QtQuick.Layouts import QtQuick.Controls import QtQuick.Window @@ -25,7 +25,7 @@ FluPopup { return 400 return Math.min(Window.window.width,400) } - + focus: true Rectangle { id:layout_content anchors.fill: parent diff --git a/src/imports/FluentUI/Controls/FluControl.qml b/src/imports/FluentUI/Controls/FluControl.qml new file mode 100644 index 0000000..f002b21 --- /dev/null +++ b/src/imports/FluentUI/Controls/FluControl.qml @@ -0,0 +1,22 @@ +import QtQuick +import QtQuick.Controls.impl +import FluentUI +import QtQuick.Templates as T + +T.Button { + id: control + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + padding: 0 + horizontalPadding: 0 + spacing: 0 + contentItem: Item{} + background: Item{ + FluFocusRectangle{ + visible: control.activeFocus + radius:8 + } + } +} diff --git a/src/imports/FluentUI/Controls/FluDropDownButton.qml b/src/imports/FluentUI/Controls/FluDropDownButton.qml index cd3a634..a78b346 100644 --- a/src/imports/FluentUI/Controls/FluDropDownButton.qml +++ b/src/imports/FluentUI/Controls/FluDropDownButton.qml @@ -6,6 +6,7 @@ import FluentUI Button { property bool disabled: false + property string contentDescription: "" 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) @@ -30,12 +31,14 @@ Button { } property var window : Window.window property alias items: menu.content + Accessible.role: Accessible.Button + Accessible.name: control.text + Accessible.description: contentDescription + Accessible.onPressAction: control.clicked() id: control rightPadding:35 enabled: !disabled - focusPolicy:Qt.TabFocus horizontalPadding:12 - Keys.onSpacePressed: control.visualFocus&&clicked() background: Rectangle{ implicitWidth: 28 implicitHeight: 28 @@ -43,7 +46,7 @@ Button { border.width: 1 radius: 4 FluFocusRectangle{ - visible: control.visualFocus + visible: control.activeFocus radius:8 } color:{ diff --git a/src/imports/FluentUI/Controls/FluFilledButton.qml b/src/imports/FluentUI/Controls/FluFilledButton.qml index ff9574b..677737b 100644 --- a/src/imports/FluentUI/Controls/FluFilledButton.qml +++ b/src/imports/FluentUI/Controls/FluFilledButton.qml @@ -5,6 +5,7 @@ import FluentUI Button { property bool disabled: false + property string contentDescription: "" property color normalColor: FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark 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) @@ -19,10 +20,13 @@ Button { return Qt.rgba(1,1,1,1) } } + Accessible.role: Accessible.Button + Accessible.name: control.text + Accessible.description: contentDescription + Accessible.onPressAction: control.clicked() id: control enabled: !disabled Keys.onSpacePressed: control.visualFocus&&clicked() - focusPolicy:Qt.TabFocus font:FluTextStyle.Body horizontalPadding:12 background: Rectangle{ @@ -31,7 +35,7 @@ Button { radius: 4 FluFocusRectangle{ visible: control.visualFocus - radius:8 + radius:4 } color:{ if(disabled){ diff --git a/src/imports/FluentUI/Controls/FluFocusRectangle.qml b/src/imports/FluentUI/Controls/FluFocusRectangle.qml index 95b7ef3..5c6c959 100644 --- a/src/imports/FluentUI/Controls/FluFocusRectangle.qml +++ b/src/imports/FluentUI/Controls/FluFocusRectangle.qml @@ -4,16 +4,15 @@ import FluentUI Item { property int radius: 4 - id:root + id:control anchors.fill: parent - anchors.margins: -3 Rectangle{ - width: root.width - height: root.height + width: control.width + height: control.height anchors.centerIn: parent color: "#00000000" - border.width: 3 - radius: root.radius + border.width: 2 + radius: control.radius border.color: FluTheme.dark ? Qt.rgba(1,1,1,1) : Qt.rgba(0,0,0,1) z: 65535 } diff --git a/src/imports/FluentUI/Controls/FluIconButton.qml b/src/imports/FluentUI/Controls/FluIconButton.qml index 05231ef..d5db0c4 100644 --- a/src/imports/FluentUI/Controls/FluIconButton.qml +++ b/src/imports/FluentUI/Controls/FluIconButton.qml @@ -8,6 +8,7 @@ Button { property int iconSource property bool disabled: false property int radius:4 + property string contentDescription: "" property color hoverColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(0,0,0,0.03) property color pressedColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(0,0,0,0.06) property color normalColor: FluTheme.dark ? Qt.rgba(0,0,0,0) : Qt.rgba(0,0,0,0) @@ -34,6 +35,10 @@ Button { return Qt.rgba(0,0,0,1) } } + Accessible.role: Accessible.Button + Accessible.name: control.text + Accessible.description: contentDescription + Accessible.onPressAction: control.clicked() id:control width: 30 height: 30 @@ -41,13 +46,11 @@ Button { implicitHeight: height padding: 0 enabled: !disabled - focusPolicy:Qt.TabFocus - Keys.onSpacePressed: control.visualFocus&&clicked() background: Rectangle{ radius: control.radius color:control.color FluFocusRectangle{ - visible: control.visualFocus + visible: control.activeFocus } } contentItem: Item{ diff --git a/src/imports/FluentUI/Controls/FluNavigationView.qml b/src/imports/FluentUI/Controls/FluNavigationView.qml index e9570f0..fe308b1 100644 --- a/src/imports/FluentUI/Controls/FluNavigationView.qml +++ b/src/imports/FluentUI/Controls/FluNavigationView.qml @@ -155,8 +155,8 @@ Item { Item{ height: 38 width: layout_list.width - Rectangle{ - radius: 4 + FluControl{ + id:item_control anchors{ top: parent.top bottom: parent.bottom @@ -167,141 +167,141 @@ Item { leftMargin: 6 rightMargin: 6 } + onClicked: { + if(d.isCompactAndNotPanel){ + control_popup.showPopup(Qt.point(50,mapToItem(control,0,0).y),model.children) + return + } + model.isExpand = !model.isExpand + } Rectangle{ - width: 3 - height: 18 - radius: 1.5 - color: FluTheme.primaryColor.dark - visible: { - for(var i=0;i