From ba565e1ee8f445f9cb3024e44aafd55dbbbca712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Thu, 24 Aug 2023 21:43:16 +0800 Subject: [PATCH] update --- example/qml-Qt6/page/T_CalendarPicker.qml | 4 ++ example/qml-Qt6/page/T_DatePicker.qml | 6 +-- example/qml-Qt6/page/T_TimePicker.qml | 5 ++- example/qml/page/T_CalendarPicker.qml | 4 ++ example/qml/page/T_DatePicker.qml | 6 +-- example/qml/page/T_Home.qml | 1 + example/qml/page/T_TimePicker.qml | 5 ++- .../FluentUI/Controls/FluCalendarPicker.qml | 18 ++++++++ .../imports/FluentUI/Controls/FluComboBox.qml | 1 + .../FluentUI/Controls/FluDatePicker.qml | 13 ++++++ .../FluentUI/Controls/FluScreenshot.qml | 2 +- .../FluentUI/Controls/FluTableView.qml | 10 ++--- .../FluentUI/Controls/FluTextBoxMenu.qml | 42 ++++++++++++++---- .../FluentUI/Controls/FluTimePicker.qml | 34 +++++++++++++-- .../FluentUI/Controls/FluCalendarPicker.qml | 18 ++++++++ .../FluentUI/Controls/FluDatePicker.qml | 13 ++++++ .../FluentUI/Controls/FluTextBoxMenu.qml | 43 +++++++++++++++---- .../FluentUI/Controls/FluTimePicker.qml | 33 ++++++++++++-- 18 files changed, 218 insertions(+), 40 deletions(-) diff --git a/example/qml-Qt6/page/T_CalendarPicker.qml b/example/qml-Qt6/page/T_CalendarPicker.qml index 4cb67901..078d19e6 100644 --- a/example/qml-Qt6/page/T_CalendarPicker.qml +++ b/example/qml-Qt6/page/T_CalendarPicker.qml @@ -36,6 +36,10 @@ FluScrollablePage{ left: parent.left } FluCalendarPicker{ + current:Date.fromLocaleString("2013年7月11日 21:17:42") + onAccepted:{ + showSuccess(current.toLocaleString()) + } } } } diff --git a/example/qml-Qt6/page/T_DatePicker.qml b/example/qml-Qt6/page/T_DatePicker.qml index 0fe6c4df..8c433b29 100644 --- a/example/qml-Qt6/page/T_DatePicker.qml +++ b/example/qml-Qt6/page/T_DatePicker.qml @@ -23,7 +23,8 @@ FluScrollablePage{ text:"showYear=true" } FluDatePicker{ - onCurrentChanged: { + current: new Date() + onAccepted: { showSuccess(current.toLocaleDateString()) } } @@ -50,10 +51,9 @@ FluScrollablePage{ FluText{ text:"showYear=false" } - FluDatePicker{ showYear:false - onCurrentChanged: { + onAccepted: { showSuccess(current.toLocaleDateString()) } } diff --git a/example/qml-Qt6/page/T_TimePicker.qml b/example/qml-Qt6/page/T_TimePicker.qml index eefce75a..136911ce 100644 --- a/example/qml-Qt6/page/T_TimePicker.qml +++ b/example/qml-Qt6/page/T_TimePicker.qml @@ -27,7 +27,8 @@ FluScrollablePage{ } FluTimePicker{ - onCurrentChanged: { + current: new Date() + onAccepted: { showSuccess(current.toLocaleTimeString(Qt.locale("de_DE"))) } } @@ -61,7 +62,7 @@ FluScrollablePage{ FluTimePicker{ hourFormat:FluTimePickerType.HH - onCurrentChanged: { + onAccepted: { showSuccess(current.toLocaleTimeString(Qt.locale("de_DE"))) } } diff --git a/example/qml/page/T_CalendarPicker.qml b/example/qml/page/T_CalendarPicker.qml index c9d10574..f894cbe2 100644 --- a/example/qml/page/T_CalendarPicker.qml +++ b/example/qml/page/T_CalendarPicker.qml @@ -36,6 +36,10 @@ FluScrollablePage{ left: parent.left } FluCalendarPicker{ + current:Date.fromLocaleString("2013年7月11日 21:17:42") + onAccepted:{ + showSuccess(current.toLocaleString()) + } } } } diff --git a/example/qml/page/T_DatePicker.qml b/example/qml/page/T_DatePicker.qml index ac978370..ffbb47c0 100644 --- a/example/qml/page/T_DatePicker.qml +++ b/example/qml/page/T_DatePicker.qml @@ -23,7 +23,8 @@ FluScrollablePage{ text:"showYear=true" } FluDatePicker{ - onCurrentChanged: { + current: new Date() + onAccepted: { showSuccess(current.toLocaleDateString()) } } @@ -50,10 +51,9 @@ FluScrollablePage{ FluText{ text:"showYear=false" } - FluDatePicker{ showYear:false - onCurrentChanged: { + onAccepted: { showSuccess(current.toLocaleDateString()) } } diff --git a/example/qml/page/T_Home.qml b/example/qml/page/T_Home.qml index 52c23211..c2a0430a 100644 --- a/example/qml/page/T_Home.qml +++ b/example/qml/page/T_Home.qml @@ -27,6 +27,7 @@ FluScrollablePage{ id: bg fillMode:Image.PreserveAspectCrop anchors.fill: parent + asynchronous: true verticalAlignment: Qt.AlignTop source: "qrc:/example/res/image/bg_home_header.png" } diff --git a/example/qml/page/T_TimePicker.qml b/example/qml/page/T_TimePicker.qml index 92bed2c5..c1655ac7 100644 --- a/example/qml/page/T_TimePicker.qml +++ b/example/qml/page/T_TimePicker.qml @@ -27,7 +27,8 @@ FluScrollablePage{ } FluTimePicker{ - onCurrentChanged: { + current: new Date() + onAccepted: { showSuccess(current.toLocaleTimeString(Qt.locale("de_DE"))) } } @@ -61,7 +62,7 @@ FluScrollablePage{ FluTimePicker{ hourFormat:FluTimePickerType.HH - onCurrentChanged: { + onAccepted: { showSuccess(current.toLocaleTimeString(Qt.locale("de_DE"))) } } diff --git a/src/Qt5/imports/FluentUI/Controls/FluCalendarPicker.qml b/src/Qt5/imports/FluentUI/Controls/FluCalendarPicker.qml index 48026e8b..c386c9bd 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluCalendarPicker.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluCalendarPicker.qml @@ -9,6 +9,8 @@ Rectangle { 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 normalColor: FluTheme.dark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(254/255,254/255,254/255,1) property string text: "请选择日期" + property var current + signal accepted() id:control color: { if(mouse_area.containsMouse){ @@ -21,6 +23,17 @@ Rectangle { radius: 4 border.width: 1 border.color: dividerColor + + Component.onCompleted: { + if(current){ + const date = current + var year = date.getFullYear() + var month = date.getMonth() + var day = date.getDate() + text_date.text = year+"-"+(month+1)+"-"+day + } + } + MouseArea{ id:mouse_area hoverEnabled: true @@ -90,6 +103,8 @@ Rectangle { var month = date.getMonth() var day = date.getDate() text_date.text = year+"-"+(month+1)+"-"+day + current= date + control.accepted() } } } @@ -99,6 +114,9 @@ Rectangle { } } function showPopup() { + container.currentDate = current + container.date = current + container.updateMouth(current) var pos = control.mapToItem(null, 0, 0) if(d.window.height>pos.y+control.height+container.height){ popup.y = control.height diff --git a/src/Qt5/imports/FluentUI/Controls/FluComboBox.qml b/src/Qt5/imports/FluentUI/Controls/FluComboBox.qml index bbe3fdfd..bce5ba64 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluComboBox.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluComboBox.qml @@ -1,5 +1,6 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 +import QtQuick.Window 2.15 import FluentUI 1.0 import QtQuick.Templates 2.15 as T diff --git a/src/Qt5/imports/FluentUI/Controls/FluDatePicker.qml b/src/Qt5/imports/FluentUI/Controls/FluDatePicker.qml index d17e12ed..fbf341f6 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluDatePicker.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluDatePicker.qml @@ -10,6 +10,7 @@ Rectangle { property color normalColor: FluTheme.dark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(254/255,254/255,254/255,1) property bool showYear: true property var current + signal accepted() id:control color: { if(mouse_area.containsMouse){ @@ -22,6 +23,17 @@ Rectangle { radius: 4 border.width: 1 border.color: dividerColor + Component.onCompleted: { + if(current){ + const now = current; + var year = text_year.text === "年"? now.getFullYear() : Number(text_year.text); + var month = text_month.text === "月"? now.getMonth() + 1 : Number(text_month.text); + var day = text_day.text === "日" ? now.getDate() : Number(text_day.text); + text_year.text = year + text_month.text = month + text_day.text = day + } + } Item{ id:d property var window: Window.window @@ -335,6 +347,7 @@ Rectangle { date.setMinutes(0); date.setSeconds(0); current = date + control.accepted() } } } diff --git a/src/Qt5/imports/FluentUI/Controls/FluScreenshot.qml b/src/Qt5/imports/FluentUI/Controls/FluScreenshot.qml index 22b7d04c..a36683f6 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluScreenshot.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluScreenshot.qml @@ -26,7 +26,7 @@ Item{ Component{ id:com_screen Window{ - property bool isZeroPos: screenshot.start === Qt.point(0,0) && screenshot.end === Qt.point(0,0) + property bool isZeroPos: screenshot.start == Qt.point(0,0) && screenshot.end == Qt.point(0,0) id:window_screen flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint x:-1 diff --git a/src/Qt5/imports/FluentUI/Controls/FluTableView.qml b/src/Qt5/imports/FluentUI/Controls/FluTableView.qml index 6be63d77..ed3d7713 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluTableView.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluTableView.qml @@ -35,9 +35,8 @@ Rectangle { property int defaultItemHeight: 42 property var header_rows:[] property bool selectionFlag: true - function obtEditDelegate(column,row){ + function obtEditDelegate(column,row,cellItem){ var display = table_model.data(table_model.index(row,column),"display") - var cellItem = table_view.itemAtCell(column, row) var cellPosition = cellItem.mapToItem(scroll_table, 0, 0) item_loader.column = column item_loader.row = row @@ -223,7 +222,7 @@ Rectangle { clip: true delegate: Rectangle { id:item_table - property var position: Qt.point(column,row) + property point position: Qt.point(column,row) color: (row%2!==0) ? control.color : (FluTheme.dark ? Qt.rgba(1,1,1,0.06) : Qt.rgba(0,0,0,0.06)) implicitHeight: 40 implicitWidth: { @@ -246,19 +245,16 @@ Rectangle { acceptedButtons: Qt.LeftButton onPressed:{ closeEditor() - table_view.interactive = false } onCanceled: { - table_view.interactive = true } onReleased: { - table_view.interactive = true } onDoubleClicked:{ if(display instanceof Component){ return } - item_loader.sourceComponent = d.obtEditDelegate(column,row) + item_loader.sourceComponent = d.obtEditDelegate(column,row,item_table) } onClicked: (event)=>{ diff --git a/src/Qt5/imports/FluentUI/Controls/FluTextBoxMenu.qml b/src/Qt5/imports/FluentUI/Controls/FluTextBoxMenu.qml index 6d5eedd8..54fa9902 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluTextBoxMenu.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluTextBoxMenu.qml @@ -11,6 +11,7 @@ FluMenu{ id:menu enableAnimation: false width: 120 + focus: false onVisibleChanged: { inputItem.forceActiveFocus() } @@ -19,33 +20,58 @@ FluMenu{ function onTextChanged() { menu.close() } + function onActiveFocusChanged() { + if(!inputItem.activeFocus){ + menu.close() + } + } } - FluMenuItem{ - text: cutText + FluIconButton{ + display: Button.TextOnly + text:cutText + focus: false + padding: 0 + height: visible ? 34 : 0 visible: inputItem.selectedText !== "" && !inputItem.readOnly onClicked: { inputItem.cut() + menu.close() } } - FluMenuItem{ - text: copyText + FluIconButton{ + display: Button.TextOnly + text:copyText + focus: false + padding: 0 + height: visible ? 34 : 0 visible: inputItem.selectedText !== "" onClicked: { inputItem.copy() + menu.close() } } - FluMenuItem{ - text: pasteText + FluIconButton{ + display: Button.TextOnly + text:pasteText + focus: false + padding: 0 + height: visible ? 34 : 0 visible: inputItem.canPaste onClicked: { inputItem.paste() + menu.close() } } - FluMenuItem{ - text: selectAllText + FluIconButton{ + display: Button.TextOnly + text:selectAllText + focus: false + padding: 0 + height: visible ? 34 : 0 visible: inputItem.text !== "" onClicked: { inputItem.selectAll() + menu.close() } } } diff --git a/src/Qt5/imports/FluentUI/Controls/FluTimePicker.qml b/src/Qt5/imports/FluentUI/Controls/FluTimePicker.qml index 208db934..5bccaff7 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluTimePicker.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluTimePicker.qml @@ -11,6 +11,7 @@ Rectangle { property int hourFormat: FluTimePickerType.H property int isH: hourFormat === FluTimePickerType.H property var current + signal accepted() id:control color: { if(mouse_area.containsMouse){ @@ -23,12 +24,40 @@ Rectangle { radius: 4 border.width: 1 border.color: dividerColor + Component.onCompleted: { + if(current){ + var now = current; + var hour + var ampm; + if(isH){ + hour = now.getHours(); + if(hour>12){ + ampm = "下午" + hour = hour-12 + }else{ + ampm = "上午" + } + }else{ + hour = now.getHours(); + } + hour = text_hour.text === "时"? hour.toString().padStart(2, '0') : text_hour.text + var minute = text_minute.text === "分"? now.getMinutes().toString().padStart(2, '0') : text_minute.text + ampm = text_ampm.text === "AM/PM"?ampm:text_ampm.text + text_hour.text = hour + text_minute.text = minute + if(isH){ + text_ampm.text = ampm + } + } + } Item{ id:d property var window: Window.window property bool changeFlag: true property var rowData: ["","",""] visible: false + + } MouseArea{ id:mouse_area @@ -333,6 +362,7 @@ Rectangle { date.setMinutes(parseInt(minutes)); date.setSeconds(0); current = date + control.accepted() } } } @@ -344,9 +374,7 @@ Rectangle { d.rowData[0] = text_hour.text d.rowData[1] = text_minute.text d.rowData[2] = text_ampm.text - var now = new Date(); - var hour var ampm; if(isH){ @@ -366,7 +394,6 @@ Rectangle { list_view_1.currentIndex = list_view_1.model.indexOf(hour); list_view_2.currentIndex = list_view_2.model.indexOf(minute); list_view_3.currentIndex = list_view_3.model.indexOf(ampm); - text_hour.text = hour text_minute.text = minute if(isH){ @@ -398,3 +425,4 @@ Rectangle { return arr; } } + diff --git a/src/Qt6/imports/FluentUI/Controls/FluCalendarPicker.qml b/src/Qt6/imports/FluentUI/Controls/FluCalendarPicker.qml index 69d81ac4..00c7c173 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluCalendarPicker.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluCalendarPicker.qml @@ -9,6 +9,8 @@ Rectangle { 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 normalColor: FluTheme.dark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(254/255,254/255,254/255,1) property string text: "请选择日期" + property var current + signal accepted() id:control color: { if(mouse_area.containsMouse){ @@ -21,6 +23,17 @@ Rectangle { radius: 4 border.width: 1 border.color: dividerColor + + Component.onCompleted: { + if(current){ + const date = current + var year = date.getFullYear() + var month = date.getMonth() + var day = date.getDate() + text_date.text = year+"-"+(month+1)+"-"+day + } + } + MouseArea{ id:mouse_area hoverEnabled: true @@ -90,6 +103,8 @@ Rectangle { var month = date.getMonth() var day = date.getDate() text_date.text = year+"-"+(month+1)+"-"+day + current= date + control.accepted() } } } @@ -99,6 +114,9 @@ Rectangle { } } function showPopup() { + container.currentDate = current + container.date = current + container.updateMouth(current) var pos = control.mapToItem(null, 0, 0) if(d.window.height>pos.y+control.height+container.height){ popup.y = control.height diff --git a/src/Qt6/imports/FluentUI/Controls/FluDatePicker.qml b/src/Qt6/imports/FluentUI/Controls/FluDatePicker.qml index 2a572023..105fc040 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluDatePicker.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluDatePicker.qml @@ -10,6 +10,7 @@ Rectangle { property color normalColor: FluTheme.dark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(254/255,254/255,254/255,1) property bool showYear: true property var current + signal accepted() id:control color: { if(mouse_area.containsMouse){ @@ -22,6 +23,17 @@ Rectangle { radius: 4 border.width: 1 border.color: dividerColor + Component.onCompleted: { + if(current){ + const now = current; + var year = text_year.text === "年"? now.getFullYear() : Number(text_year.text); + var month = text_month.text === "月"? now.getMonth() + 1 : Number(text_month.text); + var day = text_day.text === "日" ? now.getDate() : Number(text_day.text); + text_year.text = year + text_month.text = month + text_day.text = day + } + } Item{ id:d property var window: Window.window @@ -335,6 +347,7 @@ Rectangle { date.setMinutes(0); date.setSeconds(0); current = date + control.accepted() } } } diff --git a/src/Qt6/imports/FluentUI/Controls/FluTextBoxMenu.qml b/src/Qt6/imports/FluentUI/Controls/FluTextBoxMenu.qml index 061a94e9..1e94b8b3 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluTextBoxMenu.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluTextBoxMenu.qml @@ -11,6 +11,7 @@ FluMenu{ id:menu enableAnimation: false width: 120 + focus: false onVisibleChanged: { inputItem.forceActiveFocus() } @@ -19,33 +20,59 @@ FluMenu{ function onTextChanged() { menu.close() } + function onActiveFocusChanged() { + if(!inputItem.activeFocus){ + menu.close() + } + } } - FluMenuItem{ - text: cutText + FluIconButton{ + display: Button.TextOnly + text:cutText + focus: false + padding: 0 + height: visible ? 34 : 0 visible: inputItem.selectedText !== "" && !inputItem.readOnly onClicked: { inputItem.cut() + menu.close() } } - FluMenuItem{ - text: copyText + FluIconButton{ + display: Button.TextOnly + text:copyText + focus: false + padding: 0 + height: visible ? 34 : 0 visible: inputItem.selectedText !== "" onClicked: { inputItem.copy() + menu.close() } } - FluMenuItem{ - text: pasteText + FluIconButton{ + display: Button.TextOnly + text:pasteText + focus: false + padding: 0 + height: visible ? 34 : 0 visible: inputItem.canPaste onClicked: { inputItem.paste() + menu.close() } } - FluMenuItem{ - text: selectAllText + FluIconButton{ + display: Button.TextOnly + text:selectAllText + focus: false + padding: 0 + height: visible ? 34 : 0 visible: inputItem.text !== "" onClicked: { inputItem.selectAll() + menu.close() } } } + diff --git a/src/Qt6/imports/FluentUI/Controls/FluTimePicker.qml b/src/Qt6/imports/FluentUI/Controls/FluTimePicker.qml index 7abe2044..74705df3 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluTimePicker.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluTimePicker.qml @@ -11,6 +11,7 @@ Rectangle { property int hourFormat: FluTimePickerType.H property int isH: hourFormat === FluTimePickerType.H property var current + signal accepted() id:control color: { if(mouse_area.containsMouse){ @@ -23,12 +24,40 @@ Rectangle { radius: 4 border.width: 1 border.color: dividerColor + Component.onCompleted: { + if(current){ + var now = current; + var hour + var ampm; + if(isH){ + hour = now.getHours(); + if(hour>12){ + ampm = "下午" + hour = hour-12 + }else{ + ampm = "上午" + } + }else{ + hour = now.getHours(); + } + hour = text_hour.text === "时"? hour.toString().padStart(2, '0') : text_hour.text + var minute = text_minute.text === "分"? now.getMinutes().toString().padStart(2, '0') : text_minute.text + ampm = text_ampm.text === "AM/PM"?ampm:text_ampm.text + text_hour.text = hour + text_minute.text = minute + if(isH){ + text_ampm.text = ampm + } + } + } Item{ id:d property var window: Window.window property bool changeFlag: true property var rowData: ["","",""] visible: false + + } MouseArea{ id:mouse_area @@ -333,6 +362,7 @@ Rectangle { date.setMinutes(parseInt(minutes)); date.setSeconds(0); current = date + control.accepted() } } } @@ -344,9 +374,7 @@ Rectangle { d.rowData[0] = text_hour.text d.rowData[1] = text_minute.text d.rowData[2] = text_ampm.text - var now = new Date(); - var hour var ampm; if(isH){ @@ -366,7 +394,6 @@ Rectangle { list_view_1.currentIndex = list_view_1.model.indexOf(hour); list_view_2.currentIndex = list_view_2.model.indexOf(minute); list_view_3.currentIndex = list_view_3.model.indexOf(ampm); - text_hour.text = hour text_minute.text = minute if(isH){