diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index b4e8783c..13ece9ce 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -19,7 +19,7 @@ endif() file(TO_CMAKE_PATH "/" PATH_SEPARATOR) #设置版本号 -add_definitions(-DVERSION=1,3,6,2) +add_definitions(-DVERSION=1,3,7,0) find_package(Qt6 REQUIRED COMPONENTS Quick) diff --git a/example/qml/page/T_Pivot.qml b/example/qml/page/T_Pivot.qml index 696860b7..689410ee 100644 --- a/example/qml/page/T_Pivot.qml +++ b/example/qml/page/T_Pivot.qml @@ -5,76 +5,80 @@ import QtQuick.Window import FluentUI import "qrc:///example/qml/component" -FluScrollablePage{ +FluPage{ - title:"Pivot" + Component.onDestruction: { + console.debug("------------------------->") + } - FluArea{ - Layout.fillWidth: true - Layout.topMargin: 20 - height: 400 - paddings: 10 +// title:"Pivot" - FluPivot{ - anchors.fill: parent - currentIndex: 2 - FluPivotItem{ - title:"All" - contentItem:FluText{ - text:"All emails go here." - } - } - FluPivotItem{ - title:"Unread" - contentItem:FluText{ - text:"Unread emails go here." - } - } - FluPivotItem{ - title:"Flagged" - contentItem:FluText{ - text:"Flagged emails go here." - } - } - FluPivotItem{ - title:"Urgent" - contentItem:FluText{ - text:"Urgent emails go here." - } - } - } - } - CodeExpander{ - Layout.fillWidth: true - Layout.topMargin: -1 - code:'FluPivot{ - anchors.fill: parent - FluPivotItem:{ - text:"All" - contentItem: FluText{ - text:"All emails go here." - } - } - FluPivotItem:{ - text:"Unread" - contentItem: FluText{ - text:"Unread emails go here." - } - } - FluPivotItem:{ - text:"Flagged" - contentItem: FluText{ - text:"Flagged emails go here." - } - } - FluPivotItem:{ - text:"Urgent" - contentItem: FluText{ - text:"Urgent emails go here." - } - } -} -' - } +// FluArea{ +// Layout.fillWidth: true +// Layout.topMargin: 20 +// height: 400 +// paddings: 10 + +// FluPivot{ +// anchors.fill: parent +// currentIndex: 2 +// FluPivotItem{ +// title:"All" +// contentItem:FluText{ +// text:"All emails go here." +// } +// } +// FluPivotItem{ +// title:"Unread" +// contentItem:FluText{ +// text:"Unread emails go here." +// } +// } +// FluPivotItem{ +// title:"Flagged" +// contentItem:FluText{ +// text:"Flagged emails go here." +// } +// } +// FluPivotItem{ +// title:"Urgent" +// contentItem:FluText{ +// text:"Urgent emails go here." +// } +// } +// } +// } +// CodeExpander{ +// Layout.fillWidth: true +// Layout.topMargin: -1 +// code:'FluPivot{ +// anchors.fill: parent +// FluPivotItem:{ +// text:"All" +// contentItem: FluText{ +// text:"All emails go here." +// } +// } +// FluPivotItem:{ +// text:"Unread" +// contentItem: FluText{ +// text:"Unread emails go here." +// } +// } +// FluPivotItem:{ +// text:"Flagged" +// contentItem: FluText{ +// text:"Flagged emails go here." +// } +// } +// FluPivotItem:{ +// text:"Urgent" +// contentItem: FluText{ +// text:"Urgent emails go here." +// } +// } +//} +//' +// } } diff --git a/example/qml/page/T_TableView.qml b/example/qml/page/T_TableView.qml index 344208b8..b6e3a843 100644 --- a/example/qml/page/T_TableView.qml +++ b/example/qml/page/T_TableView.qml @@ -13,8 +13,26 @@ FluContentPage{ loadData(1,1000) } - Component.onDestruction: { - console.debug("T_TableView已经销毁") + Component{ + id:com_action + Item{ + RowLayout{ + anchors.centerIn: parent + FluButton{ + text:"删除" + onClicked: { + table_view.closeEditor() + tableModel.removeRow(row) + } + } + FluFilledButton{ + text:"编辑" + onClicked: { + showSuccess(JSON.stringify(tableModel.getRow(row))) + } + } + } + } } function loadData(page,count){ @@ -47,7 +65,8 @@ FluContentPage{ nickname: getRandomNickname(), height:40, minimumHeight:40, - maximumHeight:200 + maximumHeight:200, + action:com_action }) } table_view.dataSource = dataSource @@ -116,6 +135,13 @@ FluContentPage{ width:100, minimumWidth:80, maximumWidth:200 + }, + { + title: '操作', + dataIndex: 'action', + width:160, + minimumWidth:160, + maximumWidth:160 } ] } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 55f820c9..5cd65cc3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,7 +12,7 @@ endif() set(QML_PLUGIN_DIRECTORY ${CMAKE_PREFIX_PATH}/qml/FluentUI) #设置版本号 -add_definitions(-DVERSION=1,3,6,2) +add_definitions(-DVERSION=1,3,7,0) find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml) diff --git a/src/FluApp.cpp b/src/FluApp.cpp index 4dae223c..ba688e83 100644 --- a/src/FluApp.cpp +++ b/src/FluApp.cpp @@ -111,6 +111,9 @@ void FluApp::closeApp(){ } void FluApp::deleteWindow(QQuickWindow* window){ - wnds.remove(window->winId()); - window->deleteLater(); + if(window){ + wnds.remove(window->winId()); + window->deleteLater(); + window = nullptr; + } } diff --git a/src/FluTools.cpp b/src/FluTools.cpp index d012b363..e8e3e819 100644 --- a/src/FluTools.cpp +++ b/src/FluTools.cpp @@ -89,5 +89,8 @@ void FluTools::restoreOverrideCursor(){ } void FluTools::deleteItem(QObject *p){ - p->deleteLater(); + if(p){ + delete p; + p = nullptr; + } } diff --git a/src/imports/FluentUI/Controls/FluTableView.qml b/src/imports/FluentUI/Controls/FluTableView.qml index e2230792..753f3924 100644 --- a/src/imports/FluentUI/Controls/FluTableView.qml +++ b/src/imports/FluentUI/Controls/FluTableView.qml @@ -59,6 +59,16 @@ Rectangle { } } } + Component{ + id:com_text + FluText { + text: itemData + anchors.fill: parent + anchors.margins: 10 + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + } + } ScrollView{ id:scroll_table anchors.left: header_vertical.right @@ -110,6 +120,8 @@ Rectangle { model: table_model clip: true delegate: Rectangle { + id:item_table + property var position: Qt.point(column,row) required property bool selected property bool current: selection_model.currentIndex === table_model.index(row,column) color: selected ? FluTheme.primaryColor.lightest: (row%2!==0) ? control.color : (FluTheme.dark ? Qt.rgba(1,1,1,0.06) : Qt.rgba(0,0,0,0.06)) @@ -118,6 +130,9 @@ Rectangle { TapHandler{ acceptedButtons: Qt.LeftButton onDoubleTapped: { + if(display instanceof Component){ + return + } selection_model.setCurrentIndex(table_model.index(row,column), ItemSelectionModel.Current) item_loader.sourceComponent = obtEditDelegate(column,row) var index = table_model.index(row,column) @@ -128,12 +143,20 @@ Rectangle { } } } - FluText { - text: display + Loader{ + property var itemData: display + property var tableView: table_view + property var tableModel: table_model + property var position: item_table.position + property int row: position.y + property int column: position.x anchors.fill: parent - anchors.margins: 10 - elide: Text.ElideRight - verticalAlignment: Text.AlignVCenter + sourceComponent: { + if(itemData instanceof Component){ + return itemData + } + return com_text + } } } } @@ -353,13 +376,10 @@ Rectangle { } } } - function closeEditor(){ item_loader.sourceComponent = null } - function resetPosition(){ table_view.positionViewAtCell(Qt.point(0, 0),Qt.AlignTop|Qt.AlignLeft) } - }