fix: 简化Container实现代码

This commit is contained in:
hewenfei 2024-03-28 17:21:14 +08:00 committed by He Sir
parent caeee413dd
commit eed215da67
1 changed files with 3 additions and 14 deletions

View File

@ -1,5 +1,4 @@
import QtQuick 2.15
import QtQml.Models 2.15
import QtQuick.Layouts 1.15
import org.ukui.quick.widgets 1.0
@ -16,16 +15,6 @@ WidgetContainerItem {
anchors.fill = parent
}
onWidgetItemAdded: (widgetItem) => {
widgetModel.append({
"widgetItem": widgetItem
});
}
ListModel {
id: widgetModel
}
StyleBackground {
anchors.fill: parent
borderColor: Theme.ButtonText
@ -44,14 +33,14 @@ WidgetContainerItem {
bottomMargin: containerItem.WidgetContainer.padding.bottom
}
rows: containerItem.isHorizontal ? 1 : widgetModel.count
columns: containerItem.isHorizontal ? widgetModel.count : 1
rows: containerItem.isHorizontal ? 1 : repeater.count
columns: containerItem.isHorizontal ? repeater.count : 1
rowSpacing: 4
columnSpacing: 4
Repeater {
id: repeater
model: widgetModel
model: containerItem.widgetItemModel
delegate: widgetLoaderComponent
}
}