Compare commits

..

16 Commits

Author SHA1 Message Date
bf3006415b update 2023-06-28 13:16:21 +08:00
cdba8b7921 update 2023-06-28 13:15:33 +08:00
192c65a510 update 2023-06-28 13:13:39 +08:00
90943674b3 update 2023-06-28 12:12:15 +08:00
157dc9166b update 2023-06-28 09:45:47 +08:00
a7e8a5e4cf update 2023-06-28 02:28:34 +08:00
96071ac8d7 update 2023-06-27 22:14:27 +08:00
e25b944704 update 2023-06-27 21:14:20 +08:00
1566e3934e update 2023-06-27 21:02:57 +08:00
16e71f01b1 Merge pull request #172 from mentalfl0w/dev
Make the FluTableView readonly text copiable.
2023-06-27 20:47:21 +08:00
e54c161aa6 Make the FluTableView readonly text copiable. 2023-06-27 20:39:57 +08:00
2147965b00 update 2023-06-27 00:17:01 +08:00
3a940466d5 update 2023-06-27 00:00:41 +08:00
564b27cd02 update 2023-06-26 23:57:50 +08:00
4be2ad6ba0 Merge pull request #171 from mentalfl0w/dev
FluTableView bug fixed.
2023-06-26 23:41:14 +08:00
1d9f6f5eff FluTableView bug fixed. 2023-06-26 23:21:15 +08:00
19 changed files with 123 additions and 61 deletions

View File

@ -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)

View File

@ -76,5 +76,4 @@ FluScrollablePage{
}
'
}
}

View File

@ -13,6 +13,28 @@ FluContentPage{
loadData(1,1000)
}
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){
var numbers = [100, 300, 500, 1000];
function getRandomAge() {
@ -43,7 +65,8 @@ FluContentPage{
nickname: getRandomNickname(),
height:40,
minimumHeight:40,
maximumHeight:200
maximumHeight:200,
action:com_action
})
}
table_view.dataSource = dataSource
@ -112,6 +135,13 @@ FluContentPage{
width:100,
minimumWidth:80,
maximumWidth:200
},
{
title: '操作',
dataIndex: 'action',
width:160,
minimumWidth:160,
maximumWidth:160
}
]
}

View File

