QmlDesigner: Enable docking a header in PropertyEditorPane

A header component is defined in PropertyEditorPane.
This header can be docked to the top.
A header is defined for MaterialEditorPane

Task-number: QDS-12851
Change-Id: Ie5393f917803241da1f286bd05c226fd055b1174
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Ali Kianian
2024-05-28 09:28:21 +03:00
parent 934a15b16e
commit ed771ace4a
3 changed files with 85 additions and 19 deletions

View File

@@ -17,21 +17,21 @@ Item {
// invoked from C++ to refresh material preview image // invoked from C++ to refresh material preview image
function refreshPreview() function refreshPreview()
{ {
topSection.refreshPreview() itemPane.headerItem.refreshPreview()
} }
// Called from C++ to close context menu on focus out // Called from C++ to close context menu on focus out
function closeContextMenu() function closeContextMenu()
{ {
topSection.closeContextMenu() itemPane.headerItem.closeContextMenu()
Controller.closeContextMenu() Controller.closeContextMenu()
} }
// Called from C++ to initialize preview menu checkmarks // Called from C++ to initialize preview menu checkmarks
function initPreviewData(env, model) function initPreviewData(env, model)
{ {
topSection.previewEnv = env; itemPane.headerItem.previewEnv = env
topSection.previewModel = model itemPane.headerItem.previewModel = model
} }
MaterialEditorToolBar { MaterialEditorToolBar {
@@ -51,9 +51,7 @@ Item {
clip: true clip: true
MaterialEditorTopSection { headerComponent: MaterialEditorTopSection {
id: topSection
onPreviewEnvChanged: root.previewEnvChanged(previewEnv) onPreviewEnvChanged: root.previewEnvChanged(previewEnv)
onPreviewModelChanged: root.previewModelChanged(previewModel) onPreviewModelChanged: root.previewModelChanged(previewModel)
} }

View File

@@ -13,6 +13,9 @@ Column {
property string previewEnv property string previewEnv
property string previewModel property string previewModel
property real __horizontalSpacing: 5
property StudioTheme.ControlStyle buttonStyle: StudioTheme.ViewBarButtonStyle { property StudioTheme.ControlStyle buttonStyle: StudioTheme.ViewBarButtonStyle {
//This is how you can override stuff from the control styles //This is how you can override stuff from the control styles
controlSize: Qt.size(previewOptions.width, previewOptions.width) controlSize: Qt.size(previewOptions.width, previewOptions.width)
@@ -35,8 +38,7 @@ Column {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
Item { width: 1; height: 10 } // spacer Item { width: 1; height: 5 } // spacer
StudioControls.Menu { StudioControls.Menu {
id: modelMenu id: modelMenu
@@ -121,6 +123,19 @@ Column {
width: parent.width width: parent.width
height: previewRect.height height: previewRect.height
StudioControls.AbstractButton {
id: pinButton
x: root.__horizontalSpacing
style: root.buttonStyle
iconSize: StudioTheme.Values.bigFont
buttonIcon: pinButton.checked ? StudioTheme.Constants.pin : StudioTheme.Constants.unpin
checkable: true
checked: itemPane.headerDocked
onCheckedChanged: itemPane.headerDocked = pinButton.checked
}
Rectangle { Rectangle {
id: previewRect id: previewRect
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@@ -145,6 +160,7 @@ Column {
height: previewRect.height height: previewRect.height
anchors.top: previewRect.top anchors.top: previewRect.top
anchors.left: previewRect.right anchors.left: previewRect.right
anchors.leftMargin: root.__horizontalSpacing
Column { Column {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@@ -164,7 +180,6 @@ Column {
} }
} }
} }
} }
HelperWidgets.Section { HelperWidgets.Section {

View File

@@ -19,30 +19,83 @@ Rectangle {
default property alias content: mainColumn.children default property alias content: mainColumn.children
property alias scrollView: mainScrollView property alias scrollView: mainScrollView
property bool headerDocked: false
readonly property Item headerItem: headerDocked ? dockedHeaderLoader.item : undockedHeaderLoader.item
property Component headerComponent: null
// Called from C++ to close context menu on focus out // Called from C++ to close context menu on focus out
function closeContextMenu() { function closeContextMenu() {
Controller.closeContextMenu() Controller.closeContextMenu()
} }
Loader {
id: dockedHeaderLoader
anchors.top: itemPane.top
z: parent.z + 1
height: item ? item.implicitHeight : 0
width: parent.width
active: itemPane.headerDocked
sourceComponent: itemPane.headerComponent
HeaderBackground{}
}
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: forceActiveFocus() onClicked: itemPane.forceActiveFocus()
} }
HelperWidgets.ScrollView { HelperWidgets.ScrollView {
id: mainScrollView id: mainScrollView
//clip: true
anchors.fill: parent clip: true
anchors {
top: dockedHeaderLoader.bottom
bottom: itemPane.bottom
left: itemPane.left
right: itemPane.right
}
interactive: !Controller.contextMenuOpened interactive: !Controller.contextMenuOpened
ColumnLayout {
spacing: 2
width: mainScrollView.width
Loader {
id: undockedHeaderLoader
Layout.fillWidth: true
Layout.preferredHeight: item ? item.implicitHeight : 0
active: !itemPane.headerDocked
sourceComponent: itemPane.headerComponent
HeaderBackground{}
}
Column { Column {
id: mainColumn id: mainColumn
y: -1
width: itemPane.width Layout.fillWidth: true
onWidthChanged: StudioTheme.Values.responsiveResize(itemPane.width) onWidthChanged: StudioTheme.Values.responsiveResize(itemPane.width)
Component.onCompleted: StudioTheme.Values.responsiveResize(itemPane.width) Component.onCompleted: StudioTheme.Values.responsiveResize(itemPane.width)
} }
} }
}
component HeaderBackground: Rectangle {
anchors.fill: parent
anchors.leftMargin: -StudioTheme.Values.border
anchors.rightMargin: -StudioTheme.Values.border
z: parent.z - 1
color: StudioTheme.Values.themeToolbarBackground
border.color: StudioTheme.Values.themePanelBackground
border.width: StudioTheme.Values.border
}
} }