summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2019-11-21 11:13:19 +0200
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2019-11-22 14:02:32 +0000
commit9dac42f153b42c057713aadfa48aa2873643b2f3 (patch)
tree60572b842aa11fd0a616f0c3a04c56706687209b
parentc7120bde92d1ad3402fb8a093187e6b752da244f (diff)
downloadqt-creator-9dac42f153b42c057713aadfa48aa2873643b2f3.tar.gz
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>
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml39
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/ToolBarButton.qml6
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_active.pngbin0 -> 266 bytes
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_active@2x.pngbin0 -> 386 bytes
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_selected.pngbin0 -> 266 bytes
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_selected@2x.pngbin0 -> 386 bytes
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp8
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h2
-rw-r--r--share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc4
9 files changed, 51 insertions, 8 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml
index 19443113ee..56faf67ec4 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml
@@ -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);
+ }
}
}
}
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/ToolBarButton.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/ToolBarButton.qml
index cbc450ed2b..38a8608e47 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/ToolBarButton.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/ToolBarButton.qml
@@ -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);
+ }
}
}
}
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_active.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_active.png
new file mode 100644
index 0000000000..056e9ec3c8
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_active.png
Binary files differ
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_active@2x.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_active@2x.png
new file mode 100644
index 0000000000..4b05f83d46
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_active@2x.png
Binary files differ
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_selected.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_selected.png
new file mode 100644
index 0000000000..b8f98d9f12
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_selected.png
Binary files differ
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_selected@2x.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_selected@2x.png
new file mode 100644
index 0000000000..eac4361253
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/images/fit_selected@2x.png
Binary files differ
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp
index e7b091504f..30be47d2dc 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp
@@ -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);
+ });
+}
+
}
}
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h
index f667a97442..8a1cbe7001 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h
@@ -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();
diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc b/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc
index c82164c1ff..fcb510ccf0 100644
--- a/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc
+++ b/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc
@@ -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>