diff --git a/example/qml/TestWindow.qml b/example/qml/TestWindow.qml deleted file mode 100644 index 8916fecd..00000000 --- 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 fd98792c..6e33b98e 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 15c9371b..009a6090 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 286f1497..f8fb4399 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 2a888249..bdf8731b 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 39d046d6..6cc0b2eb 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 171a973e..384bdb6d 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 00000000..f002b213 --- /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 cd3a634f..a78b346d 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 ff9574b9..677737b5 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 95b7ef31..5c6c9596 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 05231efc..d5db0c43 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 e9570f03..fe308b1e 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