QmlDesigner: Implement fit selection button in 3D edit view

Shortcuts for scale and move were also updated to correct ones.

Change-Id: Iffcad0c81475553003962e65dc059879a237546e
Fixes: QDS-1235
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Miikka Heikkinen
2019-11-21 11:13:19 +02:00
parent c7120bde92
commit 9dac42f153
9 changed files with 51 additions and 8 deletions

View File

@@ -300,7 +300,8 @@ Window {
spacing: 5
padding: 5
property var group: [btnSelectItem, btnSelectGroup, btnMove, btnRotate, btnScale]
property var groupSelect: [btnSelectGroup, btnSelectItem]
property var groupTransform: [btnMove, btnRotate, btnScale]
ToolBarButton {
id: btnSelectItem
@@ -309,7 +310,7 @@ Window {
shortcut: "Q"
currentShortcut: selected ? "" : shortcut
tool: "item_selection"
buttonsGroup: col.group
buttonsGroup: col.groupSelect
}
ToolBarButton {
@@ -318,7 +319,7 @@ Window {
shortcut: "Q"
currentShortcut: btnSelectItem.currentShortcut === shortcut ? "" : shortcut
tool: "group_selection"
buttonsGroup: col.group
buttonsGroup: col.groupSelect
}
Rectangle { // separator
@@ -330,11 +331,12 @@ Window {
ToolBarButton {
id: btnMove
selected: true
tooltip: qsTr("Move current selection")
shortcut: "M"
shortcut: "W"
currentShortcut: shortcut
tool: "move"
buttonsGroup: col.group
buttonsGroup: col.groupTransform
}
ToolBarButton {
@@ -343,16 +345,37 @@ Window {
shortcut: "E"
currentShortcut: shortcut
tool: "rotate"
buttonsGroup: col.group
buttonsGroup: col.groupTransform
}
ToolBarButton {
id: btnScale
tooltip: qsTr("Scale current selection")
shortcut: "T"
shortcut: "R"
currentShortcut: shortcut
tool: "scale"
buttonsGroup: col.group
buttonsGroup: col.groupTransform
}
Rectangle { // separator
width: 25
height: 1
color: "#f1f1f1"
anchors.horizontalCenter: parent.horizontalCenter
}
ToolBarButton {
id: btnFit
tooltip: qsTr("Fit camera to current selection")
shortcut: "F"
currentShortcut: shortcut
tool: "fit"
togglable: false
onSelectedChanged: {
if (selected)
cameraControl.fitObject(viewWindow.selectedNode, editView.camera.rotation);
}
}
}
}

View File

@@ -34,6 +34,7 @@ Rectangle {
property string currentShortcut
property string tool
property variant buttonsGroup: []
property bool togglable: true
id: root
width: img.width + 5
@@ -71,6 +72,11 @@ Rectangle {
root.buttonsGroup[i].selected = false;
root.selected = true;
if (!root.togglable) {
// Deselect button after a short while (selection acts as simple click indicator)
_generalHelper.delayedPropertySet(root, 200, "selected", false);
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

View File

@@ -185,6 +185,14 @@ QVector4D GeneralHelper::fitObjectToCamera(QQuick3DCamera *camera, float default
zoomCamera(camera, 0, defaultLookAtDistance, lookAt, newZoomFactor, false));
}
void GeneralHelper::delayedPropertySet(QObject *obj, int delay, const QString &property,
const QVariant &value)
{
QTimer::singleShot(delay, [obj, property, value]() {
obj->setProperty(property.toLatin1().constData(), value);
});
}
}
}

View File

@@ -57,6 +57,8 @@ public:
float zoomFactor, bool relative);
Q_INVOKABLE QVector4D fitObjectToCamera(QQuick3DCamera *camera, float defaultLookAtDistance,
QQuick3DNode *targetObject, QQuick3DViewport *viewPort);
Q_INVOKABLE void delayedPropertySet(QObject *obj, int delay, const QString &property,
const QVariant& value);
signals:
void overlayUpdateNeeded();

View File

@@ -64,5 +64,9 @@
<file>mockfiles/images/point_light_gradient@2x.png</file>
<file>mockfiles/images/area_light_gradient.png</file>
<file>mockfiles/images/area_light_gradient@2x.png</file>
<file>mockfiles/images/fit_active.png</file>
<file>mockfiles/images/fit_active@2x.png</file>
<file>mockfiles/images/fit_selected.png</file>
<file>mockfiles/images/fit_selected@2x.png</file>
</qresource>
</RCC>