Skip to content

Commit

Permalink
feat: Page control to parent object
Browse files Browse the repository at this point in the history
Page control to parent object

Log:
Task: https://pms.uniontech.com/task-view-361721.html
  • Loading branch information
caixr23 committed Sep 24, 2024
1 parent 8464bd8 commit 3c9713d
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion include/dccobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class DccObject : public QObject
Q_ENUM(PageType)
uint pageType() const;
void setPageType(uint type);
Q_INVOKABLE QQuickItem *getSectionItem(QObject *parent = nullptr);
Q_INVOKABLE QQuickItem *getSectionItem(QObject *parent);
QQuickItem *parentItem();
void setParentItem(QQuickItem *item);
QQmlComponent *page() const;
Expand Down
2 changes: 1 addition & 1 deletion qml/DccWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ D.ApplicationWindow {
root.x = (Screen.width - root.width) / 2
root.y = (Screen.height - root.height) / 2
DccApp.root.page = rootLayout
centralView.contentItem = DccApp.root.getSectionItem()
centralView.contentItem = DccApp.root.getSectionItem(centralView)
}
}
2 changes: 1 addition & 1 deletion qml/SecondPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ SplitView {
if (activeObj.page === null) {
activeObj.page = rightLayout
}
rightView.replace(activeObj.getSectionItem())
rightView.replace(activeObj.getSectionItem(rightView))
}
Connections {
target: DccApp
Expand Down
4 changes: 2 additions & 2 deletions src/dde-control-center/frame/dccobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ QQuickItem *DccObject::getSectionItem(QObject *parent)
// QQml_setParent_noEvent(sectionItem, contentItem);
if (QQuickItem *p = qobject_cast<QQuickItem *>(parent)) {
p_ptr->m_sectionItem->setParentItem(p);
p_ptr->m_sectionItem->setParent(p);
p_ptr->m_sectionItem->setParent(this);
} else if (QQuickWindow *p = qobject_cast<QQuickWindow *>(parent)) {
p_ptr->m_sectionItem->setParent(p);
p_ptr->m_sectionItem->setParent(this);
} else {
p_ptr->m_sectionItem->setParent(this);
}
Expand Down
4 changes: 2 additions & 2 deletions src/dde-control-center/frame/plugin/DccEditorItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ D.ItemDelegate {
id: root
property alias separatorVisible: background.separatorVisible
property var item: model.item
property var rightItem: model.item.getSectionItem()
property var rightItem: null

Layout.fillWidth: true
backgroundVisible: false
Expand Down Expand Up @@ -48,7 +48,7 @@ D.ItemDelegate {
Control {
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Layout.rightMargin: 10
contentItem: rightItem
contentItem: rightItem ? rightItem : model.item.getSectionItem(this)
}
}
background: DccListViewBackground {
Expand Down
7 changes: 4 additions & 3 deletions src/dde-control-center/frame/plugin/DccGroupView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Rectangle {
id: root
property bool isGroup: true
property alias spacing: layoutView.spacing
property var model: DccModel {
root: dccObj
}

objectName: "noPadding"
color: "transparent"
Expand All @@ -23,9 +26,7 @@ Rectangle {
spacing: 0
Repeater {
id: repeater
model: DccModel {
root: dccObj
}
model: root.model

delegate: DelegateChooser {
role: "pageType"
Expand Down
2 changes: 1 addition & 1 deletion src/dde-control-center/frame/plugin/DccItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ItemDelegate {
leftPadding: 10
rightPadding: 10

contentItem: model.item.getSectionItem()
contentItem: model.item.getSectionItem(this)
background: DccListViewBackground {
id: background
separatorVisible: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Item {

Loader {
anchors.fill: parent
active: !checked && control.backgroundVisible
active: (!highlightEnable || !checked) && control.backgroundVisible
sourceComponent: D.RoundRectangle {
color: palette.base
radius: DS.Style.control.radius
Expand Down
6 changes: 3 additions & 3 deletions src/dde-control-center/frame/plugin/DccMenuEditorItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import QtQuick.Layouts 1.15
import org.deepin.dtk 1.0 as D

DccEditorItem {
property var editor: model.item.getSectionItem()
property var editor: null
leftPadding: 12
rightPadding: 10
topPadding: topInset
bottomPadding: bottomInset
implicitHeight: 58
rightItem: RowLayout {
Control {
contentItem: editor
contentItem: editor ? editor : model.item.getSectionItem(this)
}

D.IconLabel {
Expand All @@ -26,7 +26,7 @@ DccEditorItem {
if (model.item.children.length > 0) {
model.item.children[0].trigger()
} else {
console.warn(model.item.name, " MenuEditor nust include children",model.item.children.length)
console.warn(model.item.name, " MenuEditor nust include children", model.item.children.length)
}
}
}
3 changes: 2 additions & 1 deletion src/dde-control-center/frame/plugin/DccRowView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RowLayout {
id: root
objectName: "noPadding"
Layout.fillWidth: true
spacing: 10
Repeater {
id: repeater
model: DccModel {
Expand All @@ -20,7 +21,7 @@ RowLayout {
delegate: Control {
Layout.fillWidth: contentItem.Layout.fillWidth
Layout.alignment: contentItem.Layout.alignment
contentItem: model.item.getSectionItem()
contentItem: model.item.getSectionItem(this)
}
}
}
10 changes: 5 additions & 5 deletions src/dde-control-center/frame/plugin/DccSettingsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Flickable {
Component {
id: groupView
DccGroupView {
isGroup: isGroup
spacing: spacing
isGroup: root.isGroup
spacing: root.spacing
}
}
Component {
Expand All @@ -38,7 +38,7 @@ Flickable {
}
}
Rectangle {
color: root.palette.window
color: this.palette.window
implicitHeight: bottomItem.implicitHeight + 10
anchors {
left: parent.left
Expand Down Expand Up @@ -72,11 +72,11 @@ Flickable {
if (!dccObj.children[0].page) {
dccObj.children[0].page = groupView
}
centralItem.contentItem = dccObj.children[0].getSectionItem()
centralItem.contentItem = dccObj.children[0].getSectionItem(centralItem)
if (!dccObj.children[1].page) {
dccObj.children[1].page = footer
}
bottomItem.contentItem = dccObj.children[1].getSectionItem()
bottomItem.contentItem = dccObj.children[1].getSectionItem(bottomItem)
} else {
console.warn(dccObj.name, " SettingsView must contain two sub items", dccObj.children.length)
}
Expand Down

0 comments on commit 3c9713d

Please sign in to comment.