@ -112,6 +112,12 @@ CustomWindow {
}
Row{
z:8
anchors{
top: parent.top
left: parent.left
topMargin: FluTools.isMacos() ? 20 : 5
leftMargin: 5
}
FluIconButton{
iconSource: FluentIcons.ChromeBack
width: 30
@ -234,12 +240,13 @@ CustomWindow {
ctx.save()
if(img_cache.source.toString().length!==0){
try{
ctx.drawImage(img_cache, 0, 0, canvasSize.width, canvasSize.height, 0, 0, canvasSize.width, canvasSize.height)
ctx.drawImage(img_cache.source, 0, 0, canvasSize.width, canvasSize.height, 0, 0, canvasSize.width, canvasSize.height)
}catch(e){
img_cache.source = ""
}
}
clearArc(ctx, centerX, centerY, radius)
canvas.unloadImage(img_cache.source)
ctx.restore()
}
function clearArc(ctx,x, y, radius, startAngle, endAngle) {

View File

@ -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)

View File

@ -109,3 +109,11 @@ QJsonArray FluApp::awesomelist(const QString& keyword)
void FluApp::closeApp(){
qApp->exit(0);
}
void FluApp::deleteWindow(QQuickWindow* window){
if(window){
wnds.remove(window->winId());
window->deleteLater();
window = nullptr;
}
}

View File

@ -73,6 +73,8 @@ public:
*/
Q_INVOKABLE void closeApp();
Q_INVOKABLE void deleteWindow(QQuickWindow* window);
public:
/**
* @brief wnds

View File

@ -87,3 +87,10 @@ void FluTools::setOverrideCursor(Qt::CursorShape shape){
void FluTools::restoreOverrideCursor(){
qApp->restoreOverrideCursor();
}
void FluTools::deleteItem(QObject *p){
if(p){
delete p;
p = nullptr;
}
}

View File

@ -58,6 +58,7 @@ public:
Q_INVOKABLE void restoreOverrideCursor();
Q_INVOKABLE void deleteItem(QObject *p);
};
#endif // FLUTOOLS_H

View File

@ -1,7 +1,6 @@
#include "WindowHelper.h"
#include "FluRegister.h"
#include "FluApp.h"
WindowHelper::WindowHelper(QObject *parent)
: QObject{parent}
@ -19,10 +18,3 @@ QVariant WindowHelper::createRegister(QQuickWindow* window,const QString& path){
p->path(path);
return QVariant::fromValue(p);
}
void WindowHelper::deleteWindow(){
if(this->window){
FluApp::getInstance()->wnds.remove(this->window->winId());
this->window->deleteLater();
}
}

View File

@ -24,11 +24,6 @@ public:
*/
Q_INVOKABLE void initWindow(QQuickWindow* window);
/**
* @brief deleteWindow 销毁窗口释放资源QML中的Window close并不会销毁窗口只是把窗口隐藏了
*/
Q_INVOKABLE void deleteWindow();
/**
* @brief createRegister 创建一个FluRegsiter对象在FluWindow中registerForWindowResult方法调用
* @param window

View File

@ -14,6 +14,7 @@ TextEdit {
leftPadding: 0
rightPadding: 0
topPadding: 0
selectByMouse: true
selectedTextColor: FluColors.Grey220
bottomPadding: 0
selectionColor: FluTheme.primaryColor.lightest
@ -21,9 +22,11 @@ TextEdit {
onSelectedTextChanged: {
control.forceActiveFocus()
}
TapHandler {
MouseArea{
anchors.fill: parent
cursorShape: Qt.IBeamCursor
acceptedButtons: Qt.RightButton
onTapped: control.echoMode !== TextInput.Password && menu.popup()
onClicked: control.echoMode !== TextInput.Password && menu.popup()
}
FluTextBoxMenu{
id:menu

View File

@ -41,9 +41,11 @@ TextArea{
Keys.onBackPressed: {
control.commit()
}
TapHandler {
MouseArea{
anchors.fill: parent
cursorShape: Qt.IBeamCursor
acceptedButtons: Qt.RightButton
onTapped: control.echoMode !== TextInput.Password && menu.popup()
onClicked: control.echoMode !== TextInput.Password && menu.popup()
}
FluTextBoxMenu{
id:menu

View File

@ -31,7 +31,6 @@ Item {
id:control
QtObject{
id:d
property var pageMap: ({})
property var stackItems: []
property int displayMode: FluNavigationView.Open
property bool enableNavigationPanel: false
@ -519,7 +518,7 @@ Item {
disabled: nav_swipe.depth <= 1
iconSize: 13
onClicked: {
nav_swipe.pop()
FluTools.deleteItem(nav_swipe.pop())
d.stackItems.pop()
var item = d.stackItems[d.stackItems.length-1]
if(item.idx<(nav_list.count - layout_footer.count)){
@ -997,7 +996,7 @@ Item {
case FluNavigationView.SingleTask:
while(nav_swipe.currentItem !== page)
{
nav_swipe.pop()
FluTools.deleteItem(nav_swipe.pop())
d.stackItems.pop()
}
return

View File

@ -71,10 +71,6 @@ TextField{
rightMargin: icon_end.visible ? 25 : 5
}
}
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: control.echoMode !== TextInput.Password && menu.popup()
}
FluTextBoxMenu{
id:menu
inputItem: control

View File

@ -45,18 +45,30 @@ Rectangle {
FluTextBox {
anchors.fill: parent
text: display
readOnly: true === columnSource[column].readOnly
verticalAlignment: TextInput.AlignVCenter
Component.onCompleted: {
forceActiveFocus()
selectAll()
}
onCommit: {
display = text
if(!readOnly){
display = text
}
tableView.closeEditor()
}
}
}
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
@ -75,6 +87,7 @@ Rectangle {
ScrollBar.vertical: FluScrollBar{}
selectionModel: ItemSelectionModel {
id:selection_model
model: table_model
}
columnWidthProvider: function(column) {
var w = columnSource[column].width
@ -107,20 +120,22 @@ Rectangle {
model: table_model
clip: true
delegate: Rectangle {
id:item_table
property var position: Qt.point(column,row)
required property bool selected
required property bool current
property var readOnly: columnSource[column].readOnly
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))
implicitHeight: 40
implicitWidth: columnSource[column].width
TapHandler{
acceptedButtons: Qt.LeftButton
onDoubleTapped: {
if(readOnly){
if(display instanceof Component){
return
}
selection_model.setCurrentIndex(table_model.index(row,column), ItemSelectionModel.Current)
item_loader.sourceComponent = obtEditDelegate(column,row)
var index = table_view.index(row,column)
var index = table_model.index(row,column)
}
onTapped: {
if(!current){
@ -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
}
}
}
}
@ -145,13 +168,13 @@ Rectangle {
property int row
property var tableView: control
onDisplayChanged: {
table_model.setData(table_view.index(row,column),"display",display)
table_model.setData(table_model.index(row,column),"display",display)
}
}
}
function obtEditDelegate(column,row){
var display = table_model.data(table_view.index(row,column),"display")
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
@ -240,7 +263,7 @@ Rectangle {
onDoubleTapped: {
selection_model.clear()
for(var i=0;i<=table_view.rows;i++){
selection_model.select(table_view.index(i,column),ItemSelectionModel.Select)
selection_model.select(table_model.index(i,column),ItemSelectionModel.Select)
}
}
}
@ -250,7 +273,7 @@ Rectangle {
width: 4
anchors.right: parent.right
acceptedButtons: Qt.LeftButton
visible: !(obj.width === obj.maximumWidth && obj.width === obj.maximumWidth)
visible: !(obj.width === obj.minimumWidth && obj.width === obj.maximumWidth)
cursorShape: Qt.SplitHCursor
preventStealing: true
propagateComposedEvents: true
@ -313,7 +336,7 @@ Rectangle {
onDoubleTapped: {
selection_model.clear()
for(var i=0;i<=columnSource.length;i++){
selection_model.select(table_view.index(row,i),ItemSelectionModel.Select)
selection_model.select(table_model.index(row,i),ItemSelectionModel.Select)
}
}
}
@ -353,13 +376,10 @@ Rectangle {
}
}
}
function closeEditor(){
item_loader.sourceComponent = null
}
function resetPosition(){
table_view.positionViewAtCell(Qt.point(0, 0),TableView.AlignTop|TableView.AlignLeft)
table_view.positionViewAtCell(Qt.point(0, 0),Qt.AlignTop|Qt.AlignLeft)
}
}

View File

@ -56,13 +56,23 @@ TextField{
}
}
}
MouseArea{
anchors.fill: parent
cursorShape: Qt.IBeamCursor
acceptedButtons: Qt.RightButton
onClicked: control.echoMode !== TextInput.Password && menu.popup()
}
FluIconButton{
iconSource:FluentIcons.ChromeClose
iconSize: 10
width: 20
height: 20
opacity: 0.5
visible: control.text !== ""
visible: {
if(control.readOnly)
return false
return control.text !== ""
}
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
@ -72,10 +82,6 @@ TextField{
control.text = ""
}
}
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: control.echoMode !== TextInput.Password && menu.popup()
}
FluTextBoxMenu{
id:menu
inputItem: control

View File

@ -44,11 +44,6 @@ Window {
id: bg
anchors.fill: parent
color: backgroundColor
Behavior on color{
ColorAnimation {
duration: 300
}
}
}
Item{
id:container
@ -78,7 +73,7 @@ Window {
return helper.createRegister(window,path)
}
function deleteWindow(){
helper.deleteWindow()
FluApp.deleteWindow(window)
}
function onResult(data){
if(pageRegister){