forked from qt-creator/qt-creator
QmlDesigner: Add separate + buttons for material browser sections
Fixes: QDS-8343 Change-Id: Id986820c857df241cf25e55416832f189c28bfe0 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -95,24 +95,12 @@ Item {
|
||||
StudioControls.SearchBox {
|
||||
id: searchBox
|
||||
|
||||
width: root.width - addMaterialButton.width
|
||||
width: root.width
|
||||
|
||||
onSearchChanged: (searchText) => {
|
||||
rootView.handleSearchFilterChanged(searchText)
|
||||
}
|
||||
}
|
||||
|
||||
IconButton {
|
||||
id: addMaterialButton
|
||||
|
||||
tooltip: qsTr("Add a material.")
|
||||
|
||||
icon: StudioTheme.Constants.plus
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
buttonSize: searchBox.height
|
||||
onClicked: materialBrowserModel.addNewMaterial()
|
||||
enabled: materialBrowserModel.hasQuick3DImport
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
@@ -145,6 +133,10 @@ Item {
|
||||
interactive: !ctxMenu.opened
|
||||
|
||||
Column {
|
||||
Item {
|
||||
width: root.width
|
||||
height: materialsSection.height
|
||||
|
||||
Section {
|
||||
id: materialsSection
|
||||
|
||||
@@ -210,6 +202,25 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
IconButton {
|
||||
id: addMaterialButton
|
||||
|
||||
tooltip: qsTr("Add a material.")
|
||||
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: scrollView.verticalScrollBarVisible ? 10 : 0
|
||||
icon: StudioTheme.Constants.plus
|
||||
normalColor: "transparent"
|
||||
buttonSize: StudioTheme.Values.sectionHeadHeight
|
||||
onClicked: materialBrowserModel.addNewMaterial()
|
||||
enabled: materialBrowserModel.hasQuick3DImport
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
width: root.width
|
||||
height: texturesSection.height
|
||||
|
||||
Section {
|
||||
id: texturesSection
|
||||
|
||||
@@ -257,6 +268,21 @@ Item {
|
||||
width: root.width
|
||||
}
|
||||
}
|
||||
|
||||
IconButton {
|
||||
id: addTextureButton
|
||||
|
||||
tooltip: qsTr("Add a texture.")
|
||||
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: scrollView.verticalScrollBarVisible ? 10 : 0
|
||||
icon: StudioTheme.Constants.plus
|
||||
normalColor: "transparent"
|
||||
buttonSize: StudioTheme.Values.sectionHeadHeight
|
||||
onClicked: materialBrowserTexturesModel.addNewTexture()
|
||||
enabled: materialBrowserModel.hasQuick3DImport
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +154,11 @@ void MaterialBrowserTexturesModel::removeTexture(const ModelNode &texture)
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialBrowserTexturesModel::addNewTexture()
|
||||
{
|
||||
emit addNewTextureTriggered();
|
||||
}
|
||||
|
||||
void MaterialBrowserTexturesModel::deleteSelectedTexture()
|
||||
{
|
||||
deleteTexture(m_selectedIndex);
|
||||
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
void resetModel();
|
||||
|
||||
Q_INVOKABLE void selectTexture(int idx, bool force = false);
|
||||
Q_INVOKABLE void addNewTexture();
|
||||
Q_INVOKABLE void duplicateTexture(int idx);
|
||||
Q_INVOKABLE void deleteTexture(int idx);
|
||||
|
||||
@@ -52,6 +53,7 @@ signals:
|
||||
void materialSectionsChanged();
|
||||
void selectedIndexChanged(int idx);
|
||||
void duplicateTextureTriggered(const QmlDesigner::ModelNode &material);
|
||||
void addNewTextureTriggered();
|
||||
|
||||
private:
|
||||
bool isTextureVisible(int idx) const;
|
||||
|
||||
@@ -146,6 +146,10 @@ WidgetInfo MaterialBrowserView::widgetInfo()
|
||||
ModelNode texNode = m_widget->materialBrowserTexturesModel()->textureAt(idx);
|
||||
emitCustomNotification("selected_texture_changed", {texNode}, {});
|
||||
});
|
||||
|
||||
connect(texturesModel, &MaterialBrowserTexturesModel::addNewTextureTriggered, this, [&] {
|
||||
emitCustomNotification("add_new_texture");
|
||||
});
|
||||
}
|
||||
|
||||
return createWidgetInfo(m_widget.data(),
|
||||
@@ -290,18 +294,25 @@ void MaterialBrowserView::nodeReparented(const ModelNode &node,
|
||||
|
||||
ModelNode newParentNode = newPropertyParent.parentModelNode();
|
||||
ModelNode oldParentNode = oldPropertyParent.parentModelNode();
|
||||
bool matAdded = newParentNode.id() == Constants::MATERIAL_LIB_ID;
|
||||
bool matRemoved = oldParentNode.id() == Constants::MATERIAL_LIB_ID;
|
||||
bool added = newParentNode.id() == Constants::MATERIAL_LIB_ID;
|
||||
bool removed = oldParentNode.id() == Constants::MATERIAL_LIB_ID;
|
||||
|
||||
if (matAdded || matRemoved) {
|
||||
if (matAdded && !m_puppetResetPending) {
|
||||
if (!added && !removed)
|
||||
return;
|
||||
|
||||
refreshModel(removed);
|
||||
|
||||
if (isMaterial(node)) {
|
||||
if (added && !m_puppetResetPending) {
|
||||
// Workaround to fix various material issues all likely caused by QTBUG-103316
|
||||
resetPuppet();
|
||||
m_puppetResetPending = true;
|
||||
}
|
||||
refreshModel(!matAdded);
|
||||
int idx = m_widget->materialBrowserModel()->materialIndex(node);
|
||||
m_widget->materialBrowserModel()->selectMaterial(idx);
|
||||
} else { // is texture
|
||||
int idx = m_widget->materialBrowserTexturesModel()->textureIndex(node);
|
||||
m_widget->materialBrowserTexturesModel()->selectTexture(idx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user